[yum-commits] Branch 'yum-3_2_X' - 7 commits - cli.py output.py yum/__init__.py yum/packages.py yum/repos.py yum/yumRepo.py
James Antill
james at osuosl.org
Wed Dec 8 17:01:48 UTC 2010
cli.py | 9 ++---
output.py | 95 +++++++++++++++++++++++++++++++++++++++-----------------
yum/__init__.py | 44 +++++++++++++++++--------
yum/packages.py | 34 +++++++++++++++++++-
yum/repos.py | 1
yum/yumRepo.py | 2 -
6 files changed, 135 insertions(+), 50 deletions(-)
New commits:
commit 33d5b109531db1c83e2881d7e5f2bc7e00c75dd6
Author: James Antill <james at and.org>
Date: Tue Dec 7 09:54:48 2010 -0500
Dynamically work out the max action width, in the rpm callback. BZ 660576.
diff --git a/output.py b/output.py
index 0f3543f..a8bf1cc 100755
--- a/output.py
+++ b/output.py
@@ -2278,6 +2278,15 @@ class YumCliRPMCallBack(RPMBaseCallback):
def event(self, package, action, te_current, te_total, ts_current, ts_total):
# this is where a progress bar would be called
process = self.action[action]
+
+ if not hasattr(self, '_max_action_wid'):
+ wid1 = 0
+ for val in self.action.values():
+ wid_val = utf8_width(val)
+ if wid1 < wid_val:
+ wid1 = wid_val
+ self._max_action_wid = wid1
+ wid1 = self._max_action_wid
if type(package) not in types.StringTypes:
pkgname = str(package)
@@ -2292,7 +2301,7 @@ class YumCliRPMCallBack(RPMBaseCallback):
if self.output and (sys.stdout.isatty() or te_current == te_total):
(fmt, wid1, wid2) = self._makefmt(percent, ts_current, ts_total,
- pkgname=pkgname)
+ pkgname=pkgname, wid1=wid1)
msg = fmt % (utf8_width_fill(process, wid1, wid1),
utf8_width_fill(pkgname, wid2, wid2))
if msg != self.lastmsg:
@@ -2308,7 +2317,7 @@ class YumCliRPMCallBack(RPMBaseCallback):
sys.stdout.flush()
def _makefmt(self, percent, ts_current, ts_total, progress = True,
- pkgname=None):
+ pkgname=None, wid1=15):
l = len(str(ts_total))
size = "%s.%s" % (l, l)
fmt_done = "%" + size + "s/%" + size + "s"
@@ -2322,7 +2331,7 @@ class YumCliRPMCallBack(RPMBaseCallback):
pnl = utf8_width(pkgname)
overhead = (2 * l) + 2 # Length of done, above
- overhead += 19 # Length of begining
+ overhead += 2+ wid1 +2 # Length of begining (" " action " :")
overhead += 1 # Space between pn and done
overhead += 2 # Ends for progress
overhead += 1 # Space for end
@@ -2353,7 +2362,7 @@ class YumCliRPMCallBack(RPMBaseCallback):
bar = fmt_bar % (self.mark * marks, )
fmt = " %s: %s " + bar + " " + done
wid2 = pnl
- return fmt, 15, wid2
+ return fmt, wid1, wid2
def progressbar(current, total, name=None):
commit f47c22dcf5eac380b95c97a0b382004af9326b5d
Author: James Antill <james at and.org>
Date: Mon Dec 6 16:01:00 2010 -0500
Allow ranges of transactions in list/summary/pkg-list.
diff --git a/output.py b/output.py
index f99ab37..0f3543f 100755
--- a/output.py
+++ b/output.py
@@ -1353,7 +1353,52 @@ to exit.
except KeyError:
return to_unicode(str(uid))
+ @staticmethod
+ def _historyRangeRTIDs(old, tid):
+ ''' Convert a user "TID" string of 2..4 into: (2, 4). '''
+ def str2int(x):
+ try:
+ return int(x)
+ except ValueError:
+ return None
+
+ if '..' not in tid:
+ return None
+ btid, etid = tid.split('..', 2)
+ btid = str2int(btid)
+ if btid > old.tid:
+ return None
+ elif btid <= 0:
+ return None
+ etid = str2int(etid)
+ if etid > old.tid:
+ return None
+
+ # Have a range ... do a "merged" transaction.
+ if btid > etid:
+ btid, etid = etid, btid
+ return (btid, etid)
+
+ def _historyRangeTIDs(self, rtids):
+ ''' Convert a list of ranged tid typles into all the tids needed, Eg.
+ [(2,4), (6,8)] == [2, 3, 4, 6, 7, 8]. '''
+ tids = set()
+ last_end = -1 # This just makes displaying it easier...
+ for mtid in sorted(rtids):
+ if mtid[0] < last_end:
+ self.logger.warn(_('Skipping merged transaction %d to %d, as it overlaps' % (mtid[0], mtid[1])))
+ continue # Don't do overlapping
+ last_end = mtid[1]
+ for num in range(mtid[0], mtid[1] + 1):
+ tids.add(num)
+ return tids
+
def _history_list_transactions(self, extcmds):
+ old = self.history.last()
+ if old is None:
+ self.logger.critical(_('No transactions'))
+ return None, None
+
tids = set()
pats = []
usertids = extcmds[1:]
@@ -1367,6 +1412,10 @@ to exit.
int(tid)
tids.add(tid)
except ValueError:
+ rtid = self._historyRangeRTIDs(old, tid)
+ if rtid:
+ tids.update(self._historyRangeTIDs([rtid]))
+ continue
pats.append(tid)
if pats:
tids.update(self.history.search(pats))
@@ -1493,22 +1542,10 @@ to exit.
return 1, ['Failed history info']
for tid in extcmds[1:]:
- if '..' in tid:
- btid, etid = tid.split('..', 2)
- btid = str2int(btid)
- if btid > old.tid:
- btid = None
- elif btid <= 0:
- btid = None
- etid = str2int(etid)
- if etid > old.tid:
- etid = None
- if btid is not None and etid is not None:
- # Have a range ... do a "merged" transaction.
- if btid > etid:
- btid, etid = etid, btid
- mtids.add((btid, etid))
- continue
+ if self._historyRangeRTIDs(old, tid):
+ # Have a range ... do a "merged" transaction.
+ mtids.add(self._historyRangeRTIDs(old, tid))
+ continue
elif str2int(tid) is not None:
tids.add(str2int(tid))
continue
@@ -1518,14 +1555,7 @@ to exit.
utids = tids.copy()
if mtids:
mtids = sorted(mtids)
- last_end = -1 # This just makes displaying it easier...
- for mtid in mtids:
- if mtid[0] < last_end:
- self.logger.warn(_('Skipping merged transaction %d to %d, as it overlaps', mtid[0], mtid[1]))
- continue # Don't do overlapping
- last_end = mtid[1]
- for num in range(mtid[0], mtid[1] + 1):
- tids.add(num)
+ tids.update(self._historyRangeTIDs(mtids))
if not tids and len(extcmds) < 2:
old = self.history.last(complete_transactions_only=False)
commit d25596763bb11269072ee1ad7f2ba2c40eb5ed90
Author: James Antill <james at and.org>
Date: Mon Dec 6 15:35:23 2010 -0500
Don't skip installed_by/etc. if repoXML or loginuid doesn't exist.
diff --git a/yum/__init__.py b/yum/__init__.py
index 29e0284..45123a3 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1527,19 +1527,14 @@ class YumBase(depsolve.Depsolve):
if rpo.xattr_origin_url is not None:
po.yumdb_info.origin_url = rpo.xattr_origin_url
- if not hasattr(rpo.repo, 'repoXML'):
- continue
-
- md = rpo.repo.repoXML
- if md and md.revision is not None:
- po.yumdb_info.from_repo_revision = str(md.revision)
- if md:
- po.yumdb_info.from_repo_timestamp = str(md.timestamp)
+ if hasattr(rpo.repo, 'repoXML'):
+ md = rpo.repo.repoXML
+ if md and md.revision is not None:
+ po.yumdb_info.from_repo_revision = str(md.revision)
+ if md:
+ po.yumdb_info.from_repo_timestamp = str(md.timestamp)
loginuid = misc.getloginuid()
- if loginuid is None:
- continue
- loginuid = str(loginuid)
if txmbr.updates or txmbr.downgrades or txmbr.reinstall:
if txmbr.updates:
opo = txmbr.updates[0]
@@ -1549,9 +1544,10 @@ class YumBase(depsolve.Depsolve):
opo = po
if 'installed_by' in opo.yumdb_info:
po.yumdb_info.installed_by = opo.yumdb_info.installed_by
- po.yumdb_info.changed_by = loginuid
- else:
- po.yumdb_info.installed_by = loginuid
+ if loginuid is not None:
+ po.yumdb_info.changed_by = str(loginuid)
+ elif loginuid is not None:
+ po.yumdb_info.installed_by = str(loginuid)
# Remove old ones after installing new ones, so we can copy values.
for txmbr in self.tsInfo:
commit daa06de23a6d9d1276dd7031ecb07d776f91cfe7
Author: James Antill <james at and.org>
Date: Mon Dec 6 15:32:00 2010 -0500
If the .localPkg() file has a url xattr, store that in yumdb. BZ 567100
diff --git a/yum/__init__.py b/yum/__init__.py
index 58e4367..29e0284 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1524,6 +1524,9 @@ class YumBase(depsolve.Depsolve):
po.yumdb_info.from_repo_timestamp = lp_mtime
except: pass
+ if rpo.xattr_origin_url is not None:
+ po.yumdb_info.origin_url = rpo.xattr_origin_url
+
if not hasattr(rpo.repo, 'repoXML'):
continue
@@ -2090,6 +2093,7 @@ class YumBase(depsolve.Depsolve):
if local:
filelist.extend([txmbr.po.localHdr()])
else:
+ txmbr.po.xattr_origin_url # Load this, before we rm the file.
filelist.extend([txmbr.po.localPkg(), txmbr.po.localHdr()])
# now remove them
diff --git a/yum/packages.py b/yum/packages.py
index 093d3c8..6f61fea 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -41,6 +41,13 @@ import urlparse
urlparse.uses_fragment.append("media")
from urlgrabber.grabber import URLGrabber, URLGrabError
+try:
+ import xattr
+ if not hasattr(xattr, 'get'):
+ xattr = None # This is a "newer" API.
+except ImportError:
+ xattr = None
+
# For verify
import pwd
import grp
@@ -879,7 +886,32 @@ class YumAvailablePackage(PackageObject, RpmBase):
self._verify_local_pkg_cache = nst
return True
-
+
+ # See: http://www.freedesktop.org/wiki/CommonExtendedAttributes
+ def _localXattrUrl(self):
+ """ Get the user.xdg.origin.url value from the local pkg. ... if it's
+ present. We cache this so we can access it after the file has been
+ deleted (keepcache=False). """
+
+ if xattr is None:
+ return None
+
+ if hasattr(self, '__cached_localXattrUrl'):
+ return getattr(self, '__cached_localXattrUrl')
+
+ if not self.verifyLocalPkg():
+ return None
+
+ try:
+ ret = xattr.get(self.localPkg(), 'user.xdg.origin.url')
+ except: # Documented to be "EnvironmentError", but make sure
+ return None
+
+ setattr(self, '__cached_localXattrUrl', ret)
+ return ret
+
+ xattr_origin_url = property(lambda x: x._localXattrUrl())
+
def prcoPrintable(self, prcoTuple):
"""convert the prco tuples into a nicer human string"""
warnings.warn('prcoPrintable() will go away in a future version of Yum.\n',
commit 07936468bc7faaceb40d51477340b3c90c77e179
Author: James Antill <james at and.org>
Date: Mon Dec 6 14:32:19 2010 -0500
Don't delete packages when doing a test transaction.
diff --git a/yum/__init__.py b/yum/__init__.py
index 3bb1f3f..58e4367 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1455,7 +1455,8 @@ class YumBase(depsolve.Depsolve):
errors=errors)
- if not self.conf.keepcache:
+ if (not self.conf.keepcache and
+ not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST)):
self.cleanUsedHeadersPackages()
for i in ('ts_all_fn', 'ts_done_fn'):
commit e95f16d8342bc4dcdfde6b8858a8704bc4c1bdf8
Author: James Antill <james at and.org>
Date: Fri Dec 3 16:05:09 2010 -0500
Sig check one po from each repo. as we download, to save errors at the end.
diff --git a/yum/__init__.py b/yum/__init__.py
index c367959..3bb1f3f 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1868,6 +1868,7 @@ class YumBase(depsolve.Depsolve):
beg_download = time.time()
i = 0
local_size = 0
+ done_repos = set()
for po in remote_pkgs:
# Recheck if the file is there, works around a couple of weird
# edge cases.
@@ -1910,6 +1911,14 @@ class YumBase(depsolve.Depsolve):
if hasattr(urlgrabber.progress, 'text_meter_total_size'):
urlgrabber.progress.text_meter_total_size(remote_size,
local_size)
+ if po.repoid not in done_repos:
+ # Check a single package per. repo. ... to give a hint to
+ # the user on big downloads.
+ result, errmsg = self.sigCheckPkg(po)
+ if result != 0:
+ self.verbose_logger.warn("%s", errmsg)
+ done_repos.add(po.repoid)
+
except Errors.RepoError, e:
adderror(po, str(e))
else:
commit 60310f502487fae97e4d26a47dab01c342baf163
Author: James Antill <james at and.org>
Date: Fri Dec 3 12:43:07 2010 -0500
Add _override_sigchecks, to catch dynamic repos. with --nogpgcheck, BZ 573725.
diff --git a/cli.py b/cli.py
index 88d8c07..06bfb68 100644
--- a/cli.py
+++ b/cli.py
@@ -1497,12 +1497,11 @@ class YumOptionParser(OptionParser):
# Disable all gpg key checking, if requested.
if opts.nogpgcheck:
- self.base.conf.gpgcheck = False
- self.base.conf.repo_gpgcheck = False
- self.base.conf.localpkg_gpgcheck = False
+ # Altering the normal configs. doesn't work too well, esp. with
+ # regard to dynamically enabled repos.
+ self._override_sigchecks = True
for repo in self.base.repos.listEnabled():
- repo.gpgcheck = False
- repo.repo_gpgcheck = False
+ repo._override_sigchecks = True
except ValueError, e:
self.logger.critical(_('Options Error: %s'), e)
diff --git a/yum/__init__.py b/yum/__init__.py
index 92fa0d0..c367959 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -182,6 +182,7 @@ class YumBase(depsolve.Depsolve):
self.skipped_packages = [] # packages skip by the skip-broken code
self.logger = logging.getLogger("yum.YumBase")
self.verbose_logger = logging.getLogger("yum.verbose.YumBase")
+ self._override_sigchecks = False
self._repos = RepoStorage(self)
self.repo_setopts = {} # since we have to use repo_setopts in base and
# not in cli - set it up as empty so no one
@@ -2009,7 +2010,10 @@ class YumBase(depsolve.Depsolve):
might help.
- 2 - Fatal GPG verification error, give up.
'''
- if hasattr(po, 'pkgtype') and po.pkgtype == 'local':
+ if self._override_sigchecks:
+ check = False
+ hasgpgkey = 0
+ elif hasattr(po, 'pkgtype') and po.pkgtype == 'local':
check = self.conf.localpkg_gpgcheck
hasgpgkey = 0
else:
diff --git a/yum/repos.py b/yum/repos.py
index 4b74ac6..ee2903a 100644
--- a/yum/repos.py
+++ b/yum/repos.py
@@ -105,6 +105,7 @@ class RepoStorage:
repoobj.quick_enable_disable = self.quick_enable_disable
else:
self._cache_enabled_repos = None
+ repoobj._override_sigchecks = self.ayum._override_sigchecks
def delete(self, repoid):
if repoid in self.repos:
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index b0e23c6..a920db9 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1434,7 +1434,7 @@ class YumRepository(Repository, config.RepoConf):
else:
filepath = fo
- if self.repo_gpgcheck:
+ if self.repo_gpgcheck and not self._override_sigchecks:
if misc.gpgme is None:
raise URLGrabError(-1, 'pygpgme is not working so repomd.xml can not be verified for %s' % (self))
More information about the Yum-commits
mailing list