commit f964c35723285981459474f7afe194b079ac28ed
Author: James Antill <james@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 0e9bdf0b7d78a735319751692d3af5ae5ed20537
Author: Seth Vidal <skvidal@fedoraproject.org>
Date: Fri Jul 15 11:17:15 2011 -0400
when you .lower() a string you want to compare it
to lowercase values, not uppercase ones.
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 8a6f6f3..19193ad 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -406,7 +406,7 @@ class YumAvailablePackageSqlite(YumAvailablePackage, PackageObject, RpmBase):
requires = []
for ob in cur:
pre = "0"
- if ob['pre'].lower() in ['TRUE', 1]:
+ if ob['pre'].lower() in ['true', 1]:
pre = "1"
prco_set = (_share_data(ob['name']), _share_data(ob['flags']),
(_share_data(ob['epoch']),
commit 5cc20cc6581ae621d163207c1ce57b3b0776af98
Author: Seth Vidal <skvidal@fedoraproject.org>
Date: Fri Jul 15 11:21:21 2011 -0400
the "0" string of pre returns as valid on the if pre check. So turn it
into a check for "1" so our requires don't always include pre="0"
when they don't really need to.
diff --git a/yum/packages.py b/yum/packages.py
index 5ef9951..4b1265c 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1217,7 +1217,7 @@ class YumAvailablePackage(PackageObject, RpmBase):
prcostring += ''' ver="%s"''' % misc.to_xml(v, attrib=True)
if r:
prcostring += ''' rel="%s"''' % misc.to_xml(r, attrib=True)
- if pre:
+ if pre == "1":
prcostring += ''' pre="%s"''' % pre
prcostring += "/>\n"
commit ff93cd1a76a86bec43b2c712cab637bf4bfcdff7
Author: Seth Vidal <skvidal@fedoraproject.org>
Date: Fri Jul 15 11:42:02 2011 -0400
make the test !=0 instead of == 1
diff --git a/yum/packages.py b/yum/packages.py
index 4b1265c..e055edf 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1217,7 +1217,7 @@ class YumAvailablePackage(PackageObject, RpmBase):
prcostring += ''' ver="%s"''' % misc.to_xml(v, attrib=True)
if r:
prcostring += ''' rel="%s"''' % misc.to_xml(r, attrib=True)
- if pre == "1":
+ if pre != "0":
prcostring += ''' pre="%s"''' % pre
prcostring += "/>\n"
commit b6431c11672f9f0cfb09fc384c7f249c66f3c78a
Author: Seth Vidal <skvidal@fedoraproject.org>
Date: Fri Jul 15 17:37:12 2011 -0400
- make the pre check look for 0 or "0" b/c 0 comes from the pkgs and "0" comes from the sqlite :)
- if we have nothing we've used in the requires output, then don't output anything - this makes it match
the behavior of dumping to xml from the sqlite dbs
- set installedsize properly for header/local pkg objects
- use installedsize properly in the xml generation :)
- sort the requires and provides lists so if nothing has changed nothing in the repodata will change :)
diff --git a/yum/packages.py b/yum/packages.py
index e055edf..db365c5 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1083,7 +1083,7 @@ class YumAvailablePackage(PackageObject, RpmBase):
misc.to_unicode(misc.to_xml(self.summary)),
misc.to_unicode(misc.to_xml(self.description)),
packager, url, self.filetime,
- self.buildtime, self.packagesize, self.size, self.archivesize)
+ self.buildtime, self.packagesize, self.installedsize, self.archivesize)
msg += self._return_remote_location()
return msg
@@ -1133,7 +1133,7 @@ class YumAvailablePackage(PackageObject, RpmBase):
msg = ""
mylist = getattr(self, pcotype)
if mylist: msg = "\n <rpm:%s>\n" % pcotype
- for (name, flags, (e,v,r)) in mylist:
+ for (name, flags, (e,v,r)) in sorted(mylist):
pcostring = ''' <rpm:entry name="%s"''' % misc.to_xml(name, attrib=True)
if flags:
pcostring += ''' flags="%s"''' % misc.to_xml(flags, attrib=True)
@@ -1194,8 +1194,8 @@ class YumAvailablePackage(PackageObject, RpmBase):
continue
newlist.append(i)
mylist = newlist
-
- for (name, flags, (e,v,r),pre) in mylist:
+ used = 0
+ for (name, flags, (e,v,r),pre) in sorted(mylist):
if name.startswith('rpmlib('):
continue
# this drops out requires that the pkg provides for itself.
@@ -1217,13 +1217,16 @@ class YumAvailablePackage(PackageObject, RpmBase):
prcostring += ''' ver="%s"''' % misc.to_xml(v, attrib=True)
if r:
prcostring += ''' rel="%s"''' % misc.to_xml(r, attrib=True)
- if pre != "0":
+ if pre not in ("0", 0):
prcostring += ''' pre="%s"''' % pre
-
+
prcostring += "/>\n"
msg += prcostring
+ used += 1
if mylist: msg += " </rpm:requires>"
+ if used == 0:
+ return ""
return msg
def _dump_changelog(self, clog_limit):
@@ -1299,7 +1302,8 @@ class YumHeaderPackage(YumAvailablePackage):
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.packagesize = self.hdr['archivesize']
+ self.installedsize = self.hdr['size']
self.__mode_cache = {}
self.__prcoPopulated = False
commit cf07a046ba2969f25fa16801cc86940dd0ceafa7
Author: Seth Vidal <skvidal@fedoraproject.org>
Date: Fri Jul 15 17:44:25 2011 -0400
sort the files output too - it takes a bit more time but it makes things easier to read :)
diff --git a/yum/packages.py b/yum/packages.py
index db365c5..79c15db 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1161,11 +1161,11 @@ class YumAvailablePackage(PackageObject, RpmBase):
dirs = self.returnFileEntries('dir', primary_only=True)
ghosts = self.returnFileEntries('ghost', primary_only=True)
- for fn in files:
+ for fn in sorted(files):
msg += """ <file>%s</file>\n""" % misc.to_xml(fn)
- for fn in dirs:
+ for fn in sorted(dirs):
msg += """ <file type="dir">%s</file>\n""" % misc.to_xml(fn)
- for fn in ghosts:
+ for fn in sorted(ghosts):
msg += """ <file type="ghost">%s</file>\n""" % misc.to_xml(fn)
return msg