summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-07-07 12:08:47 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-07-07 12:08:47 -0700
commitd7091614badc4918a667f4478b2559e76dc2ff17 (patch)
tree1c5f8c2a68ab04f04b6fbb6cbe04fcad76b4dce1
parent09dcba81bb7220e929093913bbfcb2c47e0ed4fb (diff)
downloadsyslinux-d7091614badc4918a667f4478b2559e76dc2ff17.tar.gz
Include the git ID in the build string
If we're doing an unofficial build from git, put the git id and a dirty flag in the build string, instead of a timestamp. This is a lot more useful.
-rw-r--r--core/Makefile2
-rwxr-xr-xcore/gen-id.sh22
2 files changed, 23 insertions, 1 deletions
diff --git a/core/Makefile b/core/Makefile
index 9700ea23..73508c1c 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -71,7 +71,7 @@ ifndef HEXDATE
HEXDATE := $(shell $(PERL) now.pl $(SRCS))
endif
ifndef DATE
-DATE := $(HEXDATE)
+DATE := $(shell sh gen-id.sh $(HEXDATE))
endif
all: $(BTARGET)
diff --git a/core/gen-id.sh b/core/gen-id.sh
new file mode 100755
index 00000000..02be21a4
--- /dev/null
+++ b/core/gen-id.sh
@@ -0,0 +1,22 @@
+#!/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.
+#
+
+if test -n "$GIT_DIR" -o -d ../.git -o -f ../.git; then
+ ver="$(git rev-parse HEAD | cut -c1-8)"
+ if test -n "$ver"; then
+ if test -n "$(git diff-index --name-only HEAD)"; then
+ ver='g*'"$ver"
+ else
+ ver='g-'"$ver"
+ fi
+ fi
+fi
+if test -z "$ver"; then
+ echo "$1"
+else
+ echo "$ver"
+fi