[yum-commits] Branch 'yum-3_2_X' - 6 commits - rpmUtils/updates.py yum/__init__.py yum/packageSack.py yum/packages.py yum/rpmtrans.py yum/sqlitesack.py yum/transactioninfo.py

James Antill james at osuosl.org
Tue Aug 25 23:50:36 UTC 2009


 rpmUtils/updates.py    |   25 +++++++------------------
 yum/__init__.py        |    5 +++++
 yum/packageSack.py     |    5 +----
 yum/packages.py        |   23 ++++++-----------------
 yum/rpmtrans.py        |    3 +++
 yum/sqlitesack.py      |   12 +++++-------
 yum/transactioninfo.py |   13 +------------
 7 files changed, 28 insertions(+), 58 deletions(-)

New commits:
commit 97695055210a8adf7d0e8ab5822e9e2d500048a8
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Fri Aug 21 11:59:12 2009 +0300

    Clean up unnecessary/duplicated code.

diff --git a/yum/packageSack.py b/yum/packageSack.py
index cc90d5f..3716410 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -760,10 +760,7 @@ class PackageSack(PackageSackBase):
         repoid = obj.repoid
         (name, arch, epoch, ver, rel) = obj.pkgtup
         
-        if self.compatarchs:
-            if self.compatarchs.has_key(arch):
-                self._addToDictAsList(self.pkgsByRepo, repoid, obj)
-        else:
+        if not self.compatarchs or arch in self.compatarchs:
             self._addToDictAsList(self.pkgsByRepo, repoid, obj)
         if self.indexesBuilt:
             self._addPackageToIndex(obj)
diff --git a/yum/packages.py b/yum/packages.py
index 99ff538..9a56fc4 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1160,24 +1160,13 @@ class YumHeaderPackage(YumAvailablePackage):
                 if not self.__mode_cache.has_key(mode):
                     self.__mode_cache[mode] = stat.S_ISDIR(mode)
           
+                fkey = 'file'
                 if self.__mode_cache[mode]:
-                    if not self.files.has_key('dir'):
-                        self.files['dir'] = []
-                    self.files['dir'].append(fn)
-                else:
-                    if flag is None:
-                        if not self.files.has_key('file'):
-                            self.files['file'] = []
-                        self.files['file'].append(fn)
-                    else:
-                        if (flag & 64):
-                            if not self.files.has_key('ghost'):
-                                self.files['ghost'] = []
-                            self.files['ghost'].append(fn)
-                            continue
-                        if not self.files.has_key('file'):
-                            self.files['file'] = []
-                        self.files['file'].append(fn)
+                    fkey = 'dir'
+                elif flag is not None and (flag & 64):
+                    fkey = 'ghost'
+                self.files.setdefault(fkey, []).append(fn)
+
             self._loadedfiles = True
             
     def returnFileEntries(self, ftype='file'):
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 7a2b700..2ae11a6 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -218,13 +218,9 @@ class YumAvailablePackageSqlite(YumAvailablePackage, PackageObject, RpmBase):
             except (IndexError, KeyError):
                 pass
 
-        for item in ['pkgId']:
-            try:
-                setattr(self, item, db_obj[item])
-            except (IndexError, KeyError):
-                pass
-
         try:
+            self.pkgId = db_obj['pkgId']
+
             checksum_type = _share_data(db_obj['checksum_type'])
             check_sum = (checksum_type, db_obj['pkgId'], True)
             self._checksums = [ check_sum ]
@@ -467,7 +463,6 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         for repo in self.excludes:
             exclude_num += len(self.excludes[repo])
         pkg_num = 0
-        sql = "SELECT count(pkgId) FROM packages"
         for repo in self.primarydb:
             pkg_num += self._sql_MD_pkg_num('primary', repo)
         return pkg_num - exclude_num
commit cf5765f74a23229abcc26b4e4cf5563b4d2cfeb6
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Thu Aug 20 22:28:01 2009 +0300

    Fix script error output for erase transactions (bz#484729).

diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
index 806fd25..053b272 100644
--- a/yum/rpmtrans.py
+++ b/yum/rpmtrans.py
@@ -510,6 +510,9 @@ class RPMTransaction:
             # right behavior should be
                 
     def _scriptError(self, bytes, total, h):
+        if not isinstance(h, types.TupleType):
+            # fun with install/erase transactions, see rhbz#484729
+            h = (h, None)
         hdr, rpmloc = h[0], h[1]
         remove_hdr = False # if we're in a clean up/remove then hdr will not be an rpm.hdr
         if not isinstance(hdr, rpm.hdr):
commit 1f933fa988424a6b8ddeda6484c938db38569100
Author: James Antill <james at and.org>
Date:   Thu Aug 20 15:45:20 2009 -0400

    Cleanup doUpdate. availdict to newpkgs altered as we itered (minor speedup)

diff --git a/rpmUtils/updates.py b/rpmUtils/updates.py
index 3ce1eba..f2d43f8 100644
--- a/rpmUtils/updates.py
+++ b/rpmUtils/updates.py
@@ -56,7 +56,7 @@ class Updates:
 
         # make some dicts from installed and available
         self.installdict = self.makeNADict(self.installed, 1)
-        self.availdict = self.makeNADict(self.available, 1)
+        self.availdict = self.makeNADict(self.available, 0) # Done in doUpdate
 
         # holder for our updates dict
         self.updatesdict = {}
@@ -293,19 +293,10 @@ class Updates:
                         # make the new ones a list b/c while we _shouldn't_
                         # have multiple updaters, we might and well, it needs
                         # to be solved one way or the other <sigh>
-        newpkgs = []
         newpkgs = self.availdict
         
         archlist = self._archlist 
         for (n, a) in newpkgs.keys():
-            # remove stuff not in our archdict
-            # high log here
-            if a is None:
-                for (arch, e,v,r) in newpkgs[(n, a)]:
-                    if arch not in archlist:
-                        newpkgs[(n, a)].remove((arch, e,v,r))
-                continue
-                
             if a not in archlist:
                 # high log here
                 del newpkgs[(n, a)]
@@ -314,19 +305,12 @@ class Updates:
         # remove the older stuff - if we're doing an update we only want the
         # newest evrs                
         for (n, a) in newpkgs:
-            if a is None:
-                continue
-
             (new_e,new_v,new_r) = self.returnNewest(newpkgs[(n, a)])
-            for (e, v, r) in newpkgs[(n, a)]:
+            for (e, v, r) in newpkgs[(n, a)][:]:
                 if (new_e, new_v, new_r) != (e, v, r):
                     newpkgs[(n, a)].remove((e, v, r))
 
-                
         for (n, a) in newpkgs:
-            if a is None: # the None archs are only for lookups
-                continue
-           
             # simple ones - look for exact matches or older stuff
             if self.installdict.has_key((n, a)):
                 for (rpm_e, rpm_v, rpm_r) in self.installdict[(n, a)]:
@@ -342,6 +326,11 @@ class Updates:
                             except ValueError:
                                 pass
 
+        # Now we add the (n, None) entries back...
+        for na in newpkgs.keys():
+            all_arches = map(lambda x: (na[1], x[0], x[1], x[2]), newpkgs[na])
+            newpkgs.setdefault((na[0], None), []).extend(all_arches)
+
         # get rid of all the empty dict entries:
         for nakey in newpkgs.keys():
             if len(newpkgs[nakey]) == 0:
commit 1b36ac85cd3482d54cae780da20ee3fc5ca5b496
Author: James Antill <james at and.org>
Date:   Thu Aug 20 10:57:16 2009 -0400

    Fix makelists for reinstall, now that we've changed how they happen

diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index 84dbb4b..be772e5 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -262,14 +262,6 @@ class TransactionData:
         self.downgraded = []
         self.failed = []
 
-        if include_reinstall:
-            pkgtups = {'up' : set(), 'in' : set(), 'rm' : set()}
-            for txmbr in self.getMembers():
-                if txmbr.output_state in (TS_INSTALL, TS_TRUEINSTALL):
-                    pkgtups['in'].add(txmbr.po.pkgtup)
-                if txmbr.output_state ==  TS_ERASE:
-                    pkgtups['rm'].add(txmbr.po.pkgtup)
-
         for txmbr in self.getMembers():
             if txmbr.output_state == TS_UPDATE:
                 if txmbr.isDep:
@@ -278,7 +270,7 @@ class TransactionData:
                     self.updated.append(txmbr)
                     
             elif txmbr.output_state in (TS_INSTALL, TS_TRUEINSTALL):
-                if include_reinstall and txmbr.po.pkgtup in pkgtups['rm']:
+                if include_reinstall and self.rpmdb.contains(po=txmbr.po):
                     self.reinstalled.append(txmbr)
                     continue
 
@@ -296,9 +288,6 @@ class TransactionData:
                     self.installed.append(txmbr)
             
             elif txmbr.output_state == TS_ERASE:
-                if include_reinstall and txmbr.po.pkgtup in pkgtups['in']:
-                    continue
-
                 if include_downgrade and txmbr.downgraded_by:
                     continue
 
commit 8280987534e7dab0e44c1aae836915fed21db6a2
Author: James Antill <james at and.org>
Date:   Thu Aug 20 10:53:33 2009 -0400

     Remove erase transactions on reinstall, fixes BZ 512393.
    
     The main problem here is that yum doesn't let a user install blah-1, if
    blah-1 is already installed ... so we require a remove transaction, and
    then an install transaction of the same thing.
     However _rpm_ only wants to see the install transaction, and gets upset
    with the remove transaction as well (it has an implicit remove as part
    of the install, and so tries to remove twice).
    
     So this fix just removes the "remove transaction" when we add the
    reinstall "install transaction".

diff --git a/yum/__init__.py b/yum/__init__.py
index 0df32a3..3f75528 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2802,6 +2802,11 @@ class YumBase(depsolve.Depsolve):
                     self._add_prob_flags(rpm.RPMPROB_FILTER_REPLACEPKG,
                                          rpm.RPMPROB_FILTER_REPLACENEWFILES,
                                          rpm.RPMPROB_FILTER_REPLACEOLDFILES)
+                    #  Yum needs the remove to happen before we allow the
+                    # install of the same version. But rpm doesn't like that
+                    # as it then has an install which removes the old version
+                    # and a remove, which also tries to remove the old version.
+                    self.tsInfo.remove(ipkg.pkgtup)
                     break
                 if ipkg.verGT(po):
                     self._add_prob_flags(rpm.RPMPROB_FILTER_OLDPACKAGE)
commit d452149f2a4fa9ffc56b5bd1afec73f3ae473bb0
Author: James Antill <james at and.org>
Date:   Wed Aug 19 01:34:40 2009 -0400

     Optimization for pkgExcluder, if we have no excluders do nothing.
    
     This seems like what it'd do anyway, the big differences are:
    
    1. We don't .lower() the elements of pkgtup for each call.
    
    2. We don't store everything we load in the whitelist.
    
    ...this nets me a 5-10% improvement ... roughly 2.56 seconds => 2.35
    seconds, for check-update.

diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 5b75cf5..7a2b700 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -585,6 +585,9 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
             self._delPackageRK(repo, pkgKey)
             return True
 
+        if not self._pkgExcluder:
+            return False
+
         data = {'n' : n.lower(), 'pkgtup' : (n, a, e, v, r), 'marked' : False}
         e = e.lower()
         v = v.lower()


More information about the Yum-commits mailing list