[yum] latest head
Seth Vidal
skvidal at fedoraproject.org
Wed Feb 16 19:25:06 UTC 2011
commit 3521d9aab73d9f98b2bdf36324df339f45b2f00d
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Wed Feb 16 14:25:07 2011 -0500
latest head
yum-HEAD.patch | 767 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
yum.spec | 5 +-
2 files changed, 757 insertions(+), 15 deletions(-)
---
diff --git a/yum-HEAD.patch b/yum-HEAD.patch
index 0f21f25..8509f33 100644
--- a/yum-HEAD.patch
+++ b/yum-HEAD.patch
@@ -1,3 +1,100 @@
+diff --git a/cli.py b/cli.py
+index 640f190..6cf6753 100644
+--- a/cli.py
++++ b/cli.py
+@@ -504,30 +504,35 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
+ if self.gpgsigcheck(downloadpkgs) != 0:
+ return 1
+
+- if self.conf.rpm_check_debug:
+- rcd_st = time.time()
+- self.verbose_logger.log(yum.logginglevels.INFO_2,
+- _('Running rpm_check_debug'))
+- msgs = self._run_rpm_check_debug()
+- if msgs:
+- rpmlib_only = True
+- for msg in msgs:
+- if msg.startswith('rpmlib('):
+- continue
+- rpmlib_only = False
+- if rpmlib_only:
+- print _("ERROR You need to update rpm to handle:")
+- else:
+- print _('ERROR with rpm_check_debug vs depsolve:')
++ self.initActionTs()
++ # save our dsCallback out
++ dscb = self.dsCallback
++ self.dsCallback = None # dumb, dumb dumb dumb!
++ self.populateTs(keepold=0) # sigh
+
+- for msg in msgs:
+- print to_utf8(msg)
++ rcd_st = time.time()
++ self.verbose_logger.log(yum.logginglevels.INFO_2,
++ _('Running Transaction Check'))
++ msgs = self.ts.check()
++ if msgs:
++ rpmlib_only = True
++ for msg in msgs:
++ if msg.startswith('rpmlib('):
++ continue
++ rpmlib_only = False
++ if rpmlib_only:
++ print _("ERROR You need to update rpm to handle:")
++ else:
++ print _('ERROR with transaction check vs depsolve:')
+
+- if rpmlib_only:
+- return 1, [_('RPM needs to be updated')]
+- return 1, [_('Please report this error in %s') % self.conf.bugtracker_url]
++ for msg in msgs:
++ print to_utf8(msg)
+
+- self.verbose_logger.debug('rpm_check_debug time: %0.3f' % (time.time() - rcd_st))
++ if rpmlib_only:
++ return 1, [_('RPM needs to be updated')]
++ return 1, [_('Please report this error in %s') % self.conf.bugtracker_url]
++
++ self.verbose_logger.debug('Transaction Check time: %0.3f' % (time.time() - rcd_st))
+
+ tt_st = time.time()
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+@@ -535,14 +540,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
+ if not self.conf.diskspacecheck:
+ self.tsInfo.probFilterFlags.append(rpm.RPMPROB_FILTER_DISKSPACE)
+
++ self.ts.order() # order the transaction
++ self.ts.clean() # release memory not needed beyond this point
+
+ testcb = RPMTransaction(self, test=True)
+-
+- self.initActionTs()
+- # save our dsCallback out
+- dscb = self.dsCallback
+- self.dsCallback = None # dumb, dumb dumb dumb!
+- self.populateTs(keepold=0) # sigh
+ tserrors = self.ts.test(testcb)
+ del testcb
+
+@@ -555,7 +556,6 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
+ self.errorSummary(errstring)
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+ _('Transaction Test Succeeded'))
+- del self.ts
+
+ self.verbose_logger.debug('Transaction Test time: %0.3f' % (time.time() - tt_st))
+
+@@ -563,10 +563,6 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
+ signal.signal(signal.SIGQUIT, signal.SIG_DFL)
+
+ ts_st = time.time()
+- self.initActionTs() # make a new, blank ts to populate
+- self.populateTs(keepold=0) # populate the ts
+- self.ts.check() #required for ordering
+- self.ts.order() # order
+
+ # put back our depcheck callback
+ self.dsCallback = dscb
diff --git a/docs/yum.8 b/docs/yum.8
index 52f6b53..3b414e2 100644
--- a/docs/yum.8
@@ -25,6 +122,19 @@ index 52f6b53..3b414e2 100644
.I \fB>\fR - The rpmdb was changed, outside yum, after the transaction.
.br
+diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
+index e1c3480..a535b79 100644
+--- a/docs/yum.conf.5
++++ b/docs/yum.conf.5
+@@ -474,6 +474,8 @@ bugtrackers.
+ \fBcolor \fR
+ Display colorized output automatically, depending on the output terminal,
+ always (using ANSI codes) or never.
++Default is `auto'.
++Possible values are: auto, never, always.
+ Command-line option: \fB\-\-color\fP
+
+ .IP
diff --git a/etc/yum.bash b/etc/yum.bash
index f4be628..1ccb83d 100644
--- a/etc/yum.bash
@@ -72,10 +182,122 @@ index f4be628..1ccb83d 100644
2>/dev/null | \
sed -ne 's/^[[:space:]]*\([0-9]\{1,\}\).*/\1/p' )" \
diff --git a/output.py b/output.py
-index b1d92e5..04b718b 100755
+index b1d92e5..08fe0e3 100755
--- a/output.py
+++ b/output.py
-@@ -1936,6 +1936,9 @@ to exit.
+@@ -1619,6 +1619,18 @@ to exit.
+
+ self._historyInfoCmd(mobj)
+
++ def _hpkg2from_repo(self, hpkg):
++ """ Given a pkg, find the ipkg.ui_from_repo ... if none, then
++ get an apkg. ... and put a ? in there. """
++ ipkgs = self.rpmdb.searchPkgTuple(hpkg.pkgtup)
++ if not ipkgs:
++ apkgs = self.pkgSack.searchPkgTuple(hpkg.pkgtup)
++ if not apkgs:
++ return '?'
++ return '@?' + str(apkgs[0].repoid)
++
++ return ipkgs[0].ui_from_repo
++
+ def _historyInfoCmd(self, old, pats=[]):
+ name = self._pwd_ui_username(old.loginuid)
+
+@@ -1631,7 +1643,8 @@ to exit.
+ _pkg_states_available.values())])[-1]
+ _pkg_states_installed['maxlen'] = maxlen
+ _pkg_states_available['maxlen'] = maxlen
+- def _simple_pkg(pkg, prefix_len, was_installed=False, highlight=False):
++ def _simple_pkg(pkg, prefix_len, was_installed=False, highlight=False,
++ pkg_max_len=0):
+ prefix = " " * prefix_len
+ if was_installed:
+ _pkg_states = _pkg_states_installed
+@@ -1655,7 +1668,9 @@ to exit.
+ else:
+ (hibeg, hiend) = self._highlight('normal')
+ state = utf8_width_fill(state, _pkg_states['maxlen'])
+- print "%s%s%s%s %s" % (prefix, hibeg, state, hiend, hpkg)
++ print "%s%s%s%s %-*s %s" % (prefix, hibeg, state, hiend,
++ pkg_max_len, hpkg,
++ self._hpkg2from_repo(hpkg))
+
+ if type(old.tid) == type([]):
+ print _("Transaction ID :"), "%u..%u" % (old.tid[0], old.tid[-1])
+@@ -1732,24 +1747,31 @@ to exit.
+ print _("Additional non-default information stored: %d"
+ % len(non_default))
+
+- print _("Transaction performed with:")
++ if old.trans_with:
++ # This is _possible_, but not common
++ print _("Transaction performed with:")
++ pkg_max_len = max((len(str(hpkg)) for hpkg in old.trans_with))
+ for hpkg in old.trans_with:
+- _simple_pkg(hpkg, 4, was_installed=True)
++ _simple_pkg(hpkg, 4, was_installed=True, pkg_max_len=pkg_max_len)
+ print _("Packages Altered:")
+ self.historyInfoCmdPkgsAltered(old, pats)
+
+ if old.trans_skip:
+ print _("Packages Skipped:")
++ pkg_max_len = max((len(str(hpkg)) for hpkg in old.trans_skip))
+ for hpkg in old.trans_skip:
+- _simple_pkg(hpkg, 4)
++ _simple_pkg(hpkg, 4, pkg_max_len=pkg_max_len)
+
+ if old.rpmdb_problems:
+ print _("Rpmdb Problems:")
+ for prob in old.rpmdb_problems:
+ key = "%s%s: " % (" " * 4, prob.problem)
+ print self.fmtKeyValFill(key, prob.text)
++ if prob.packages:
++ pkg_max_len = max((len(str(hpkg)) for hpkg in prob.packages))
+ for hpkg in prob.packages:
+- _simple_pkg(hpkg, 8, was_installed=True, highlight=hpkg.main)
++ _simple_pkg(hpkg, 8, was_installed=True, highlight=hpkg.main,
++ pkg_max_len=pkg_max_len)
+
+ if old.output:
+ print _("Scriptlet output:")
+@@ -1783,10 +1805,13 @@ to exit.
+ # version in the transaction and now.
+ all_uistates = self._history_state2uistate
+ maxlen = 0
++ pkg_max_len = 0
+ for hpkg in old.trans_data:
+ uistate = all_uistates.get(hpkg.state, hpkg.state)
+ if maxlen < len(uistate):
+ maxlen = len(uistate)
++ if pkg_max_len < len(str(hpkg)):
++ pkg_max_len = len(str(hpkg))
+
+ for hpkg in old.trans_data:
+ prefix = " " * 4
+@@ -1813,18 +1838,18 @@ to exit.
+ hpkg.state == 'Update'):
+ ln = len(hpkg.name) + 1
+ cn = (" " * ln) + cn[ln:]
+- print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
+ elif (last is not None and
+ last.state == 'Downgrade' and last.name == hpkg.name and
+ hpkg.state == 'Downgraded'):
+ ln = len(hpkg.name) + 1
+ cn = (" " * ln) + cn[ln:]
+- print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
+ else:
+ last = None
+ if hpkg.state in ('Updated', 'Downgrade'):
+ last = hpkg
+- print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
++ print "%s%s%s%s %-*s %s" % (prefix, hibeg, uistate, hiend,
++ pkg_max_len, cn,
++ self._hpkg2from_repo(hpkg))
+
+ def historySummaryCmd(self, extcmds):
+ tids, printall = self._history_list_transactions(extcmds)
+@@ -1936,6 +1961,9 @@ to exit.
of a package(s) instead of via. transactions. """
tids = self.history.search(extcmds)
limit = None
@@ -85,6 +307,92 @@ index b1d92e5..04b718b 100755
if not tids:
limit = 20
+diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
+index e8f4459..c5167d3 100644
+--- a/rpmUtils/transaction.py
++++ b/rpmUtils/transaction.py
+@@ -13,6 +13,7 @@
+
+ import rpm
+ import miscutils
++from yum.i18n import to_str
+
+ read_ts = None
+ ts = None
+@@ -22,18 +23,12 @@ ts = None
+ class TransactionWrapper:
+ def __init__(self, root='/'):
+ self.ts = rpm.TransactionSet(root)
+- self._methods = ['dbMatch',
+- 'check',
+- 'order',
++ self._methods = ['order',
+ 'addErase',
+ 'addInstall',
+ 'run',
+- 'IDTXload',
+- 'IDTXglob',
+- 'rollback',
+ 'pgpImportPubkey',
+ 'pgpPrtPkts',
+- 'Debug',
+ 'problems',
+ 'setFlags',
+ 'setVSFlags',
+@@ -54,6 +49,28 @@ class TransactionWrapper:
+ self.ts = None
+ self.open = False
+
++ def check(self):
++ results = []
++ self.ts.check()
++ for prob in self.ts.problems():
++ # Newer rpm (4.8.0+) has problem objects, older have just strings.
++ # Should probably move to using the new objects, when we can. For
++ # now just be compatible.
++ results.append(to_str(prob))
++
++ return results
++
++ def dbMatch(self, *args, **kwds):
++ if 'patterns' in kwds:
++ patterns = kwds.pop('patterns')
++ else:
++ patterns = []
++
++ mi = self.ts.dbMatch(*args, **kwds)
++ for (tag, tp, pat) in patterns:
++ mi.pattern(tag, tp, pat)
++ return mi
++
+ def __getattr__(self, attr):
+ if attr in self._methods:
+ return self.getMethod(attr)
+@@ -91,6 +108,9 @@ class TransactionWrapper:
+ def isTsFlagSet(self, flag):
+ val = self.getTsFlags()
+ return bool(flag & val)
++
++ def setScriptFd(self, fd):
++ self.ts.scriptFd = fd.fileno()
+
+ # def addProblemFilter(self, filt):
+ # curfilter = self.ts.setProbFilter(0)
+@@ -100,12 +120,14 @@ class TransactionWrapper:
+ """tests the ts we've setup, takes a callback function and a conf dict
+ for flags and what not"""
+
++ origflags = self.getTsFlags()
+ self.addTsFlag(rpm.RPMTRANS_FLAG_TEST)
+ # FIXME GARBAGE - remove once this is reimplemented elsehwere
+ # KEEPING FOR API COMPLIANCE ONLY
+ if conf.get('diskspacecheck') == 0:
+ self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)
+ tserrors = self.ts.run(cb.callback, '')
++ self.ts.setFlags(origflags)
+
+ reserrors = []
+ if tserrors:
diff --git a/test/skipbroken-tests.py b/test/skipbroken-tests.py
index 4e6b2c8..31482bc 100644
--- a/test/skipbroken-tests.py
@@ -114,7 +422,7 @@ index a1fbc72..65a2397 100644
%config(noreplace) %{_sysconfdir}/sysconfig/yum-cron
diff --git a/yum/__init__.py b/yum/__init__.py
-index f6e8a6b..de393f1 100644
+index f6e8a6b..e395cc5 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -349,7 +349,10 @@ class YumBase(depsolve.Depsolve):
@@ -141,15 +449,22 @@ index f6e8a6b..de393f1 100644
thisrepo.base_persistdir = self.conf._repos_persistdir
-@@ -1437,10 +1437,11 @@ class YumBase(depsolve.Depsolve):
+@@ -1435,12 +1435,17 @@ class YumBase(depsolve.Depsolve):
+ # will be we store what we thought, not what happened (so it'll be an
+ # invalid cache).
self.rpmdb.transactionResultVersion(frpmdbv)
-
+-
# transaction has started - all bets are off on our saved ts file
- try:
- os.unlink(self._ts_save_file)
- except (IOError, OSError), e:
- pass
+ if self._ts_save_file is not None:
++ # write the saved transaction data to the addon location in history
++ # so we can pull it back later if we need to
++ savetx_msg = open(self._ts_save_file, 'r').read()
++ self.history.write_addon_data('saved_tx', savetx_msg)
++
+ try:
+ os.unlink(self._ts_save_file)
+ except (IOError, OSError), e:
@@ -157,7 +472,7 @@ index f6e8a6b..de393f1 100644
self._ts_save_file = None
errors = self.ts.run(cb.callback, '')
-@@ -1485,7 +1486,12 @@ class YumBase(depsolve.Depsolve):
+@@ -1485,7 +1490,12 @@ class YumBase(depsolve.Depsolve):
# drop out the rpm cache so we don't step on bad hdr indexes
@@ -171,7 +486,7 @@ index f6e8a6b..de393f1 100644
self.plugins.run('posttrans')
# sync up what just happened versus what is in the rpmdb
if not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST):
-@@ -1674,8 +1680,11 @@ class YumBase(depsolve.Depsolve):
+@@ -1674,8 +1684,11 @@ class YumBase(depsolve.Depsolve):
def doLock(self, lockfile = YUM_PID_FILE):
"""perform the yum locking, raise yum-based exceptions, not OSErrors"""
@@ -184,7 +499,7 @@ index f6e8a6b..de393f1 100644
root = self.conf.cachedir
# Don't want <cachedir>/var/run/yum.pid ... just: <cachedir>/yum.pid
lockfile = os.path.basename(lockfile)
-@@ -1690,7 +1699,7 @@ class YumBase(depsolve.Depsolve):
+@@ -1690,7 +1703,7 @@ class YumBase(depsolve.Depsolve):
fd = open(lockfile, 'r')
except (IOError, OSError), e:
msg = _("Could not open lock %s: %s") % (lockfile, e)
@@ -193,7 +508,7 @@ index f6e8a6b..de393f1 100644
try: oldpid = int(fd.readline())
except ValueError:
-@@ -1707,7 +1716,7 @@ class YumBase(depsolve.Depsolve):
+@@ -1707,7 +1720,7 @@ class YumBase(depsolve.Depsolve):
else:
# Whoa. What the heck happened?
msg = _('Unable to check if PID %s is active') % oldpid
@@ -202,7 +517,7 @@ index f6e8a6b..de393f1 100644
else:
# Another copy seems to be running.
msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid)
-@@ -1752,7 +1761,7 @@ class YumBase(depsolve.Depsolve):
+@@ -1752,7 +1765,7 @@ class YumBase(depsolve.Depsolve):
if not msg.errno == errno.EEXIST:
# Whoa. What the heck happened?
errmsg = _('Could not create lock at %s: %s ') % (filename, str(msg))
@@ -211,7 +526,7 @@ index f6e8a6b..de393f1 100644
return 0
else:
os.write(fd, contents)
-@@ -4557,16 +4566,25 @@ class YumBase(depsolve.Depsolve):
+@@ -4557,16 +4570,25 @@ class YumBase(depsolve.Depsolve):
keyurl, info['hexkeyid']))
key_installed = True
continue
@@ -242,7 +557,7 @@ index f6e8a6b..de393f1 100644
self._getKeyImportMessage(info, keyurl, keytype)
rc = False
if self.conf.assumeyes:
-@@ -4587,7 +4605,18 @@ class YumBase(depsolve.Depsolve):
+@@ -4587,7 +4609,18 @@ class YumBase(depsolve.Depsolve):
raise Errors.YumBaseError, _('Key import failed')
self.logger.info(_('Key imported successfully'))
key_installed = True
@@ -262,6 +577,107 @@ index f6e8a6b..de393f1 100644
if not key_installed:
raise Errors.YumBaseError, \
_('The GPG keys listed for the "%s" repository are ' \
+@@ -4775,26 +4808,31 @@ class YumBase(depsolve.Depsolve):
+
+ def _doTestTransaction(self,callback,display=None):
+ ''' Do the RPM test transaction '''
++ self.initActionTs()
++ # save our dsCallback out
++ dscb = self.dsCallback
++ self.dsCallback = None # dumb, dumb dumb dumb!
++ self.populateTs( keepold=0 ) # sigh
++
+ # This can be overloaded by a subclass.
+- if self.conf.rpm_check_debug:
+- self.verbose_logger.log(logginglevels.INFO_2,
+- _('Running rpm_check_debug'))
+- msgs = self._run_rpm_check_debug()
+- if msgs:
+- rpmlib_only = True
+- for msg in msgs:
+- if msg.startswith('rpmlib('):
+- continue
+- rpmlib_only = False
+- if rpmlib_only:
+- retmsgs = [_("ERROR You need to update rpm to handle:")]
+- retmsgs.extend(msgs)
+- raise Errors.YumRPMCheckError, retmsgs
+- retmsgs = [_('ERROR with rpm_check_debug vs depsolve:')]
+- retmsgs.extend(msgs)
+- retmsgs.append(_('Please report this error at %s')
+- % self.conf.bugtracker_url)
+- raise Errors.YumRPMCheckError,retmsgs
++ self.verbose_logger.log(logginglevels.INFO_2,
++ _('Running Transaction Check'))
++ msgs = self.ts.check()
++ if msgs:
++ rpmlib_only = True
++ for msg in msgs:
++ if msg.startswith('rpmlib('):
++ continue
++ rpmlib_only = False
++ if rpmlib_only:
++ retmsgs = [_("ERROR You need to update rpm to handle:")]
++ retmsgs.extend(msgs)
++ raise Errors.YumRPMCheckError, retmsgs
++ retmsgs = [_('ERROR with transaction check vs depsolve:')]
++ retmsgs.extend(msgs)
++ retmsgs.append(_('Please report this error at %s')
++ % self.conf.bugtracker_url)
++ raise Errors.YumRPMCheckError,retmsgs
+
+ tsConf = {}
+ for feature in ['diskspacecheck']: # more to come, I'm sure
+@@ -4804,14 +4842,7 @@ class YumBase(depsolve.Depsolve):
+ # overwrite the default display class
+ if display:
+ testcb.display = display
+- # clean out the ts b/c we have to give it new paths to the rpms
+- del self.ts
+
+- self.initActionTs()
+- # save our dsCallback out
+- dscb = self.dsCallback
+- self.dsCallback = None # dumb, dumb dumb dumb!
+- self.populateTs( keepold=0 ) # sigh
+ tserrors = self.ts.test( testcb, conf=tsConf )
+ del testcb
+
+@@ -4839,22 +4870,6 @@ class YumBase(depsolve.Depsolve):
+ cb.display = display
+ self.runTransaction( cb=cb )
+
+- def _run_rpm_check_debug(self):
+- results = []
+- # save our dsCallback out
+- dscb = self.dsCallback
+- self.dsCallback = None # dumb, dumb dumb dumb!
+- self.populateTs(test=1)
+- self.ts.check()
+- for prob in self.ts.problems():
+- # Newer rpm (4.8.0+) has problem objects, older have just strings.
+- # Should probably move to using the new objects, when we can. For
+- # now just be compatible.
+- results.append(to_str(prob))
+-
+- self.dsCallback = dscb
+- return results
+-
+ def add_enable_repo(self, repoid, baseurls=[], mirrorlist=None, **kwargs):
+ """add and enable a repo with just a baseurl/mirrorlist and repoid
+ requires repoid and at least one of baseurl and mirrorlist
+diff --git a/yum/config.py b/yum/config.py
+index 97e5e3d..9c2db93 100644
+--- a/yum/config.py
++++ b/yum/config.py
+@@ -691,6 +691,7 @@ class YumConf(StartupConf):
+ metadata_expire = SecondsOption(60 * 60 * 6) # Time in seconds (6h).
+ # Time in seconds (1 day). NOTE: This isn't used when using metalinks
+ mirrorlist_expire = SecondsOption(60 * 60 * 24)
++ # XXX rpm_check_debug is unused, left around for API compatibility for now
+ rpm_check_debug = BoolOption(True)
+ disable_excludes = ListOption()
+ skip_broken = BoolOption(False)
diff --git a/yum/depsolve.py b/yum/depsolve.py
index de2849a..3aaba0e 100644
--- a/yum/depsolve.py
@@ -278,10 +694,324 @@ index de2849a..3aaba0e 100644
return (1, errors)
if not len(self.tsInfo):
+diff --git a/yum/packages.py b/yum/packages.py
+index 6f61fea..15eeeaa 100644
+--- a/yum/packages.py
++++ b/yum/packages.py
+@@ -1069,6 +1069,9 @@ class YumAvailablePackage(PackageObject, RpmBase):
+
+ if self.sourcerpm:
+ msg += """ <rpm:sourcerpm>%s</rpm:sourcerpm>\n""" % misc.to_xml(self.sourcerpm)
++ else: # b/c yum 2.4.3 and OLD y-m-p willgfreak out if it is not there.
++ msg += """ <rpm:sourcerpm/>\n"""
++
+ msg +=""" <rpm:header-range start="%s" end="%s"/>""" % (self.hdrstart,
+ self.hdrend)
+ msg += self._dump_pco('provides')
+diff --git a/yum/rpmsack.py b/yum/rpmsack.py
+index 0982a7c..227ed89 100644
+--- a/yum/rpmsack.py
++++ b/yum/rpmsack.py
+@@ -234,7 +234,7 @@ class RPMDBPackageSack(PackageSackBase):
+ self._simple_pkgtup_list = csumpkgtups.keys()
+
+ if not self._simple_pkgtup_list:
+- for (hdr, mi) in self._all_packages():
++ for (hdr, mi) in self._get_packages():
+ self._simple_pkgtup_list.append(self._hdr2pkgTuple(hdr))
+
+ return self._simple_pkgtup_list
+@@ -378,54 +378,36 @@ class RPMDBPackageSack(PackageSackBase):
+ pass
+
+ def searchAll(self, name, query_type='like'):
+- ts = self.readOnlyTS()
+ result = {}
+
+ # check provides
+ tag = self.DEP_TABLE['provides'][0]
+- mi = ts.dbMatch()
+- mi.pattern(tag, rpm.RPMMIRE_GLOB, name)
+- for hdr in mi:
+- if hdr['name'] == 'gpg-pubkey':
+- continue
+- pkg = self._makePackageObject(hdr, mi.instance())
++ mi = self._get_packages(patterns=[(tag, rpm.RPMMIRE_GLOB, name)])
++ for hdr, idx in mi:
++ pkg = self._makePackageObject(hdr, idx)
+ result.setdefault(pkg.pkgid, pkg)
+- del mi
+
+ fileresults = self.searchFiles(name)
+ for pkg in fileresults:
+ result.setdefault(pkg.pkgid, pkg)
+
+- if self.auto_close:
+- self.ts.close()
+-
+ return result.values()
+
+ def searchFiles(self, name):
+ """search the filelists in the rpms for anything matching name"""
+
+- ts = self.readOnlyTS()
+ result = {}
+
+ name = os.path.normpath(name)
+- mi = ts.dbMatch('basenames', name)
+ # Note that globs can't be done. As of 4.8.1:
+ # mi.pattern('basenames', rpm.RPMMIRE_GLOB, name)
+ # ...produces no results.
+
+- for hdr in mi:
+- if hdr['name'] == 'gpg-pubkey':
+- continue
+- pkg = self._makePackageObject(hdr, mi.instance())
++ for hdr, idx in self._get_packages('basenames', name):
++ pkg = self._makePackageObject(hdr, idx)
+ result.setdefault(pkg.pkgid, pkg)
+- del mi
+
+- result = result.values()
+-
+- if self.auto_close:
+- self.ts.close()
+-
+- return result
++ return result.values()
+
+ def searchPrco(self, name, prcotype):
+
+@@ -438,21 +420,15 @@ class RPMDBPackageSack(PackageSackBase):
+ if misc.re_glob(n):
+ glob = True
+
+- ts = self.readOnlyTS()
+ result = {}
+ tag = self.DEP_TABLE[prcotype][0]
+- mi = ts.dbMatch(tag, misc.to_utf8(n))
+- for hdr in mi:
+- if hdr['name'] == 'gpg-pubkey':
+- continue
+- po = self._makePackageObject(hdr, mi.instance())
++ for hdr, idx in self._get_packages(tag, misc.to_utf8(n)):
++ po = self._makePackageObject(hdr, idx)
+ if not glob:
+ if po.checkPrco(prcotype, (n, f, (e,v,r))):
+ result[po.pkgid] = po
+ else:
+ result[po.pkgid] = po
+- del mi
+-
+
+ # If it's not a provides or filename, we are done
+ if prcotype == 'provides' and name[0] == '/':
+@@ -463,9 +439,6 @@ class RPMDBPackageSack(PackageSackBase):
+ result = result.values()
+ self._cache[prcotype][name] = result
+
+- if self.auto_close:
+- self.ts.close()
+-
+ return result
+
+ def searchProvides(self, name):
+@@ -607,7 +580,7 @@ class RPMDBPackageSack(PackageSackBase):
+
+ if not self._completely_loaded:
+ rpats = self._compile_patterns(patterns, ignore_case)
+- for hdr, idx in self._all_packages():
++ for hdr, idx in self._get_packages():
+ if self._match_repattern(rpats, hdr, ignore_case):
+ self._makePackageObject(hdr, idx)
+ self._completely_loaded = patterns is None
+@@ -636,18 +609,13 @@ class RPMDBPackageSack(PackageSackBase):
+
+ if self._cached_conflicts_data is None:
+ result = {}
+- ts = self.readOnlyTS()
+- mi = ts.dbMatch('conflictname')
+-
+- for hdr in mi:
+- if hdr['name'] == 'gpg-pubkey': # Just in case...
+- continue
+
++ for hdr, idx in self._get_packages('conflictname'):
+ if not hdr[rpm.RPMTAG_CONFLICTNAME]:
+ # Pre. rpm-4.9.x the above dbMatch() does nothing.
+ continue
+
+- po = self._makePackageObject(hdr, mi.instance())
++ po = self._makePackageObject(hdr, idx)
+ result[po.pkgid] = po
+ if po._has_hdr:
+ continue # Unlikely, but, meh...
+@@ -659,9 +627,6 @@ class RPMDBPackageSack(PackageSackBase):
+ del po.hdr
+ self._cached_conflicts_data = result.values()
+
+- if self.auto_close:
+- self.ts.close()
+-
+ return self._cached_conflicts_data
+
+ def _write_conflicts_new(self, pkgs, rpmdbv):
+@@ -1168,7 +1133,7 @@ class RPMDBPackageSack(PackageSackBase):
+ if not lowered:
+ searchstrings = map(lambda x: x.lower(), searchstrings)
+ ret = []
+- for hdr, idx in self._all_packages():
++ for hdr, idx in self._get_packages():
+ n = self._find_search_fields(fields, searchstrings, hdr)
+ if n > 0:
+ ret.append((self._makePackageObject(hdr, idx), n))
+@@ -1190,41 +1155,20 @@ class RPMDBPackageSack(PackageSackBase):
+ return [ self._makePackageObject(h, mi) for (h, mi) in ts.returnLeafNodes(headers=True) ]
+
+ # Helper functions
+- def _all_packages(self):
+- '''Generator that yield (header, index) for all packages
++ def _get_packages(self, *args, **kwds):
++ '''dbMatch() wrapper generator that yields (header, index) for matches
+ '''
+ ts = self.readOnlyTS()
+- mi = ts.dbMatch()
+
+- for hdr in mi:
+- if hdr['name'] != 'gpg-pubkey':
+- yield (hdr, mi.instance())
++ mi = ts.dbMatch(*args, **kwds)
++ for h in mi:
++ if h['name'] != 'gpg-pubkey':
++ yield (h, mi.instance())
+ del mi
+- if self.auto_close:
+- self.ts.close()
+-
+- def _header_from_index(self, idx):
+- """returns a package header having been given an index"""
+- warnings.warn('_header_from_index() will go away in a future version of Yum.\n',
+- Errors.YumFutureDeprecationWarning, stacklevel=2)
+
+- ts = self.readOnlyTS()
+- try:
+- mi = ts.dbMatch(0, idx)
+- except (TypeError, StopIteration), e:
+- #FIXME: raise some kind of error here
+- print 'No index matching %s found in rpmdb, this is bad' % idx
+- yield None # it should REALLY not be returning none - this needs to be right
+- else:
+- hdr = mi.next()
+- yield hdr
+- del hdr
+-
+- del mi
+ if self.auto_close:
+ self.ts.close()
+
+-
+ def _search(self, name=None, epoch=None, ver=None, rel=None, arch=None):
+ '''List of matching packages, to zero or more of NEVRA.'''
+ if name is not None and name in self._pkgname_fails:
+@@ -1254,18 +1198,16 @@ class RPMDBPackageSack(PackageSackBase):
+
+ ts = self.readOnlyTS()
+ if name is not None:
+- mi = ts.dbMatch('name', name)
++ mi = self._get_packages('name', name)
+ elif arch is not None:
+- mi = ts.dbMatch('arch', arch)
++ mi = self._get_packages('arch', arch)
+ else:
+- mi = ts.dbMatch()
++ mi = self._get_packages()
+ self._completely_loaded = True
+
+ done = False
+- for hdr in mi:
+- if hdr['name'] == 'gpg-pubkey':
+- continue
+- po = self._makePackageObject(hdr, mi.instance())
++ for hdr, idx in mi:
++ po = self._makePackageObject(hdr, idx)
+ # We create POs out of all matching names, even if we don't return
+ # them.
+ self._pkgnames_loaded.add(po.name)
+@@ -1277,9 +1219,6 @@ class RPMDBPackageSack(PackageSackBase):
+ else:
+ ret.append(po)
+
+- if self.auto_close:
+- self.ts.close()
+-
+ if not done and name is not None:
+ self._pkgname_fails.add(name)
+
+@@ -1323,7 +1262,7 @@ class RPMDBPackageSack(PackageSackBase):
+ def getHdrList(self):
+ warnings.warn('getHdrList() will go away in a future version of Yum.\n',
+ DeprecationWarning, stacklevel=2)
+- return [ hdr for hdr, idx in self._all_packages() ]
++ return [ hdr for hdr, idx in self._get_packages() ]
+
+ def getNameArchPkgList(self):
+ warnings.warn('getNameArchPkgList() will go away in a future version of Yum.\n',
+diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
+index 0340153..d479829 100644
+--- a/yum/rpmtrans.py
++++ b/yum/rpmtrans.py
+@@ -209,8 +209,7 @@ class RPMTransaction:
+ io_r = tempfile.NamedTemporaryFile()
+ self._readpipe = io_r
+ self._writepipe = open(io_r.name, 'w+b')
+- # This is dark magic, it really needs to be "base.ts.ts".
+- self.base.ts.ts.scriptFd = self._writepipe.fileno()
++ self.base.ts.setScriptFd(self._writepipe)
+ rpmverbosity = {'critical' : 'crit',
+ 'emergency' : 'emerg',
+ 'error' : 'err',
+diff --git a/yum/update_md.py b/yum/update_md.py
+index 83e56c6..39fa72e 100644
+--- a/yum/update_md.py
++++ b/yum/update_md.py
+@@ -32,6 +32,15 @@ import Errors
+
+ import rpmUtils.miscutils
+
++
++def safe_iterparse(filename):
++ """ Works like iterparse, but hides XML errors (prints a warning). """
++ try:
++ for event, elem in iterparse(filename):
++ yield event, elem
++ except SyntaxError: # Bad XML
++ print >> sys.stderr, "File is not valid XML:", filename
++
+ class UpdateNoticeException(Exception):
+ """ An exception thrown for bad UpdateNotice data. """
+ pass
+@@ -445,7 +454,7 @@ class UpdateMetadata(object):
+ else: # obj is a file object
+ infile = obj
+
+- for event, elem in iterparse(infile):
++ for event, elem in safe_iterparse(infile):
+ if elem.tag == 'update':
+ try:
+ un = UpdateNotice(elem)
diff --git a/yumcommands.py b/yumcommands.py
-index ecce347..45cd209 100644
+index ecce347..f196477 100644
--- a/yumcommands.py
+++ b/yumcommands.py
+@@ -46,7 +46,7 @@ def checkRootUID(base):
+ def checkGPGKey(base):
+ if not base.gpgKeyCheck():
+ for repo in base.repos.listEnabled():
+- if (repo.gpgcheck or repo.repo_gpgcheck) and repo.gpgkey == '':
++ if (repo.gpgcheck or repo.repo_gpgcheck) and not repo.gpgkey:
+ msg = _("""
+ You have enabled checking of packages via GPG keys. This is a good thing.
+ However, you do not have any GPG public keys installed. You need to download
@@ -972,6 +972,12 @@ class RepoListCommand(YumCommand):
elif repo.mirrorlist:
out += [base.fmtKeyValFill(_("Repo-mirrors : "),
@@ -296,7 +1026,7 @@ index ecce347..45cd209 100644
if not os.path.exists(repo.metadata_cookie):
last = _("Unknown")
diff --git a/yummain.py b/yummain.py
-index c64b140..9f9b7d4 100755
+index c64b140..32c65aa 100755
--- a/yummain.py
+++ b/yummain.py
@@ -23,6 +23,7 @@ import os.path
@@ -325,3 +1055,12 @@ index c64b140..9f9b7d4 100755
else:
logger.critical(_("Another app is currently holding the yum lock; exiting as configured by exit_on_lock"))
return 1
+@@ -205,7 +210,7 @@ def main(args):
+ except IOError, e:
+ return exIOError(e)
+
+- # rpm_check_debug failed.
++ # rpm ts.check() failed.
+ if type(return_code) == type((0,)) and len(return_code) == 2:
+ (result, resultmsgs) = return_code
+ for msg in resultmsgs:
diff --git a/yum.spec b/yum.spec
index e24b696..2b06bd0 100644
--- a/yum.spec
+++ b/yum.spec
@@ -7,7 +7,7 @@
Summary: RPM package installer/updater/manager
Name: yum
Version: 3.2.29
-Release: 4%{?dist}
+Release: 5%{?dist}
License: GPLv2+
Group: System Environment/Base
Source0: http://yum.baseurl.org/download/3.2/%{name}-%{version}.tar.gz
@@ -247,6 +247,9 @@ exit 0
%config(noreplace) %{_sysconfdir}/sysconfig/yum-cron
%changelog
+* Wed Feb 16 2011 Seth Vidal <skvidal at fedoraproject.org> - 3.2.29-5
+- lots of hopefully NOT exciting changes to rpmutils/rpmsack from head.
+
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 3.2.29-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
More information about the scm-commits
mailing list