summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBrian Tarricone <brian@tarricone.org>2009-07-28 22:10:06 +0000
committerBrian Tarricone <brian@tarricone.org>2009-07-28 22:10:06 +0000
commitf03b6d77c4a2bcf7bdf4855a61ff6501e83021b6 (patch)
tree82466f50a2ddeb2e6e6b10e2b1cb84d893315ec6 /scripts
parent83019e7af8e87b2010b4f1fcb27135814722bdb6 (diff)
downloadxfce4-dev-tools-f03b6d77c4a2bcf7bdf4855a61ff6501e83021b6.tar.gz
add --version and -V options, add required minimum version check.
users who wish to require a minimum version of xdt-autogen should export XDT_AUTOGEN_REQUIRED_VERSION, set to the minimum required version that is supported. (Old svn revision: 30414)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am4
-rw-r--r--scripts/xdt-autogen.in.in (renamed from scripts/xdt-autogen.in)83
2 files changed, 86 insertions, 1 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index a3ecd01..28fe7e1 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -20,8 +20,10 @@ xdt-autogen: Makefile $(srcdir)/xdt-autogen.in
CLEANFILES = \
xdt-autogen
+DISTCLEANFILES = \
+ xdt-autogen.in
+
EXTRA_DIST = \
- xdt-autogen.in \
xdt-commit
# vi:set ts=8 sw=8 noet ai:
diff --git a/scripts/xdt-autogen.in b/scripts/xdt-autogen.in.in
index d842a12..c3b9f77 100644
--- a/scripts/xdt-autogen.in
+++ b/scripts/xdt-autogen.in.in
@@ -24,6 +24,13 @@
# xdt-autogen - Part of the Xfce developer tools.
#
+VERSION="@VERSION@"
+
+XDT_AUTOGEN_VERSION_MAJOR="@VERSION_MAJOR@"
+XDT_AUTOGEN_VERSION_MINOR="@VERSION_MINOR@"
+XDT_AUTOGEN_VERSION_MICRO="@VERSION_MICRO@"
+XDT_AUTOGEN_VERSION_NANO="@VERSION_NANO@"
+XDT_AUTOGEN_VERSION_REVISION="@VERSION_REVISION@"
##
## Helper function to lookup configure.{in,ac} files recursively.
@@ -56,6 +63,82 @@ EOF
done
}
+##
+## check command-line args
+##
+if test "x$1" = "x--version" -o "x$1" = "x-V"; then
+ echo "`basename $0` $VERSION"
+ exit 0
+fi
+
+##
+## see if the caller is requesting a minimum version
+##
+do_version_check() {
+ test -z "$XDT_AUTOGEN_REQUIRED_VERSION" && return 0
+
+ major=`echo $XDT_AUTOGEN_REQUIRED_VERSION | cut -d. -f1`
+ test "$major" || return 1
+ test $major -le $XDT_AUTOGEN_VERSION_MAJOR || return 1
+ test $XDT_AUTOGEN_VERSION_MAJOR -gt $major && return 0
+
+ minor=`echo $XDT_AUTOGEN_REQUIRED_VERSION | cut -d. -f2`
+ test "$minor" || return 1
+ test $minor -le $XDT_AUTOGEN_VERSION_MINOR || return 1
+ test $XDT_AUTOGEN_VERSION_MINOR -gt $minor && return 0
+
+ micro=`echo $XDT_AUTOGEN_REQUIRED_VERSION | cut -d. -f3`
+ if echo "$micro" | grep -E -q "svn|git"; then
+ revision=`echo "$micro" | sed -e 's/[[:digit:].]\+\(.*\)/\1/'`
+ micro=`echo "$micro" | sed -e 's/\([[:digit:].]\+\).*/\1/'`
+ fi
+ if echo "$micro" | grep -q '\.'; then
+ nano=`echo "$micro" | cut -d. -f2`
+ micro=`echo "$micro" | cut -d. -f1`
+ fi
+
+ test "$micro" || return 1
+ test $micro -le $XDT_AUTOGEN_VERSION_MICRO || return 1
+ test $XDT_AUTOGEN_VERSION_MICRO -gt $micro && return 0
+
+ # the caller may or may not have specified a nano
+ if test "$nano"; then
+ # and we may or may not have a nano
+ test "$XDT_AUTOGEN_VERSION_NANO" || XDT_AUTOGEN_VERSION_NANO="0"
+
+ test $nano -le $XDT_AUTOGEN_VERSION_NANO || return 1
+ test $XDT_AUTOGEN_VERSION_NANO -gt $nano && return 0
+ fi
+
+ # the caller may or may not have specified a revision
+ if test "$revision"; then
+ # if we don't have a revision, then the check fails
+ test "$XDT_AUTOGEN_VERSION_REVISION" || return 1
+
+ # version compares are handled differently between svn and git.
+ if echo "$revision" | grep -q "svn"; then
+ # if our revision includes "git", then we must be newer
+ echo "$XDT_AUTOGEN_VERSION_REVISION" | grep -q "git" && return 0
+
+ # figure out the revision numbers
+ rev_num=`echo "$revision" | sed -e 's/svn-r\([[:digit:]]\+\)/\1/'`
+ XDT_AUTOGEN_VERSION_REV_NUM=`echo "$XDT_AUTOGEN_VERSION_REVISION" | sed -e 's/svn-r\([[:digit:]]\+\)/\1/'`
+ test $rev_num -le $XDT_AUTOGEN_VERSION_REV_NUM || return 1
+ elif echo "$revision" | grep -q "git"; then
+ echo "Error: git revision comparison not yet implemented. Please file a bug:"
+ echo "@PACKAGE_BUGREPORT@"
+ exit 1
+ fi
+ fi
+
+ return 0
+}
+
+if ! do_version_check; then
+ echo "This version of xdt-autogen ($VERSION) is too old. Version" >&2
+ echo "$XDT_AUTOGEN_REQUIRED_VERSION or greater is required." >&2
+ exit 1
+fi
##
## Determine XDG data dirs