CTS tests rpm building. This just uses the branch name instead of a tag (if no tag). Also move shell scripting into build-aux/git-spec-version
Signed-off-by: Angus Salkeld <[email protected]> --- Makefile.am | 39 +------------------------- build-aux/git-spec-version | 66 ++++++++++++++++++++++++++++++++++++++++++++ build-aux/git-version-gen | 7 ++++ 3 files changed, 74 insertions(+), 38 deletions(-) create mode 100755 build-aux/git-spec-version diff --git a/Makefile.am b/Makefile.am index f448eaa..4781d0a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -106,44 +106,7 @@ clean-generic: ## make rpm/srpm section. $(SPEC): $(SPEC).in - rm -f $...@-t $@ - LC_ALL=C date="$(shell date "+%a %b %d %Y")" && \ - if [ -f .tarball-version ]; then \ - gitver="$(shell cat .tarball-version)" && \ - rpmver=$$gitver && \ - alphatag="" && \ - dirty="" && \ - numcomm="0"; \ - else \ - gitver="$(shell git describe --abbrev=4 --match='v*' HEAD 2>/dev/null)" && \ - rpmver=`echo $$gitver | sed -e "s/^v//" -e "s/-.*//g"` && \ - alphatag=`echo $$gitver | sed -e "s/.*-//" -e "s/^g//"` && \ - vtag=`echo $$gitver | sed -e "s/-.*//g"` && \ - numcomm=`git rev-list $$vtag..HEAD | wc -l` && \ - git update-index --refresh > /dev/null 2>&1 || true && \ - dirty=`git diff-index --name-only HEAD 2>/dev/null`; \ - fi && \ - if [ -n "$$dirty" ]; then dirty="dirty"; else dirty=""; fi && \ - if [ "$$numcomm" = "0" ]; then \ - sed \ - -e "s...@version@#$$rpmver#g" \ - -e "s#%glo.*alpha.*##g" \ - -e "s#%glo.*numcomm.*##g" \ - -e "s...@dirty@#$$dirty#g" \ - -e "s...@date@#$$date#g" \ - $< > $...@-t; \ - else \ - sed \ - -e "s...@version@#$$rpmver#g" \ - -e "s...@alphatag@#$$alphatag#g" \ - -e "s...@numcomm@#$$numcomm#g" \ - -e "s...@dirty@#$$dirty#g" \ - -e "s...@date@#$$date#g" \ - $< > $...@-t; \ - fi; \ - if [ -z "$$dirty" ]; then sed -i -e "s#%glo.*dirty.*##g" $...@-t; fi - chmod a-w $...@-t - mv $...@-t $@ + $(srcdir)/build-aux/git-spec-version $(SPEC).in $(SPEC) $(TARFILE): $(MAKE) dist diff --git a/build-aux/git-spec-version b/build-aux/git-spec-version new file mode 100755 index 0000000..ef57b7f --- /dev/null +++ b/build-aux/git-spec-version @@ -0,0 +1,66 @@ +#!/bin/sh + +SPEC=$2 +SPEC_IN=$1 + +set -e + +rm -f $SPEC-t $SPEC +LC_ALL=C date="$(date "+%a %b %d %Y")" +if [ -f .tarball-version ] +then + gitver=$(cat .tarball-version) + rpmver=$gitver + alphatag="" + dirty="" + numcomm="0" +else + IS_TAG=1 + git describe --abbrev=4 --match='v*' HEAD 2>/dev/null || IS_TAG=0 ; true + if [ $IS_TAG -eq 0 ] + then + # git tree, but probably no tag + branch=`git branch | grep "* " | cut -d' ' -f 2` + commit=`git describe --always --abbrev=4` + numcomm=`git rev-list HEAD | wc -l` + rpmver=$branch + alphatag=$commit + else + gitver=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null` + rpmver=`echo $gitver | sed -e "s/^v//" -e "s/-.*//g"` + alphatag=`echo $gitver | sed -e "s/.*-//" -e "s/^g//"` + vtag=`echo $gitver | sed -e "s/-.*//g"` + numcomm=`git rev-list $vtag..HEAD | wc -l` + fi + git update-index --refresh > /dev/null 2>&1 || true + dirty=`git diff-index --name-only HEAD 2>/dev/null` +fi +if [ -n "$dirty" ] +then + dirty="dirty" +else + dirty="" +fi +if [ "$numcomm" = "0" ] +then + sed -e "s...@version@#$rpmver#g" \ + -e "s#%glo.*alpha.*##g" \ + -e "s#%glo.*numcomm.*##g" \ + -e "s...@dirty@#$dirty#g" \ + -e "s...@date@#$date#g" \ + $SPEC_IN > $SPEC-t +else + sed -e "s...@version@#$rpmver#g" \ + -e "s...@alphatag@#$alphatag#g" \ + -e "s...@numcomm@#$numcomm#g" \ + -e "s...@dirty@#$dirty#g" \ + -e "s...@date@#$date#g" \ + $SPEC_IN > $SPEC-t +fi +if [ -z "$dirty" ] +then + sed -i -e "s#%glo.*dirty.*##g" $SPEC-t +fi +chmod a-w $SPEC-t +mv $SPEC-t $SPEC + diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 795a98b..c724121 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -130,6 +130,13 @@ then # Change the first '-' to a '.', so version-comparing tools work properly. # Remove the "g" in git describe's output string, to save a byte. v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`; +elif test "`git log -1 --pretty=format:x . 2>&1`" = x +then + # git tree, but probably no tag + branch=`git branch | grep "* " | cut -d' ' -f 2` + commit=`git describe --always --abbrev=4` + numcommits=`git rev-list HEAD | wc -l` + v=$branch.$numcommits-$commit else v=UNKNOWN fi -- 1.7.3.4 _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
