Skip to contentSkip to conversation

scripts/bitbake: unbreak the git version comparison

PATCH New Christopher Larson 1 participant 1 message Jul 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/bitbake: unbreak the git version comparison

From: Christopher Larson <[email protected]>

With the current code, we're calling awk to do a floating point comparison between '1.7.0.4' and '1.7.5' (on an ubuntu 10.04 LTS machine). These clearly aren't proper floating point numbers, and the comparison is incorrect. It's returning true for 1.7.0.4 >= 1.7.5.

Instead of using a floating point comparison for this, call out to python and let it do it.

---
 scripts/bitbake |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/bitbake +4 -1
index 580f377..09f8a86 100755
@@ -64,13 +64,16 @@ GITVERSION=`git --version | cut -d ' ' -f 3`
 float_test() {
      echo | awk 'END { exit ( !( '"$1"')); }'
 }
+version_compare() {
+    python -c "from distutils.version import LooseVersion; import sys; sys.exit(not (LooseVersion('$1') $2 LooseVersion('$3')))"
+}
 
 # Tar version 1.24 and onwards handle overwriting symlinks correctly
 # but earlier versions do not; this needs to work properly for sstate
 float_test "$TARVERSION > 1.23" && needtar="0"
 
 # Need git >= 1.7.5 for git-remote --mirror=xxx syntax
-float_test "$GITVERSION >= 1.7.5" && needgit="0"
+version_compare $GITVERSION ">=" 1.7.5 && needgit="0"
 
 
 buildpseudo="1"
Signature · 1 line
1.7.9.5