[PATCH v3 34/36] Makefile: Set TOPDIR_PATH and generate its sha256sum at run time

Chuck Lever <[email protected]>
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Chuck Lever <[email protected]>

Commit 42d27579a9d0 ("guestfs: enhance ssh config choice") added a
uniquifier to the name of the ssh config to avoid multiple kdevops
runs clobbering each other's ssh config entries. It uses the TOPDIR
pathname set in the current .config to benefit from the nice
convenience of generating an Ansible extra_var using "output yaml".

Commit 42d27579a9d0 ("guestfs: enhance ssh config choice") broke the
ability to share a .config with other users because
CONFIG_TOPDIR_PATH contains a fixed string pointing to the home
directory where the .config was created.

The TOPDIR and its checksum need to be generated not by "make
menuconfig" but rather by "make" in order that .config files (as
saved in defconfigs/) can be truly portable.

Reviewed-by: Luis Chamberlain <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
---
 Kconfig                    | 10 ----------
 Makefile                   |  2 ++
 scripts/gen-hosts.Makefile |  1 +
 scripts/ssh.Makefile       |  2 +-
 4 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/Kconfig b/Kconfig
index 54921617b8b2..948befbce4de 100644
--- a/Kconfig
+++ b/Kconfig
@@ -5,16 +5,6 @@
 
 mainmenu "$(PROJECT) $(PROJECTRELEASE)"
 
-config TOPDIR_PATH
-	string
-	output yaml
-	default $(shell, echo $TOPDIR_PATH)
-
-config TOPDIR_PATH_SHA256SUM
-	string
-	output yaml
-	default $(shell, ./scripts/compute_sha256sum.sh $(TOPDIR_PATH))
-
 config HAVE_KDEVOPS_CUSTOM_DEFAULTS
 	bool
 	default n
diff --git a/Makefile b/Makefile
index 381470097938..7230c2871d4d 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ export KDEVOPS_NODES :=
 export PYTHONUNBUFFERED=1
 export TOPDIR=./
 export TOPDIR_PATH = $(shell readlink -f $(TOPDIR))
+export TOPDIR_PATH_SHA256SUM = $(shell ./scripts/compute_sha256sum.sh $(TOPDIR_PATH))
 include scripts/refs.Makefile
 
 KDEVOPS_NODES_ROLE_TEMPLATE_DIR :=		$(KDEVOPS_PLAYBOOKS_DIR)/roles/gen_nodes/templates
@@ -82,6 +83,7 @@ INCLUDES = -I include/
 CFLAGS += $(INCLUDES)
 
 ANSIBLE_EXTRA_ARGS += kdevops_version='$(PROJECTRELEASE)'
+ANSIBLE_EXTRA_ARGS += topdir_path_sha256sum='$(TOPDIR_PATH_SHA256SUM)'
 
 export KDEVOPS_HOSTS_TEMPLATE := hosts.j2
 
diff --git a/scripts/gen-hosts.Makefile b/scripts/gen-hosts.Makefile
index 0d1e0cd77c2e..c809b1da18e5 100644
--- a/scripts/gen-hosts.Makefile
+++ b/scripts/gen-hosts.Makefile
@@ -3,6 +3,7 @@
 KDEVOPS_PLAYBOOKS_DIR_FULL_PATH=$(TOPDIR_PATH)/$(KDEVOPS_PLAYBOOKS_DIR)
 KDEVOPS_HOSTS_TEMPLATE_DIR=$(KDEVOPS_PLAYBOOKS_DIR_FULL_PATH)/roles/gen_hosts/templates
 
+GENHOSTS_EXTRA_ARGS += topdir_path='$(TOPDIR_PATH)'
 GENHOSTS_EXTRA_ARGS += kdevops_playbooks_dir='$(KDEVOPS_PLAYBOOKS_DIR)'
 
 # Relative path so that ansible can work with it
diff --git a/scripts/ssh.Makefile b/scripts/ssh.Makefile
index 68c6dcdd4dcd..82e9a8dd33b5 100644
--- a/scripts/ssh.Makefile
+++ b/scripts/ssh.Makefile
@@ -10,7 +10,7 @@ ifeq (y,$(CONFIG_KDEVOPS_SSH_CONFIG_UPDATE))
 SSH_CONFIG_FILE:=$(subst ",,$(CONFIG_KDEVOPS_SSH_CONFIG))
 ANSIBLE_EXTRA_ARGS += sshconfig=$(shell realpath $(SSH_CONFIG_FILE))
 
-ANSIBLE_EXTRA_ARGS += kdevops_ssh_config=$(shell scripts/append-makefile-vars.sh $(CONFIG_KDEVOPS_SSH_CONFIG_PREFIX) $(CONFIG_TOPDIR_PATH_SHA256SUM))
+ANSIBLE_EXTRA_ARGS += kdevops_ssh_config=$(shell scripts/append-makefile-vars.sh $(CONFIG_KDEVOPS_SSH_CONFIG_PREFIX) $(TOPDIR_PATH_SHA256SUM))
 
 endif # CONFIG_KDEVOPS_SSH_CONFIG_UPDATE
 
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.