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

James Antill james at osuosl.org
Mon Feb 21 21:16:27 UTC 2011


 yum/__init__.py |    5 +++++
 yum/packages.py |   27 ++++++++++++++++++++-------
 yum/rpmsack.py  |   17 +++++++++--------
 3 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit 6a5d265a960cf37ae3f3cf71449584ffaf89f4c5
Author: James Antill <james at and.org>
Date:   Mon Feb 21 14:28:30 2011 -0500

    The kernel packages are special, so skip normal processing. BZ 678969

diff --git a/yum/__init__.py b/yum/__init__.py
index 16aef1a..059095a 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1029,6 +1029,11 @@ class YumBase(depsolve.Depsolve):
         for txmbr in txmbrs:
             if kern_pkgtup is not None and txmbr.pkgtup == kern_pkgtup:
                 pass
+            elif kern_pkgtup is not None and txmbr.name == kern_pkgtup[0]:
+                #  We don't care if they've explicitly set protected on the
+                # kernel package. Because we don't allow you to uninstall the
+                # running one so it has _special_ semantics anyway.
+                continue
             elif txmbr.name not in protected:
                 continue
             if txmbr.name not in bad_togo:
commit 9d2c4e2b79456ad0243ae403ba76a9eb4ef159c8
Author: Ricky Zhou <ricky at fedoraproject.org>
Date:   Mon Feb 21 14:12:48 2011 -0500

    Remove undefined variable (done in _RPMVerifyPackageFile). BZ 671198.

diff --git a/yum/packages.py b/yum/packages.py
index 8ffe51e..db3e973 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1845,7 +1845,6 @@ class YumInstalledPackage(YumHeaderPackage):
                 my_mode = my_st.st_mode
                 if 'ghost' in ftypes: #  This is what rpm does, although it
                     my_mode &= 0777   # doesn't usually get here.
-                    mode    &= 0777
                 if check_perms and pf.verify_mode and my_mode != pf.mode:
                     prob = _PkgVerifyProb('mode', 'mode does not match', ftypes)
                     prob.database_value = pf.mode
commit f964c35723285981459474f7afe194b079ac28ed
Author: James Antill <james at and.org>
Date:   Mon Feb 21 11:34:29 2011 -0500

    Don't preload summary/desc/url/source, also _needed_ for pkgtup only pkgs.

diff --git a/yum/packages.py b/yum/packages.py
index 15eeeaa..8ffe51e 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1246,18 +1246,32 @@ class YumHeaderPackage(YumAvailablePackage):
         self.ver = self.version
         self.rel = self.release
         self.pkgtup = (self.name, self.arch, self.epoch, self.version, self.release)
-        # Summaries "can be" empty, which rpm return [], see BZ 473239, *sigh*
-        self.summary = self.hdr['summary'] or ''
-        self.summary = misc.share_data(self.summary.replace('\n', ''))
-        self.description = self.hdr['description'] or ''
-        self.description = misc.share_data(self.description)
+        self._loaded_summary = None
+        self._loaded_description = None
         self.pkgid = self.hdr[rpm.RPMTAG_SHA1HEADER]
         if not self.pkgid:
             self.pkgid = "%s.%s" %(self.hdr['name'], self.hdr['buildtime'])
         self.packagesize = self.hdr['size']
         self.__mode_cache = {}
         self.__prcoPopulated = False
-        
+
+    def _loadSummary(self):
+        # Summaries "can be" empty, which rpm return [], see BZ 473239, *sigh*
+        if self._loaded_summary is None:
+            summary = self._get_hdr()['summary'] or ''
+            summary = misc.share_data(summary.replace('\n', ''))
+            self._loaded_summary = summary
+        return self._loaded_summary
+    summary = property(lambda x: x._loadSummary())
+
+    def _loadDescription(self):
+        if self._loaded_description is None:
+            description = self._get_hdr()['description'] or ''
+            description = misc.share_data(description)
+            self._loaded_description = description
+        return self._loaded_description
+    description = property(lambda x: x._loadDescription())
+
     def __str__(self):
         if self.epoch == '0':
             val = '%s-%s-%s.%s' % (self.name, self.version, self.release,
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 4e9835d..e93df20 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -42,11 +42,6 @@ class RPMInstalledPackage(YumInstalledPackage):
     def __init__(self, rpmhdr, index, rpmdb):
         self._has_hdr = True
         YumInstalledPackage.__init__(self, rpmhdr, yumdb=rpmdb.yumdb)
-        # NOTE: We keep summary/description/url because it doesn't add much
-        # and "yum search" uses them all.
-        self.url       = rpmhdr['url']
-        # Also keep sourcerpm for pirut/etc.
-        self.sourcerpm = rpmhdr['sourcerpm']
 
         self.idx   = index
         self.rpmdb = rpmdb
commit beeac8855224b6732801a0cc3d03c0d4593a7851
Author: James Antill <james at and.org>
Date:   Mon Feb 21 11:31:48 2011 -0500

    Don't cache the hdr, it's just not measurable speed wise and they are BIG.

diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 3830339..4e9835d 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -71,9 +71,15 @@ class RPMInstalledPackage(YumInstalledPackage):
         # Prevent access of __foo__, _cached_foo etc from loading the header 
         if varname.startswith('_'):
             raise AttributeError, "%s has no attribute %s" % (self, varname)
-            
-        self.hdr = val = self._get_hdr()
-        self._has_hdr = True
+
+        if varname != 'hdr': # Don't cache the hdr, unless explicitly requested
+            #  Note that we don't even cache the .blah value, but looking up the
+            # header is _really_ fast so it's not obvious any of it is worth it.
+            # This is different to prco etc. data, which is loaded separately.
+            val = self._get_hdr()
+        else:
+            self.hdr = val = self._get_hdr()
+            self._has_hdr = True
         if varname != 'hdr':   #  This is unusual, for anything that happens
             val = val[varname] # a lot we should preload at __init__.
                                # Also note that pkg.no_value raises KeyError.


More information about the Yum-commits mailing list