From 0132a14856395c78fd09bacc1d8717b292b00a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= Date: Mon, 6 Feb 2017 17:17:33 +0100 Subject: [PATCH 1/2] Build: GNUMakefile: normalize quoting a bit, simplify repeated seds By using single quotes, it's less probable that make variables will be confused with shell ones. Also remove quoting when superfluous. --- GNUmakefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 5f4119de322..bad7d0c5df1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -45,13 +45,13 @@ ARCH ?= $(shell test -e /etc/fedora-release && rpm --eval %{_arch}) MOCK_CFG ?= $(shell test -e /etc/fedora-release && echo fedora-$(F)-$(ARCH)) DISTRO ?= $(shell test -e /etc/SuSE-release && echo suse; echo fedora) COMMIT ?= HEAD -TAG ?= $(shell T=$$(git describe --all "$(COMMIT)" | sed -n 's|tags/\(.*\)|\1|p'); \ +TAG ?= $(shell T=$$(git describe --all '$(COMMIT)' | sed -n 's|tags/\(.*\)|\1|p'); \ test -n "$${T}" && echo "$${T}" \ - || git log --pretty="format:%H" -n 1 "$(COMMIT)") + || git log --pretty=format:%H -n 1 '$(COMMIT)') lparen = ( rparen = ) -SHORTTAG ?= $(shell case $(TAG) in Pacemaker-*$(rparen) echo $(TAG) | cut -c11-;; \ - *$(rparen) git log --pretty="format:%h" -n 1 "$(TAG)";; esac) +SHORTTAG ?= $(shell case $(TAG) in Pacemaker-*$(rparen) echo '$(TAG)' | cut -c11-;; \ + *$(rparen) git log --pretty=format:%h -n 1 '$(TAG)';; esac) WITH ?= --without doc #WITH ?= --without=doc --with=gcov @@ -192,8 +192,9 @@ srpm-%: export $(PACKAGE)-%.spec if [ -e $(BUILD_COUNTER) ]; then \ echo $(COUNT) > $(BUILD_COUNTER); \ fi - sed -i 's/global\ specversion.*/global\ specversion\ $(SPECVERSION)/' $(PACKAGE).spec - sed -i 's/global\ commit.*/global\ commit\ $(TAG)/' $(PACKAGE).spec + sed -e 's/global\ specversion.*/global\ specversion\ $(SPECVERSION)/' \ + -e 's/global\ commit.*/global\ commit\ $(TAG)/' \ + -i $(PACKAGE).spec $(call rpmbuild-with,$(WITH),-bs --define "dist .$*" $(RPM_OPTS),$(PACKAGE).spec) chroot: mock-$(MOCK_CFG) mock-install-$(MOCK_CFG) mock-sh-$(MOCK_CFG) From b35399b8dd7d8e56d43dcabd55b567f2a0ff7594 Mon Sep 17 00:00:00 2001 From: Jan Pokorny Date: Mon, 6 Feb 2017 16:47:16 +0100 Subject: [PATCH 2/2] Build: spec: accommodate git's new autoscaling hash abbreviation Since that new feature of git v2.11.0, "make srpm" stopped working properly as currently, pacemaker ranks as eligible for commits abbreviated at 9 hexa digits, not mere 7, which was previously a default and also implicitly assumed in the build/release process as a constant. --- GNUmakefile | 6 ++++-- pacemaker.spec.in | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index bad7d0c5df1..5752276efb7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -52,6 +52,7 @@ lparen = ( rparen = ) SHORTTAG ?= $(shell case $(TAG) in Pacemaker-*$(rparen) echo '$(TAG)' | cut -c11-;; \ *$(rparen) git log --pretty=format:%h -n 1 '$(TAG)';; esac) +SHORTTAG_ABBREV = $(shell printf %s '$(SHORTTAG)' | wc -c) WITH ?= --without doc #WITH ?= --without=doc --with=gcov @@ -192,8 +193,9 @@ srpm-%: export $(PACKAGE)-%.spec if [ -e $(BUILD_COUNTER) ]; then \ echo $(COUNT) > $(BUILD_COUNTER); \ fi - sed -e 's/global\ specversion.*/global\ specversion\ $(SPECVERSION)/' \ - -e 's/global\ commit.*/global\ commit\ $(TAG)/' \ + sed -e 's/global\ specversion\ .*/global\ specversion\ $(SPECVERSION)/' \ + -e 's/global\ commit\ .*/global\ commit\ $(TAG)/' \ + -e 's/global\ commit_abbrev\ .*/global\ commit_abbrev\ $(SHORTTAG_ABBREV)/' \ -i $(PACKAGE).spec $(call rpmbuild-with,$(WITH),-bs --define "dist .$*" $(RPM_OPTS),$(PACKAGE).spec) diff --git a/pacemaker.spec.in b/pacemaker.spec.in index 595d7a4193e..34a107674c8 100644 --- a/pacemaker.spec.in +++ b/pacemaker.spec.in @@ -19,6 +19,9 @@ ## Upstream commit (or git tag, such as "Pacemaker-" plus the ## {pcmkversion} macro for an official release) to use for this package %global commit HEAD +## Since git v2.11, the extent of abbreviation is autoscaled by default +## (used to be constant of 7), so we need to convey it for non-tags, too. +%global commit_abbrev 7 # Define globals for convenient use later @@ -30,7 +33,7 @@ ## Short version of git commit %define shortcommit %(c=%{commit}; case ${c} in Pacemaker-*%{rparen} echo ${c:10};; - *%{rparen} echo ${c:0:7};; esac) + *%{rparen} echo ${c:0:%{commit_abbrev}};; esac) ## Whether this is a tagged release %define tag_release %([ %{commit} != Pacemaker-%{shortcommit} ]; echo $?)