[yum-commits] Branch 'yum-3_2_X' - 6 commits - cli.py rpmUtils/transaction.py yum/config.py yum/__init__.py yummain.py yum/rpmtrans.py
Panu Matilainen
pmatilai at osuosl.org
Thu Feb 10 09:01:57 UTC 2011
cli.py | 53 ++++++++++++++++++--------------------
rpmUtils/transaction.py | 22 ++++++++++++----
yum/__init__.py | 66 +++++++++++++++++-------------------------------
yum/config.py | 1
yum/rpmtrans.py | 3 --
yummain.py | 2 -
6 files changed, 70 insertions(+), 77 deletions(-)
New commits:
commit 72143a2de302829caab36564127b077986d622dc
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date: Wed Feb 9 16:58:57 2011 +0200
Save and restore original transaction flags in wrapper test() method
...and here lies the key to the mystery of yum needing to repopulate
the transaction after a test-run, doh :)
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index fa23a87..897c30f 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -110,12 +110,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:
commit b433c4cbc213de64d724d1c7e7ce4280f55718ec
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date: Wed Feb 9 16:16:01 2011 +0200
Make transaction scriptFd setting less voodooish
In older rpm versions ts.scriptFd is an invisible write-only
pseudo-attribute hack, so __getattr__() tricks in the transaction wrapper
wont work for it. Add a new wrapper method for setting it to make it
less gruesome, accept any file-like object as the fd argument.
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index d36109b..fa23a87 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -98,6 +98,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)
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',
commit 9bb8dc755fb1d378691cf017465903ad0eb3944b
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date: Wed Feb 9 16:08:34 2011 +0200
Remove cruft from transaction wrapper
With newer rpm versions these would just raise AttributeErrors,
in older versions they are broken to various degrees and yum
never used them for anything anyway.
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index 4c4a420..d36109b 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -28,12 +28,8 @@ class TransactionWrapper:
'addErase',
'addInstall',
'run',
- 'IDTXload',
- 'IDTXglob',
- 'rollback',
'pgpImportPubkey',
'pgpPrtPkts',
- 'Debug',
'problems',
'setFlags',
'setVSFlags',
commit 16c88823c48240e4ac9068066fcc0c524b7e40b9
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date: Wed Feb 9 15:55:10 2011 +0200
Make ts.check() unconditional + adjust related messages
ts.check() is not really an optional call, as there are dependencies
which yum does not check for (notably rpmlib() dependencies). Always
call ts.check(), looking at the return values.
diff --git a/cli.py b/cli.py
index 9cee6a6..7237f6c 100644
--- a/cli.py
+++ b/cli.py
@@ -510,30 +510,29 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.dsCallback = None # dumb, dumb dumb dumb!
self.populateTs(keepold=0) # sigh
- if self.conf.rpm_check_debug:
- rcd_st = time.time()
- self.verbose_logger.log(yum.logginglevels.INFO_2,
- _('Running rpm_check_debug'))
- 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 rpm_check_debug vs depsolve:')
+ 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:')
- for msg in msgs:
- print to_utf8(msg)
+ for msg in msgs:
+ print to_utf8(msg)
- if rpmlib_only:
- return 1, [_('RPM needs to be updated')]
- return 1, [_('Please report this error in %s') % self.conf.bugtracker_url]
+ 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('rpm_check_debug time: %0.3f' % (time.time() - rcd_st))
+ 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,
diff --git a/yum/__init__.py b/yum/__init__.py
index 02b4780..c160201 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4811,25 +4811,24 @@ class YumBase(depsolve.Depsolve):
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.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 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
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/yummain.py b/yummain.py
index 9f9b7d4..32c65aa 100755
--- a/yummain.py
+++ b/yummain.py
@@ -210,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:
commit c54c9082d702b6ba45620ecf3ca5834b9b104543
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date: Wed Feb 9 15:18:44 2011 +0200
Move _run_rpm_check_debug() functionality to the ts wrapper check()
Nothing in yum cares for the dependency-tuples-of-doom that the
rpm-level ts.check() returns, having this in transaction wrapper check()
method seems like a more sensible place than in yum base class with
a funny name
diff --git a/cli.py b/cli.py
index 23ef686..9cee6a6 100644
--- a/cli.py
+++ b/cli.py
@@ -514,7 +514,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
rcd_st = time.time()
self.verbose_logger.log(yum.logginglevels.INFO_2,
_('Running rpm_check_debug'))
- msgs = self._run_rpm_check_debug()
+ msgs = self.ts.check()
if msgs:
rpmlib_only = True
for msg in msgs:
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index e8f4459..4c4a420 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
@@ -23,7 +24,6 @@ class TransactionWrapper:
def __init__(self, root='/'):
self.ts = rpm.TransactionSet(root)
self._methods = ['dbMatch',
- 'check',
'order',
'addErase',
'addInstall',
@@ -54,6 +54,17 @@ 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 __getattr__(self, attr):
if attr in self._methods:
return self.getMethod(attr)
diff --git a/yum/__init__.py b/yum/__init__.py
index 4147678..02b4780 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4814,7 +4814,7 @@ class YumBase(depsolve.Depsolve):
if self.conf.rpm_check_debug:
self.verbose_logger.log(logginglevels.INFO_2,
_('Running rpm_check_debug'))
- msgs = self._run_rpm_check_debug()
+ msgs = self.ts.check()
if msgs:
rpmlib_only = True
for msg in msgs:
@@ -4867,17 +4867,6 @@ class YumBase(depsolve.Depsolve):
cb.display = display
self.runTransaction( cb=cb )
- def _run_rpm_check_debug(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 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
commit fc395ef14b135b3591488816ec902057fd8d03f4
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date: Wed Feb 9 14:46:38 2011 +0200
Eliminate an unnecessary round of transaction re-population
Initialize + populate the transaction set to be used for the test-run
before calling rpm_check_debug to let them use the same set, avoiding
one round of the fairly expensive re-population of the entire transaction.
diff --git a/cli.py b/cli.py
index 640f190..23ef686 100644
--- a/cli.py
+++ b/cli.py
@@ -504,6 +504,12 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
if self.gpgsigcheck(downloadpkgs) != 0:
return 1
+ self.initActionTs()
+ # save our dsCallback out
+ dscb = self.dsCallback
+ self.dsCallback = None # dumb, dumb dumb dumb!
+ self.populateTs(keepold=0) # sigh
+
if self.conf.rpm_check_debug:
rcd_st = time.time()
self.verbose_logger.log(yum.logginglevels.INFO_2,
@@ -537,12 +543,6 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
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
diff --git a/yum/__init__.py b/yum/__init__.py
index de393f1..4147678 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4804,6 +4804,12 @@ 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,
@@ -4833,14 +4839,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
@@ -4870,10 +4869,6 @@ class YumBase(depsolve.Depsolve):
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.
@@ -4881,7 +4876,6 @@ class YumBase(depsolve.Depsolve):
# now just be compatible.
results.append(to_str(prob))
- self.dsCallback = dscb
return results
def add_enable_repo(self, repoid, baseurls=[], mirrorlist=None, **kwargs):
More information about the Yum-commits
mailing list