Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > c4aaebff5a034775f37cbc49827cf3b9 > files > 4

smart-0.51-17mdv2008.0.src.rpm

diff -Naur smart-0.51/smart/backends/rpm/base.py smart-0.51.tpg/smart/backends/rpm/base.py
--- smart-0.51/smart/backends/rpm/base.py	2006-11-07 20:22:46.000000000 +0000
+++ smart-0.51.tpg/smart/backends/rpm/base.py	2007-08-29 10:34:44.000000000 +0000
@@ -41,11 +41,21 @@
         traceback.print_exc()
     raise Error, _("'rpm' python module is not available")
 
-archscore = rpm.archscore
+system_is_x86_64 = os.uname()[4] == 'x86_64'
+
+archscores = {}
+
+def archscore(arch):
+    if not arch in archscores:
+        if not sysconf.get("rpm-enable-biarch", True) and os.uname()[4] == 'x86_64' and arch != 'x86_64':
+            archscores[arch] = 0
+        else:
+            archscores[arch] = rpm.archscore(arch)
+    return archscores[arch]
 
 __all__ = ["RPMPackage", "RPMProvides", "RPMNameProvides", "RPMPreRequires",
            "RPMRequires", "RPMUpgrades", "RPMConflicts", "RPMObsoletes",
-           "rpm", "getTS", "system_provides"]
+           "rpm", "getTS", "system_provides", "archscore"]
 
 def getTS(new=False):
     if not hasattr(getTS, "ts"):
@@ -88,13 +98,23 @@
 
 class RPMPackage(Package):
 
-    __slots__ = ()
+    __slots__ = ('ver', 'archscore', 'arch_is_not_x86_64')
+    def __init__(self, name, version):
+        Package.__init__(self, name, version)
+        self.ver, arch = splitarch(self.version)
+        self.archscore = archscore(arch)
+        self.arch_is_not_x86_64 = arch != 'x86_64'
 
     packagemanager = RPMPackageManager
 
     def equals(self, other):
         if self.name != other.name or self.version != other.version:
             return False
+        if not sysconf.get("rpm-enable-biarch", True):
+            selfver, selfarch = splitarch(self.version)
+            otherver, otherarch = splitarch(other.version)
+            if selfarch != otherarch:
+                return False
         if Package.equals(self, other):
             return True
         fk = dict.fromkeys
@@ -137,8 +157,9 @@
             return False
         selfver, selfarch = splitarch(self.version)
         otherver, otherarch = splitarch(other.version)
-        if getArchColor(selfarch) != getArchColor(otherarch):
-            return True
+        if sysconf.get("rpm-enable-biarch", True):
+            if getArchColor(selfarch) != getArchColor(otherarch):
+                return True
         if not pkgconf.testFlag("multi-version", self):
             return False
         return selfver != otherver
@@ -182,16 +203,37 @@
         if ratio:
             searcher.addResult(self, ratio)
 
+    def __setstate__(self, state):
+        Package.__setstate__(self, state)
+        self.ver, arch = splitarch(self.version)
+        self.archscore = archscore(arch)
+        self.arch_is_not_x86_64 = arch != 'x86_64'
+
+    def __getstate__(self):
+        state = Package.__getstate__(self)
+        return state
+
     def __lt__(self, other):
         rc = cmp(self.name, other.name)
         if type(other) is RPMPackage:
+            if self.archscore == 0:
+                return True
+            if other.archscore == 0:
+                return False
+            if system_is_x86_64:
+                if self.arch_is_not_x86_64 and other.arch_is_not_x86_64:
+                    pass
+                else:
+                    if self.arch_is_not_x86_64:
+                        return True
+                    if other.arch_is_not_x86_64:
+                        return False
+                             
             if rc == 0 and self.version != other.version:
-                selfver, selfarch = splitarch(self.version)
-                otherver, otherarch = splitarch(other.version)
-                if selfver != otherver:
+                if self.ver != other.ver:
                     rc = vercmp(self.version, other.version)
                 if rc == 0:
-                    rc = -cmp(archscore(selfarch), archscore(otherarch))
+                    rc = -cmp(self.archscore, other.archscore)
         return rc == -1
 
 class RPMProvides(Provides):         __slots__ = ()
@@ -270,6 +312,7 @@
     psyco.bind(RPMPackage.coexists)
     psyco.bind(RPMPackage.matches)
     psyco.bind(RPMPackage.search)
+    psyco.bind(RPMPackage.__setstate__)
     psyco.bind(RPMPackage.__lt__)
     psyco.bind(RPMDepends.matches)
     psyco.bind(RPMObsoletes.matches)
diff -Naur smart-0.51/smart/backends/rpm/header.py smart-0.51.tpg/smart/backends/rpm/header.py
--- smart-0.51/smart/backends/rpm/header.py	2006-11-07 20:22:46.000000000 +0000
+++ smart-0.51.tpg/smart/backends/rpm/header.py	2007-08-29 10:34:11.000000000 +0000
@@ -203,7 +203,7 @@
             if h[1106]: # RPMTAG_SOURCEPACKAGE
                 continue
             arch = h[1022] # RPMTAG_ARCH
-            if rpm.archscore(arch) == 0:
+            if archscore(arch) == 0:
                 continue
 
             name = h[1000] # RPMTAG_NAME
diff -Naur smart-0.51/smart/backends/rpm/metadata.py smart-0.51.tpg/smart/backends/rpm/metadata.py
--- smart-0.51/smart/backends/rpm/metadata.py	2006-11-14 19:37:00.000000000 +0000
+++ smart-0.51.tpg/smart/backends/rpm/metadata.py	2007-08-29 10:34:11.000000000 +0000
@@ -168,7 +168,7 @@
                         skip = None
 
                 elif tag == ARCH:
-                    if rpm.archscore(elem.text) == 0:
+                    if archscore(elem.text) == 0:
                         skip = PACKAGE
                     else:
                         arch = elem.text
diff -Naur smart-0.51/smart/backends/rpm/redcarpet.py smart-0.51.tpg/smart/backends/rpm/redcarpet.py
--- smart-0.51/smart/backends/rpm/redcarpet.py	2006-11-07 20:22:46.000000000 +0000
+++ smart-0.51.tpg/smart/backends/rpm/redcarpet.py	2007-08-29 10:34:11.000000000 +0000
@@ -191,7 +191,7 @@
         self._release = data
 
     def handleArchEnd(self, name, attrs, data):
-        if rpm.archscore(data) == 0:
+        if archscore(data) == 0:
             self._skip = self.PACKAGE
         else:
             self._arch = data
diff -Naur smart-0.51/smart/backends/rpm/synthesis.py smart-0.51.tpg/smart/backends/rpm/synthesis.py
--- smart-0.51/smart/backends/rpm/synthesis.py	2006-11-07 20:22:46.000000000 +0000
+++ smart-0.51.tpg/smart/backends/rpm/synthesis.py	2007-08-29 10:34:11.000000000 +0000
@@ -165,7 +165,7 @@
                     version, arch = version[:dot], version[dot+1:]
                 versionarch = "@".join((version, arch))
                 
-                if rpm.archscore(arch) == 0:
+                if archscore(arch) == 0:
                     continue
 
                 name = "-".join(rpmnameparts[0:-2])
diff -Naur smart-0.51/smart/backends/rpm/yast2.py smart-0.51.tpg/smart/backends/rpm/yast2.py
--- smart-0.51/smart/backends/rpm/yast2.py	2006-11-20 16:44:34.000000000 +0000
+++ smart-0.51.tpg/smart/backends/rpm/yast2.py	2007-08-29 10:34:11.000000000 +0000
@@ -181,7 +181,7 @@
                     raise Error("Error loading YaST2 channel info. Possibly " \
                                 "corrupted file.\n%s" % self._pkginfofile)
                 
-                if rpm.archscore(arch) <= 0:
+                if archscore(arch) <= 0:
                     return
                 name = nameparts[0]
                 self.curpkgname = name