[OS-BUILD PATCHv2 1/4] redhat/self-test: Fix up create-data.sh to not report local variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Prarit Bhargava <prarit@xxxxxxxxxx>

redhat/self-test: Fix up create-data.sh to not report local variables

Fix the create-data.sh script by moving the reporting of the
Makefile.variables into the dist-dump-variables target.  This has the
minor annoyance that dist-dump-variables will report Makefile.variables
twice when executed on the command line, however, it's something I think
we can live with.

Fix up create-data.sh to not report local variables.

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>

diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -714,7 +714,8 @@ dist-os-version:
 	@echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
 
 dist-dump-variables:
-	@$(foreach V,$(sort $(.VARIABLES)), $(if $(filter-out environment% default automatic, $(origin $V)),$(info $V=$($V) )))
+	$(eval VARS:=$(sort $(shell cat Makefile.variables | sed '/^#/d; /^$$/d; s/[ ]*[?:]=.*//')))
+	@$(foreach V,$(sort $(.VARIABLES)), $(if $(filter-out environment default automatic, $(origin $V)),$(info $V=$($V) ),$(if $(filter $(VARS),$(V)),$(info $V=$($V)))))
 
 dist-self-test:
 	@if test -x /usr/bin/bats; then \
diff --git a/redhat/self-test/data/create-data.sh b/redhat/self-test/data/create-data.sh
index blahblah..blahblah 100755
--- a/redhat/self-test/data/create-data.sh
+++ b/redhat/self-test/data/create-data.sh
@@ -32,28 +32,25 @@ do
 
 			echo "building $varfilename"
 
-			# CURDIR is a make special target and cannot be easily changed.  Omit
-			# CURDIR from the output.
+			# Ignored Makefile variables:
+			# CURDIR is a make special target and cannot be easily changed.
 			# UPSTREAM is the base merge commit and can change from day-to-day as
-			# the tree is changed.  Omit UPSTREAM from the output.
+			# the tree is changed.
 			# RHEL_RELEASE can change build-to-build.
 			# SHELL can change depending on user's environment
-			make RHSELFTESTDATA=1 DIST="${DIST}" DISTRO="${DISTRO}" HEAD=${commit} dist-dump-variables | grep "=" | grep -v CURDIR | grep -v -w UPSTREAM | grep -v -w RHEL_RELEASE | grep -v -w SHELL >& "${varfilename}"
-
-			# When executed from a script, the variables in Makefile.variables are
-			# listed as having origin 'environment'.  This is because the script
-			# inherits the variables from the 'export' command in the redhat/Makefile.
-			# The 'dist-dump-variables' target explicitly omits these variables from
-			# its output.  As a workaround, read in the variables and output them to
-			# the data file.
-			# shellcheck disable=SC2002
-			cat Makefile.variables | grep -v "^#" | sed '/^$/d' | tr -d " " | awk -F "?=|:=" '{print $1}' | while read -r VAR
-			do
-				[ "$VAR" == "RHDISTDATADIR" ] && continue
-				[ "$VAR" == "RHGITURL" ] && continue
-				[ "$VAR" == "BUILD" ] && continue
-				echo "$VAR=${!VAR}"
-			done >> "${varfilename}"
+			# RHGITURL may change depending on the user's method of cloning
+			# RHDISTDATADIR will change based on these tests
+			# VARS is a list of variables added for the 'dist-dump-variables' target
+			# and can be ignored.
+			make RHSELFTESTDATA=1 DIST="${DIST}" DISTRO="${DISTRO}" HEAD=${commit} dist-dump-variables | grep "=" |\
+				grep -v -w CURDIR |\
+				grep -v -w UPSTREAM |\
+				grep -v -w RHEL_RELEASE |\
+				grep -v -w SHELL |\
+				grep -v -w RHGITURL |\
+				grep -v -w RHDISTDATADIR |\
+				grep -v -w VARS |\
+				sort -u >& "${varfilename}"
 
 			echo "building ${varfilename}.spec"
 			make RHSELFTESTDATA=1 DIST="${DIST}" DISTRO="${DISTRO}" HEAD=${commit} setup-source

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1800
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux