Skip to content

Commit

Permalink
Build: spec: accommodate git's new autoscaling hash abbreviation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jnpkrn committed Feb 6, 2017
1 parent 0132a14 commit b35399b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions GNUmakefile
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion pacemaker.spec.in
Expand Up @@ -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
Expand All @@ -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 $?)
Expand Down

0 comments on commit b35399b

Please sign in to comment.