Skip to content

Commit b35399b

Browse files
committed
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.
1 parent 0132a14 commit b35399b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

GNUmakefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ lparen = (
5252
rparen = )
5353
SHORTTAG ?= $(shell case $(TAG) in Pacemaker-*$(rparen) echo '$(TAG)' | cut -c11-;; \
5454
*$(rparen) git log --pretty=format:%h -n 1 '$(TAG)';; esac)
55+
SHORTTAG_ABBREV = $(shell printf %s '$(SHORTTAG)' | wc -c)
5556
WITH ?= --without doc
5657
#WITH ?= --without=doc --with=gcov
5758

@@ -192,8 +193,9 @@ srpm-%: export $(PACKAGE)-%.spec
192193
if [ -e $(BUILD_COUNTER) ]; then \
193194
echo $(COUNT) > $(BUILD_COUNTER); \
194195
fi
195-
sed -e 's/global\ specversion.*/global\ specversion\ $(SPECVERSION)/' \
196-
-e 's/global\ commit.*/global\ commit\ $(TAG)/' \
196+
sed -e 's/global\ specversion\ .*/global\ specversion\ $(SPECVERSION)/' \
197+
-e 's/global\ commit\ .*/global\ commit\ $(TAG)/' \
198+
-e 's/global\ commit_abbrev\ .*/global\ commit_abbrev\ $(SHORTTAG_ABBREV)/' \
197199
-i $(PACKAGE).spec
198200
$(call rpmbuild-with,$(WITH),-bs --define "dist .$*" $(RPM_OPTS),$(PACKAGE).spec)
199201

pacemaker.spec.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
## Upstream commit (or git tag, such as "Pacemaker-" plus the
2020
## {pcmkversion} macro for an official release) to use for this package
2121
%global commit HEAD
22+
## Since git v2.11, the extent of abbreviation is autoscaled by default
23+
## (used to be constant of 7), so we need to convey it for non-tags, too.
24+
%global commit_abbrev 7
2225

2326

2427
# Define globals for convenient use later
@@ -30,7 +33,7 @@
3033
## Short version of git commit
3134
%define shortcommit %(c=%{commit}; case ${c} in
3235
Pacemaker-*%{rparen} echo ${c:10};;
33-
*%{rparen} echo ${c:0:7};; esac)
36+
*%{rparen} echo ${c:0:%{commit_abbrev}};; esac)
3437

3538
## Whether this is a tagged release
3639
%define tag_release %([ %{commit} != Pacemaker-%{shortcommit} ]; echo $?)

0 commit comments

Comments
 (0)