[vlc-commits] tools: bootstrap: Split version check in a separate function

Hugo Beauzée-Luyssen git at videolan.org
Mon Mar 26 13:20:39 CEST 2018


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Mar 26 13:19:07 2018 +0200| [8dc86858b52a6b2808c0a01961b7c4fbb7e4e917] | committer: Hugo Beauzée-Luyssen

tools: bootstrap: Split version check in a separate function

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8dc86858b52a6b2808c0a01961b7c4fbb7e4e917
---

 extras/tools/bootstrap | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/extras/tools/bootstrap b/extras/tools/bootstrap
index e5b56fc903..f416945b90 100755
--- a/extras/tools/bootstrap
+++ b/extras/tools/bootstrap
@@ -24,6 +24,26 @@ then
 	exit 1
 fi
 
+check_version() {
+    gotver=$2
+    gotmajor=`echo $gotver|cut -d. -f1`
+    gotminor=`echo $gotver|cut -d. -f2`
+    gotmicro=`echo $gotver|cut -d. -f3`
+    [ -z "$gotmicro" ] && gotmicro=0
+    needmajor=`echo $3|cut -d. -f1`
+    needminor=`echo $3|cut -d. -f2`
+    needmicro=`echo $3|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
+
+}
+
 check_tar() {
 if ! tar PcJ /dev/null >/dev/null 2>&1
 then
@@ -52,21 +72,7 @@ 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
+    check_version $1 $gotver $2
 fi
 }
 



More information about the vlc-commits mailing list