summaryrefslogtreecommitdiffstats
path: root/get-version.sh
diff options
context:
space:
mode:
Diffstat (limited to 'get-version.sh')
-rwxr-xr-xget-version.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/get-version.sh b/get-version.sh
new file mode 100755
index 0000000..f962146
--- /dev/null
+++ b/get-version.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Needed to remove the new line when echoing the version
+nl='
+'
+
+VERSION=
+
+usage="\
+Usage: $0 version_file
+Print a version string.
+"
+
+version_file="$1"
+if test -z "$version_file"; then
+ echo "$usage"
+ exit 1
+fi
+if test -f $version_file; then
+ . ./$version_file
+else
+ echo "Version file $version_file not found"
+ exit 1
+fi
+
+if test -z $PKG_VERSION; then
+ echo "No version found in $version_file"
+ exit 1
+fi
+
+# Omit the trailing newline
+echo "$PKG_VERSION" | tr -d "$nl"