summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rwxr-xr-xpackaging/macosx/make-package.sh2
-rw-r--r--scripts13
-rwxr-xr-xscripts/get-version56
4 files changed, 64 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 43ab19a29..63528a93c 100644
--- a/Makefile
+++ b/Makefile
@@ -26,11 +26,14 @@ MANFILES = $(NAME).1
XSLTFILES = xslt/*.xslt
UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win")
-VERSION_STRING := $(shell git describe --tags --abbrev=12 || echo "v$(VERSION)")
-# Windows .nsi style with four numbers 1.2.3.4
-PRODVERSION_STRING := $(shell git describe --tags --abbrev=12 | sed 's/v\([0-9]*\)\.\([0-9]*\)-\([0-9]*\)-.*/\1.\2.\3.0/ ; s/v\([0-9]\)\.\([0-9]*\)/\1.\2.0.0/' || echo "$(VERSION).0.0")
+GET_VERSION = ./scripts/get-version
+VERSION_STRING := $(shell $(GET_VERSION) linux || echo "v$(VERSION)")
# Mac Info.plist style with three numbers 1.2.3
-CFBUNDLEVERSION_STRING := $(shell git describe --tags --abbrev=12 | sed 's/v\([0-9]*\)\.\([0-9]*\)-\([0-9]*\)-.*/\1.\2.\3/ ; s/v\([0-9]\)\.\([0-9]*\)/\1.\2.0/' || echo "$(VERSION).0")
+CFBUNDLEVERSION_STRING := $(shell $(GET_VERSION) darwin $(VERSION_STRING) || \
+ echo "$(VERSION).0")
+# Windows .nsi style with four numbers 1.2.3.4
+PRODVERSION_STRING := $(shell $(GET_VERSION) win $(VERSION_STRING) || \
+ echo "$(VERSION).0.0")
# find libdivecomputer
# First deal with the cross compile environment and with Mac.
diff --git a/packaging/macosx/make-package.sh b/packaging/macosx/make-package.sh
index 0556ecb84..c9558b36f 100755
--- a/packaging/macosx/make-package.sh
+++ b/packaging/macosx/make-package.sh
@@ -24,7 +24,7 @@ PREFIX="/Applications/Subsurface.app/Contents/Resources"
INFOPLIST=./packaging/macosx/Info.plist
# same git version magic as in the Makefile
-VERSION=`git describe --tags --abbrev=12 | sed 's/v\([0-9]*\)\.\([0-9]*\)-\([0-9]*\)-.*/\1.\2.\3/ ; s/v\([0-9]\)\.\([0-9]*\)/\1.\2.0/' || echo "git.missing.please.hardcode.version"`
+VERSION=$(./scripts/get-version darwin)
# gtk-mac-bundler allegedly supports signing by setting this environment
# variable, but this fails as we change the shared objects below and all
diff --git a/scripts b/scripts
deleted file mode 100644
index 5afc688b1..000000000
--- a/scripts
+++ /dev/null
@@ -1,13 +0,0 @@
-Downloading with 'libdivecomputer':
-
- - result: one XML file for all dives in the computer
-
- [torvalds@i5 examples]$ ./universal -b vyper2 /dev/ttyUSB0
- [torvalds@i5 examples]$ mv output.xml 2011-08-28.xml
-
-Unpacking Suunto SDE files:
-
- - result: one XML file per dive:
-
- mv LinusDivelogs.SDE LinusDivelogs.zip
- unzip LinusDivelogs.zip
diff --git a/scripts/get-version b/scripts/get-version
new file mode 100755
index 000000000..c59e2000b
--- /dev/null
+++ b/scripts/get-version
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# $1 - os name {linux|darwin|win}
+# $2 - [optional] raw version string "vX.Y-patchN-sha1". as from `git describe'
+# (see below)
+
+set -eu
+#set -x
+
+croak() {
+ echo "$0: $*" >&2
+ exit 1
+}
+
+[ $# -ge 1 ] || croak "missing OS argument"
+os=$1
+
+if [ $# -eq 2 ] && [ "$2" ]; then
+ v0=$2
+else
+ cmd="git describe --tags --abbrev=12"
+ v0=$($cmd) || croak "odd; command '$cmd' failed"
+fi
+
+# strip off the 'v' prefix, if any
+v0=${v0#v}
+
+case $os in
+ linux)
+ v=$v0
+ ;;
+ darwin|win)
+ # split version string using a '-' separator
+ IFS='-'
+ set -- $v0
+ v1=$1
+ if [ $# -gt 1 ]; then
+ v1=$v1.$2
+ else
+ v1=$v1.0
+ fi
+ case $os in
+ darwin)
+ v=$v1
+ ;;
+ win)
+ # always add '0' as the 4:th digit
+ v=$v1.0
+ ;;
+ esac
+ ;;
+ *)
+ v='git.missing.please.hardcode.version'
+ ;;
+esac
+printf '%s' $v