aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2007-12-13 06:25:54 +0000
committerFelix Fietkau <nbd@openwrt.org>2007-12-13 06:25:54 +0000
commitd42667f87b64429b0919f542996ca5132d09e8b6 (patch)
tree0f0417bb685fd2df11ad192254a394cd7401e162 /scripts
parentb5e0831f1e38330b2c18ec2634d447200e04414f (diff)
downloadupstream-d42667f87b64429b0919f542996ca5132d09e8b6.tar.gz
upstream-d42667f87b64429b0919f542996ca5132d09e8b6.tar.bz2
upstream-d42667f87b64429b0919f542996ca5132d09e8b6.zip
clean up openwrt version handling, use a separate script that is executed at the beginning of the build process, fix revision checking with git
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9723 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/getver.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/getver.sh b/scripts/getver.sh
new file mode 100755
index 0000000000..c33505edc7
--- /dev/null
+++ b/scripts/getver.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+export LANG=C
+[ -n "$TOPDIR" ] && cd $TOPDIR
+
+try_version() {
+ [ -f version ] || return 1
+ REV="$(cat version)"
+ [ -n "$REV" ]
+}
+
+try_svn() {
+ [ -d .svn ] || return 1
+ REV="$(svn info | awk '/^Revision:/ { print $2 }')"
+ REV="${REV:+r$REV}"
+ [ -n "$REV" ]
+}
+
+try_git() {
+ [ -d .git ] || return 1
+ REV="$(git-log | grep -m 1 git-svn-id | awk '{ gsub(/.*@/, "", $2); print $2 }')"
+ REV="${REV:+r$REV}"
+ [ -n "$REV" ]
+}
+
+try_version || try_svn || try_git || REV="unknown"
+echo "$REV"