[yum-git] Branch 'yum-3_2_X' - 3 commits - cli.py output.py shell.py test/depsolvetests.py yumcommands.py yum/config.py yum/__init__.py yum/yumRepo.py
James Antill
james at linux.duke.edu
Wed Aug 6 16:56:23 UTC 2008
cli.py | 8 ++++---
output.py | 25 +++++++++++++++++++++--
shell.py | 22 --------------------
test/depsolvetests.py | 25 ++++++++++++++++++++++-
yum/__init__.py | 53 ++++++++++++++++++++++++++++++--------------------
yum/config.py | 19 ++++++++---------
yum/yumRepo.py | 5 ++--
yumcommands.py | 2 -
8 files changed, 98 insertions(+), 61 deletions(-)
New commits:
commit 0b512bf03fa36b9c55c091a0371d34df407d68f8
Author: James Antill <james at and.org>
Date: Wed Aug 6 12:54:21 2008 -0400
Change gpgcheck again, back to two Bool options -- repo_gpgcheck is the new one
diff --git a/cli.py b/cli.py
index 2291fbd..90e5e44 100644
--- a/cli.py
+++ b/cli.py
@@ -1081,9 +1081,11 @@ class YumOptionParser(OptionParser):
# Disable all gpg key checking, if requested.
if opts.nogpgcheck:
- self.base.conf.gpgcheck = 'none'
+ self.base.conf.gpgcheck = False
+ self.base.conf.repo_gpgcheck = False
for repo in self.base.repos.listEnabled():
- repo.gpgcheck = 'none'
+ repo.gpgcheck = False
+ repo.repo_gpgcheck = False
except ValueError, e:
self.logger.critical(_('Options Error: %s'), e)
diff --git a/shell.py b/shell.py
index ff9960b..cb134d2 100644
--- a/shell.py
+++ b/shell.py
@@ -214,7 +214,7 @@ class YumShell(cmd.Cmd):
elif cmd == 'errorlevel':
logginglevels.setErrorLevel(val)
# bools
- elif cmd in ['obsoletes', 'assumeyes']:
+ elif cmd in ['gpgcheck', 'repo_gpgcheck', 'obsoletes', 'assumeyes']:
opts = self._shlex_split(args)
if not opts:
self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
@@ -229,26 +229,6 @@ class YumShell(cmd.Cmd):
if cmd == 'obsoletes':
self.base.up = None
- elif cmd in ['gpgcheck']:
- opts = self._shlex_split(args)
- if not opts:
- self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
- getattr(self.base.conf, cmd))
- else:
- value = opts[0]
- if value.lower() in ('0', 'no'):
- value = 'false'
- if value.lower() in ('1', 'yes'):
- value = 'true'
- if value.lower() == 'repository':
- value = 'repo'
- if value.lower() == 'pkgs':
- value = 'packages'
- if value.lower() not in ('false', 'true', 'packages', 'repo'):
- self.logger.critical('Value %s for %s is not a GPGcheck value', value, cmd)
- return False
- setattr(self.base.conf, cmd, value.lower())
-
elif cmd in ['exclude']:
args = args.replace(',', ' ')
opts = self._shlex_split(args)
diff --git a/yum/__init__.py b/yum/__init__.py
index cd26ccc..9203c0a 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1232,7 +1232,7 @@ class YumBase(depsolve.Depsolve):
check = repo.gpgcheck
hasgpgkey = not not repo.gpgkey
- if check in ('all', 'packages'):
+ if check:
ts = self.rpmdb.readOnlyTS()
sigresult = rpmUtils.miscutils.checkSig(ts, po.localPkg())
localfn = os.path.basename(po.localPkg())
@@ -3121,6 +3121,7 @@ class YumBase(depsolve.Depsolve):
newrepo.enablegroups = True
newrepo.metadata_expire = 0
newrepo.gpgcheck = self.conf.gpgcheck
+ newrepo.repo_gpgcheck = self.conf.repo_gpgcheck
newrepo.basecachedir = self.conf.cachedir
for key in kwargs.keys():
diff --git a/yum/config.py b/yum/config.py
index 3df157b..7f761e3 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -32,6 +32,10 @@ import rpmUtils.transaction
import rpmUtils.arch
import Errors
+# Alter/patch these to change the default checking...
+__pkgs_gpgcheck_default__ = False
+__repo_gpgcheck_default__ = False
+
class Option(object):
'''
This class handles a single Yum configuration file option. Create
@@ -624,16 +628,9 @@ class YumConf(StartupConf):
diskspacecheck = BoolOption(True)
overwrite_groups = BoolOption(False)
keepalive = BoolOption(True)
- gpgcheck = CaselessSelectionOption('none',
- ('none', 'all', 'packages', 'repo'),
- {'0' : 'none',
- 'no' : 'none',
- 'false' : 'none',
- '1' : 'all',
- 'yes' : 'all',
- 'true' : 'all',
- 'pkgs' : 'packages',
- 'repository' : 'repo'})
+ # FIXME: rename gpgcheck to pkgs_gpgcheck
+ gpgcheck = BoolOption(__pkgs_gpgcheck_default__)
+ repo_gpgcheck = BoolOption(__repo_gpgcheck_default__)
obsoletes = BoolOption(False)
showdupesfromrepos = BoolOption(False)
enabled = BoolOption(True)
@@ -687,7 +684,9 @@ class RepoConf(BaseConfig):
retries = Inherit(YumConf.retries)
failovermethod = Inherit(YumConf.failovermethod)
+ # FIXME: rename gpgcheck to pkgs_gpgcheck
gpgcheck = Inherit(YumConf.gpgcheck)
+ repo_gpgcheck = Inherit(YumConf.repo_gpgcheck)
keepalive = Inherit(YumConf.keepalive)
enablegroups = Inherit(YumConf.enablegroups)
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index c0a47b2..dc98f81 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -338,7 +338,8 @@ class YumRepository(Repository, config.RepoConf):
def dump(self):
output = '[%s]\n' % self.id
vars = ['name', 'bandwidth', 'enabled', 'enablegroups',
- 'gpgcheck', 'includepkgs', 'keepalive', 'proxy',
+ 'gpgcheck', 'repo_gpgcheck', # FIXME: gpgcheck => pkgs_gpgcheck
+ 'includepkgs', 'keepalive', 'proxy',
'proxy_password', 'proxy_username', 'exclude',
'retries', 'throttle', 'timeout', 'mirrorlist',
'cachedir', 'gpgkey', 'pkgdir', 'hdrdir']
@@ -1108,7 +1109,7 @@ class YumRepository(Repository, config.RepoConf):
else:
filepath = fo
- if self.gpgcheck in ('all', 'repo'): # or whatever FIXME
+ if self.repo_gpgcheck:
sigfile = self.cachedir + '/repomd.xml.asc'
try:
diff --git a/yumcommands.py b/yumcommands.py
index 50a210a..2244ddb 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -42,7 +42,7 @@ def checkRootUID(base):
def checkGPGKey(base):
if not base.gpgKeyCheck():
for repo in base.repos.listEnabled():
- if repo.gpgcheck != 'false' and repo.gpgkey == '':
+ if repo.gpgcheck or repo.repo_gpgcheck and 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
commit 41bb94630c2a993350ec704346626918c504ec3e
Author: James Antill <james at and.org>
Date: Wed Aug 6 12:41:04 2008 -0400
Remove the prints out of __init__ and into. output.py
diff --git a/cli.py b/cli.py
index 09073f8..2291fbd 100644
--- a/cli.py
+++ b/cli.py
@@ -379,7 +379,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.verbose_logger.log(yum.logginglevels.INFO_2,
_('Downloading Packages:'))
- problems = self.downloadPkgs(downloadpkgs)
+ problems = self.downloadPkgs(downloadpkgs, callback_total=self.download_callback_total_cb)
if len(problems) > 0:
errstring = ''
diff --git a/output.py b/output.py
index a2c70aa..b483389 100644
--- a/output.py
+++ b/output.py
@@ -27,6 +27,7 @@ import rpm
import re # For YumTerm
from urlgrabber.progress import TextMeter
+import urlgrabber.progress
from urlgrabber.grabber import URLGrabError
from yum.misc import sortPkgObj, prco_tuple_to_string, to_str, to_unicode, get_my_lang_code
import yum.misc
@@ -474,8 +475,6 @@ class YumOutput:
for po in reqlist:
print " provider: %s" % po.compactPrint()
-
-
def format_number(self, number, SI=0, space=' '):
"""Turn numbers into human-readable metric-like numbers"""
symbols = ['', # (none)
@@ -516,6 +515,10 @@ class YumOutput:
return(format % (number, space, symbols[depth]))
+ @staticmethod
+ def format_time(seconds, use_hours=0):
+ return urlgrabber.progress.format_time(seconds, use_hours)
+
def matchcallback(self, po, values, matchfor=None, verbose=None):
""" Output search/provides type callback matches. po is the pkg object,
values are the things in the po that we've matched.
@@ -738,6 +741,24 @@ Remove %5.5s Package(s)
self._last_interrupt = now
raise URLGrabError(15, _('user interrupt'))
+ def download_callback_total_cb(self, remote_pkgs, remote_size,
+ download_start_timestamp):
+ if len(remote_pkgs) <= 1:
+ return
+ if not hasattr(urlgrabber.progress, 'TerminalLine'):
+ return
+
+ tl = urlgrabber.progress.TerminalLine(8)
+ print "-" * tl.rest()
+ dl_time = time.time() - download_start_timestamp
+ ui_size = tl.add(' | %5sB' % self.format_number(remote_size))
+ ui_time = tl.add(' %9s' % self.format_time(dl_time))
+ ui_end = tl.add(' ' * 5)
+ ui_bs = tl.add(' %5sB/s' % self.format_number(remote_size / dl_time))
+ print "%-*.*s%s%s%s%s" % (tl.rest(), tl.rest(), _("Total"),
+ ui_bs, ui_size, ui_time, ui_end)
+
+
class DepSolveProgressCallBack:
"""provides text output callback functions for Dependency Solver callback"""
diff --git a/yum/__init__.py b/yum/__init__.py
index 264e913..cd26ccc 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -53,7 +53,7 @@ from parser import ConfigPreProcessor, varReplace
import transactioninfo
import urlgrabber
from urlgrabber.grabber import URLGrabError
-from urlgrabber.progress import format_number, format_time
+from urlgrabber.progress import format_number
from packageSack import packagesNewestByNameArch, packagesNewestByName
import depsolve
import plugins
@@ -1034,9 +1034,8 @@ class YumBase(depsolve.Depsolve):
raise URLGrabError(-1, _('Package does not match checksum'))
return 0
-
-
- def downloadPkgs(self, pkglist, callback=None):
+
+ def downloadPkgs(self, pkglist, callback=None, callback_total=None):
def mediasort(apo, bpo):
# FIXME: we should probably also use the mediaid; else we
# could conceivably ping-pong between different disc1's
@@ -1135,16 +1134,8 @@ class YumBase(depsolve.Depsolve):
if errors.has_key(po):
del errors[po]
- if len(remote_pkgs) > 1 and hasattr(urlgrabber.progress,'TerminalLine'):
- tl = urlgrabber.progress.TerminalLine(8)
- print "-" * tl.rest()
- dl_time = time.time() - beg_download
- ui_size = tl.add(' | %5sB' % format_number(remote_size))
- ui_time = tl.add(' %9s' % format_time(dl_time))
- ui_end = tl.add(' ' * 5)
- ui_bs = tl.add(' %5sB/s' % format_number(remote_size / dl_time))
- print "%-*.*s%s%s%s%s" % (tl.rest(), tl.rest(), _("Total"),
- ui_bs, ui_size, ui_time, ui_end)
+ if callback_total is not None:
+ callback_total(remote_pkgs, remote_size, beg_download)
self.plugins.run('postdownload', pkglist=pkglist, errors=errors)
commit 72ba6ac2c8609e409217a1e08d471f450fd38537
Author: James Antill <james at and.org>
Date: Wed Aug 6 12:19:19 2008 -0400
Add almost working test_min_up_and_dep fix, but turn it off
diff --git a/test/depsolvetests.py b/test/depsolvetests.py
index af873d4..4e2e263 100644
--- a/test/depsolvetests.py
+++ b/test/depsolvetests.py
@@ -943,7 +943,7 @@ class DepsolveTests(DepsolveTests):
self.assertEquals('ok', *self.resolveCode())
self.assertResult((ipo2, po4))
- def test_min_up_and_dep(self):
+ def test_min_up_and_dep1(self):
rpo1 = FakePackage('bar', version='1')
self.rpmdb.addPackage(rpo1)
@@ -965,3 +965,26 @@ class DepsolveTests(DepsolveTests):
self.assertEquals('ok', *self.resolveCode())
self.assertResult((ipo2, po4))
+
+ def test_min_up_and_dep2(self):
+ rpo1 = FakePackage('bar', version='1')
+ self.rpmdb.addPackage(rpo1)
+
+ ipo1 = FakePackage('bar', version='2')
+
+ ipo2 = FakePackage('foo')
+ ipo2.addRequires('bar', 'GE', (None, '3', '0'))
+ self.tsInfo.addInstall(ipo2)
+ self.tsInfo.addUpdate(ipo1, oldpo=rpo1)
+
+ po1 = FakePackage('foo')
+ po2 = FakePackage('bar', version='2')
+ po3 = FakePackage('bar', version='3')
+ po4 = FakePackage('bar', version='4')
+ self.xsack.addPackage(po4)
+ self.xsack.addPackage(po3)
+ self.xsack.addPackage(po2)
+ self.xsack.addPackage(po1)
+
+ self.assertEquals('ok', *self.resolveCode())
+ self.assertResult((ipo2, po4))
diff --git a/yum/__init__.py b/yum/__init__.py
index c6dcc99..264e913 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2344,7 +2344,29 @@ class YumBase(depsolve.Depsolve):
return tx_return
-
+ def _newer_update_in_trans(self, pkgtup, available_pkg):
+ """ We return True if there is a newer package already in the
+ transaction. If there is an older one, we remove it and return
+ False so we'll goto this available one. """
+ found = False
+ for txmbr in self.tsInfo.getMembersWithState(pkgtup, [TS_UPDATED]):
+ if True: # FIXME: This "works" but fails related deps.
+ # Ie. update-minimal glibc pam == works
+ # Ie. update-minimal glibc glibc-common pam == hard fail
+ return True
+ count = 0
+ for po in txmbr.updated_by:
+ if available_pkg.verLE(po):
+ count += 1
+ else:
+ for ntxmbr in self.tsInfo.getMembers(po.pkgtup):
+ self.tsInfo.remove(ntxmbr.po.pkgtup)
+ if count:
+ found = True
+ else:
+ self.tsInfo.remove(txmbr.po.pkgtup)
+ return found
+
def update(self, po=None, requiringPo=None, **kwargs):
"""try to mark for update the item(s) specified.
po is a package object - if that is there, mark it for update,
@@ -2489,13 +2511,12 @@ class YumBase(depsolve.Depsolve):
txmbr.setAsDep(requiringPo)
tx_return.append(txmbr)
-
for available_pkg in availpkgs:
for updated in self.up.updating_dict.get(available_pkg.pkgtup, []):
if self.tsInfo.isObsoleted(updated):
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already obsoleted: %s.%s %s:%s-%s'),
updated)
- elif self.tsInfo.getMembersWithState(updated, [TS_UPDATED]):
+ elif self._newer_update_in_trans(updated, available_pkg):
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already updated: %s.%s %s:%s-%s'),
updated)
@@ -2517,7 +2538,7 @@ class YumBase(depsolve.Depsolve):
if self.tsInfo.isObsoleted(ipkg.pkgtup):
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already obsoleted: %s.%s %s:%s-%s'),
ipkg.pkgtup)
- elif self.tsInfo.getMembersWithState(ipkg.pkgtup, [TS_UPDATED]):
+ elif self._newer_update_in_trans(ipkg.pkgtup, available_pkg):
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already updated: %s.%s %s:%s-%s'),
ipkg.pkgtup)
elif ipkg.verLT(available_pkg):
@@ -2525,11 +2546,9 @@ class YumBase(depsolve.Depsolve):
if requiringPo:
txmbr.setAsDep(requiringPo)
tx_return.append(txmbr)
-
return tx_return
-
def remove(self, po=None, **kwargs):
"""try to find and mark for remove the specified package(s) -
if po is specified then that package object (if it is installed)
More information about the Yum-cvs-commits
mailing list