threads / patch / 3024

patchGIT-VERSION-GEN: allow overriding from Makefile

Subject: [PATCH] GIT-VERSION-GEN: allow overriding from Makefile

## tl;dr

2 messages between Jan 9, 2006 and Jan 10, 2006. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Junio C Hamano· Jan 9, 2006, 23:01 UTC · lore

The RPM building procedure relied on being able to build from a freshly untarred tarball, so there is no way "git describe" could figure out from which commit it is building (there was no HEAD).

This still does not allow you to build RPM binary package from an untagged interim version because RPM does not like '-' in version number, but that probably is a blessing.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * For 1.1.1; the binary in 1.1.0 RPM was affected with this bug.
 GIT-VERSION-GEN |   13 +++++++++----
 Makefile        |    2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)
1900d64cbecf46844dd7910d78676e0cace7139e
Show changes to 2 files +10 −5

GIT-VERSION-GEN, Makefile

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 845b9dc..c878819 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -2,8 +2,15 @@
 
 GVF=GIT-VERSION-FILE
 
-VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT
-VN=$(expr "$VN" : v'\(.*\)')
+case "${VN+set}" in
+set)
+	;;
+*)
+	VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT
+	VN=$(expr "$VN" : v'\(.*\)')
+	;;
+esac
+
 if test -r $GVF
 then
 	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
@@ -14,5 +21,3 @@ test "$VN" = "$VC" || {
 	echo >&2 "GIT_VERSION = $VN"
 	echo "GIT_VERSION = $VN" >$GVF
 }
-
-
diff --git a/Makefile b/Makefile
index c9c15b5..0bbb5b8 100644
--- a/Makefile
+++ b/Makefile
@@ -494,7 +494,7 @@ dist: git.spec git-tar-tree
 	gzip -f -9 $(GIT_TARNAME).tar
 
 rpm: dist
-	$(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
+	VN=$(GIT_VERSION) $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
 
 ### Cleaning rules
 
-- 
1.1.0
H. Peter Anvin· Jan 10, 2006, 02:07 UTC · re: Junio C Hamano · lore

[PATCH] For release tarballs, include the proper version

When producing a release tarball, include a "version" file, which GIT-VERSION-GEN can then use to do the right thing when building from a tarball.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Show changes to 2 files +11 −3

GIT-VERSION-GEN, Makefile

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 845b9dc..7763639 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,9 +1,15 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
+DEF_VER=v1.1.GIT
 
-VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT
-VN=$(expr "$VN" : v'\(.*\)')
+# First try git-describe, then see if there is a version file
+# (included in release tarballs), then default
+VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) ||
+VN=$(cat version) ||
+VN="$DEF_VER"
+
+VN=$(expr "$VN" : v*'\(.*\)')
 if test -r $GVF
 then
 	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
diff --git a/Makefile b/Makefile
index c9c15b5..fa0cd83 100644
--- a/Makefile
+++ b/Makefile
@@ -489,7 +489,9 @@ dist: git.spec git-tar-tree
 	./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
 	@mkdir -p $(GIT_TARNAME)
 	@cp git.spec $(GIT_TARNAME)
-	$(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec
+	@echo $(GIT_VERSION) > $(GIT_TARNAME)/version
+	$(TAR) rf $(GIT_TARNAME).tar \
+		$(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
 	@rm -rf $(GIT_TARNAME)
 	gzip -f -9 $(GIT_TARNAME).tar
 

← back to recent threads