Subject: [PATCH] rpmbuild doesn't like '-' in version strings

From: John Ellson <[email-masked]>
Date: Fri, 30 Dec 2005 12:29:10 -0500

Problem:

	ellson@ellson:git> make rpm
	GIT_VERSION = 1.0.6-g58e3
	sed -e 's/@@VERSION@@/1.0.6-g58e3/g' < git.spec.in > git.spec
	./git-tar-tree HEAD git-1.0.6-g58e3 > git-1.0.6-g58e3.tar
	tar rf git-1.0.6-g58e3.tar git-1.0.6-g58e3/git.spec
	gzip -f -9 git-1.0.6-g58e3.tar
	rpmbuild -ta git-1.0.6-g58e3.tar.gz
	error: line 3: Illegal char '-' in version: Version:    1.0.6-g58e3
	make: *** [rpm] Error 1

Suggested fix:  Use '_' instead of '-'

There is probably a cleaner implementation of the fix, but this works for me.

----------------------------------------

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 845b9dc..e4e0ab1 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -3,7 +3,9 @@
  GVF=GIT-VERSION-FILE

  VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT
-VN=$(expr "$VN" : v'\(.*\)')
+VN1=$(expr "$VN" : '[^-]*-\(.*\)')
+VN=$(expr "$VN" : v'\([^-]*\)')
+test "$VN1" = "" || VN="$VN"_"$VN1"
  if test -r $GVF
  then
         VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)

--------------------------------------------

Signed-off-by: John Ellson <[email-masked]>