[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (921b387050782174526852411782bd4ea9586485)

Jaka Kranjc scm at sourcemage.org
Sun Dec 14 07:32:33 EST 2008


GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx at sourcemage.org>:

 ChangeLog                       |    5 +++++
 var/lib/sorcery/modules/libgcc2 |   28 +++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

New commits:
commit 921b387050782174526852411782bd4ea9586485
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    libgcc2: use_gcc now also supports a greater-or-equal comparison,
          triggered by appending + to the passed version #14620, based on a
          patch by Fredrik Carlström
    
    bash quirk: (( 2 > 0 )) returns 0, but echo $(( 2 > 0 )) echoes 1

diff --git a/ChangeLog b/ChangeLog
index 094b900..fd1f9dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-14 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
+	* libgcc2: use_gcc now also supports a greater-or-equal comparison,
+	  triggered by appending + to the passed version #14620, based on a
+	  patch by Fredrik Carlström
+
 2008-12-12 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
 	* libcast: fixed a syntax error in custom cppflag setting, patch from
 	  Mario García H. #14954
diff --git a/var/lib/sorcery/modules/libgcc2 b/var/lib/sorcery/modules/libgcc2
index 41f7685..18510bc 100755
--- a/var/lib/sorcery/modules/libgcc2
+++ b/var/lib/sorcery/modules/libgcc2
@@ -29,14 +29,32 @@
 
 
 #---------------------------------------------------------------------
-## @param gcc version (2.95. or 3.3.)
-## @return 0 if gcc is being used to compile
+## @param gcc version (digits and dots)
+## @return 0 if version of installed gcc contains the parameter as a substring
+## @return 0 if the parameter is of the form "version+" and the version of the
+##             installed gcc is at least "version"
 ## @return 1 otherwise
 #---------------------------------------------------------------------
 function use_gcc()  {
-
-  gcc  -dumpversion  |  grep  -q  $(esc_str $1)  >  /dev/null
-
+  local needed_version=${1%+}
+  local installed_version=$(gcc -dumpversion)
+
+  if [[ $needed_version == $1 ]]; then
+    grep -q $(esc_str $needed_version) <<< "$installed_version"
+  else
+    local i=0 needed_version2 installed_version2
+    explode "$needed_version" . needed_version2
+    explode "$installed_version" . installed_version2
+
+    while [[ ${needed_version2[$i]} ]] || [[ ${installed_version2[$i]} ]]; do
+      if [[ ${needed_version2[$i]:-0} == ${installed_version2[$i]:-0} ]]; then
+        let i++
+        continue
+      fi
+      # capturing the return value of arithmetic comparison inverts it
+      return $(( ${needed_version2[$i]:-0} > ${installed_version2[$i]:-0} ))
+    done
+  fi
 }
 
 #---------------------------------------------------------------------



More information about the SM-Commit mailing list