public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "wenyi,xie" <xiewenyi2@huawei.com>
To: <devel@edk2.groups.io>, <afish@apple.com>,
	<quic_llindhol@quicinc.com>, <michael.d.kinney@intel.com>
Cc: <songdongkuang@huawei.com>, <xiewenyi2@huawei.com>
Subject: [PATCH EDK2 v1 1/1] edksetup.sh:The version compare issue in shell script
Date: Tue, 14 Jun 2022 11:25:34 +0800	[thread overview]
Message-ID: <20220614032534.3386430-2-xiewenyi2@huawei.com> (raw)
In-Reply-To: <20220614032534.3386430-1-xiewenyi2@huawei.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3948

In function of SetupPython3, the version of python will be
compared to get the new one. When python 3.10 is compared with
python 3.4, the result is not right. Because the version number
is treated as a float and 3.10 is smaller than 3.4.
So using sort to arrange the version from old to new in order
to get the new one.

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
 edksetup.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/edksetup.sh b/edksetup.sh
index 06d2f041e635..b9da62440f71 100755
--- a/edksetup.sh
+++ b/edksetup.sh
@@ -20,6 +20,11 @@
 SCRIPTNAME="edksetup.sh"
 RECONFIG=FALSE
 
+function IsVersionGreaterThan()
+{
+  test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1";
+}
+
 function HelpMsg()
 {
   echo "Usage: $SCRIPTNAME [Options]"
@@ -122,7 +127,7 @@ function SetupPython3()
       export PYTHON_COMMAND=$python
       continue
     fi
-      if [[ "$origin_version" < "$python_version" ]]; then
+    if IsVersionGreaterThan $python_version $origin_version; then
       origin_version=$python_version
       export PYTHON_COMMAND=$python
     fi
@@ -164,7 +169,7 @@ function SetupPython()
         export PYTHON_COMMAND=$python
         continue
       fi
-      if [[ "$origin_version" < "$python_version" ]]; then
+      if IsVersionGreaterThan $python_version $origin_version; then
         origin_version=$python_version
         export PYTHON_COMMAND=$python
       fi
-- 
2.20.1.windows.1


      reply	other threads:[~2022-06-14  3:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14  3:25 [PATCH EDK2 v1 0/1] edksetup.sh:The version compare issue in shell script wenyi,xie
2022-06-14  3:25 ` wenyi,xie [this message]

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-list 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=20220614032534.3386430-2-xiewenyi2@huawei.com \
    --to=devel@edk2.groups.io \
    /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