Source cmdlineopts.clp from same folder as grml-debootstrap file (issue #59)
[grml-debootstrap.git] / grml-debootstrap
index add5973..f7b85eb 100755 (executable)
@@ -8,7 +8,11 @@
 
 # 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.$$"
 
@@ -289,8 +293,9 @@ fi
 
 # cmdline handling {{{
 # source external command line parameter-processing script
-if [ -r ./cmdlineopts.clp ] ; then
-   . ./cmdlineopts.clp
+self_dir="$(dirname "$(which "$0")")"
+if [ -r "${self_dir}"/cmdlineopts.clp ] ; then
+   . "${self_dir}"/cmdlineopts.clp
 elif [ -r /usr/share/grml-debootstrap/functions/cmdlineopts.clp ] ; then
    . /usr/share/grml-debootstrap/functions/cmdlineopts.clp
 else