Browse code

Add support for compiling using make.sh without '.git' (ie, from a Github tarball, for example)

Tianon Gravi authored on 2013/11/22 07:11:17
Showing 1 changed files
... ...
@@ -41,9 +41,19 @@ DEFAULT_BUNDLES=(
41 41
 )
42 42
 
43 43
 VERSION=$(cat ./VERSION)
44
-GITCOMMIT=$(git rev-parse --short HEAD)
45
-if [ -n "$(git status --porcelain)" ]; then
46
-	GITCOMMIT="$GITCOMMIT-dirty"
44
+if [ -d .git ] && command -v git &> /dev/null; then
45
+	GITCOMMIT=$(git rev-parse --short HEAD)
46
+	if [ -n "$(git status --porcelain)" ]; then
47
+		GITCOMMIT="$GITCOMMIT-dirty"
48
+	fi
49
+elif [ "$DOCKER_GITCOMMIT" ]; then
50
+	GITCOMMIT="$DOCKER_GITCOMMIT"
51
+else
52
+	echo >&2 'error: .git directory missing and DOCKER_GITCOMMIT not specified'
53
+	echo >&2 '  Please either build with the .git directory accessible, or specify the'
54
+	echo >&2 '  exact (--short) commit hash you are building using DOCKER_GITCOMMIT for'
55
+	echo >&2 '  future accountability in diagnosing build issues.  Thanks!'
56
+	exit 1
47 57
 fi
48 58
 
49 59
 # Use these flags when compiling the tests and final binary