Skip to content

Commit

Permalink
Merge pull request ClusterLabs#1221 from jnpkrn/build
Browse files Browse the repository at this point in the history
Build: keep "make srpm" working with newer git versions
  • Loading branch information
kgaillot authored Feb 6, 2017
2 parents a39ea64 + b35399b commit 7b6e292
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 9 additions & 6 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ 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)
SHORTTAG_ABBREV = $(shell printf %s '$(SHORTTAG)' | wc -c)
WITH ?= --without doc
#WITH ?= --without=doc --with=gcov

Expand Down Expand Up @@ -192,8 +193,10 @@ 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)/' \
-e 's/global\ commit_abbrev\ .*/global\ commit_abbrev\ $(SHORTTAG_ABBREV)/' \
-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)
Expand Down
5 changes: 4 additions & 1 deletion pacemaker.spec.in
Original file line number Diff line number Diff line change
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 7b6e292

Please sign in to comment.