Fixed version reported when run from Git (issue #55)
[grml-debootstrap.git] / grml-debootstrap
index add5973..2a27c46 100755 (executable)
@@ -8,7 +8,11 @@
 
 # variables {{{
 PN="$(basename "$0")"
 
 # variables {{{
 PN="$(basename "$0")"
-VERSION="$(dpkg-query --show --showformat='${Version}' "$PN")"
+if [[ -d "$(dirname "$(which "$0")")"/.git ]]; then
+  VERSION="$(git describe | sed 's|^v||')"
+else
+  VERSION="$(dpkg-query --show --showformat='${Version}' "$PN")"
+fi
 VERSION="${VERSION:-unknown}"
 MNTPOINT="/mnt/debootstrap.$$"
 
 VERSION="${VERSION:-unknown}"
 MNTPOINT="/mnt/debootstrap.$$"