Share the gen-id stuff between core and memdisk
[profile/ivi/syslinux.git] / gen-id.sh
1 #!/bin/sh
2 #
3 # Create a 10-character ID for this build.  If we're using a git tree,
4 # generate an ID of the form g[-*]XXXXXXXX (* = modified); otherwise use
5 # the passed-in timestamp.
6 #
7
8 if test -n "$GIT_DIR" -o -d ../.git -o -f ../.git; then
9     ver="$(git rev-parse HEAD | cut -c1-8)"
10     if test -n "$ver"; then
11         if test -n "$(git diff-index --name-only HEAD)"; then
12             ver='g*'"$ver"
13         else
14             ver='g-'"$ver"
15         fi
16     fi
17 fi
18 if test -z "$ver"; then
19   echo "$1"
20 else
21   echo "$ver"
22 fi