Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Christopher Larson <kergoth@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Christopher Larson <chris_larson@mentor.com>
Subject: [PATCH] scripts/bitbake: unbreak the git version comparison
Date: Mon, 30 Jul 2012 09:08:46 -0700	[thread overview]
Message-ID: <1343664526-7842-1-git-send-email-kergoth@gmail.com> (raw)

From: Christopher Larson <chris_larson@mentor.com>

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.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 scripts/bitbake |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/bitbake b/scripts/bitbake
index 580f377..09f8a86 100755
--- a/scripts/bitbake
+++ b/scripts/bitbake
@@ -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"
-- 
1.7.9.5




                 reply	other threads:[~2012-07-30 16:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343664526-7842-1-git-send-email-kergoth@gmail.com \
    --to=kergoth@gmail.com \
    --cc=chris_larson@mentor.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox