[yum-commits] Branch 'yum-3_2_X' - 4 commits - cli.py yum/__init__.py yum/packages.py yum/sqlitesack.py

James Antill james at osuosl.org
Tue Apr 14 13:51:12 UTC 2009


 cli.py            |   16 +++++++---------
 yum/__init__.py   |   38 ++++++++++++++++++++++++++++++++++++++
 yum/packages.py   |   12 ++++++++++--
 yum/sqlitesack.py |   15 +++++++++++++--
 4 files changed, 68 insertions(+), 13 deletions(-)

New commits:
commit cf5f4c2069be7991f48fdbd3dbfcc23f0b8b2d90
Author: James Antill <james at and.org>
Date:   Tue Apr 14 09:46:59 2009 -0400

    Only put / in front of "local" repoids

diff --git a/yum/packages.py b/yum/packages.py
index 7ca88f9..3dc7a15 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -170,16 +170,24 @@ class FakeRepository:
         #  We don't want repoids to contain random bytes that can be
         # in the FS directories. It's also nice if they aren't "huge". So
         # just chop to the rpm name.
-        repoid = os.path.basename(repoid)
+        pathbased = False
+        if '/' in repoid:
+            repoid = os.path.basename(repoid)
+            pathbased = True
+
         if repoid.endswith(".rpm"):
             repoid = repoid[:-4]
+            pathbased = True
 
         bytes = [] # Just in case someone uses mv to be evil:
+        if pathbased:
+            bytes.append('/')
+
         for byte in repoid:
             if ord(byte) >= 128:
                 byte = '?'
             bytes.append(byte)
-        self.id = "/" + "".join(bytes)
+        self.id = "".join(bytes)
 
     def __init__(self, repoid):
         self._set_cleanup_repoid(repoid)
commit 941b6528ffa974fad2942f37072e9f3cc7c6959b
Author: James Antill <james at and.org>
Date:   Tue Apr 14 03:11:03 2009 -0400

    Don't do stat() for local* if file doesn't end in .rpm. Allow localdowngrade

diff --git a/cli.py b/cli.py
index 9a78e9b..f6ba8d3 100644
--- a/cli.py
+++ b/cli.py
@@ -575,8 +575,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         oldcount = len(self.tsInfo)
         
         for arg in userlist:
-            if os.path.exists(arg) and arg.endswith('.rpm'): # this is hurky, deal w/it
-                val, msglist = self.localInstall(filelist=[arg])
+            if arg.endswith('.rpm') and os.path.exists(arg): # this is hurky, deal w/it
+                self.localInstall(filelist=[arg])
                 continue # it was something on disk and it ended in rpm 
                          # no matter what we don't go looking at repos
             try:
@@ -608,11 +608,11 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
             # pass them off to localInstall() and then move on
             localupdates = []
             for item in userlist:
-                if os.path.exists(item) and item[-4:] == '.rpm': # this is hurky, deal w/it
+                if item.endswith('.rpm') and os.path.exists(item): # this is hurky, deal w/it
                     localupdates.append(item)
             
             if len(localupdates) > 0:
-                val, msglist = self.localInstall(filelist=localupdates, updateonly=1)
+                self.localInstall(filelist=localupdates, updateonly=1)
                 for item in localupdates:
                     userlist.remove(item)
                 
@@ -652,10 +652,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         oldcount = len(self.tsInfo)
         
         for arg in userlist:
-            # FIXME: We should allow local file downgrades too
-            #        even more important for Fedora.
-            if False and os.path.exists(arg) and arg.endswith('.rpm'):
-                val, msglist = self.localDowngrade(filelist=[arg])
+            if arg.endswith('.rpm') and os.path.exists(arg):
+                self.downgradeLocal(arg)
                 continue # it was something on disk and it ended in rpm 
                          # no matter what we don't go looking at repos
 
@@ -797,7 +795,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
 
         pkgs = []
         for arg in args:
-            if os.path.exists(arg) and arg.endswith('.rpm'): # this is hurky, deal w/it
+            if arg.endswith('.rpm') and os.path.exists(arg): # this is hurky, deal w/it
                 thispkg = yum.packages.YumLocalPackage(self.ts, arg)
                 pkgs.append(thispkg)
             else:                
diff --git a/yum/__init__.py b/yum/__init__.py
index 7e5e600..90a9737 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -3147,6 +3147,44 @@ class YumBase(depsolve.Depsolve):
         tx_mbrs.extend(new_members)
         return tx_mbrs
         
+    def downgradeLocal(self, pkg, po=None):
+        """
+        handles downgrades of rpms provided on the filesystem in a
+        local dir (ie: not from a repo)
+
+        Return the added transaction members.
+
+        @param pkg: a path to an rpm file on disk.
+        @param po: A YumLocalPackage
+        """
+
+        if not po:
+            try:
+                po = YumLocalPackage(ts=self.rpmdb.readOnlyTS(), filename=pkg)
+            except Errors.MiscError:
+                self.logger.critical(_('Cannot open file: %s. Skipping.'), pkg)
+                return []
+            self.verbose_logger.log(logginglevels.INFO_2,
+                _('Examining %s: %s'), po.localpath, po)
+
+        if po.arch not in rpmUtils.arch.getArchList():
+            self.logger.critical(_('Cannot add package %s to transaction. Not a compatible architecture: %s'), pkg, po.arch)
+            return []
+
+        # handle excludes for a local downgrade
+        toexc = []
+        if len(self.conf.exclude) > 0:
+            exactmatch, matched, unmatched = \
+                   parsePackages(installpkgs + map(lambda x: x[0], updatepkgs),
+                                 self.conf.exclude, casematch=1)
+            toexc = exactmatch + matched
+
+        if po in toexc:
+            self.verbose_logger.debug(_('Excluding %s'), po)
+            return []
+
+        return self.downgrade(po=po)
+
     def downgrade(self, po=None, **kwargs):
         """ Try to downgrade a package. Works like:
             % yum shell <<EOL
commit ea4746b6ed6e233427850404edbad36f96bf9b71
Author: James Antill <james at and.org>
Date:   Tue Apr 14 02:36:55 2009 -0400

    Speed up searchNames() when we've loaded all the pkg objects

diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 0b194a1..df24fe1 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -893,6 +893,16 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
             return []
         
         returnList = []
+        if hasattr(self, 'pkgobjlist'):
+            names = set(names)
+            for po in self.pkgobjlist:
+                if po.name not in names:
+                    continue
+                if self._pkgExcluded(po):
+                    continue
+                returnList.append(po)
+            return returnList
+
         max_entries = constants.PATTERNS_INDEXED_MAX
         if len(names) > max_entries:
             returnList = set() # Unique
commit a46ef6078c843c88f6ecf90c3e1ebd0d8b6d2df4
Author: James Antill <james at and.org>
Date:   Tue Apr 14 02:36:06 2009 -0400

    Don't show duplicates in searchNames, when splitting the query

diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 21c717f..0b194a1 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -895,9 +895,10 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         returnList = []
         max_entries = constants.PATTERNS_INDEXED_MAX
         if len(names) > max_entries:
+            returnList = set() # Unique
             for names in seq_max_split(names, max_entries):
-                returnList.extend(self.searchNames(names))
-            return returnList
+                returnList.update(self.searchNames(names))
+            return list(returnList)
 
         pat_sqls = []
         qsql = """select pkgId,pkgKey,name,epoch,version,release,arch


More information about the Yum-commits mailing list