gen-id: only truncate tags starting with syslinux-<version>-
authorH. Peter Anvin <hpa@zytor.com>
Tue, 15 Jul 2008 23:10:46 +0000 (16:10 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 15 Jul 2008 23:21:01 +0000 (16:21 -0700)
If git-describe comes up with a tag not starting with
syslinux-<version>- then leave it as-is.

core/Makefile
gen-id.sh
memdisk/Makefile

index b81f052..278d7af 100644 (file)
@@ -72,7 +72,7 @@ ifndef HEXDATE
 HEXDATE := $(shell $(PERL) ../now.pl $(SRCS))
 endif
 ifndef DATE
-DATE    := $(shell sh ../gen-id.sh $(HEXDATE))
+DATE    := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE))
 endif
 
 all: $(BTARGET)
index c8f8979..1b3e108 100755 (executable)
--- a/gen-id.sh
+++ b/gen-id.sh
@@ -1,20 +1,32 @@
 #!/bin/sh
 #
-# Create a 10-character ID for this build.  If we're using a git tree,
-# generate an ID of the form g[-*]XXXXXXXX (* = modified); otherwise use
-# the passed-in timestamp.
+# Create a build ID for this build.  If we're using a git tree,
+# generate an ID from "git describe", otherwise use the passed-in
+# timestamp.
 #
+# Usage: gen-id.sh version timestamp
+#
+
+ver="$1"
+tim="$1"
 
 if test -n "$GIT_DIR" -o -d ../.git -o -f ../.git; then
-    ver="$(git describe | cut -d- -f3-)"
-    if test -n "$ver"; then
+    id="$(git describe)"
+    if test -n "$id"; then
+       if test x"$(echo "$id" | cut -d- -f1)" = xsyslinux; then
+            id="$(echo "$id" | cut -d- -f2-)"
+            if test x"$(echo "$id" | cut -d- -f1)" = x"$ver"; then
+               id="$(echo "$id" | cut -d- -f2-)"
+            fi
+        fi
+    fi
+    if test -n "$id"; then
        if test -n "$(git diff-index --name-only HEAD)"; then
-           ver="${ver}"\*
+           id="${id}"\*
        fi
     fi
 fi
-if test -z "$ver"; then
-  echo "$1"
-else
-  echo "$ver"
+if test -z "$id"; then
+  id="$tim"
 fi
+echo "$id"
index b9701ff..529d4a6 100644 (file)
@@ -47,7 +47,7 @@ ifndef HEXDATE
 HEXDATE := $(shell $(PERL) ../now.pl $(SRCS))
 endif
 ifndef DATE
-DATE    := $(shell sh ../gen-id.sh $(HEXDATE))
+DATE    := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE))
 endif
 
 # Important: init.o16 must be first!!