[vlc-devel] [PATCH 2/5] bootstrap: check: allow pass for multiple versions
Robert Mourning
robedmo.git at gmail.com
Wed May 31 01:56:01 CEST 2017
Allows passing multiple version arguments to the "check" function.
Each argument is checked according to previous rules (specified version
or newer, match major version exactly). Multiple major versions can
be configured to pass, each requiring a minimum minor version.
Adds version 3.1.0 to the "protoc" check, in addition to the existing
2.6.0. Since version 3.1.0 is built if the check fails, versions
>= 3.1.0 should pass.
---
extras/tools/bootstrap | 61 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 21 deletions(-)
diff --git a/extras/tools/bootstrap b/extras/tools/bootstrap
index e60e5eb..19b08a2 100755
--- a/extras/tools/bootstrap
+++ b/extras/tools/bootstrap
@@ -43,30 +43,49 @@ then
fi
}
+check_ver() {
+# assumes the command $1 was found
+[ -z "$2" ] && return 1 # empty version arg will always fail check
+gotver=`$1 --version | head -1 | sed s/'.* '//`
+gotmajor=`echo $gotver|cut -d. -f1`
+gotminor=`echo $gotver|cut -d. -f2`
+gotmicro=`echo $gotver|cut -d. -f3`
+[ -z "$gotmicro" ] && gotmicro=0
+needmajor=`echo $2|cut -d. -f1`
+needminor=`echo $2|cut -d. -f2`
+needmicro=`echo $2|cut -d. -f3`
+[ -z "$needmicro" ] && needmicro=0
+if [ "$needmajor" -ne "$gotmajor" \
+ -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
+ -o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
+then
+ return 1
+else
+ return 0
+fi
+}
+
check() {
-if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1
+# usage:
+# check command; require any version of command, otherwise build it
+# check command 1.2.0; require command with version >= specified, must match major version exactly
+# check command 1.2.0 2.1.1; same matching rules as above, require at least one version to match
+# check command ""; build command regardless of installed version
+commandname="$1"
+shift # remove command name from args for version iteration
+if ! $commandname --version >/dev/null 2>&1 && ! $commandname -version >/dev/null 2>&1
then
- echo "$1 not found"
- NEEDED="$NEEDED .$1"
+ echo "$commandname not found"
+ NEEDED="$NEEDED .$commandname"
else
# found, need to check version ?
- [ -z "$2" ] && return # no
- gotver=`$1 --version | head -1 | sed s/'.* '//`
- gotmajor=`echo $gotver|cut -d. -f1`
- gotminor=`echo $gotver|cut -d. -f2`
- gotmicro=`echo $gotver|cut -d. -f3`
- [ -z "$gotmicro" ] && gotmicro=0
- needmajor=`echo $2|cut -d. -f1`
- needminor=`echo $2|cut -d. -f2`
- needmicro=`echo $2|cut -d. -f3`
- [ -z "$needmicro" ] && needmicro=0
- if [ "$needmajor" -ne "$gotmajor" \
- -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
- -o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
- then
- echo "$1 too old"
- NEEDED="$NEEDED .$1"
- fi
+ [ -z "${1+x}" ] && return # no
+ for verindex in "$@"
+ do
+ check_ver "$commandname" "$verindex" && return
+ done
+ echo "$commandname too old"
+ NEEDED="$NEEDED .$commandname"
fi
}
@@ -80,7 +99,7 @@ check yasm
check_tar
check ragel
check_sed
-check protoc 2.6.0
+check protoc 2.6.0 3.1.0
check ant
check xz
--
2.7.4
More information about the vlc-devel
mailing list