From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
On Thu, 01 Oct 2020 00:44:27 -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Acked-by: Jiri Benc jbenc@redhat.com
On Thu, Oct 01, 2020 at 12:44:27AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Test comment. Please ignore.
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
GitLab _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
On Thu, Oct 01, 2020 at 12:44:27AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Acked-by: Don Zickus dzickus@redhat.com
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
GitLab _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
On Fri, Oct 02, 2020 at 01:19:07PM -0400, Don Zickus wrote:
On Thu, Oct 01, 2020 at 12:44:27AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Acked-by: Don Zickus dzickus@redhat.com
Re-acking to see if the bridge is fixed.
Acked-by: Don Zickus dzickus@redhat.com
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
GitLab _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
On Fri, Oct 02, 2020 at 01:19:07PM -0400, Don Zickus wrote:
On Thu, Oct 01, 2020 at 12:44:27AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Acked-by: Don Zickus dzickus@redhat.com
More useless noise. Sorry.
Acked-by: Don Zickus dzickus@redhat.com
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
GitLab _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
On Fri, Oct 02, 2020 at 01:19:07PM -0400, Don Zickus wrote:
On Thu, Oct 01, 2020 at 12:44:27AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Acked-by: Don Zickus dzickus@redhat.com
/me wishes he had a better way to debug permission problems..
Acked-by: Don Zickus dzickus@redhat.com
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
GitLab _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
On Fri, Oct 02, 2020 at 01:19:07PM -0400, Don Zickus wrote:
On Thu, Oct 01, 2020 at 12:44:27AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Acked-by: Don Zickus dzickus@redhat.com
ugh. last time
Acked-by: Don Zickus dzickus@redhat.com
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
GitLab _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common is broken out into its own case. At the moment, the output of either 'git describe' or 'git merge-base' can be overridden by means of environment variables, EGIT_OVERRIDE_DESCRIBE and EGIT_OVERRIDE_MERGE_BASE respectively.
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
Other git subcommands are simply passed through.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/egit.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 redhat/egit.sh
diff --git a/redhat/egit.sh b/redhat/egit.sh new file mode 100755 index 000000000000..e8d7f7390d8a --- /dev/null +++ b/redhat/egit.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + add ) + git add "$@" + ;; + branch ) + git branch "$@" + ;; + commit ) + git commit "$@" + ;; + config ) + git config "$@" + ;; + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + diff ) + git diff "$@" + ;; + diff-index ) + git diff-index "$@" + ;; + log ) + git log "$@" + ;; + merge-base ) + if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] + then + # This should be an SHA1: + echo "$EGIT_OVERRIDE_MERGE_BASE" + else + git merge-base "$@" + fi + ;; + rev-parse ) + git rev-parse "$@" + ;; + show ) + git show "$@" + ;; + tag ) + git tag "$@" + ;; + remote ) + git remote "$@" + ;; + * ) + git "$arg" "$@" + ;; +esac
On Wed, 07 Oct 2020 19:48:50 -0000, GitLab Bridge on behalf of bcrocker wrote:
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
[...]
redhat/egit.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
Please put this into a subdirectory, e.g. redhat/selftests (or whatever), to make it clear what the script is good for to anyone browsing through redhat/.
Thanks!
Politely requesting a new version, Nacked-by: Jiri Benc jbenc@redhat.com
From: Ben Crocker bcrocker@redhat.com
Add dist-dump-variables and dist-check-variables for dynamically deriving variables from Makefile.common and dumping or checking them. At the moment, the dist-dump-variables and dist-check-variables are identical, except in the name of the script generated.
Add a dist-clean-scripts target to clean up generated scripts.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/redhat/Makefile b/redhat/Makefile index ee3702434e05..7ec891df01ac 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,11 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + @if [ -f dist-check-variables.sh ]; then rm dist-check-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +386,18 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-check-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-check-variables.sh + chmod +x $(REDHAT)/dist-check-variables.sh + @$(REDHAT)/dist-check-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.'
On Wed, 07 Oct 2020 19:48:50 -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
Add dist-dump-variables and dist-check-variables for dynamically deriving variables from Makefile.common and dumping or checking them. At the moment, the dist-dump-variables and dist-check-variables are identical, except in the name of the script generated.
What is this good for? It's not clear from your patch description.
Thanks,
Jiri
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_42565308...
Sample use case: self test with canned output values for\ 'git describe' and/or 'git merge-base' commands.
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common is broken out into its own case. At the moment, the output of either 'git describe' or 'git merge-base' can be overridden by means of environment variables, EGIT_OVERRIDE_DESCRIBE and EGIT_OVERRIDE_MERGE_BASE respectively.
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
Other git subcommands are simply passed through.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/egit.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 redhat/egit.sh
diff --git a/redhat/egit.sh b/redhat/egit.sh new file mode 100755 index 000000000000..e8d7f7390d8a --- /dev/null +++ b/redhat/egit.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + add ) + git add "$@" + ;; + branch ) + git branch "$@" + ;; + commit ) + git commit "$@" + ;; + config ) + git config "$@" + ;; + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + diff ) + git diff "$@" + ;; + diff-index ) + git diff-index "$@" + ;; + log ) + git log "$@" + ;; + merge-base ) + if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] + then + # This should be an SHA1: + echo "$EGIT_OVERRIDE_MERGE_BASE" + else + git merge-base "$@" + fi + ;; + rev-parse ) + git rev-parse "$@" + ;; + show ) + git show "$@" + ;; + tag ) + git tag "$@" + ;; + remote ) + git remote "$@" + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
Add dist-dump-variables and dist-check-variables for dynamically deriving variables from Makefile.common and dumping or checking them. At the moment, the dist-dump-variables and dist-check-variables are identical, except in the name of the script generated.
Add a dist-clean-scripts target to clean up generated scripts.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/redhat/Makefile b/redhat/Makefile index ee3702434e05..7ec891df01ac 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,11 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + @if [ -f dist-check-variables.sh ]; then rm dist-check-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +386,18 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-check-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-check-variables.sh + chmod +x $(REDHAT)/dist-check-variables.sh + @$(REDHAT)/dist-check-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.'
From: Phil Auld pauld@redhat.com
CONFIG_ENERGY_MODEL will help make the schedutil frequency governor more accurate. This will be useful in the future. It also enables the use of the energy aware scheduler.
Signed-off-by: Phil Auld pauld@redhat.com --- redhat/configs/ark/generic/CONFIG_ENERGY_MODEL | 1 + 1 file changed, 1 insertion(+) create mode 100644 redhat/configs/ark/generic/CONFIG_ENERGY_MODEL
diff --git a/redhat/configs/ark/generic/CONFIG_ENERGY_MODEL b/redhat/configs/ark/generic/CONFIG_ENERGY_MODEL new file mode 100644 index 000000000000..a4fec3a5d9eb --- /dev/null +++ b/redhat/configs/ark/generic/CONFIG_ENERGY_MODEL @@ -0,0 +1 @@ +CONFIG_ENERGY_MODEL=y
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
Add dist-dump-variables and dist-check-variables for dynamically deriving variables from Makefile.common and dumping or checking them. At the moment, the dist-dump-variables and dist-check-variables are identical, except in the name of the script generated.
Add a dist-clean-scripts target to clean up generated scripts.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/redhat/Makefile b/redhat/Makefile index ee3702434e05..7ec891df01ac 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,11 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + @if [ -f dist-check-variables.sh ]; then rm dist-check-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +386,18 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-check-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-check-variables.sh + chmod +x $(REDHAT)/dist-check-variables.sh + @$(REDHAT)/dist-check-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.'
From: Ben Crocker bcrocker@redhat.com
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common is broken out into its own case. At the moment, the output of either 'git describe' or 'git merge-base' can be overridden by means of environment variables, EGIT_OVERRIDE_DESCRIBE and EGIT_OVERRIDE_MERGE_BASE respectively.
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
Other git subcommands are simply passed through.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/egit.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 redhat/egit.sh
diff --git a/redhat/egit.sh b/redhat/egit.sh new file mode 100755 index 000000000000..e8d7f7390d8a --- /dev/null +++ b/redhat/egit.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + add ) + git add "$@" + ;; + branch ) + git branch "$@" + ;; + commit ) + git commit "$@" + ;; + config ) + git config "$@" + ;; + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + diff ) + git diff "$@" + ;; + diff-index ) + git diff-index "$@" + ;; + log ) + git log "$@" + ;; + merge-base ) + if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] + then + # This should be an SHA1: + echo "$EGIT_OVERRIDE_MERGE_BASE" + else + git merge-base "$@" + fi + ;; + rev-parse ) + git rev-parse "$@" + ;; + show ) + git show "$@" + ;; + tag ) + git tag "$@" + ;; + remote ) + git remote "$@" + ;; + * ) + git "$arg" "$@" + ;; +esac
On Thu, 08 Oct 2020 21:10:25 -0000, GitLab Bridge on behalf of bcrocker wrote:
redhat/egit.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
My comments from v2 have not been addressed nor responded to. Neither for this patch nor for patch 2. Ben, it is not acceptable to ignore reviewers' feedback.
series Nacked-by: Jiri Benc jbenc@redhat.com
Also, do not push hastily new versions. All your force pushes create chaos in reviews, unnecessary traffic to mailing list, etc. You are also supposed to describe what changed between the versions.
From: Ben Crocker bcrocker@redhat.com
Simplify the case statement to only the git subcommands we actually provide overrides for.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm GIT=<path to egit.sh> EGIT_OVERRIDE_MERGE_BASE=<sha1> DIST=.elrdy make dist-srpm
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/egit.sh | 33 --------------------------------- 1 file changed, 33 deletions(-)
diff --git a/redhat/egit.sh b/redhat/egit.sh index e8d7f7390d8a..b998f868a314 100755 --- a/redhat/egit.sh +++ b/redhat/egit.sh @@ -3,18 +3,6 @@ arg=$1 shift case $arg in - add ) - git add "$@" - ;; - branch ) - git branch "$@" - ;; - commit ) - git commit "$@" - ;; - config ) - git config "$@" - ;; describe ) if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] then @@ -24,15 +12,6 @@ case $arg in git describe "$@" fi ;; - diff ) - git diff "$@" - ;; - diff-index ) - git diff-index "$@" - ;; - log ) - git log "$@" - ;; merge-base ) if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] then @@ -42,18 +21,6 @@ case $arg in git merge-base "$@" fi ;; - rev-parse ) - git rev-parse "$@" - ;; - show ) - git show "$@" - ;; - tag ) - git tag "$@" - ;; - remote ) - git remote "$@" - ;; * ) git "$arg" "$@" ;;
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 27d2cd94e78f..ee3702434e05 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_42655096...
egit.sh usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm\ GIT=<path to egit.sh> EGIT_OVERRIDE_MERGE_BASE=<sha1> DIST=.elrdy make dist-srpm
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_42707069...
Hi Jiri,
My apologies for not having responded sooner!
Your suggestion to move egit.sh to a new redhat/self-test directory is a good one, and I intend to take care of it as soon as another merge request of mine (666), which establishes the self-test directory and populates it with some initial tests, goes through.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_42735949...
@bcrocker - Yes, I acked the 666 patch to get you a self-tests directory. Let's convert this back to a WIP to stop the email spam and rebase this patch set on top of 666. Then you can move the updated egit.sh there.
Once that is done, ping me and I can privately review it before we take the WIP tag off. That way we can reduce the mailing list noise to only a final copy.
Thoughts?
Cheers, Don
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44520038...
Nitpick, can we not use 'dnf' here? It is slow. I think a 'test -x $(which bats)' or something similar is faster and just as effective.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44520100...
Same here, maybe use 'test -x' instead of 'dnf list'?
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44520111...
Another 'dnf list'
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44521084...
Changing dnf to test -x; thanks!
-- Ben
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..115ffc172960 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Simplify the case statement to only the git subcommands we actually provide overrides for.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm GIT=<path to egit.sh> EGIT_OVERRIDE_MERGE_BASE=<sha1> DIST=.elrdy make dist-srpm
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/egit.sh | 33 --------------------------------- 1 file changed, 33 deletions(-)
diff --git a/redhat/egit.sh b/redhat/egit.sh index e8d7f7390d8a..b998f868a314 100755 --- a/redhat/egit.sh +++ b/redhat/egit.sh @@ -3,18 +3,6 @@ arg=$1 shift case $arg in - add ) - git add "$@" - ;; - branch ) - git branch "$@" - ;; - commit ) - git commit "$@" - ;; - config ) - git config "$@" - ;; describe ) if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] then @@ -24,15 +12,6 @@ case $arg in git describe "$@" fi ;; - diff ) - git diff "$@" - ;; - diff-index ) - git diff-index "$@" - ;; - log ) - git log "$@" - ;; merge-base ) if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] then @@ -42,18 +21,6 @@ case $arg in git merge-base "$@" fi ;; - rev-parse ) - git rev-parse "$@" - ;; - show ) - git show "$@" - ;; - tag ) - git tag "$@" - ;; - remote ) - git remote "$@" - ;; * ) git "$arg" "$@" ;;
From: Ben Crocker bcrocker@redhat.com
Map returned version: vV.P-rcN-... => vV.P-rcN vV.P-N-hash => (same)
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/egit.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh index b998f868a314..068d486e4993 100755 --- a/redhat/self-test/egit.sh +++ b/redhat/self-test/egit.sh @@ -7,10 +7,22 @@ case $arg in if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] then # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac - echo "$EGIT_OVERRIDE_DESCRIBE" + version="$EGIT_OVERRIDE_DESCRIBE" else - git describe "$@" + version=$(git describe "$@") fi + va=(${version//-/ }) + v=${va[0]} + r=${va[1]} + if [ "${r/rc/}" != "${r}" ] # Quotes are crucial here + then + # vV.P-rcN-stuff => vV.P-rcN + v="$v-$r" + else + # Keep vV.P-N-hash + v="$version" + fi + echo "$v" ;; merge-base ) if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ]
From: Ben Crocker bcrocker@redhat.com
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/{ => self-test}/egit.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename redhat/{ => self-test}/egit.sh (100%)
diff --git a/redhat/egit.sh b/redhat/self-test/egit.sh similarity index 100% rename from redhat/egit.sh rename to redhat/self-test/egit.sh
From: Ben Crocker bcrocker@redhat.com
This is not what we're after.
This reverts commit 69f0bb9907ef8293c3b37a90cf437fad074d5dc1. --- redhat/self-test/egit.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh index 068d486e4993..b998f868a314 100755 --- a/redhat/self-test/egit.sh +++ b/redhat/self-test/egit.sh @@ -7,22 +7,10 @@ case $arg in if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] then # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac - version="$EGIT_OVERRIDE_DESCRIBE" + echo "$EGIT_OVERRIDE_DESCRIBE" else - version=$(git describe "$@") + git describe "$@" fi - va=(${version//-/ }) - v=${va[0]} - r=${va[1]} - if [ "${r/rc/}" != "${r}" ] # Quotes are crucial here - then - # vV.P-rcN-stuff => vV.P-rcN - v="$v-$r" - else - # Keep vV.P-N-hash - v="$version" - fi - echo "$v" ;; merge-base ) if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ]
From: Ben Crocker bcrocker@redhat.com
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common is broken out into its own case. At the moment, the output of either 'git describe' or 'git merge-base' can be overridden by means of environment variables, EGIT_OVERRIDE_DESCRIBE and EGIT_OVERRIDE_MERGE_BASE respectively.
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
Other git subcommands are simply passed through.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/egit.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 redhat/egit.sh
diff --git a/redhat/egit.sh b/redhat/egit.sh new file mode 100755 index 000000000000..e8d7f7390d8a --- /dev/null +++ b/redhat/egit.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + add ) + git add "$@" + ;; + branch ) + git branch "$@" + ;; + commit ) + git commit "$@" + ;; + config ) + git config "$@" + ;; + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + diff ) + git diff "$@" + ;; + diff-index ) + git diff-index "$@" + ;; + log ) + git log "$@" + ;; + merge-base ) + if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] + then + # This should be an SHA1: + echo "$EGIT_OVERRIDE_MERGE_BASE" + else + git merge-base "$@" + fi + ;; + rev-parse ) + git rev-parse "$@" + ;; + show ) + git show "$@" + ;; + tag ) + git tag "$@" + ;; + remote ) + git remote "$@" + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
Add dist-dump-variables and dist-check-variables for dynamically deriving variables from Makefile.common and dumping or checking them. At the moment, the dist-dump-variables and dist-check-variables are identical, except in the name of the script generated.
Add a dist-clean-scripts target to clean up generated scripts.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 115ffc172960..ffb479a7d43b 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,11 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + @if [ -f dist-check-variables.sh ]; then rm dist-check-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +386,18 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-check-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-check-variables.sh + chmod +x $(REDHAT)/dist-check-variables.sh + @$(REDHAT)/dist-check-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.'
From: Ben Crocker bcrocker@redhat.com
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 1 + 1 file changed, 1 insertion(+)
diff --git a/redhat/Makefile b/redhat/Makefile index aa8600ae7fd4..a7656b7bb4b7 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -512,4 +512,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo ''
From: Ben Crocker bcrocker@redhat.com
These four tests test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- .../self-test/1005-dist-dump-variables.bats | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats
diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..2ebea70baf59 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,73 @@ +#!/usr/bin/env bats +function get_rpmversion +{ + # ts = tag or sha1 + ts=$1 + RPMKVERSION=$(git show $ts:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') + RPMKPATCHLEVEL=$(git show $ts:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') + RPMKSUBLEVEL=$(git show $ts:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') + RPMKEXTRAVERSION=$(git show $ts:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +} + +function prologue() +{ + tag=$1 + git show $tag:Makefile > Makefile + git add Makefile + git commit -m "Temporarily replace with $tag Makefile" + ofile=$BATS_TMPDIR/$tag.out + GIT=$BATS_TEST_DIRNAME/egit.sh EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function epilogue() +{ + git reset --hard HEAD^ +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=" $ofile && grep -x "SNAPSHOT=0" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc7" $ofile && grep -x "KEXTRAVERSION=.rc7" $ofile && grep -x "SNAPSHOT=0" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=9" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=.rc0" $ofile && grep -x "SNAPSHOT=1" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc5" $ofile && grep -x "KEXTRAVERSION=.rc5" $ofile && grep -x "SNAPSHOT=1" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
Makefile:
Create new dist-self-test target and hook up the BATS self tests.
1005-dist-dump-variables.bats:
In prologue, need to unset environment variables that may have been inherited from a supra-make.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 3 +++ redhat/self-test/1005-dist-dump-variables.bats | 3 +++ 2 files changed, 6 insertions(+)
diff --git a/redhat/Makefile b/redhat/Makefile index 5ea04019d763..aa8600ae7fd4 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,9 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @bats $(REDHAT)/self-test/*.bats + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats index bff950e6643a..a2090b5c2194 100644 --- a/redhat/self-test/1005-dist-dump-variables.bats +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -4,6 +4,9 @@ function prologue() { tag=$1 ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $BATS_TEST_DIRNAME/../Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile }
From: Ben Crocker bcrocker@redhat.com
Remove the dist-check-variables target. Everything we WERE going to do for dist-check-variables is done in dist-dump-variables + BATS test.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index ffb479a7d43b..5ea04019d763 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -168,7 +168,6 @@ dist-clean-rpmdirs:
dist-clean-scripts: @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi - @if [ -f dist-check-variables.sh ]; then rm dist-check-variables.sh; fi
dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
@@ -393,11 +392,6 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
-dist-check-variables: - grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-check-variables.sh - chmod +x $(REDHAT)/dist-check-variables.sh - @$(REDHAT)/dist-check-variables.sh - dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.'
From: Ben Crocker bcrocker@redhat.com
Change
GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H)
to
GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/Makefile.common b/redhat/Makefile.common index a3dfb5716595..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -11,7 +11,7 @@ RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s// RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting.
From: Ben Crocker bcrocker@redhat.com
• Makefile.common: make HEAD an overridable variable • 1005-dist-dump-variables.bats: override HEAD with the tag under test; simplifies (and speeds up) prologue, obviates epilogue, makes the whole process more robust by eliminating even temporary changes to the git repo; • egit.sh: eliminate as-yet-unused merge-base case.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile.common | 11 +++++---- .../self-test/1005-dist-dump-variables.bats | 23 +------------------ redhat/self-test/egit.sh | 9 -------- 3 files changed, 7 insertions(+), 36 deletions(-)
diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..a3dfb5716595 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,10 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats index 2ebea70baf59..bff950e6643a 100644 --- a/redhat/self-test/1005-dist-dump-variables.bats +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -1,27 +1,10 @@ #!/usr/bin/env bats -function get_rpmversion -{ - # ts = tag or sha1 - ts=$1 - RPMKVERSION=$(git show $ts:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') - RPMKPATCHLEVEL=$(git show $ts:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') - RPMKSUBLEVEL=$(git show $ts:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') - RPMKEXTRAVERSION=$(git show $ts:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -}
function prologue() { tag=$1 - git show $tag:Makefile > Makefile - git add Makefile - git commit -m "Temporarily replace with $tag Makefile" ofile=$BATS_TMPDIR/$tag.out - GIT=$BATS_TEST_DIRNAME/egit.sh EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile -} - -function epilogue() -{ - git reset --hard HEAD^ + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile }
@test "dist-dump-variables v5.8" { @@ -32,7 +15,6 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] }
@@ -44,7 +26,6 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] }
@@ -56,7 +37,6 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] }
@@ -68,6 +48,5 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] } diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh index b998f868a314..f26921cc2aca 100755 --- a/redhat/self-test/egit.sh +++ b/redhat/self-test/egit.sh @@ -12,15 +12,6 @@ case $arg in git describe "$@" fi ;; - merge-base ) - if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] - then - # This should be an SHA1: - echo "$EGIT_OVERRIDE_MERGE_BASE" - else - git merge-base "$@" - fi - ;; * ) git "$arg" "$@" ;;
From: Ben Crocker bcrocker@redhat.com
In dist-self-test target, check for installation of the bats package and complain if it is not installed.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/redhat/Makefile b/redhat/Makefile index a7656b7bb4b7..555dea25ea0f 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -393,7 +393,11 @@ dist-dump-variables: @$(REDHAT)/dist-dump-variables.sh
dist-self-test: - @bats $(REDHAT)/self-test/*.bats + @if dnf list installed bats >& /dev/null; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi
dist-help: @echo 'Cleaning targets:'
From: Ben Crocker bcrocker@redhat.com
Collect the actual testing code into a new checkversion() function; add line breaks and indentation in both prologue() and checkversion() for better readability.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- .../self-test/1005-dist-dump-variables.bats | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats index a2090b5c2194..9251ca4636d5 100644 --- a/redhat/self-test/1005-dist-dump-variables.bats +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -5,51 +5,51 @@ function prologue() tag=$1 ofile=$BATS_TMPDIR/$tag.out # Have to unset environment variables that may be inherited from supra-make: - grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $BATS_TEST_DIRNAME/../Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | sort | uniq > $BATS_TMPDIR/unset-vars.sh + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh source $BATS_TMPDIR/unset-vars.sh GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile }
-@test "dist-dump-variables v5.8" { - tag=v5.8 - prologue $tag +function checkversion() +{ status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=" $ofile && grep -x "SNAPSHOT=0" $ofile + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile then status=$? fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" [ "$status" = 0 ] }
@test "dist-dump-variables v5.8-rc7" { tag=v5.8-rc7 prologue $tag - status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc7" $ofile && grep -x "KEXTRAVERSION=.rc7" $ofile && grep -x "SNAPSHOT=0" $ofile - then - status=$? - fi + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" [ "$status" = 0 ] }
@test "dist-dump-variables v5.8-9-g565674d613d7" { tag=v5.8-9-g565674d613d7 prologue $tag - status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=9" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=.rc0" $ofile && grep -x "SNAPSHOT=1" $ofile - then - status=$? - fi + checkversion $tag "5" "9" "0" "" ".rc0" "1" [ "$status" = 0 ] }
@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { tag=v5.8-rc5-99-g25ccd24ffd91 prologue $tag - status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc5" $ofile && grep -x "KEXTRAVERSION=.rc5" $ofile && grep -x "SNAPSHOT=1" $ofile - then - status=$? - fi + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the rpminspect package.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1003-rpminspect.bats | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..0bda8e52000c --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,15 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! dnf list installed rpminspect >& /dev/null + then + skip "The rpminspect package is not installed" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
Check whether the ShellCheck package is installed; if it is not installed, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..0d838fd254e5 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! dnf list installed ShellCheck >& /dev/null + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
Check whether the rpmlint package is installed; if it is not installed, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..15d9bb1e27db 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,11 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! dnf list installed rpmlint >& /dev/null + then + skip "The rpmlint package is not installed" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
Use test -x instead of dnf to test for presence of shellcheck.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index 0d838fd254e5..420b863e7453 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,5 +1,5 @@ @test "shellcheck" { - if ! dnf list installed ShellCheck >& /dev/null + if ! test -x /usr/bin/shellcheck >& /dev/null then skip "The ShellCheck package is not installed" fi
From: Ben Crocker bcrocker@redhat.com
Use test -x instead of dnf to check for presence of rpmlint.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index 15d9bb1e27db..1a639dead873 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,7 @@ }
@test "rpmlint" { - if ! dnf list installed rpmlint >& /dev/null + if ! test -x /usr/bin/rpmlint >& /dev/null then skip "The rpmlint package is not installed" fi
From: Ben Crocker bcrocker@redhat.com
Using 'test -x' instead of 'dnf list installed' to test for presence of bats package, don't need to redirect stdout & stderr.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/Makefile b/redhat/Makefile index e7ba07066177..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -393,7 +393,7 @@ dist-dump-variables: @$(REDHAT)/dist-dump-variables.sh
dist-self-test: - @if test -x /usr/bin/bats >& /dev/null; then \ + @if test -x /usr/bin/bats; then \ bats $(REDHAT)/self-test/*.bats ; \ else \ echo "dist-self-test: The bats package is not installed" ; \
From: Ben Crocker bcrocker@redhat.com
Use test -x instead of dnf to test for presence of rpminspect.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1003-rpminspect.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats index 0bda8e52000c..3dcf7f1ecc78 100644 --- a/redhat/self-test/1003-rpminspect.bats +++ b/redhat/self-test/1003-rpminspect.bats @@ -5,7 +5,7 @@ }
@test "rpminspect" { - if ! dnf list installed rpminspect >& /dev/null + if ! test -x /usr/bin/rpminspect >& /dev/null then skip "The rpminspect package is not installed" fi
From: Ben Crocker bcrocker@redhat.com
Using 'test -x' instead of 'dnf list installed' to test for presence of shellcheck, don't need to redirect stdout/stderr.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index 420b863e7453..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,5 +1,5 @@ @test "shellcheck" { - if ! test -x /usr/bin/shellcheck >& /dev/null + if ! test -x /usr/bin/shellcheck then skip "The ShellCheck package is not installed" fi
From: Ben Crocker bcrocker@redhat.com
Using 'test -x' instead of 'dnf list installed' to test for the presence of rpmlint, don't need to redirect stdout/stderr.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index 1a639dead873..093041d8cbfa 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,7 @@ }
@test "rpmlint" { - if ! test -x /usr/bin/rpmlint >& /dev/null + if ! test -x /usr/bin/rpmlint then skip "The rpmlint package is not installed" fi
From: Ben Crocker bcrocker@redhat.com
Use test -x instead of dnf to test for presence of bats.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 555dea25ea0f..e7ba07066177 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -393,7 +393,7 @@ dist-dump-variables: @$(REDHAT)/dist-dump-variables.sh
dist-self-test: - @if dnf list installed bats >& /dev/null; then \ + @if test -x /usr/bin/bats >& /dev/null; then \ bats $(REDHAT)/self-test/*.bats ; \ else \ echo "dist-self-test: The bats package is not installed" ; \
On Tue, 10 Nov 2020 22:49:53 -0000, GitLab Bridge on behalf of bcrocker wrote:
diff --git a/redhat/Makefile b/redhat/Makefile index 555dea25ea0f..e7ba07066177 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -393,7 +393,7 @@ dist-dump-variables: @$(REDHAT)/dist-dump-variables.sh
dist-self-test:
- @if dnf list installed bats >& /dev/null; then \
- @if test -x /usr/bin/bats >& /dev/null; then \ bats $(REDHAT)/self-test/*.bats ; \ else \ echo "dist-self-test: The bats package is not installed" ; \
Please merge this to the patch that is introducing this code instead of piling a fixup on top. Similarly for other patching in this set.
Nacked-by: Jiri Benc jbenc@redhat.com
On Wed, Nov 11, 2020 at 10:49:24AM +0100, Jiri Benc wrote:
On Tue, 10 Nov 2020 22:49:53 -0000, GitLab Bridge on behalf of bcrocker wrote:
diff --git a/redhat/Makefile b/redhat/Makefile index 555dea25ea0f..e7ba07066177 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -393,7 +393,7 @@ dist-dump-variables: @$(REDHAT)/dist-dump-variables.sh
dist-self-test:
- @if dnf list installed bats >& /dev/null; then \
- @if test -x /usr/bin/bats >& /dev/null; then \ bats $(REDHAT)/self-test/*.bats ; \ else \ echo "dist-self-test: The bats package is not installed" ; \
Please merge this to the patch that is introducing this code instead of piling a fixup on top. Similarly for other patching in this set.
Yes, as a tip on your local git tree you can do:
git rebase -i <previous sha1 from patch that introduced the dnf list line>
then you can pick the commit which adds test -x and squash it into the first commit:
pick <sha1 from patch that introduced the dnf list line> squash <sha1 from patch that adds test -x> ...
You can update the changelog with v2 and what changed, and then force push to the MR the new set.
If you already aware of rebase -i ignore me, just trying to help.
From: Ben Crocker bcrocker@redhat.com
Using 'test -x' instead of 'dnf list installed' to test for the presence of rpminspect, don't need to redirect stdout/stderr.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1003-rpminspect.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats index 3dcf7f1ecc78..58ec8f9665cd 100644 --- a/redhat/self-test/1003-rpminspect.bats +++ b/redhat/self-test/1003-rpminspect.bats @@ -5,7 +5,7 @@ }
@test "rpminspect" { - if ! test -x /usr/bin/rpminspect >& /dev/null + if ! test -x /usr/bin/rpminspect then skip "The rpminspect package is not installed" fi
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44657511...
Used 'git rebase -i' to squash the original 26 commits down to 8.
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44657593...
Good suggestion! Replaced dnf command with
if test -x /usr/bin/bats;
Also, no need now to redirect stdout/stderr.
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44657613...
Again, replaced 'dnf list installed' with 'test -x' (and removed the redirection of stdout/stderr).
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44657638...
Changed 'dnf list installed' to 'test -x'; also removed redirection of stdout/stderr.
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
These four tests test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- .../self-test/1005-dist-dump-variables.bats | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats
diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..2ebea70baf59 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,73 @@ +#!/usr/bin/env bats +function get_rpmversion +{ + # ts = tag or sha1 + ts=$1 + RPMKVERSION=$(git show $ts:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') + RPMKPATCHLEVEL=$(git show $ts:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') + RPMKSUBLEVEL=$(git show $ts:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') + RPMKEXTRAVERSION=$(git show $ts:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +} + +function prologue() +{ + tag=$1 + git show $tag:Makefile > Makefile + git add Makefile + git commit -m "Temporarily replace with $tag Makefile" + ofile=$BATS_TMPDIR/$tag.out + GIT=$BATS_TEST_DIRNAME/egit.sh EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function epilogue() +{ + git reset --hard HEAD^ +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=" $ofile && grep -x "SNAPSHOT=0" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc7" $ofile && grep -x "KEXTRAVERSION=.rc7" $ofile && grep -x "SNAPSHOT=0" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=9" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=.rc0" $ofile && grep -x "SNAPSHOT=1" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + status=1 + if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc5" $ofile && grep -x "KEXTRAVERSION=.rc5" $ofile && grep -x "SNAPSHOT=1" $ofile + then + status=$? + fi + epilogue + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of either 'git describe' or 'git merge-base' can be overridden by means of environment variables, EGIT_OVERRIDE_DESCRIBE and EGIT_OVERRIDE_MERGE_BASE respectively.
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm GIT=<path to egit.sh> EGIT_OVERRIDE_MERGE_BASE=<sha1> DIST=.elrdy make dist-srpm
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/egit.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..b998f868a314 --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + merge-base ) + if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] + then + # This should be an SHA1: + echo "$EGIT_OVERRIDE_MERGE_BASE" + else + git merge-base "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests. • 1005-dist-dump-variables.bats: override HEAD with the tag under test; simplifies (and speeds up) prologue, obviates epilogue, makes the whole process more robust by eliminating even temporary changes to the git repo; • egit.sh: eliminate as-yet-unused merge-base case.
Signed-off-by: Ben Crocker bcrocker@redhat.com
[redhat] Makefile.common: fix GITID for overridable HEAD
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile.common | 13 ++++++----- .../self-test/1005-dist-dump-variables.bats | 23 +------------------ redhat/self-test/egit.sh | 9 -------- 3 files changed, 8 insertions(+), 37 deletions(-)
diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats index 2ebea70baf59..bff950e6643a 100644 --- a/redhat/self-test/1005-dist-dump-variables.bats +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -1,27 +1,10 @@ #!/usr/bin/env bats -function get_rpmversion -{ - # ts = tag or sha1 - ts=$1 - RPMKVERSION=$(git show $ts:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') - RPMKPATCHLEVEL=$(git show $ts:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') - RPMKSUBLEVEL=$(git show $ts:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') - RPMKEXTRAVERSION=$(git show $ts:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -}
function prologue() { tag=$1 - git show $tag:Makefile > Makefile - git add Makefile - git commit -m "Temporarily replace with $tag Makefile" ofile=$BATS_TMPDIR/$tag.out - GIT=$BATS_TEST_DIRNAME/egit.sh EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile -} - -function epilogue() -{ - git reset --hard HEAD^ + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile }
@test "dist-dump-variables v5.8" { @@ -32,7 +15,6 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] }
@@ -44,7 +26,6 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] }
@@ -56,7 +37,6 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] }
@@ -68,6 +48,5 @@ function epilogue() then status=$? fi - epilogue [ "$status" = 0 ] } diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh index b998f868a314..f26921cc2aca 100755 --- a/redhat/self-test/egit.sh +++ b/redhat/self-test/egit.sh @@ -12,15 +12,6 @@ case $arg in git describe "$@" fi ;; - merge-base ) - if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] - then - # This should be an SHA1: - echo "$EGIT_OVERRIDE_MERGE_BASE" - else - git merge-base "$@" - fi - ;; * ) git "$arg" "$@" ;;
From: Ben Crocker bcrocker@redhat.com
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Checks for existence of /usr/bin/rpminspect via test -x
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1003-rpminspect.bats | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..58ec8f9665cd --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,15 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether the rpmlint package is installed; if it is not installed, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..093041d8cbfa 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,11 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
Makefile:
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
1005-dist-dump-variables.bats:
In prologue, need to unset environment variables that may have been inherited from a supra-make.
Collect the actual testing code into a new checkversion() function; add line breaks and indentation in both prologue() and checkversion() for better readability.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 7 ++++ .../self-test/1005-dist-dump-variables.bats | 41 ++++++++++--------- 2 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index fd10ac8f145d..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,13 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats index bff950e6643a..9251ca4636d5 100644 --- a/redhat/self-test/1005-dist-dump-variables.bats +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -4,49 +4,52 @@ function prologue() { tag=$1 ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile }
-@test "dist-dump-variables v5.8" { - tag=v5.8 - prologue $tag +function checkversion() +{ status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=" $ofile && grep -x "SNAPSHOT=0" $ofile + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile then status=$? fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" [ "$status" = 0 ] }
@test "dist-dump-variables v5.8-rc7" { tag=v5.8-rc7 prologue $tag - status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc7" $ofile && grep -x "KEXTRAVERSION=.rc7" $ofile && grep -x "SNAPSHOT=0" $ofile - then - status=$? - fi + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" [ "$status" = 0 ] }
@test "dist-dump-variables v5.8-9-g565674d613d7" { tag=v5.8-9-g565674d613d7 prologue $tag - status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=9" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=" $ofile && grep -x "KEXTRAVERSION=.rc0" $ofile && grep -x "SNAPSHOT=1" $ofile - then - status=$? - fi + checkversion $tag "5" "9" "0" "" ".rc0" "1" [ "$status" = 0 ] }
@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { tag=v5.8-rc5-99-g25ccd24ffd91 prologue $tag - status=1 - if grep -x "_TAG=$tag" $ofile && grep -x "RPMKVERSION=5" $ofile && grep -x "RPMKPATCHLEVEL=8" $ofile && grep -x "RPMKSUBLEVEL=0" $ofile && grep -x "RPMKEXTRAVERSION=-rc5" $ofile && grep -x "KEXTRAVERSION=.rc5" $ofile && grep -x "SNAPSHOT=1" $ofile - then - status=$? - fi + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" [ "$status" = 0 ] }
On Fri, Nov 13, 2020 at 09:11:36PM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Hi Ben,
Is there anyway you can combine parts of patch 4 and 5 into patch 3? It seems odd to see the history of the code in the patches like that.
Also you mentioned the rpmlint and rpminspect are not successful on invocation, but they still seemed wired up to make dist-self-tests. I would like to make sure 'make dist-self-tests' is always successful.
You can keep the rpmlint and rpminspect code in there, just disable it and put a comment that there is work to do before it passes and can be re-enabled.
Thoughts?
Cheers, Don
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of either 'git describe' or 'git merge-base' can be overridden by means of environment variables, EGIT_OVERRIDE_DESCRIBE and EGIT_OVERRIDE_MERGE_BASE respectively.
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm GIT=<path to egit.sh> EGIT_OVERRIDE_MERGE_BASE=<sha1> DIST=.elrdy make dist-srpm
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/egit.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..b998f868a314 --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + merge-base ) + if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] + then + # This should be an SHA1: + echo "$EGIT_OVERRIDE_MERGE_BASE" + else + git merge-base "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
On Mon, Nov 16, 2020 at 09:34:36PM -0000, GitLab Bridge on behalf of bcrocker wrote:
- merge-base )
if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ]
then
# This should be an SHA1:
echo "$EGIT_OVERRIDE_MERGE_BASE"
else
git merge-base "$@"
fi
;;
- )
git "$arg" "$@"
;;
Hi Ben,
Can we drop the above piece? You add it here, unused and then drop it in the next patch. Seems like unnecessary code churn.
Cheers, Don
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• egit.sh: eliminate as-yet-unused merge-base case.
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 7 +++ redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 9 --- 4 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats
diff --git a/redhat/Makefile b/redhat/Makefile index fd10ac8f145d..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,13 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh index b998f868a314..f26921cc2aca 100755 --- a/redhat/self-test/egit.sh +++ b/redhat/self-test/egit.sh @@ -12,15 +12,6 @@ case $arg in git describe "$@" fi ;; - merge-base ) - if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] - then - # This should be an SHA1: - echo "$EGIT_OVERRIDE_MERGE_BASE" - else - git merge-base "$@" - fi - ;; * ) git "$arg" "$@" ;;
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44943259...
Just a test comment
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44943358...
Another test comment
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44945155...
last one.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_44945397...
double email
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_45046055...
Hi Don,
OK, squashed two commits:
1) egit.sh initial commit; 2) Makefile, Makefile.common, egit.sh, 1005-dist-dump-variables.bats
I think this does what you asked for.
-- Ben
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 7 +++ redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index fd10ac8f145d..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,13 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 7 +++ redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index fd10ac8f145d..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,13 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 7 +++ redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index fd10ac8f145d..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,13 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 7 +++ redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index fd10ac8f145d..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,13 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
Add a description of the new dist-self-test target to dist-full-help.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
On Fri, Nov 20, 2020 at 12:17:02AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
Hi Ben I have some comments, please see them below and inline in the code.
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
I would split the addition of the dist-dump-variables in a new patch, because it's not related to the git replacement, it's a different topic. The dist-clean-scripts change is related to the dist-dump-variables, so it can be in the same dist-dump-variables new patch.
Add a description of the new dist-self-test target to dist-full-help.
You are adding the dist-self-test help in this patch, instead of patch 2, which really adds the dist-self-test target. I think you should move this to patch 2.
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 42 +++++++++++++++++++++++++++--------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..fd10ac8f145d 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -165,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts:
- @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi
This is subject to dist-dump-variables code and should be in the dist-dump-variables.sh patch as I suggested above.
+dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -199,7 +203,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +223,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +269,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +304,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- @git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" @@ -381,6 +385,13 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables:
- grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh
- chmod +x $(REDHAT)/dist-dump-variables.sh
- @$(REDHAT)/dist-dump-variables.sh
This hunk should be in the dist-dump-variables patch I suggested above.
dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -498,4 +509,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.'
- @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory'
This hunk should be in patch 2 in current series which is the one which really adds the dist-self-test target, doesn't belong here.
@echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
GitLab _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
On Mon, Nov 23, 2020 at 12:02:44PM -0300, Herton R. Krzesinski wrote:
On Fri, Nov 20, 2020 at 12:17:02AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
Hi Ben I have some comments, please see them below and inline in the code.
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Add dist-dump-variables for dynamically deriving variables from Makefile.common and dumping them.
Add a dist-clean-scripts target to clean up generated scripts.
I would split the addition of the dist-dump-variables in a new patch, because it's not related to the git replacement, it's a different topic. The dist-clean-scripts change is related to the dist-dump-variables, so it can be in the same dist-dump-variables new patch.
Actually you can move dist-dump-variables stuff to patch 2 as well, since it's where it's use is introduced, no need for a new patch.
I just had these comments, other than that the remaining patches/changes looks good to me.
Add a description of the new dist-self-test target to dist-full-help.
You are adding the dist-self-test help in this patch, instead of patch 2, which really adds the dist-self-test target. I think you should move this to patch 2.
(...)
- []'s Herton
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 7 +++ redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index fd10ac8f145d..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -392,6 +392,13 @@ dist-dump-variables: chmod +x $(REDHAT)/dist-dump-variables.sh @$(REDHAT)/dist-dump-variables.sh
+dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
On Fri, Nov 20, 2020 at 12:17:01AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
Acked-by: Don Zickus dzickus@redhat.com
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..115ffc172960 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-dump-variables target for dynamically deriving variables from Makefile.common and dumping them.
Create new dist-clean-scripts target to clean up generated scripts.
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
Add a description of the new dist-self-test target to dist-full-help.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 20 ++++++- redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index 115ffc172960..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +385,20 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -499,4 +516,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..115ffc172960 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-dump-variables target for dynamically deriving variables from Makefile.common and dumping them.
Create new dist-clean-scripts target to clean up generated scripts.
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
Add a description of the new dist-self-test target to dist-full-help.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 20 ++++++- redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index 115ffc172960..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +385,20 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -499,4 +516,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..115ffc172960 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-dump-variables target for dynamically deriving variables from Makefile.common and dumping them.
Create new dist-clean-scripts target to clean up generated scripts.
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
Add a description of the new dist-self-test target to dist-full-help.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 20 ++++++- redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index 115ffc172960..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +385,20 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -499,4 +516,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_45318353...
Herton,
I moved the code, as you suggested here and in your last comment, to patch 2.
-- Ben
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..115ffc172960 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-dump-variables target for dynamically deriving variables from Makefile.common and dumping them.
Create new dist-clean-scripts target to clean up generated scripts.
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
Add a description of the new dist-self-test target to dist-full-help.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 20 ++++++- redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index 115ffc172960..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +385,20 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -499,4 +516,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-dump-variables target for dynamically deriving variables from Makefile.common and dumping them.
Create new dist-clean-scripts target to clean up generated scripts.
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
Add a description of the new dist-self-test target to dist-full-help.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 20 ++++++- redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index 115ffc172960..84950bf876af 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -382,6 +385,20 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -499,4 +516,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..115ffc172960 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true + $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ - git add $(REDHAT)/$(CHANGELOG); \ - git add $(REDHAT)/marker; \ - git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \ + $(GIT) add $(REDHAT)/$(CHANGELOG); \ + $(GIT) add $(REDHAT)/marker; \ + $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + $(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
On Tue, Nov 24, 2020 at 05:00:20AM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Ben, sorry there are still some things I didn't catch earlier, please see below.
Signed-off-by: Ben Crocker bcrocker@redhat.com
redhat/Makefile | 29 +++++++++++++++-------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 834704a1a0a7..115ffc172960 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \
- set -- $$(git --version); \
- set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \
@@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH)
- @git diff --no-renames HEAD > $(TESTPATCH).tmp
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like
@@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch:
- @git diff --no-renames HEAD > $(TESTPATCH);
- @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -300,34 +301,34 @@ dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release
- git diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true
- $(GIT) diff-index --quiet HEAD && (echo "Nothing changed, skipping updates"; exit 0) || true $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \
- git add $(REDHAT)/$(CHANGELOG); \
- git add $(REDHAT)/marker; \
- git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
- $(GIT) add $(REDHAT)/$(CHANGELOG); \
- $(GIT) add $(REDHAT)/marker; \
- $(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)"; \
This hunk looks weird, because it's from before merge request 764 was merged.
I see that you fixed that through fixing conflicts at the merge commit https://gitlab.com/cki-project/kernel-ark/-/commit/d63caa0a5a5e9af524e486a09...
But can you instead just rebase your merge request here? Do a git rebase against current os-build and squash the merge conflict resolution into the first patch, it'll look cleaner and it's easier to review.
I think I didn't catch this as I looked at full diff yesterday on gitlab WebUI instead of the commit diff, and when I was re-reviewing today I just bumped on it here.
dist-release: dist-clean-sources @$(MAKE) dist-release-finish dist-release-tag:
- @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
- @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check:
- @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \
- @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi
- @git diff-index --quiet HEAD || \
- @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check
- @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \
@if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD
- @git checkout $(DIST_BRANCH)
- $(GIT) checkout $(DIST_BRANCH)
Any reason to remove the leading '@' here?
@cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline.
- MERGE_BASE:=$(shell git merge-base HEAD master)
- _TAG:=$(shell git describe $(MERGE_BASE))
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
- _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g')
else
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Herton Krzesinski on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_45371028...
Thanks, yes all things pointed above are addressed, this thread can be marked as solved.
From: Herton Krzesinski on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_45371059...
Thanks, yes all things pointed above are addressed, this thread can be marked as solved.
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-dump-variables target for dynamically deriving variables from Makefile.common and dumping them.
Create new dist-clean-scripts target to clean up generated scripts.
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
Add a description of the new dist-self-test target to dist-full-help.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 20 ++++++- redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index d74a0d3a27c1..00fd6b0c5384 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -389,6 +392,20 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -506,4 +523,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
On Tue, 24 Nov 2020 19:03:43 -0000, GitLab Bridge on behalf of bcrocker wrote:
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts:
- @if [ -f dist-dump-variables.sh ]; then rm dist-dump-variables.sh; fi
This does the same thing and is usually used:
rm -f dist-dump-variables.sh
The rest of the patch set looks good to me. I'm not sure what the latest version of the patches is, though, it seems the gitlab<->email gateway is not really working as it should.
Jiri
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 33 +++++++++++++++++---------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 7130f4e25c8c..d74a0d3a27c1 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -298,43 +299,43 @@ dist-rpm-baseonly: dist-sources # unless you know what you're doing, you don't want to use the next four ones dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) - @git add $(REDHAT)/$(CHANGELOG) - @git add $(REDHAT)/marker - @git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)" + @$(GIT) add $(REDHAT)/$(CHANGELOG) + @$(GIT) add $(REDHAT)/marker + @$(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)" dist-release-changed: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - @git update-index -q --really-refresh - @if git diff-index --quiet HEAD; then \ + @$(GIT) update-index -q --really-refresh + @if $(GIT) diff-index --quiet HEAD; then \ echo "Nothing changed, skipping updates"; \ else \ - git checkout -- $(REDHAT)/$(CHANGELOG); \ + $(GIT) checkout -- $(REDHAT)/$(CHANGELOG); \ $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ $(MAKE) dist-release-finish; \ fi dist-release: dist-clean-sources @$(MAKE) dist-release-changed dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + @$(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_45376670...
Rebased as suggested; fixed inadvertently-dropped '@'
On Tue, Nov 24, 2020 at 07:03:42PM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
Acked-by: Herton R. Krzesinski herton@redhat.com
On Tue, Nov 24, 2020 at 07:03:42PM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Acked-by: Don Zickus dzickus@redhat.com
Signed-off-by: Ben Crocker bcrocker@redhat.com _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/35#note_453840783
Should be resolved now with the new spec file changes introduced last month.
On Tue, Nov 24, 2020 at 09:37:57PM -0000, GitLab Bridge on behalf of Don Zickus wrote:
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/35#note_453840783
Should be resolved now with the new spec file changes introduced last month.
Sorry email bridge bug. A reply to 'issues' is attached to the last MR.
Cheers, Don
kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/33#note_453842283
Hmm, not sure why the new docs have not been updated on that page. We now recommend everyone start on 'os-build' and apply changes there.
Does that address your concern?
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/32#note_453843747
That is stale document data. Your clone should set you up at os-build (default branch) and everything should just work as expected. The 'master' branch just follows upstream but is merged nightly into os- build.
If you run the 'git clone' command or just run 'git fetch origin' and then git checkout os-build. You should be able to run 'make dist-srpm' and build the srpm to pass to koji.
Does that work?
From: Bastien Nocera on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/32#note_458163750
After checking out a fork of `kernel-ark`, I'd get warnings about the `master` branch not existing: ```sh $ make dist-srpm make -C redhat dist-srpm make[1]: Entering directory '/home/hadess/Projects/kernel/kernel- ark/redhat' fatal: Not a valid object name master BUILDID is ".test". cd /home/hadess/Projects/kernel/kernel-ark/redhat/configs; rm -f kernel-*.config \ kernel-*.config.orig \ kernel-*.config.tmp Gathering new log entries since 52c12966bf0ed365f95a3c3e6191a479d83d9d46 fatal: bad revision '^master' Creating linux-20201201git4b68483108eb.tar.xz... MARKER is 4b68483108eb fatal: ambiguous argument 'master..': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' ... ```
From: Bastien Nocera on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/33#note_458175202
Does that address your concern?
Should do once the docs are updated.
From: Bastien Nocera on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/35#note_458286006
No, it still fails trying to reference a master branch that might not exist, as mentioned in: https://gitlab.com/cki-project/kernel-ark/-/issues/32#note_458163750
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/35#note_459195031
Ok. Should be resolved with a documentation update [diffs](https://gitlab.com/cki-project/kernel- ark/-/merge_requests/772/diffs). Does executing "git branch master --track upstream/master" resolve the issue for you?
From: Bastien Nocera on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/35#note_460549580
Ok. Should be resolved with a documentation update
[diffs](https://gitlab.com/cki-project/kernel- ark/-/merge_requests/772/diffs). Does executing "git branch master --track upstream/master" resolve the issue for you?
It would create a `master` branch locally, but is that the right branch to get a commit ID that shows which upstream commit this kernel build is based on, rather than the commit ID of the last upstream branch merge on the current branch?
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
From: Ben Crocker bcrocker@redhat.com
GIT ?= git
and replace literal occurrences of 'git' with $(GIT). This change enables us to override 'git' with, e.g., some arbitrary shell script that prints additional information and/or does additional processing before and/or after (or even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 33 +++++++++++++++++---------------- redhat/Makefile.common | 16 ++++++++-------- 2 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/redhat/Makefile b/redhat/Makefile index 7130f4e25c8c..d74a0d3a27c1 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -1,3 +1,4 @@ +GIT ?= git include Makefile.common include Makefile.rhpkg
@@ -32,8 +33,8 @@ endif BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET) FLAVOR =
-RHGITURL?=$(shell git config rhg.url || git config remote.origin.url) -RHGITCOMMIT?=$(shell git log -1 --pretty=format:%H) +RHGITURL?=$(shell $(GIT) config rhg.url || $(GIT) config remote.origin.url) +RHGITCOMMIT?=$(shell $(GIT) log -1 --pretty=format:%H)
# this section is needed in order to make O= to work _OUTPUT := .. @@ -199,7 +200,7 @@ $(KABIDW_TARBALL): dist-git-version-check: @# genspec.sh uses pathspec magic that wasn't introduced until version 2.13 @IFS=" ."; \ - set -- $$(git --version); \ + set -- $$($(GIT) --version); \ IFS=; \ if [ "$$3" -lt 2 -o ( "$$3" -eq 2 -a "$$4" -lt 13 ) ]; then \ echo "ERROR: You need git version 2.13 or newer to run some setup commands"; \ @@ -219,7 +220,7 @@ setup-source: dist-git-version-check dist-clean-sources sources-rh: $(TARBALL) @cp -l $(TARBALL) $(SOURCES)/ || cp $(TARBALL) $(SOURCES)/ @touch $(TESTPATCH) - @git diff --no-renames HEAD > $(TESTPATCH).tmp + @$(GIT) diff --no-renames HEAD > $(TESTPATCH).tmp @# 1) filterdiff will return crap from the patches it just filtered, @# that's why egrep is needed so if there're changes under redhat/ @# but not everywhere else, it will be empty just like @@ -265,7 +266,7 @@ sources-rh: $(TARBALL) dist-sources: setup-source dist-configs-check dist-kabi dist-kabi-dup sources-rh
dist-test-patch: - @git diff --no-renames HEAD > $(TESTPATCH); + @$(GIT) diff --no-renames HEAD > $(TESTPATCH); @($(FILTERDIFF) $(TESTPATCH) | egrep -v "^index|^diff" >$(TESTPATCH).tmp; true) @mv $(TESTPATCH).tmp $(TESTPATCH);
@@ -298,43 +299,43 @@ dist-rpm-baseonly: dist-sources # unless you know what you're doing, you don't want to use the next four ones dist-release-finish: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) - @git add $(REDHAT)/$(CHANGELOG) - @git add $(REDHAT)/marker - @git commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)" + @$(GIT) add $(REDHAT)/$(CHANGELOG) + @$(GIT) add $(REDHAT)/marker + @$(GIT) commit -s ../Makefile.rhelver $(REDHAT)/marker $(REDHAT)/$(CHANGELOG) $(PACKAGE_NAME).spec.template -m "[redhat] $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PREBUILD)$(BUILD)$(BUILDID)" dist-release-changed: setup-source @cp $(SOURCES)/$(CHANGELOG) $(REDHAT)/$(CHANGELOG) @echo $(MARKER) > $(REDHAT)/marker @# if neither changelog nor marker was updated, skip bumping a release - @git update-index -q --really-refresh - @if git diff-index --quiet HEAD; then \ + @$(GIT) update-index -q --really-refresh + @if $(GIT) diff-index --quiet HEAD; then \ echo "Nothing changed, skipping updates"; \ else \ - git checkout -- $(REDHAT)/$(CHANGELOG); \ + $(GIT) checkout -- $(REDHAT)/$(CHANGELOG); \ $(REDHAT)/scripts/new_release.sh $(REDHAT) $(__YSTREAM) $(__ZSTREAM); \ $(MAKE) dist-release-finish; \ fi dist-release: dist-clean-sources @$(MAKE) dist-release-changed dist-release-tag: - @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE) + @$(GIT) tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" $(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
git-tree-check: - @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url gitlab 2>/dev/null)"; then \ + @if test -n "$(DIST_PUSH)" && test -z "$(shell $(GIT) remote get-url gitlab 2>/dev/null)"; then \ echo -e "Please run 'git remote add gitlab <url>' to enable git-push.\n"; \ exit 1; \ fi - @git diff-index --quiet HEAD || \ + @$(GIT) diff-index --quiet HEAD || \ { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
DIST_BRANCH ?= "os-build" dist-merge-upstream: git-tree-check - @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then \ + @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ exit 1; \ fi;
@# If TAG is empty, script defaults to master:HEAD - @git checkout $(DIST_BRANCH) + @$(GIT) checkout $(DIST_BRANCH) @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
dist-merge-upstream-push: export DIST_PUSH="1" diff --git a/redhat/Makefile.common b/redhat/Makefile.common index b335f3c77c7d..80c3b8dfccd4 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -1,4 +1,4 @@ -TOPDIR:=$(shell git rev-parse --show-toplevel) +TOPDIR:=$(shell $(GIT) rev-parse --show-toplevel) REDHAT:=$(TOPDIR)/redhat include $(TOPDIR)/Makefile.rhelver
@@ -6,11 +6,11 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell git show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell git show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell git log --max-count=1 --pretty=format:%H) +RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,8 +42,8 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) - _TAG:=$(shell git describe $(MERGE_BASE)) + MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') else
From: Ben Crocker bcrocker@redhat.com
Check via 'test -x' whether /usr/bin/shellcheck is present; if not, skip the test and print a message.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/0001-shellcheck.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/redhat/self-test/0001-shellcheck.bats b/redhat/self-test/0001-shellcheck.bats index cac9e3ab7c29..2fb9afbc875b 100644 --- a/redhat/self-test/0001-shellcheck.bats +++ b/redhat/self-test/0001-shellcheck.bats @@ -1,4 +1,8 @@ @test "shellcheck" { - run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") - [ "$status" = 0 ] + if ! test -x /usr/bin/shellcheck + then + skip "The ShellCheck package is not installed" + fi + run shellcheck $(find $BATS_TEST_DIRNAME/.. -name "*.sh") + [ "$status" = 0 ] }
From: Ben Crocker bcrocker@redhat.com
• Makefile:
Create new dist-dump-variables target for dynamically deriving variables from Makefile.common and dumping them.
Create new dist-clean-scripts target to clean up generated scripts.
Create new dist-self-test target and hook up the BATS self tests. Check for the presence of /usr/bin/bats (via 'test -x') and complain if it is not installed.
Add a description of the new dist-self-test target to dist-full-help.
• Makefile.common: make HEAD an overridable variable. Change GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) to GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be overridden by, e.g., self-tests.
• self-test/egit.sh: Initial commit
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common can be broken out into its own case. At the moment, the output of 'git describe' can be overridden by means of an environment variable, EGIT_OVERRIDE_DESCRIBE.
Use case: self test with test values for 'git describe'.
Other git subcommands are simply passed through.
Usage:
GIT=<path to egit.sh> EGIT_OVERRIDE_DESCRIBE=v5.9-rc8 DIST=.elrdy make dist-srpm
• self-test/1005-dist-dump-variables.bats: initial commit
The four tests in 1005-dist-dump-variables.bats test the RPM version generation, name generation, and snapshot designation for several previously chosen tags/commits.
The tags/commits chosen are:
a) v5.8 b) v5.8-rc7 c) v5.8-9-g565674d613d7 d) v5.8-rc5-99-g25ccd24ffd91
and the expected results are: a) RPMVERSION = 5.8.0, no rc b) RPMVERSION = 5.8.0, .rc7 c) RPMVERSION = 5.9.0, .rc0, snapshot d) RPMVERSION = 5.8.0, .rc5, snapshot
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/Makefile | 20 ++++++- redhat/Makefile.common | 13 +++-- .../self-test/1005-dist-dump-variables.bats | 55 +++++++++++++++++++ redhat/self-test/egit.sh | 18 ++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 redhat/self-test/1005-dist-dump-variables.bats create mode 100755 redhat/self-test/egit.sh
diff --git a/redhat/Makefile b/redhat/Makefile index d74a0d3a27c1..c807609fbf21 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -166,7 +166,10 @@ dist-clean-rpmdirs: rm -rf $$i; \ done;
-dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs +dist-clean-scripts: + @rm -f dist-dump-variables.sh + +dist-clean: dist-clean-sources dist-clean-configs dist-clean-rpmdirs dist-clean-scripts
dist-stub-key: @echo "Copying pre-generated keys"; @@ -389,6 +392,20 @@ dist-get-latest: dist-os-version: @echo "OSVERSION: $(RHEL_MAJOR).$(RHEL_MINOR)"
+.EXPORT_ALL_VARIABLES: +.PHONY: dist-dump-variables +dist-dump-variables: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" $(REDHAT)/Makefile.common | sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/echo "\1=$$\1"/' | sort | uniq > dist-dump-variables.sh + chmod +x $(REDHAT)/dist-dump-variables.sh + @$(REDHAT)/dist-dump-variables.sh + +dist-self-test: + @if test -x /usr/bin/bats; then \ + bats $(REDHAT)/self-test/*.bats ; \ + else \ + echo "dist-self-test: The bats package is not installed" ; \ + fi + dist-help: @echo 'Cleaning targets:' @echo ' dist-clean - Clean redhat/configs/ and redhat/rpm/ directories.' @@ -506,4 +523,5 @@ dist-full-help: @echo ' development tag.' @echo ' dist-os-version - Displays the current Red Hat Enterprise Linux versioni' @echo ' target used by the current branch/tree.' + @echo ' dist-self-test - Runs self-tests from the redhat/self-test directory' @echo '' diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 80c3b8dfccd4..cdffa9fb3d3d 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ else echo rpm; fi)
MACH := $(shell uname -m) -RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') -GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H) +HEAD ?= HEAD +RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') +RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') +RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') +RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') +GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD)) # marker is git tag which we base off of for exporting patches # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel # makefile as opposed to any adjusted version for snapshotting. @@ -42,7 +43,7 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base HEAD master) + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats new file mode 100644 index 000000000000..9251ca4636d5 --- /dev/null +++ b/redhat/self-test/1005-dist-dump-variables.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats + +function prologue() +{ + tag=$1 + ofile=$BATS_TMPDIR/$tag.out + # Have to unset environment variables that may be inherited from supra-make: + grep "^[ ]*[a-zA-Z_][a-zA-Z_0-9]*[ ]*[:?]*=" \ + $BATS_TEST_DIRNAME/../Makefile.common | \ + sed -e 's/[ ]*([a-zA-Z_][a-zA-Z_0-9]*).*/unset \1/' | \ + sort | uniq > $BATS_TMPDIR/unset-vars.sh + source $BATS_TMPDIR/unset-vars.sh + GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile +} + +function checkversion() +{ + status=1 + if grep -x "_TAG=$1" $ofile && \ + grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \ + grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \ + grep -x "KEXTRAVERSION=$6" $ofile && \ + grep -x "SNAPSHOT=$7" $ofile + then + status=$? + fi +} + +@test "dist-dump-variables v5.8" { + tag=v5.8 + prologue $tag + checkversion $tag "5" "8" "0" "" "" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc7" { + tag=v5.8-rc7 + prologue $tag + checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-9-g565674d613d7" { + tag=v5.8-9-g565674d613d7 + prologue $tag + checkversion $tag "5" "9" "0" "" ".rc0" "1" + [ "$status" = 0 ] +} + +@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" { + tag=v5.8-rc5-99-g25ccd24ffd91 + prologue $tag + checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1" + [ "$status" = 0 ] +} diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh new file mode 100755 index 000000000000..f26921cc2aca --- /dev/null +++ b/redhat/self-test/egit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + * ) + git "$arg" "$@" + ;; +esac
From: Ben Crocker bcrocker@redhat.com
1003-rpminspect.bats: initial commit.
Like the 1001-rpmlint.bats test, this test • tests for exactly one SRPM • runs rpminspect (instead of rpmlint) on that SRPM, after checking for the presence of the /usr/bin/rpminspect.
Both 1001-rpmlint.bats and 1003-rpminspect.bats Check via 'test -x' whether the /usr/bin/rpmlint or rpminspect, respectively, is installed; if not, skip the test and print a message.
For now, skip both tests entirely, pending fixes to kernel.spec.template.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/self-test/1001-rpmlint.bats | 12 +++++++++--- redhat/self-test/1003-rpminspect.bats | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 redhat/self-test/1003-rpminspect.bats
diff --git a/redhat/self-test/1001-rpmlint.bats b/redhat/self-test/1001-rpmlint.bats index bd0d8d1bcc24..6329fb0dc0a2 100644 --- a/redhat/self-test/1001-rpmlint.bats +++ b/redhat/self-test/1001-rpmlint.bats @@ -5,7 +5,13 @@ }
@test "rpmlint" { - srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") - run rpmlint $srpm - [ "$status" = 0 ] + if ! test -x /usr/bin/rpmlint + then + skip "The rpmlint package is not installed" + else + skip "Skip rpmlint test pending kernel.spec.template changes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpmlint $srpm + [ "$status" = 0 ] } diff --git a/redhat/self-test/1003-rpminspect.bats b/redhat/self-test/1003-rpminspect.bats new file mode 100644 index 000000000000..85194f8c083d --- /dev/null +++ b/redhat/self-test/1003-rpminspect.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats +@test "Exactly one SRPM exists" { + result=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm" | wc -l) + [ "$result" = 1 ] +} + +@test "rpminspect" { + if ! test -x /usr/bin/rpminspect + then + skip "The rpminspect package is not installed" + else + skip "Skip rpminspect test pending fixes" + fi + srpm=$(find "$BATS_TEST_DIRNAME"/.. -name "*.rpm") + run rpminspect $srpm + [ "$status" = 0 ] +}
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_46070143...
Jiri,
I made the change you suggested; thanks!
On Fri, 04 Dec 2020 14:25:21 -0000, GitLab Bridge on behalf of Ben Crocker wrote:
I made the change you suggested; thanks!
Thanks!
Acked-by: Jiri Benc jbenc@redhat.com
On Fri, Dec 04, 2020 at 02:23:11PM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com
Acked-by: Herton R. Krzesinski herton@redhat.com
On Fri, Dec 04, 2020 at 02:23:11PM -0000, GitLab Bridge on behalf of bcrocker wrote:
From: bcrocker on gitlab.com
Add a GIT macro to Makefile:
GIT ?= git
and replace literal occurrences of 'git' with $(GIT)\ in Makefile and Makefile.common.
Acked-by: Don Zickus dzickus@redhat.com
This change enables us to override 'git' with, e.g., some\ arbitrary shell script that prints additional information\ and/or does additional processing before and/or after (or\ even instead of) invoking /usr/bin/git.
Signed-off-by: Ben Crocker bcrocker@redhat.com _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-leave@lists.fedoraproject.org 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@lists.fedoraproject.org
From: Nicolas Chauvet on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/37#note_483827197
Wrong bug tracker.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/38#note_533778704
@grsm2020 - can you open a bug at bugzilla.redhat.com for this? These gitlab issues are mainly to track workflow problems. You actually have a kernel issue which is tracked by bugzilla.
-Don
From: grsm2020 on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/38#note_533799613
@dzickusrh Thanks!
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/2#note_535161266
Closing this. It is a known issue but I can't find anyone who has time to pursue it.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/6#note_535163575
Closing this out. A bunch of these docs are there. Not all though.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/8#note_535163819
Closing as merged.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/12#note_535164230
Closing as this is done.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/19#note_535164553
Closing as we went in a different direction.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/20#note_535165126
Closing as this is properly caught with a config update trigger a new CI pipeline.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/21#note_535165611
@jmflinuxtx - do we still need this or can we drop it from the spec file?
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/22#note_535165867
Closing as I think this is addressed now
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/24#note_535166635
@jmflinuxtx - i assume we still need this change for out-of-tree drivers that install in 'extras' even if kernel-module-extras is not installed?
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/25#note_535167332
closing as merged
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/28#note_535167940
Closing this out and we settled on a compromise solution for now.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/24#note_540248405
Closing as no kernel package owns that directory.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547598365
As a prerelease kernel, we have never relied on <N> for ordering, nor should we. This is not a valid 5.12 release. 5.12.0-1 should supercede it. I will say that the release bump is not entirely necessary, though you can get into the case of building multiple snapshots in the same day (rarely), and it can matter. I thought the solution we agreed upon was to reset the release number for each kernel series, so when we start snapshots for 5.13, that 186 drops back to 1.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547716096
I agree this is outside of Fedora here (although the NVR is not being changed for Rawhide, which is a different matter).
I wanted to clarify: in the example above, you would have `Release: 0.186.rc6.2021...` when the Fedora versioning guidelines are used, which have a lot of detail about handling pre-releases. This NVR would be superceded by kernel-5.12.0-1.
Aside: it seems `<N>` is not being dropped to 1 after each release. For kernel-5.12.0, the first tag uses 158, continuing from kernel-5.11.0-158.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547725975
The decision to drop `<N>` to 1 was made after 5.12 started as the numbers are climbing inconsistently with what we want. Realistically 100/200/300 have special meaning for Fedora stable releases, and rawhide should always be below 100. As to moving the `<N>` to before the rc, I don't have particularly strong opinion on it, it has always been used just before the fedora release for well over a decade at this point, so that was where it was kept when we added the git tag. Though `<N>` was typically '1'. For instance:
kernel-5.6.0-0.rc2.git2.1.fc33 kernel-3.0-0.rc6.git0.1.fc16
My only concern might be that someone has a script somewhere expecting behavior that has existed for over a decade.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547733607
My guess would be that the script would already have become confused at this point, given that `<snapinfo>` was added.
Related to `<snapinfo>`: it contains the date that the [RPM source files are generated](https://gitlab.com/cki-project/kernel-ark/-/blob/4712146f 5f9576d52f1276c1932d66bc6767a7d4/redhat/Makefile.common#L72-73). I believe it should actually contain the date that the code was committed to upstream (as extracted using Git). Otherwise, if you run the Makefile locally to generate RPMs you can use for bisection, the date is not meaningful.
I don't see that spelled out in the packaging guidelines, but I assume that is how it was meant to be used?
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547745411
Date in this case is very much important and different in that the git commit there is the upstream (Linus tree) commit, and not the kernel-ark commit id. Date gives us a bit more information as to what changes might have gone in between when Linus last pushed code, and when we created the dist-git for it. In fact, in all cases, I would assume git ID will give you the date of the upstream source commit, and date should be when the package was prepared for Fedora. Otherwise, the date is basically redundant information.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547864291
We can't rely on that, because a date is only used for snapshotting. `kernel-5.12.0-0.rc6.184` does not have a date in it, but everything you mentioned still applies; you could rebuild the same source with a new tag after making configuration fixes. My understanding is that `<N>` is supposed to be the field that distinguish changes in dist-git the way you described.
Yes, it is redundant to have both a date and a commit hash, but [it was meant](https://docs.fedoraproject.org/en-US/packaging- guidelines/Versioning/#_snapshots) to be that way:
All snapshots MUST contain a snapshot information field
(`<snapinfo>:`) in the Release: tag. That field must at minimum consist of the date in eight-digit "YYYYMMDD" format. The packager MAY include up to 17 characters of additional information after the date. The following formats are suggested:
`YYYYMMDD.<revision>`
`YYYYMMDD<scm><revision>`
Again, I'm just making sure I understand how this is expected to work now, and if it should be different based on the Fedora Versioning Guidelines or any other reason. I can open a MR for changes that make sense.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547881033
rc releases such as kernel-5.12.0-0.rc6.184 are built as release kernels which is why they differ. It is an actual upstream release.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547885204
https://www.kernel.org/ for reference.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547939066
Sorry if I am misunderstanding something. I was saying that for `kernel-5.12.0-0.rc6.20210408git454859c5.186` we should make the date (`20210408`) correspond to the upstream commit (`454859c5`). If we use the date that the Makefile is run, that is not reproducible behavior. It affects the filenames of source tarballs (which have to be generated), along with the package NVR itself.
You mentioned using the date to distinguish changes in dist-git that are independent of the upstream source. My comment was that we should being use `<N>` for that, not the snapshot date. A major reason is that the date might not even be in the NVR to begin with (which is expected). For example: - kernel-5.11.0-155 - kernel-5.11.0-156 - kernel-5.11.0-157 - kernel-5.11.0-158 can only be distinguished by `<N>`.
Similarly, I am suggesting we should be using `<N>` to distinguish these tags (from the last cycle), where dist-git changed but the upstream sources did not: - kernel-5.11.0-0.rc5.20210130git0e9bcda5.139 - kernel-5.11.0-0.rc5.20210131git0e9bcda5.140
If I rebuild from those tags on my local system today, and make no modifications, it would generate packages named - kernel-5.11.0-0.rc5.20210408git0e9bcda5.139 - kernel-5.11.0-0.rc5.20210408git0e9bcda5.140 which does not reproduce the earlier behavior. (If I make any local changes, I should set the BUILDID or somehow tag the package differently.)
Is that reasonable? Am I overlooking something?
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547944992
kernel-5.11.0-155 kernel-5.11.0-156 kernel-5.11.0-157 kernel-5.11.0-158
These are tags by an autogenerated by scripts and have nothing to do with dist-git because most of them were not used. Of those, only kernel-5.11.0-155 was built for rawhide, with an extra build of 156 for F34. The rest of them were never in dist-git at all. `<N>` does distinguish the actual tag applied and is useful there. The date is useful in being able to quickly see when a build was last done, or more importantly to distinguish quickly if a script failed and ark-latest does not have a valid new build. As we build rawhide almost daily, and in the morning, I can tell you what I build in dist-git today was in Linus' tree yesterday most of the time. There is a 1 day difference in most cases. It is static, and as a maintainer it is much more useful as a representation of when the tree was built vs when linus handled a pull request. Remember, this date doesn't necessarily correlate with when I generate dist-git so much as when ark-latest is composed in practice. It has happened several times that I don't get to a build until the next day, but before the script runs. By the time that finishes koji, it looks like a fresh build, but it is probably time to start the next one because that was older. Developers are doing various things from os- build, but from a maintainer standpoint, dist-git is only generated from ark-latest.
As to whether `<N>` remains where it is, or is moved to between the 0 and rc, I just don't care all that much. The reasons for keeping it at the end are, it seems more logical with the build number being at the end, as versioning gets more granular from left to right. It also falls into the "if it ain't broke" category in that it has been there for a good 10 years now, and I don't see any particular advantage to changing it. But in the end, it doesn't really make a ton of difference to me. Perhaps some of the ELN developers and maintainers would have stronger opinions there as they have a *lot* more tooling around completed builds than Fedora does.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_547946553
It is an important distinction that the typical package has an upstream source repository, and dist-git. We have essentially 2 different upstream repositories and dist-git, so having the date generated the way it does gives me some information about the kernel-ark repository, while the git tag gives me some information about upstream, both are useful in day to day at a glance.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/40#note_548390887
Two more odd observations about the error. First, I closed all of those MRs yestrday, and when the script ran again, it just recreated them, even though there should be no config issues (files are in pending- fedora, the config should be sane).
Second, it creates the files in pending-fedora, it does not create files in pending-common (and shouldn't need to because the configs options are not exposed for RHEL), but the MR is for new empty files in common. Typical behavior would create files in pending-common and create an MR to move those to common.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/41#note_550913432
There are a couple of things here:
Fedora RPM tagging in the ARK kernel began in May 2020 for fc33.
This line is not entirely accurate, as ARK was only used for Rawhide from May of 2020 until the 5.11 rebases happened last month. At that point, ARK was used for all 5.11.* releases.
They are not tagged differently because they are not different in any way. The script to do stable releases literally sits on the same commit (currently in the fedora-5.11 branch) and does: ``` for release in `cat redhat/release_targets`; do case "$release" in 34) build=300 ;; 33) build=200 ;; 32) build=100 ;; esac make IS_FEDORA=1 DIST=".fc$release" BUILDID="" BUILD=$build RHDISTGIT_BRANCH=f$release dist-git; done ```
There have been cases where the configs differ across versions, but that is not currently the case Any time that case does pop up, it will be notated in redhat/rebase-notes.txt. The source tarball and patch set are identical as they are built from the same script based on the same commit on the same branch. The 15 mentioned there is somewhat relevant in that it is the 15th tagged build of 5.11, but given that we very rarely do more than one build of a given upstream release, just searching for 5.11.13 will likely find you the tag you are looking for. I suppose we could reset that number with every version bump so that it would match the last digit of BUILD always.
From: Denis Efremov on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/41#note_550926292
I suppose we could reset that number with every version bump so that
it would match the last digit of BUILD always.
This would be handy. Because, otherwise I can't determine a tagname automatically based only on a "package-version" name. Currently, I need first to grep all available tags for kernel-5.11.13, find the tag with suffix -15 and only after checkout to it.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/41#note_550951201
This would be handy. Because, otherwise I can't determine a tagname
automatically based only on a "package-version" name. Currently, I need first to grep all available tags for kernel-5.11.13, find the tag with suffix -15 and only after checkout to it.
Okay, will look at getting this built into the scripts. In the meantime, grep all available tags for kernel-5.11.13 should return exactly 1 result, and the same goes for any 5.11.x that we actually shipped to a stable fedora release.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/41#note_551800150
Just as an update, for a quick temp fix, I modified the fedora-5.11 tree to always set it to 0, and I can manually bump it if I end up doing a second build for any reason. Better solution to come in 5.12
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_555069659
The reason that this is set is because there is overhead in running debug builds. We have a whole lot of users willing to run a rawhide kernel for day to day, and the testing we get from that is very valuable. The agreement we have, is the first build for each new rcX is built as a release kernel. That is also copied off to the rawhide no- debug repository so we have a secure-boot signed kernel there which is not a debug kernel.
The debug builds in between are much more useful for various testing mechanisms, and for users who are more interested in test environments than running their desktop off of it, though we do have a few users who will run their desktops on those builds as well. Making the in between releases debug only kind of forces some testing that would not otherwise occur, and leads to frequent finds of new lockdep issue, etc.
The 'make debug' and 'make release' commands mentioned in the spec file should be changed, they are a relic from the pre-kernel-ark days when I did have to run 'make release' for every rcX build and 'make debug' to get back to snapshots. Those commands would just flip the bit in the spec file and bumpspec for the changelog.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_555101078
Ok, that's what I had assumed. Can we make the naming consistent though, while still accomplishing that?
I'm suggesting we build non-releases using `--with-dbgonly`. Then either we: - follow the branched naming scheme — so non-releases only produce packages named `kernel-debug`, while releases also produce packages named `kernel`; or - invert the branched naming scheme — so non-releases only produce packages named `kernel`, while releases also produce packages named `kernel-nodebug`
I'm not sure what you mean by the no-debug repository? All packages are going into the mirrors now, e.g.: https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everyt hing/source/tree/Packages/k/kernel-5.12.0-0.rc7.20210416git7e25f40eab52. 191.fc35.src.rpm
so someone who has the "kernel" package installed and upgrades it is constantly switching from a debug build to a non-debug build.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_555112975
Ok, that's what I had assumed. Can we make the naming consistent
though, while still accomplishing that?
The naming is inline with package guidelines. rcX releases are in fact upstream releases (you can download the tarball on kernel.org). The git snapshots are not releases, and are snapshots. Versioning follows for each. As to the sub packages, producing only kernel-debug for a non debug build will break a whole lot of the things we wish to test. The existance of a package called 'kernel' is fairly critical. Inverting the naming would just be confusing for everyone involved. Again, we want those scripts which just rely on 'kernel' to test the debug kernel frequently, but also the non debug kernel at least once a week (we have had issues where things worked in a debug kernel, and broke in non debug). As to the users who prefer to only run non-debug kernels, they get those in Rawhide nodebug, or only do updates on Monday evening or Tuesday morning.
I'm not sure what you mean by the no-debug repository?
https://dl.fedoraproject.org/pub/alt/rawhide-kernel-nodebug/ It is set to ensure that people always get the latest debug kernel with a 'dnf update' for people using the rawhide repository for other things, they can exclude kernel in the rawhide repository config, for people using stable kernel but running a rawhide kernel, stable versions will always be lower. In either case, adding rawhide-nodebug as a separate repository will keep the intended kernel installed. We added this repository and model in 2012.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_555122607
What about users who only want to install debug kernels, and want to stay up-to-date with the latest build (regardless of whether it is a snapshot and release)? Is there a way to do that automatically?
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_555184424
`kernel` and `kernel-debug` are both just metapackages.
When `%{debugbuildsenabled}` is 0, can we still produce a `kernel-debug` metapackage?
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_555185290
It is not a use case that has an easy solution within the confines of rpm/dnf right now, though the simple way to do it would be to write up repo builder script that grabs the latest build daily if it has changed. If kernel-debug exists, delete the non-debug packages, otherwise keep the base packages, run createrepo and add a dnf config for kernels from that local repository.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_555188897
`kernel` and `kernel-debug` are both just metapackages.
When `%{debugbuildsenabled}` is 0, can we still produce a `kernel-
debug` metapackage?
This would be a possible solution. Don't think there is any problem with multiple meta packages.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/43#note_555971912
Fixed with https://gitlab.com/cki-project/kernel- ark/-/commit/8691fd224224aa9aecce9ad2105e4b0828f5cd8d
From: Denis Efremov on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/41#note_557826775
Thank you for your help. I faced that there is no tag for kernel-5.11.2 release (kernel-5.11.2-300.fc34.src.rpm). ``` $ git tag | grep kernel-5.11.[123]- kernel-5.11.1-2 kernel-5.11.3-5 ``` If you can add it, this would greatly simplify my life. Thanks once again
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_562573307
I think I lumped too many different things together, and I'd like to focus on just one question that is important to me.
If someone checks out a specific tag in kernel-ark (which in turn corresponds to a specific upstream commit), and runs `make dist-all-rpm` to produce a package — how can we make sure it produces exactly the same NVR, regardless of what the system clock says when that command is run?
I believe the correct answer is, for snapshots, we should replace `date +%Y%m%d` with the date that the tagged commit was made in kernel-ark. (This is _not_ an upstream commit merged by Linus; it is a commit on the `os-build` branch.) If that tagged commit is `$(HEAD)`, then the date would be `git show -s --format=%cd --date=format:%Y%m%d $(HEAD)`.
If I'm interested in the exact time that a build was run, rather than what sources the build contains, that information exists outside of the NVR. The RPM package metadata contains the build date. Koji [also shows](https://koji.fedoraproject.org/koji/buildinfo?buildID=1740788) when the build task was started and completed.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_562593935
Koji has nothing to do with the date tag in the n-v-r, the date tag is when 'make release' was run, which may not be the same date that release is pushed to dist-git with 'make dist-git', and neither of those dates have any direct correlation to when the build was submitted to koji. The git tag in the NVR is the git tag of the upstream commit used. The tag in the kernel-ark tree is placed on the commit used in os-build to make that release, and the date is the date at which the make release was tagged. Make dist-all-rpm is used for testing and development purposes, and expects that there may be changes not from a tagged release, so it can intentionally change the goalpost. Make dist-git is what I would use to create an exact copy of a release.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_562616785
Focusing on this part:
The tag in the kernel-ark tree is placed on the commit used in os-
build to make that release, and the date is the date at which the make release was tagged.
We want to use this exact moment as the date in the NVR. But, I believe we should read that from the commit date, not from the system clock.
Make dist-all-rpm is used for testing and development purposes, and
expects that there may be changes not from a tagged release, so it can intentionally change the goalpost.
If there are local changes, they should be committed locally (not necessarily tagged) and that would affect the commit date though, right?
Can we make it so that if there are no local changes — if this is a pristine copy of earlier sources — we get the same NVR? If I am rebuilding a package today from the exact sources that were tagged 3 weeks ago, I believe the date should be 3 weeks ago, not today.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_562648033
We want to use this exact moment as the date in the NVR. But, I
believe we should read that from the commit date for that tag, not from the shell script checking the system clock after it has been tagged.
We can't use the exact moment, the version string on a snapshot is as long as practical, we can barely append 'test' for a test build due to rpm limitation. It could be that date I suppose. Though there is nothing there that guarantees it matches what was tagged.
If there are local changes, they should be committed locally (not
necessarily tagged) and that would affect the commit date though, right?
Can we make it so that if there are no local changes — if this is a
pristine copy of earlier sources — we get the same NVR? If I am rebuilding a package today from the exact sources that were tagged 3 weeks ago, I believe the date should be 3 weeks ago, not today.
I don't think this is a versioning issue, so much as a script issue. The right way to do this would be to add a make reproduceable-build target which did a clean checkout of that tag and disgarded all untracked files, then it used that date. That target does not exist right now, and there is no way for current targets to validate that what you are building is in fact identical. The actual kernel patches are checked for uncommitted changes, but the rpm files, configs, etc are not.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_562665828
Of note, I think the reason this does not exist, and no one has cared to put in the effort, is because dist-git is still considered the canonical source of truth for Fedora builds, and if you want an exact reproduction of that day, this is where you would build it from. The kernel-ark tree is used for development, releases are tagged because it is helpful for debugging issues with a specific build, but the versioning changing makes complete sense because you are not reproducing the exact build, you are building something possibly quite different. If you wanted the exact build, you would use dist-git.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_562688620
We can't use the exact moment [...] It could be that date I suppose.
Though there is nothing there that guarantees it matches what was tagged.
This is what I meant. I'd like to create a MR that does this.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/44#note_565170086
This was fixed with f23ad26468fce25011739cf9980761ef81483c43 Sorry, was getting to it, today's build was broken in multiple ways, and I have been workign through them.
From: Julian Sikorski on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/45#note_566019053
`git remote add stable git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git && git fetch stable` allows to work this issue around.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/45#note_566036154
Tags are there, I never did a tag push because I hadn't gotten that far in the release yet for 5.12.1 and 5.11.18 builds. I changed my sync script to push them when I pull from greg though. Sorry about that.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/45#note_566062987
Of note, the commit log from 8da650b56e4fec39041edc15f2c328e2b7d29717:
A few more fixes for local builds. None of this works until .1
Until I have tagged and pushed kernel-5.12.1-0, do not expect the fedora-5.12 branch to be effective. I mainly pushed it so that Peter could do the arm clean ups that he typically does for stable releases as he has time, and so that fixes from 5.11 could be applied and don't get forgotten. I should have everything working today at some point.
From: Herton R. Krzesinski on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/46#note_566395197
In the case of sctp, sctp_diag is on kernel-modules and is pulling sctp back to it. The fix is to add sctp_diag to the mod-extra.list.
In the case of the l2tp* modules, the l2tp_ip6 is pulling l2tp_core and l2tp_ip into kernel-modules. THe fix is to add l2tp_ip6 to mod- extra.list.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/47#note_567069865
Did a test build with # CONFIG_DEBUG_INFO_BTF is not set, this is not the problem, I get the same output.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/48#note_567130107
No, it is not, the issue came up a while ago in Linux next, and they fixed it for everything but aarch64. I have brought it up with upstream maintainers and was told:
the fix is being worked on, just figuring the proper way at the
moment:
https://lore.kernel.org/bpf/20210427182053.ttiuxdt675lzmvk3@kafai-
mbp.dhcp.thefacebook.com/T/#mb49c7d3d32700fa0e9c8b019fa3bf9d9e0cc3bf5
I am still pushing to rawhide because the build data for other architectures is useful and relevant. Closing this as it is an upstream issue that will be fixed in ark within a day of the fix landing upstream.
From: John Villalovos on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/48#note_567132410
Thanks! I was thinking I was making a mistake in my build.
I'll try again with x86_64 and see if my build system can build that.
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/48#note_567145528
Wait just a minute on that, there is a filter issue with the surface modules merge. I am testing a fix, but your x86_64 build will fail until I get that pushed.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_569254855
@dpward @jmflinuxtx - do we have an agreed solution here?
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/40#note_569255302
@jmflinuxtx - i think my MR earlier this week addresses your example? If so, can we close this an open a new issue when a new example shows up?
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_569256340
@dpward @jmflinuxtx - did the two of you agreed to a path forward?
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_569259385
I thought this was fixed with MR https://gitlab.com/cki-project/kernel- ark/-/merge_requests/1061
From: Justin Forbes on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/40#note_569259804
I was waiting until the merge window closes to do the Fedora configs, which would properly test this. Either close it, and I can reopen if it doesn't, or I will close the issue once I have done them and verified that it does.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/40#note_569264346
Works for me.
Cheers, Don
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/39#note_569300704
Yes, I meant this to close this.
From: David Ward on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_569309561
I'm going to open an MR which fixes the text in the SPEC file to reflect the current behavior, now that I understand the way this flag is meant to be used, and let that close this issue.
I believe we agree that metapackaging would make it possible to keep the latest debug variant installed in Rawhide, which would be useful; but I think that's a separate issue.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/42#note_570141957
David Ward commented:
I'm going to open an MR which fixes the text in the SPEC file to
reflect the current behavior, now that I understand the way this flag is meant to be used, and let that close this issue.
I believe we agree that metapackaging would make it possible to keep
the latest debug variant installed in Rawhide, which would be useful; but I think that's a separate issue.
Thanks. Works for me.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/46#note_582301236
Resolved with !1117
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/30#note_582336789
Dummy message to see if this still hits mailing list.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/30#note_582363024
Trying again.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/30#note_582366819
testing
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/issues/30#note_582368302
another
From: Ben Crocker on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/670#note_45318331...
Herton,
I moved the code, as you suggested here and in your next comment, to patch 2. This does, indeed, improve the logical flow.
-- Ben
kernel@lists.fedoraproject.org