[yum-commits] 18 commits - cli.py docs/yum.8 docs/yum.conf.5 output.py yumcommands.py yum/config.py yum-cron/Makefile yum/depsolve.py yum/__init__.py yum/misc.py yum.spec yum/transactioninfo.py yum/update_md.py yum/yumRepo.py
James Antill
james at osuosl.org
Mon Jan 28 15:30:29 UTC 2013
cli.py | 15 +
docs/yum.8 | 48 ++++
docs/yum.conf.5 | 50 ++++
output.py | 9
yum-cron/Makefile | 4
yum.spec | 2
yum/__init__.py | 67 +++++-
yum/config.py | 7
yum/depsolve.py | 26 ++
yum/misc.py | 25 ++
yum/transactioninfo.py | 3
yum/update_md.py | 10
yum/yumRepo.py | 29 ++
yumcommands.py | 504 ++++++++++++++++++++++++++++++++++++++++++++++++-
14 files changed, 769 insertions(+), 30 deletions(-)
New commits:
commit 73b7aaf1ff3267b564776252961e03326d8d49b3
Merge: a27f697 1ae97b4
Author: James Antill <james at and.org>
Date: Mon Jan 28 10:29:31 2013 -0500
Merge branch 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum
* 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum:
YumRepo.populate(): always decompresses new database
commit a27f69747c5c82b35d39dc631d3964436e3eec13
Author: James Antill <james at and.org>
Date: Fri Jan 25 14:18:58 2013 -0500
Don't fail for file based repos. when using --downloadonly. BZ 903294.
diff --git a/yum/__init__.py b/yum/__init__.py
index 3411bd7..509b231 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2322,7 +2322,10 @@ much more problems).
# we may throw away partial file here- but we don't lock,
# so can't rename tempfile to rpmfile safely
misc.unlink_f(po.localpath)
- if po not in errors:
+
+ # Note that for file:// repos. urlgrabber won't "download"
+ # so we have to check that po.localpath exists.
+ if po not in errors and os.path.exists(po.localpath):
# verifyPkg() didn't complain, so (potentially)
# overwriting another copy should not be a problem
os.rename(po.localpath, rpmfile)
commit 3fe292adc0d992c5817447c0fc59668b78a26311
Author: James Antill <james at and.org>
Date: Fri Jan 25 14:13:55 2013 -0500
Eat exceptions for _preload_file().
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 09b2534..a7410ac 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1908,7 +1908,11 @@ Insufficient space in download directory %s
if os.path.exists(destfn):
if os.stat(fn)[stat.ST_CTIME] <= os.stat(destfn)[stat.ST_CTIME]:
return False
- shutil.copy2(fn, destfn)
+ try:
+ # IOError is the main culprit, with mode=600. But ignore everything.
+ shutil.copy2(fn, destfn)
+ except:
+ return False
return True
def _preload_file_from_system_cache(self, filename, subdir='',
commit 718a69f138939d31dc8e7cf47c5f9fd0850ef920
Author: James Antill <james at and.org>
Date: Tue Jan 22 16:01:49 2013 -0500
Add repo-pkgs update and make repo-pkgs sync more distro-sync like.
diff --git a/docs/yum.8 b/docs/yum.8
index f3487fc..eef282b 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -372,6 +372,9 @@ only shows packages from the givien repository.
"repository\-packages <repo> install" - Install all of the packages in the
repository, basicallly the same as: yum install $(repoquery --repoid=<repo> -a).
+"repository\-packages <repo> upgrade" - Update all of the packages in the
+repository, basicallly the same as: yum upgrade $(repoquery --repoid=<repo> -a).
+
"repo\-pkgs <repo> remove" - Remove all of the packages in the repository, very
similar to: yum remove $(repoquery --repoid=<repo> -a). However the
repopkgsremove_leaf_only option is obeyed.
@@ -383,8 +386,7 @@ reinstalled.
"repo\-pkgs <repo> remove-or-distro-sync" - Works like remove for any package
that doesn't exist in another repository. For any package that does exist
-another version will be reinstalled, upgraded or downgraded to (in that order
-of preference).
+it tries to work as if distro-sync was called (with the repo. disabled).
.IP
.IP "\fBversion\fP"
diff --git a/yum/__init__.py b/yum/__init__.py
index 2ba8b79..3411bd7 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4826,8 +4826,8 @@ much more problems).
except yum.Errors.YumBaseError, e:
self.logger.critical(_('%s') % e)
- depmatches = misc.filter_pkgs_repoid(depmatches,
- kwargs.get('repoid'))
+ depmatches = misc.filter_pkgs_repoid(depmatches,
+ kwargs.get('repoid'))
if update_to:
availpkgs.extend(depmatches)
else:
@@ -4844,6 +4844,7 @@ much more problems).
m = self.pkgSack.returnNewestByNameArch(patterns=pats)
except Errors.PackageSackError:
m = []
+ m = misc.filter_pkgs_repoid(m, kwargs.get('repoid'))
availpkgs.extend(m)
if not availpkgs and not instpkgs:
diff --git a/yumcommands.py b/yumcommands.py
index 6f416d7..25165b7 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -3254,7 +3254,7 @@ class RepoPkgsCommand(YumCommand):
:return: a usage string for this command
"""
- return "<enabled-repoid> <list|info|install|remove|remove-or-reinstall|remove-or-sync> [pkg(s)]"
+ return "<repoid> <list|info|install|remove|upgrade|remove-or-*> [pkg(s)]"
def getSummary(self):
"""Return a one line summary of this command.
@@ -3311,6 +3311,7 @@ class RepoPkgsCommand(YumCommand):
'remove-or-distro-sync' : 'remove-or-sync',
'erase-or-distribution-synchronization' : 'remove-or-sync',
'remove-or-distribution-synchronization' : 'remove-or-sync',
+ 'upgrade' : 'update', # Hack, but meh.
}
cmd = remap.get(cmd, cmd)
@@ -3330,6 +3331,16 @@ class RepoPkgsCommand(YumCommand):
return 2, P_('%d package to install', '%d packages to install',
num)
+ elif cmd == 'update': # update is basically the same as install...
+ for arg in args:
+ txmbrs = base.update(pattern=arg, repoid=repoid)
+ _add_repopkg2txmbrs(txmbrs, repoid)
+ num += len(txmbrs)
+
+ if num:
+ return 2, P_('%d package to update', '%d packages to update',
+ num)
+
elif cmd == 'remove': # Also mostly the same...
for arg in args:
txmbrs = base.remove(pattern=arg, repoid=repoid)
@@ -3355,6 +3366,10 @@ class RepoPkgsCommand(YumCommand):
_add_repopkg2txmbrs(txmbrs, repoid)
num += len(txmbrs)
+ if num:
+ return 2, P_('%d package to remove/reinstall',
+ '%d packages to remove/reinstall', num)
+
elif cmd == 'remove-or-sync': # Even more complicated...
for arg in args:
txmbrs = base.remove(pattern=arg, repoid=repoid)
@@ -3362,20 +3377,26 @@ class RepoPkgsCommand(YumCommand):
# repo.
for txmbr in txmbrs[:]:
pkgs = base.pkgSack.searchNames([txmbr.name])
- toinst = None
+ apkgs = None
for pkg in sorted(pkgs):
- if pkg.repoid == repoid: # Backwrds filter_pkgs_repoid
+ if pkg.repoid == repoid: # Backwards filter_pkgs_repoid
continue
- if toinst is None:
- toinst = pkg
- if toinst.verLT(pkg):
- if toinst.verEQ(txmbr.po):
- break
- toinst = pkg
- if toinst.verEQ(txmbr.po) and toinst.arch == txmbr.arch:
+ if apkgs and pkg.verEQ(apkgs[0]):
+ apkgs.append(pkg)
+ else:
+ apkgs = [pkg]
+
+ if apkgs:
+ for pkg in apkgs:
+ if pkg.arch != txmbr.arch:
+ continue
+ apkgs = [pkg]
break
+ if len(apkgs) != 1:
+ apkgs = base.bestPackagesFromList(apkgs)
- if toinst is not None:
+ for toinst in apkgs:
+ n,a,e,v,r = toinst.pkgtup
if toinst.verEQ(txmbr.po):
txmbrs += base.install(po=toinst)
elif toinst.verGT(txmbr.po):
@@ -3389,8 +3410,8 @@ class RepoPkgsCommand(YumCommand):
num += len(txmbrs)
if num:
- return 2, P_('%d package to remove/reinstall',
- '%d packages to remove/reinstall', num)
+ return 2, P_('%d package to remove/sync',
+ '%d packages to remove/sync', num)
else:
return 1, [_('Not a valid sub-command of %s') % basecmd]
commit 7ed7516c7b5879e2b170118bb878919c62b6eb4d
Author: James Antill <james at and.org>
Date: Tue Jan 22 14:37:39 2013 -0500
Add generic misc.filter_pkgs_repoid, change update() to use repoid.
diff --git a/yum/__init__.py b/yum/__init__.py
index 9dcb1a8..2ba8b79 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2637,27 +2637,6 @@ much more problems).
recent = []
extras = []
- def _filter_ipkgs_repoid(pkgs):
- if not repoid: return pkgs
-
- ret = []
- for pkg in pkgs:
- if 'from_repo' not in pkg.yumdb_info:
- continue
- if pkg.yumdb_info.from_repo != repoid:
- continue
- ret.append(pkg)
- return ret
- def _filter_apkgs_repoid(pkgs):
- if not repoid: return pkgs
-
- ret = []
- for pkg in pkgs:
- if pkg.repoid != repoid:
- continue
- ret.append(pkg)
- return ret
-
ic = ignore_case
# list all packages - those installed and available, don't 'think about it'
if pkgnarrow == 'all':
@@ -2665,7 +2644,7 @@ much more problems).
ndinst = {} # Newest versions by name.arch
for po in self.rpmdb.returnPackages(patterns=patterns,
ignore_case=ic):
- if not _filter_ipkgs_repoid([po]):
+ if not misc.filter_pkgs_repoid([po], repoid):
continue
dinst[po.pkgtup] = po
if showdups:
@@ -2723,7 +2702,7 @@ much more problems).
matches = self.pkgSack.searchNevra(name=n, arch=a, epoch=e,
ver=v, rel=r)
# This is kind of wrong, depending on how you look at it.
- matches = _filter_apkgs_repoid(matches)
+ matches = misc.filter_pkgs_repoid(matches, repoid)
if len(matches) > 1:
updates.append(matches[0])
self.verbose_logger.log(logginglevels.DEBUG_1,
@@ -2743,7 +2722,7 @@ much more problems).
elif pkgnarrow == 'installed':
installed = self.rpmdb.returnPackages(patterns=patterns,
ignore_case=ic)
- installed = _filter_ipkgs_repoid(installed)
+ installed = misc.filter_pkgs_repoid(installed, repoid)
# available in a repository
elif pkgnarrow == 'available':
@@ -2789,7 +2768,7 @@ much more problems).
avail = set(avail)
for po in self.rpmdb.returnPackages(patterns=patterns,
ignore_case=ic):
- if not _filter_ipkgs_repoid([po]):
+ if not misc.filter_pkgs_repoid([po], repoid):
continue
if po.pkgtup not in avail:
extras.append(po)
@@ -2801,7 +2780,7 @@ much more problems).
for (pkgtup, instTup) in self.up.getObsoletesTuples():
(n,a,e,v,r) = pkgtup
pkgs = self.pkgSack.searchNevra(name=n, arch=a, ver=v, rel=r, epoch=e)
- pkgs = _filter_apkgs_repoid(pkgs)
+ pkgs = misc.filter_pkgs_repoid(pkgs, repoid)
instpo = self.getInstalledPackageObject(instTup)
for po in pkgs:
obsoletes.append(po)
@@ -4497,15 +4476,7 @@ much more problems).
ver=nevra_dict['version'], rel=nevra_dict['release'])
self._add_not_found_a(pkgs, nevra_dict)
- if 'repoid' in kwargs:
- def _filter_repoid(pkgs):
- ret = []
- for pkg in pkgs:
- if pkg.repoid != kwargs['repoid']:
- continue
- ret.append(pkg)
- return ret
- pkgs = _filter_repoid(pkgs)
+ pkgs = misc.filter_pkgs_repoid(pkgs, kwargs.get('repoid'))
if pkgs:
# if was_pattern or nevra-dict['arch'] is none, take the list
@@ -4587,7 +4558,7 @@ much more problems).
# make sure this shouldn't be passed to update:
ipkgs = self.rpmdb.searchNames([po.name])
if ipkgs and self._install_is_upgrade(po, ipkgs):
- txmbrs = self.update(po=po)
+ txmbrs = self.update(po=po, repoid=kwargs.get('repoid'))
tx_return.extend(txmbrs)
continue
@@ -4597,6 +4568,7 @@ much more problems).
# Make sure we're not installing a package which is obsoleted by
# something else in the repo. Unless there is a obsoletion loop,
# at which point ignore everything.
+ # NOTE: This is broken wrt. repoid...
obsoleting_pkg = None
if self.conf.obsoletes and not isinstance(po, YumLocalPackage):
obsoleting_pkg = self._test_loop(po, self._pkg2obspkg)
@@ -4642,7 +4614,7 @@ much more problems).
break
if not found:
pkg_warn(_('Package matching %s already installed. Checking for update.'), po)
- txmbrs = self.update(po=po)
+ txmbrs = self.update(po=po, repoid=kwargs.get('repoid'))
tx_return.extend(txmbrs)
continue
@@ -4838,8 +4810,11 @@ much more problems).
arg = kwargs['pattern']
if not update_to:
instpkgs = self.rpmdb.returnPackages(patterns=[arg])
+ instpkgs = misc.filter_pkgs_repoid(instpkgs,
+ kwargs.get('repoid'))
else:
- availpkgs = self.pkgSack.returnPackages(patterns=[arg])
+ availpkgs = self.pkgSack.returnPackages(patterns=[arg],
+ repoid=kwargs.get('repoid'))
if not instpkgs and not availpkgs:
depmatches = []
@@ -4851,6 +4826,8 @@ much more problems).
except yum.Errors.YumBaseError, e:
self.logger.critical(_('%s') % e)
+ depmatches = misc.filter_pkgs_repoid(depmatches,
+ kwargs.get('repoid'))
if update_to:
availpkgs.extend(depmatches)
else:
@@ -4864,7 +4841,6 @@ much more problems).
m = []
else:
pats = [kwargs['pattern']]
- # pats += list(set([pkg.name for pkg in instpkgs]))
m = self.pkgSack.returnNewestByNameArch(patterns=pats)
except Errors.PackageSackError:
m = []
@@ -4925,6 +4901,7 @@ much more problems).
if obsoleting_pkg is None:
continue
obs_pkgs.append(obsoleting_pkg)
+ # NOTE: Broekn wrt. repoid
for obsoleting_pkg in packagesNewestByName(obs_pkgs):
tx_return.extend(self.install(po=obsoleting_pkg))
for available_pkg in availpkgs:
@@ -5077,18 +5054,8 @@ much more problems).
(e,m,u) = self.rpmdb.matchPackageNames([kwargs['pattern']])
if 'repoid' in kwargs:
- def _filter_repoid(pkgs):
- ret = []
- for pkg in pkgs:
- if 'from_repo' not in pkg.yumdb_info:
- continue
- if pkg.yumdb_info.from_repo != kwargs['repoid']:
- continue
- ret.append(pkg)
- return ret
-
- e = _filter_repoid(e)
- m = _filter_repoid(m)
+ e = misc.filter_pkgs_repoid(e, kwargs['repoid'])
+ m = misc.filter_pkgs_repoid(m, kwargs['repoid'])
pkgs.extend(e)
pkgs.extend(m)
@@ -5101,7 +5068,8 @@ much more problems).
self.logger.critical(_('%s') % e)
if 'repoid' in kwargs:
- depmatches = _filter_repoid(depmatches)
+ depmatches = misc.filter_pkgs_repoid(depmatches,
+ kwargs['repoid'])
if not depmatches:
arg = to_unicode(arg)
diff --git a/yum/misc.py b/yum/misc.py
index df5c0d5..0ae980b 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -1197,3 +1197,22 @@ def cElementTree_xmlparse(filename):
""" Lazily load/run: cElementTree.parse """
_cElementTree_import()
return __cached_cElementTree.parse(filename)
+
+def filter_pkgs_repoid(pkgs, repoid):
+ """ Given a list of packages, filter them for those "in" the repoid.
+ uses from_repo for installed packages, used by repo-pkgs commands. """
+
+ if repoid is None:
+ return pkgs
+
+ ret = []
+ for pkg in pkgs:
+ if pkg.repoid == 'installed':
+ if 'from_repo' not in pkg.yumdb_info:
+ continue
+ if pkg.yumdb_info.from_repo != repoid:
+ continue
+ elif pkg.repoid != repoid:
+ continue
+ ret.append(pkg)
+ return ret
diff --git a/yumcommands.py b/yumcommands.py
index 86a2b59..6f416d7 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -3364,7 +3364,7 @@ class RepoPkgsCommand(YumCommand):
pkgs = base.pkgSack.searchNames([txmbr.name])
toinst = None
for pkg in sorted(pkgs):
- if pkg.repoid == repoid:
+ if pkg.repoid == repoid: # Backwrds filter_pkgs_repoid
continue
if toinst is None:
toinst = pkg
commit 51f6e5bb76fed255ebee7f3a233cc595fdaa35d6
Author: James Antill <james at and.org>
Date: Tue Jan 22 12:51:18 2013 -0500
Add repo-pkgs list/info sub-commands.
diff --git a/cli.py b/cli.py
index 01024cd..4e57620 100755
--- a/cli.py
+++ b/cli.py
@@ -1259,7 +1259,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
return 2, [_('Package(s) to install')]
return 0, [_('Nothing to do')]
- def returnPkgLists(self, extcmds, installed_available=False):
+ def returnPkgLists(self, extcmds, installed_available=False, repoid=None):
"""Return a :class:`yum.misc.GenericHolder` object containing
lists of package objects that match the given names or wildcards.
@@ -1268,6 +1268,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
:param installed_available: whether the available package list
is present as .hidden_available when doing all, available,
or installed
+ :param repoid: a repoid that all packages should belong to
:return: a :class:`yum.misc.GenericHolder` instance with the
following lists defined::
@@ -1296,7 +1297,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
pkgnarrow = extcmds.pop(0)
ypl = self.doPackageLists(pkgnarrow=pkgnarrow, patterns=extcmds,
- ignore_case=True)
+ ignore_case=True, repoid=repoid)
if self.conf.showdupesfromrepos:
ypl.available += ypl.reinstall_available
diff --git a/docs/yum.8 b/docs/yum.8
index b8c0e79..f3487fc 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -363,7 +363,14 @@ This command works exactly like repolist -v.
Treat a repo. as a collection of packages (like "yum groups") allowing the user
to install or remove them as a single entity.
-"repository\-packages <repo> install" - Install all of the packages in the repository, basicallly the same as: yum install $(repoquery --repoid=<repo> -a).
+"repository\-packages <repo> list" - Works like the "yum list" command, but
+only shows packages from the givien repository.
+
+"repository\-packages <repo> info" - Works like the "yum info" command, but
+only shows packages from the givien repository.
+
+"repository\-packages <repo> install" - Install all of the packages in the
+repository, basicallly the same as: yum install $(repoquery --repoid=<repo> -a).
"repo\-pkgs <repo> remove" - Remove all of the packages in the repository, very
similar to: yum remove $(repoquery --repoid=<repo> -a). However the
diff --git a/yum/__init__.py b/yum/__init__.py
index 8a0501d..9dcb1a8 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2598,7 +2598,7 @@ much more problems).
return 0, [msg]
def doPackageLists(self, pkgnarrow='all', patterns=None, showdups=None,
- ignore_case=False):
+ ignore_case=False, repoid=None):
"""Return a :class:`yum.misc.GenericHolder` containing
lists of package objects. The contents of the lists are
specified in various ways by the arguments.
@@ -2612,6 +2612,7 @@ much more problems).
lists
:param ignore_case: whether to ignore case when searching by
package names
+ :param repoid: repoid that all pkgs will belong to
:return: a :class:`yum.misc.GenericHolder` instance with the
following lists defined::
@@ -2636,6 +2637,27 @@ much more problems).
recent = []
extras = []
+ def _filter_ipkgs_repoid(pkgs):
+ if not repoid: return pkgs
+
+ ret = []
+ for pkg in pkgs:
+ if 'from_repo' not in pkg.yumdb_info:
+ continue
+ if pkg.yumdb_info.from_repo != repoid:
+ continue
+ ret.append(pkg)
+ return ret
+ def _filter_apkgs_repoid(pkgs):
+ if not repoid: return pkgs
+
+ ret = []
+ for pkg in pkgs:
+ if pkg.repoid != repoid:
+ continue
+ ret.append(pkg)
+ return ret
+
ic = ignore_case
# list all packages - those installed and available, don't 'think about it'
if pkgnarrow == 'all':
@@ -2643,6 +2665,8 @@ much more problems).
ndinst = {} # Newest versions by name.arch
for po in self.rpmdb.returnPackages(patterns=patterns,
ignore_case=ic):
+ if not _filter_ipkgs_repoid([po]):
+ continue
dinst[po.pkgtup] = po
if showdups:
continue
@@ -2652,8 +2676,13 @@ much more problems).
installed = dinst.values()
if showdups:
- avail = self.pkgSack.returnPackages(patterns=patterns,
+ avail = self.pkgSack.returnPackages(repoid=repoid,
+ patterns=patterns,
ignore_case=ic)
+ elif repoid:
+ avail = self.pkgSack.sacks[repoid]
+ avail = avail.returnNewestByNameArch(patterns=patterns,
+ ignore_case=ic)
else:
try:
avail = self.pkgSack.returnNewestByNameArch(patterns=patterns,
@@ -2693,6 +2722,8 @@ much more problems).
for (n,a,e,v,r) in self.up.getUpdatesList():
matches = self.pkgSack.searchNevra(name=n, arch=a, epoch=e,
ver=v, rel=r)
+ # This is kind of wrong, depending on how you look at it.
+ matches = _filter_apkgs_repoid(matches)
if len(matches) > 1:
updates.append(matches[0])
self.verbose_logger.log(logginglevels.DEBUG_1,
@@ -2712,13 +2743,19 @@ much more problems).
elif pkgnarrow == 'installed':
installed = self.rpmdb.returnPackages(patterns=patterns,
ignore_case=ic)
+ installed = _filter_ipkgs_repoid(installed)
# available in a repository
elif pkgnarrow == 'available':
if showdups:
avail = self.pkgSack.returnPackages(patterns=patterns,
- ignore_case=ic)
+ ignore_case=ic,
+ repoid=repoid)
+ elif repoid:
+ avail = self.pkgSack.sacks[repoid]
+ avail = avail.returnNewestByNameArch(patterns=patterns,
+ ignore_case=ic)
else:
try:
avail = self.pkgSack.returnNewestByNameArch(patterns=patterns,
@@ -2752,6 +2789,8 @@ much more problems).
avail = set(avail)
for po in self.rpmdb.returnPackages(patterns=patterns,
ignore_case=ic):
+ if not _filter_ipkgs_repoid([po]):
+ continue
if po.pkgtup not in avail:
extras.append(po)
@@ -2762,6 +2801,7 @@ much more problems).
for (pkgtup, instTup) in self.up.getObsoletesTuples():
(n,a,e,v,r) = pkgtup
pkgs = self.pkgSack.searchNevra(name=n, arch=a, ver=v, rel=r, epoch=e)
+ pkgs = _filter_apkgs_repoid(pkgs)
instpo = self.getInstalledPackageObject(instTup)
for po in pkgs:
obsoletes.append(po)
@@ -2793,7 +2833,12 @@ much more problems).
recentlimit = now-(self.conf.recent*86400)
if showdups:
avail = self.pkgSack.returnPackages(patterns=patterns,
- ignore_case=ic)
+ ignore_case=ic,
+ repoid=repoid)
+ elif repoid:
+ avail = self.pkgSack.sacks[repoid]
+ avail = avail.returnNewestByNameArch(patterns=patterns,
+ ignore_case=ic)
else:
try:
avail = self.pkgSack.returnNewestByNameArch(patterns=patterns,
diff --git a/yumcommands.py b/yumcommands.py
index b32418c..86a2b59 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -602,7 +602,7 @@ class InfoCommand(YumCommand):
"""
return _("Display details about a package or group of packages")
- def doCommand(self, base, basecmd, extcmds):
+ def doCommand(self, base, basecmd, extcmds, repoid=None):
"""Execute this command.
:param base: a :class:`yum.Yumbase` object
@@ -623,7 +623,8 @@ class InfoCommand(YumCommand):
# than providing colour for a single line. Usable updatesd/etc. FTW.
if basecmd == 'info' and extcmds and extcmds[0] == 'installed':
highlight = False
- ypl = base.returnPkgLists(extcmds, installed_available=highlight)
+ ypl = base.returnPkgLists(extcmds, installed_available=highlight,
+ repoid=repoid)
except yum.Errors.YumBaseError, e:
return 1, [exception2msg(e)]
else:
@@ -700,7 +701,7 @@ class InfoCommand(YumCommand):
for obtup in sorted(ypl.obsoletesTuples,
key=operator.itemgetter(0)):
base.updatesObsoletesList(obtup, 'obsoletes',
- columns=columns)
+ columns=columns, repoid=repoid)
else:
rop = base.listPkgs(ypl.obsoletes, _('Obsoleting Packages'),
basecmd, columns=columns)
@@ -3253,7 +3254,7 @@ class RepoPkgsCommand(YumCommand):
:return: a usage string for this command
"""
- return "<enabled-repoid> <install|remove|remove-or-reinstall|remove-or-sync> [pkg(s)]"
+ return "<enabled-repoid> <list|info|install|remove|remove-or-reinstall|remove-or-sync> [pkg(s)]"
def getSummary(self):
"""Return a one line summary of this command.
@@ -3314,6 +3315,11 @@ class RepoPkgsCommand(YumCommand):
cmd = remap.get(cmd, cmd)
if False: pass
+ elif cmd == 'list': # list/info is easiest...
+ return ListCommand().doCommand(base, cmd, args, repoid=repoid)
+ elif cmd == 'info':
+ return InfoCommand().doCommand(base, cmd, args, repoid=repoid)
+
elif cmd == 'install': # install is simpler version of installPkgs...
for arg in args:
txmbrs = base.install(pattern=arg, repoid=repoid)
@@ -3390,3 +3396,35 @@ class RepoPkgsCommand(YumCommand):
return 1, [_('Not a valid sub-command of %s') % basecmd]
return 0, [_('Nothing to do')]
+
+ def needTs(self, base, basecmd, extcmds):
+ """Return whether a transaction set must be set up before this
+ command can run.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: True if a transaction set is needed, False otherwise
+ """
+ cmd = 'install'
+ if len(extcmds) > 1:
+ cmd = extcmds[1]
+ if cmd in ('info', 'list'):
+ return InfoCommand().cacheRequirement(base, cmd, extcmds[2:])
+
+ return True
+
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ cmd = 'install'
+ if len(extcmds) > 1:
+ cmd = extcmds[1]
+ if cmd in ('info', 'list'):
+ return InfoCommand().cacheRequirement(base, cmd, extcmds[2:])
+ return 'write'
commit c0de8a3e4743eff9712d74d5241bcfad63161bda
Author: James Antill <james at and.org>
Date: Tue Jan 22 09:44:50 2013 -0500
Use cacheReq read-only:past for installed/extras/recent in list/info cmds.
diff --git a/yumcommands.py b/yumcommands.py
index f4b9e88..b32418c 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -738,6 +738,9 @@ class InfoCommand(YumCommand):
"""
if len(extcmds) and extcmds[0] in ('updates', 'obsoletes'):
return 'read-only:future'
+ if len(extcmds) and extcmds[0] in ('installed', 'extras', 'recent'):
+ return 'read-only:past'
+ # available/all
return 'read-only:present'
commit f9ae668c543bd8fb338d0e4e5f2efae97938157e
Author: James Antill <james at and.org>
Date: Mon Jan 21 16:00:39 2013 -0500
Don't return a decompressed filename that doesn't exist. BZ 895854.
diff --git a/yum/misc.py b/yum/misc.py
index 6c3c349..df5c0d5 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -1146,7 +1146,11 @@ def repo_gen_decompress(filename, generated_name, cached=False):
generated name, and use check_timestamps. filename _must_ be from
a repo. and generated_name is the type of the file. """
dest = os.path.dirname(filename) + '/gen/' + generated_name
- return decompress(filename, dest=dest, check_timestamps=True,fn_only=cached)
+ ret = decompress(filename, dest=dest, check_timestamps=True,fn_only=cached)
+
+ if cached and ret and not os.path.exists(ret):
+ return None
+ return ret
def read_in_items_from_dot_dir(thisglob, line_as_list=True):
"""takes a glob of a dir (like /etc/foo.d/*.foo)
commit cb97a36f908f0933062ec3acd2df1b1066051940
Author: James Antill <james at and.org>
Date: Mon Jan 21 10:16:00 2013 -0500
Add documentation for repo-pkgs command.
diff --git a/docs/yum.8 b/docs/yum.8
index 505289d..b8c0e79 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -70,6 +70,8 @@ gnome\-packagekit application\&.
.br
.I \fR * repoinfo [all|enabled|disabled]
.br
+.I \fR * repository-packages <enabled-repoid> <install|remove|remove-or-reinstall|remove-or-distribution-synchronization> [package2] [\&.\&.\&.]
+.br
.I \fR * version [ all | installed | available | group-* | nogroups* | grouplist | groupinfo ]
.br
.I \fR * history [info|list|packages-list|packages-info|summary|addon-info|redo|undo|rollback|new|sync|stats]
@@ -357,6 +359,27 @@ package counts/etc. will be zeroed out).
.IP
This command works exactly like repolist -v.
.IP
+.IP "\fBrepository\-packages\fP"
+Treat a repo. as a collection of packages (like "yum groups") allowing the user
+to install or remove them as a single entity.
+
+"repository\-packages <repo> install" - Install all of the packages in the repository, basicallly the same as: yum install $(repoquery --repoid=<repo> -a).
+
+"repo\-pkgs <repo> remove" - Remove all of the packages in the repository, very
+similar to: yum remove $(repoquery --repoid=<repo> -a). However the
+repopkgsremove_leaf_only option is obeyed.
+
+"repo\-pkgs <repo> remove-or-reinstall" - Works like remove for any package
+that doesn't have the exact same version in another repository. For any package
+that does have the exact NEVRA in another repoitory then that version will be
+reinstalled.
+
+"repo\-pkgs <repo> remove-or-distro-sync" - Works like remove for any package
+that doesn't exist in another repository. For any package that does exist
+another version will be reinstalled, upgraded or downgraded to (in that order
+of preference).
+
+.IP
.IP "\fBversion\fP"
Produces a "version" of the rpmdb, and of the enabled repositories if "all" is
given as the first argument. You can also specify version groups in the
diff --git a/yumcommands.py b/yumcommands.py
index 591b541..f4b9e88 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -3250,7 +3250,7 @@ class RepoPkgsCommand(YumCommand):
:return: a usage string for this command
"""
- return "<enabled-repoid> <install|remove|remove-or-reinstall> [pkg(s)]"
+ return "<enabled-repoid> <install|remove|remove-or-reinstall|remove-or-sync> [pkg(s)]"
def getSummary(self):
"""Return a one line summary of this command.
@@ -3299,6 +3299,17 @@ class RepoPkgsCommand(YumCommand):
if not args:
args = ['*']
num = 0
+
+ remap = {'erase' : 'remove',
+ 'erase-or-reinstall' : 'remove-or-reinstall',
+ 'erase-or-sync' : 'remove-or-sync',
+ 'erase-or-distro-sync' : 'remove-or-sync',
+ 'remove-or-distro-sync' : 'remove-or-sync',
+ 'erase-or-distribution-synchronization' : 'remove-or-sync',
+ 'remove-or-distribution-synchronization' : 'remove-or-sync',
+ }
+ cmd = remap.get(cmd, cmd)
+
if False: pass
elif cmd == 'install': # install is simpler version of installPkgs...
for arg in args:
commit 56fa2d791e5837b5070c1648d4bf2e28198388d8
Author: James Antill <james at and.org>
Date: Wed Jan 16 16:36:27 2013 -0500
Fixup the install of yum-cron.service to use _unitdir rpm macro.
diff --git a/yum-cron/Makefile b/yum-cron/Makefile
index 0b68d37..27fcdfd 100644
--- a/yum-cron/Makefile
+++ b/yum-cron/Makefile
@@ -1,3 +1,5 @@
+UNITDIR=/lib/systemd/system
+
all:
echo "Nothing to do"
@@ -11,5 +13,5 @@ install:
# Install yum-update.cron as 0yum-update.cron so it runs before items like
# manpage update, mlocate, and prelink
install -D -m 755 yum-update.cron.sh $(DESTDIR)/etc/cron.daily/0yum-update.cron
- install -D -m 644 yum-cron.service $(DESTDIR)/usr/lib/systemd/system/yum-cron.service
+ install -D -m 644 yum-cron.service $(DESTDIR)/$(UNITDIR)/yum-cron.service
install -D -m 755 yum-cron.py $(DESTDIR)/usr/sbin/yum-cron
diff --git a/yum.spec b/yum.spec
index c3e065b..02cbbd6 100644
--- a/yum.spec
+++ b/yum.spec
@@ -139,7 +139,7 @@ make check
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
+make DESTDIR=$RPM_BUILD_ROOT UNITDIR=%{_unitdir} install
install -m 644 %{SOURCE1} $RPM_BUILD_ROOT/%{_sysconfdir}/yum.conf
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/yum/pluginconf.d $RPM_BUILD_ROOT/%{yum_pluginslib}
mkdir -p $RPM_BUILD_ROOT/%{yum_pluginsshare}
commit e32d49e1b83279257f20b06f8cd6c5d09dcfca3d
Author: James Antill <james at and.org>
Date: Wed Jan 16 11:37:04 2013 -0500
Fix repoid filtering in .install().
diff --git a/yum/__init__.py b/yum/__init__.py
index 3631faf..8a0501d 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4420,7 +4420,7 @@ much more problems).
if kwargs['pattern'] and kwargs['pattern'][0] == '@':
return self._at_groupinstall(kwargs['pattern'])
- repo = None # All of them
+ repoid = None # All of them
if 'repoid' in kwargs:
repoid = kwargs['repoid']
@@ -4447,15 +4447,21 @@ much more problems).
else:
nevra_dict = self._nevra_kwarg_parse(kwargs)
- repo = None # All of them
- if 'repoid' in kwargs:
- repoid = kwargs['repoid']
-
pkgs = self.pkgSack.searchNevra(name=nevra_dict['name'],
epoch=nevra_dict['epoch'], arch=nevra_dict['arch'],
ver=nevra_dict['version'], rel=nevra_dict['release'])
self._add_not_found_a(pkgs, nevra_dict)
+ if 'repoid' in kwargs:
+ def _filter_repoid(pkgs):
+ ret = []
+ for pkg in pkgs:
+ if pkg.repoid != kwargs['repoid']:
+ continue
+ ret.append(pkg)
+ return ret
+ pkgs = _filter_repoid(pkgs)
+
if pkgs:
# if was_pattern or nevra-dict['arch'] is none, take the list
# of arches based on our multilib_compat config and
commit 2d85fcd88061e81d38e84a598ed2ad14bb93a7d1
Author: James Antill <james at and.org>
Date: Tue Jan 15 14:58:39 2013 -0500
Add repopkg txmbr attribute to save-ts/load-ts.
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index 8545bac..96c75b5 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -870,5 +870,7 @@ class TransactionMember:
msg += " groups: %s\n" % ' '.join(self.groups)
if self.environments:
msg += " environments: %s\n" % ' '.join(self.environments)
+ if self.repopkg:
+ msg += " repopkg: %s\n" % self.repopkg
return msg
commit 489a1a0fc7ee95fa6ccddae6ecc4faf13eda5b49
Author: James Antill <james at and.org>
Date: Fri Jan 11 15:05:04 2013 -0500
Add remove_leaf_only and repopkg* options, use removeReq cb and fix the API.
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 30ac844..17f9bae 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -201,12 +201,32 @@ Default is `true'.
Command-line option: \fB\-\-obsoletes\fP
.IP
+\fBremove_leaf_only \fR
+Either `0' or `1'. Used to determine yum's behaviour when a package is removed.
+If \fBremove_leaf_only\fR is `0' (default) then
+packages, and their deps, will be removed. If \fBremove_leaf_only\fR is
+`1' then only those packages that aren't required by another
+package will be removed.
+
+.IP
+\fBrepopkgsremove_leaf_only \fR
+Either `0' or `1'. Used to determine yum's behaviour when the repo-pkg remove
+command is run. If \fBrepopkgremove_leaf_only\fR is `0' (default) then
+all packages in the repo. will be removed. If \fBrepopkgremove_leaf_only\fR is
+`1' then only those packages in the repo. that aren't required by another
+package will be removed.
+Note that this option does not override remove_leaf_only, so enabling that
+option means this has almost no affect.
+
+.IP
\fBoverwrite_groups \fR
Either `0' or `1'. Used to determine yum's behaviour if two or more
repositories offer the package groups with the same name. If
\fBoverwrite_groups\fR is `1' then the group packages of the last matching
repository will be used. If \fBoverwrite_groups\fR is `0' then the groups
from all matching repositories will be merged together as one large group.
+Note that this option does not override remove_leaf_only, so enabling that
+option means this has almost no affect.
.IP
\fBgroupremove_leaf_only \fR
diff --git a/output.py b/output.py
index 885eb09..26e3928 100755
--- a/output.py
+++ b/output.py
@@ -2827,17 +2827,18 @@ class DepSolveProgressCallBack:
_('--> Processing Dependency: %s for package: %s'), formatted_req,
po)
- def groupRemoveReq(self, po, hits):
+ def removeReq(self, po, deppo, hits):
"""Output a message stating that the given package will not be
- removed. This method is used during leaf-only group remove
- commands to indicate that the package will be kept.
+ removed. This method is used during leaf-only group remove, leaf-only
+ repo-pkg remove and normal remove commands to indicate that the
+ package will be kept.
:param po: the :class:`yum.packages.PackageObject` that will
not be removed
:param hits: unused
"""
self.verbose_logger.log(logginglevels.INFO_2,
- _('---> Keeping package: %s'), po)
+ _('---> Keeping package: %s due to %s'), po, deppo)
def unresolved(self, msg):
"""Output a message stating that there is an unresolved
diff --git a/yum/config.py b/yum/config.py
index 3cdb0fd..5856aa2 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -774,6 +774,8 @@ class YumConf(StartupConf):
obsoletes = BoolOption(True)
showdupesfromrepos = BoolOption(False)
enabled = BoolOption(True)
+ remove_leaf_only = BoolOption(False)
+ repopkgsremove_leaf_only = BoolOption(False)
enablegroups = BoolOption(True)
enable_group_conditionals = BoolOption(True)
groupremove_leaf_only = BoolOption(False)
diff --git a/yum/depsolve.py b/yum/depsolve.py
index a16f1f5..74f9a48 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -1121,12 +1121,36 @@ class Depsolve(object):
# FIXME: This is probably the best place to fix the postfix rename
# problem long term (post .21) ... see compare_providers.
for pkg, hits in self.tsInfo.getRequires(*prov).iteritems():
- # See the docs, this is to make groupremove "more useful".
+ # See the docs, this is to make remove* "more useful".
+ if (self.conf.repopkgsremove_leaf_only and txmbr.repopkg and
+ txmbr.output_state == TS_ERASE):
+ cb = self.dsCallback
+ if cb and hasattr(cb, 'repoPkgRemoveReq'):
+ cb.repoPkgRemoveReq(txmbr.po, hits)
+ elif cb and hasattr(cb, 'removeReq'):
+ cb.removeReq(txmbr.po, pkg, hits)
+ # We don't undo anything else here ... hopefully that's
+ # fine.
+ self.tsInfo.remove(txmbr.pkgtup)
+ return []
+
if (self.conf.groupremove_leaf_only and txmbr.groups and
txmbr.output_state == TS_ERASE):
cb = self.dsCallback
if cb and hasattr(cb, 'groupRemoveReq'):
cb.groupRemoveReq(pkg, hits)
+ elif cb and hasattr(cb, 'removeReq'):
+ cb.removeReq(txmbr.po, pkg, hits)
+ # We don't undo anything else here ... hopefully that's
+ # fine.
+ self.tsInfo.remove(txmbr.pkgtup)
+ return []
+
+ if (self.conf.remove_leaf_only and
+ txmbr.output_state == TS_ERASE):
+ cb = self.dsCallback
+ if cb and hasattr(cb, 'removeReq'):
+ cb.removeReq(txmbr.po, pkg, hits)
# We don't undo anything else here ... hopefully that's
# fine.
self.tsInfo.remove(txmbr.pkgtup)
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index 2fdd8f0..8545bac 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -794,6 +794,7 @@ class TransactionMember:
self.reinstall = False
self.groups = [] # groups it's in
self.environments = [] # Env. groups it's in
+ self.repopkg = None # repo pkg "group" it was removed/installed by
self._poattr = ['pkgtup', 'repoid', 'name', 'arch', 'epoch', 'version',
'release']
diff --git a/yumcommands.py b/yumcommands.py
index 8ad588f..591b541 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -3289,6 +3289,10 @@ class RepoPkgsCommand(YumCommand):
2 = we've got work yet to do, onto the next stage
"""
+ def _add_repopkg2txmbrs(txmbrs, repoid):
+ for txmbr in txmbrs:
+ txmbr.repopkg = repoid
+
repoid = extcmds[0]
cmd = extcmds[1]
args = extcmds[2:]
@@ -3299,6 +3303,7 @@ class RepoPkgsCommand(YumCommand):
elif cmd == 'install': # install is simpler version of installPkgs...
for arg in args:
txmbrs = base.install(pattern=arg, repoid=repoid)
+ _add_repopkg2txmbrs(txmbrs, repoid)
num += len(txmbrs)
if num:
@@ -3308,6 +3313,7 @@ class RepoPkgsCommand(YumCommand):
elif cmd == 'remove': # Also mostly the same...
for arg in args:
txmbrs = base.remove(pattern=arg, repoid=repoid)
+ _add_repopkg2txmbrs(txmbrs, repoid)
num += len(txmbrs)
if num:
@@ -3326,6 +3332,7 @@ class RepoPkgsCommand(YumCommand):
txmbrs += base.install(po=pkg)
break
+ _add_repopkg2txmbrs(txmbrs, repoid)
num += len(txmbrs)
elif cmd == 'remove-or-sync': # Even more complicated...
@@ -3358,6 +3365,7 @@ class RepoPkgsCommand(YumCommand):
txmbrs.remove(txmbr)
txmbrs += base.downgrade(po=toinst)
+ _add_repopkg2txmbrs(txmbrs, repoid)
num += len(txmbrs)
if num:
commit 309436a1463a67aae0d24ecdf3c494ca98cef91d
Author: James Antill <james at and.org>
Date: Thu Jan 10 17:23:36 2013 -0500
Add a repo-pkgs command, to treat a repo. as a set of packages.
diff --git a/cli.py b/cli.py
index b74606c..01024cd 100755
--- a/cli.py
+++ b/cli.py
@@ -108,6 +108,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.registerCommand(yumcommands.DistroSyncCommand())
self.registerCommand(yumcommands.LoadTransactionCommand())
self.registerCommand(yumcommands.SwapCommand())
+ self.registerCommand(yumcommands.RepoPkgsCommand())
def registerCommand(self, command):
"""Register a :class:`yumcommands.YumCommand` so that it can be called by
@@ -825,7 +826,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
return ret
- def installPkgs(self, userlist, basecmd='install'):
+ def installPkgs(self, userlist, basecmd='install', repoid=None):
"""Attempt to take the user specified list of packages or
wildcards and install them, or if they are installed, update
them to a newer version. If a complete version number is
diff --git a/yum/__init__.py b/yum/__init__.py
index 10a5477..3631faf 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4420,9 +4420,14 @@ much more problems).
if kwargs['pattern'] and kwargs['pattern'][0] == '@':
return self._at_groupinstall(kwargs['pattern'])
+ repo = None # All of them
+ if 'repoid' in kwargs:
+ repoid = kwargs['repoid']
+
was_pattern = True
pats = [kwargs['pattern']]
mypkgs = self.pkgSack.returnPackages(patterns=pats,
+ repoid=repoid,
ignore_case=False)
pkgs.extend(mypkgs)
# if we have anything left unmatched, let's take a look for it
@@ -4442,6 +4447,10 @@ much more problems).
else:
nevra_dict = self._nevra_kwarg_parse(kwargs)
+ repo = None # All of them
+ if 'repoid' in kwargs:
+ repoid = kwargs['repoid']
+
pkgs = self.pkgSack.searchNevra(name=nevra_dict['name'],
epoch=nevra_dict['epoch'], arch=nevra_dict['arch'],
ver=nevra_dict['version'], rel=nevra_dict['release'])
@@ -5016,6 +5025,20 @@ much more problems).
return self._at_groupremove(kwargs['pattern'])
(e,m,u) = self.rpmdb.matchPackageNames([kwargs['pattern']])
+ if 'repoid' in kwargs:
+ def _filter_repoid(pkgs):
+ ret = []
+ for pkg in pkgs:
+ if 'from_repo' not in pkg.yumdb_info:
+ continue
+ if pkg.yumdb_info.from_repo != kwargs['repoid']:
+ continue
+ ret.append(pkg)
+ return ret
+
+ e = _filter_repoid(e)
+ m = _filter_repoid(m)
+
pkgs.extend(e)
pkgs.extend(m)
if u:
@@ -5026,6 +5049,9 @@ much more problems).
except yum.Errors.YumBaseError, e:
self.logger.critical(_('%s') % e)
+ if 'repoid' in kwargs:
+ depmatches = _filter_repoid(depmatches)
+
if not depmatches:
arg = to_unicode(arg)
self.logger.critical(_('No Match for argument: %s') % to_unicode(arg))
diff --git a/yumcommands.py b/yumcommands.py
index 3e02dd6..8ad588f 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -22,7 +22,7 @@ Classes for subcommands of the yum command line interface.
import os
import cli
from yum import logginglevels
-from yum import _
+from yum import _, P_
from yum import misc
import yum.Errors
import operator
@@ -115,6 +115,39 @@ def checkSwapPackageArg(base, basecmd, extcmds):
_err_mini_usage(base, basecmd)
raise cli.CliError
+def checkRepoPackageArg(base, basecmd, extcmds):
+ """Verify that *extcmds* contains the name of at least one package for
+ *basecmd* to act on.
+
+ :param base: a :class:`yum.Yumbase` object.
+ :param basecmd: the name of the command being checked for
+ :param extcmds: a list of arguments passed to *basecmd*
+ :raises: :class:`cli.CliError`
+ """
+ if len(extcmds) < 2: # <repoid> install|remove [pkgs]
+ base.logger.critical(
+ _('Error: Need to pass a repoid. and command to %s') % basecmd)
+ _err_mini_usage(base, basecmd)
+ raise cli.CliError
+
+ repos = base.repos.findRepos(extcmds[0])
+ if not repos:
+ base.logger.critical(
+ _('Error: Need to pass a single valid repoid. to %s') % basecmd)
+ _err_mini_usage(base, basecmd)
+ raise cli.CliError
+
+ if len(repos) != 1 or repos[0].id != extcmds[0]:
+ base.logger.critical(
+ _('Error: Need to pass a single valid repoid. to %s') % basecmd)
+ _err_mini_usage(base, basecmd)
+ raise cli.CliError
+ if not repos[0].isEnabled():
+ base.logger.critical(
+ _('Error: Repo %s is not enabled') % extcmds[0])
+ _err_mini_usage(base, basecmd)
+ raise cli.CliError
+
def checkItemArg(base, basecmd, extcmds):
"""Verify that *extcmds* contains the name of at least one item for
@@ -3196,3 +3229,142 @@ class SwapCommand(YumCommand):
base.cmdstring = oline
return 2, ['%s %s' % (basecmd, " ".join(extcmds))]
+
+
+class RepoPkgsCommand(YumCommand):
+ """A class containing methods needed by the cli to execute the
+ repo command.
+ """
+
+ def getNames(self):
+ """Return a list containing the names of this command. This
+ command can be called from the command line by using any of these names.
+
+ :return: a list containing the names of this command
+ """
+ return ['repo-pkgs',
+ 'repo-packages', 'repository-pkgs', 'repository-packages']
+
+ def getUsage(self):
+ """Return a usage string for this command.
+
+ :return: a usage string for this command
+ """
+ return "<enabled-repoid> <install|remove|remove-or-reinstall> [pkg(s)]"
+
+ def getSummary(self):
+ """Return a one line summary of this command.
+
+ :return: a one line summary of this command
+ """
+ return _("Treat a repo. as a group of packages, so we can install/remove all of them")
+
+ def doCheck(self, base, basecmd, extcmds):
+ """Verify that conditions are met so that this command can run.
+ These include that the program is being run by the root user,
+ that there are enabled repositories with gpg keys, and that
+ this command is called with appropriate arguments.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: the command line arguments passed to *basecmd*
+ """
+ checkRootUID(base)
+ checkGPGKey(base)
+ checkRepoPackageArg(base, basecmd, extcmds)
+ checkEnabledRepo(base, extcmds)
+
+ def doCommand(self, base, basecmd, extcmds):
+ """Execute this command.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: the command line arguments passed to *basecmd*
+ :return: (exit_code, [ errors ])
+
+ exit_code is::
+
+ 0 = we're done, exit
+ 1 = we've errored, exit with error string
+ 2 = we've got work yet to do, onto the next stage
+ """
+
+ repoid = extcmds[0]
+ cmd = extcmds[1]
+ args = extcmds[2:]
+ if not args:
+ args = ['*']
+ num = 0
+ if False: pass
+ elif cmd == 'install': # install is simpler version of installPkgs...
+ for arg in args:
+ txmbrs = base.install(pattern=arg, repoid=repoid)
+ num += len(txmbrs)
+
+ if num:
+ return 2, P_('%d package to install', '%d packages to install',
+ num)
+
+ elif cmd == 'remove': # Also mostly the same...
+ for arg in args:
+ txmbrs = base.remove(pattern=arg, repoid=repoid)
+ num += len(txmbrs)
+
+ if num:
+ return 2, P_('%d package to remove', '%d packages to remove',
+ num)
+
+ elif cmd == 'remove-or-reinstall': # More complicated...
+ for arg in args:
+ txmbrs = base.remove(pattern=arg, repoid=repoid)
+ # Add an install() if it's in another repo.
+ for txmbr in txmbrs[:]:
+ pkgs = base.pkgSack.searchPkgTuple(txmbr.pkgtup)
+ for pkg in sorted(pkgs):
+ if pkg.repoid == repoid:
+ continue
+ txmbrs += base.install(po=pkg)
+ break
+
+ num += len(txmbrs)
+
+ elif cmd == 'remove-or-sync': # Even more complicated...
+ for arg in args:
+ txmbrs = base.remove(pattern=arg, repoid=repoid)
+ # Add an install/upgrade/downgrade if a version is in another
+ # repo.
+ for txmbr in txmbrs[:]:
+ pkgs = base.pkgSack.searchNames([txmbr.name])
+ toinst = None
+ for pkg in sorted(pkgs):
+ if pkg.repoid == repoid:
+ continue
+ if toinst is None:
+ toinst = pkg
+ if toinst.verLT(pkg):
+ if toinst.verEQ(txmbr.po):
+ break
+ toinst = pkg
+ if toinst.verEQ(txmbr.po) and toinst.arch == txmbr.arch:
+ break
+
+ if toinst is not None:
+ if toinst.verEQ(txmbr.po):
+ txmbrs += base.install(po=toinst)
+ elif toinst.verGT(txmbr.po):
+ txmbrs += base.update(po=toinst)
+ else:
+ base.tsInfo.remove(txmbr.pkgtup)
+ txmbrs.remove(txmbr)
+ txmbrs += base.downgrade(po=toinst)
+
+ num += len(txmbrs)
+
+ if num:
+ return 2, P_('%d package to remove/reinstall',
+ '%d packages to remove/reinstall', num)
+
+ else:
+ return 1, [_('Not a valid sub-command of %s') % basecmd]
+
+ return 0, [_('Nothing to do')]
commit ee0f002237a2df37ad59376fdd1e8d150837bb0e
Author: James Antill <james at and.org>
Date: Thu Jan 10 15:38:54 2013 -0500
Add a swap command, for simple shell cases.
diff --git a/cli.py b/cli.py
index 01b21e6..b74606c 100755
--- a/cli.py
+++ b/cli.py
@@ -107,6 +107,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.registerCommand(yumcommands.CheckRpmdbCommand())
self.registerCommand(yumcommands.DistroSyncCommand())
self.registerCommand(yumcommands.LoadTransactionCommand())
+ self.registerCommand(yumcommands.SwapCommand())
def registerCommand(self, command):
"""Register a :class:`yumcommands.YumCommand` so that it can be called by
diff --git a/docs/yum.8 b/docs/yum.8
index 604bc26..505289d 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -310,6 +310,22 @@ should work (thus, all the simple cases will work). Also this does not
work for "installonly" packages, like Kernels. downgrade operates
on groups, files, provides, filelists and rpm files just like the "install" command\&.
.IP
+.IP "\fBswap\fP"
+At it's simplest this is just a simpler way to remove one set of package(s) and
+install another set of package(s) without having to use the "shell" command.
+However you can specify different commands to call than just remove or install,
+and you can list multiple packages (it splits using the "--" marker).
+Note that option parsing will remove the first "--" in an argument list on the
+command line.
+
+
+Examples:
+
+swap foo bar
+swap -- remove foo -- install bar
+swap foo group install bar-grp
+swap -- group remove foo-grp -- group install bar-grp
+.IP
.IP "\fBdeplist\fP"
Produces a list of all dependencies and what packages provide those
dependencies for the given packages. As of 3.2.30 it now just shows the latest
diff --git a/yumcommands.py b/yumcommands.py
index 14a1375..3e02dd6 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -97,6 +97,25 @@ def checkPackageArg(base, basecmd, extcmds):
_err_mini_usage(base, basecmd)
raise cli.CliError
+def checkSwapPackageArg(base, basecmd, extcmds):
+ """Verify that *extcmds* contains the name of at least two packages for
+ *basecmd* to act on.
+
+ :param base: a :class:`yum.Yumbase` object.
+ :param basecmd: the name of the command being checked for
+ :param extcmds: a list of arguments passed to *basecmd*
+ :raises: :class:`cli.CliError`
+ """
+ min_args = 2
+ if '--' in extcmds:
+ min_args = 3
+ if len(extcmds) < min_args:
+ base.logger.critical(
+ _('Error: Need at least two packages to %s') % basecmd)
+ _err_mini_usage(base, basecmd)
+ raise cli.CliError
+
+
def checkItemArg(base, basecmd, extcmds):
"""Verify that *extcmds* contains the name of at least one item for
*basecmd* to act on. Generally, the items are command-line
@@ -3017,6 +3036,7 @@ class CheckRpmdbCommand(YumCommand):
"""
return False
+
class LoadTransactionCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
load-transaction command.
@@ -3083,3 +3103,96 @@ class LoadTransactionCommand(YumCommand):
"""
return True
+
+class SwapCommand(YumCommand):
+ """A class containing methods needed by the cli to execute the
+ swap command.
+ """
+
+ def getNames(self):
+ """Return a list containing the names of this command. This
+ command can be called from the command line by using any of these names.
+
+ :return: a list containing the names of this command
+ """
+ return ['swap']
+
+ def getUsage(self):
+ """Return a usage string for this command.
+
+ :return: a usage string for this command
+ """
+ return "[remove|cmd] <pkg|arg(s)> [-- install|cmd] <pkg|arg(s)>"
+
+ def getSummary(self):
+ """Return a one line summary of this command.
+
+ :return: a one line summary of this command
+ """
+ return _("Simple way to swap packages, isntead of using shell")
+
+ def doCheck(self, base, basecmd, extcmds):
+ """Verify that conditions are met so that this command can run.
+ These include that the program is being run by the root user,
+ that there are enabled repositories with gpg keys, and that
+ this command is called with appropriate arguments.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: the command line arguments passed to *basecmd*
+ """
+ checkRootUID(base)
+ checkGPGKey(base)
+ checkSwapPackageArg(base, basecmd, extcmds)
+ checkEnabledRepo(base, extcmds)
+
+ def doCommand(self, base, basecmd, extcmds):
+ """Execute this command.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: the command line arguments passed to *basecmd*
+ :return: (exit_code, [ errors ])
+
+ exit_code is::
+
+ 0 = we're done, exit
+ 1 = we've errored, exit with error string
+ 2 = we've got work yet to do, onto the next stage
+ """
+
+ if '--' in extcmds:
+ off = extcmds.index('--')
+ rextcmds = extcmds[:off]
+ iextcmds = extcmds[off+1:]
+ else:
+ rextcmds = extcmds[:1]
+ iextcmds = extcmds[1:]
+
+ if not (rextcmds and iextcmds):
+ return 1, ['swap'] # impossible
+
+ if rextcmds[0] not in base.yum_cli_commands:
+ rextcmds = ['remove'] + rextcmds
+ if iextcmds[0] not in base.yum_cli_commands:
+ iextcmds = ['install'] + iextcmds
+
+ # Very similar to what the shell command does...
+ ocmds = base.cmds
+ oline = base.cmdstring
+ for cmds in (rextcmds, iextcmds):
+ base.cmdstring = " ".join(cmds)
+ base.cmds = cmds
+ # Don't call this atm. as the line has gone through it already,
+ # also makes it hard to do the "is ?extcmds[0] a cmd" check.
+ # base.plugins.run('args', args=base.cmds)
+
+ # We don't catch exceptions, just pass them up and fail...
+ base.parseCommands()
+ cmdret = base.doCommands()
+ if cmdret[0] != 2:
+ return cmdret[0], ['%s %s' % (basecmd, " ".join(cmds))]
+ base.cmds = ocmds
+ base.cmdstring = oline
+
+ return 2, ['%s %s' % (basecmd, " ".join(extcmds))]
commit b52cecf339bd1731bcbfcc3243ba4f39242bb854
Author: James Antill <james at and.org>
Date: Thu Jan 10 12:08:07 2013 -0500
Add severity and release to updateinfo errata equality test. BZ 893994
diff --git a/yum/update_md.py b/yum/update_md.py
index 3b22995..3ac0010 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -101,6 +101,7 @@ class UpdateNotice(object):
return False
for data in ('type', 'update_id', 'status', 'rights',
+ 'severity', 'release',
'issued', 'updated', 'version', 'pushcount',
'from', 'title', 'summary', 'description', 'solution'):
if self._md[data] != other._md[data]:
commit 34b44b8376d1ab5fccdf46478a207319a397d878
Author: James Antill <james at and.org>
Date: Tue Jan 8 10:07:26 2013 -0500
Add return to add_notice(), use it to print a dup. message. BZ 737173.
diff --git a/yum/update_md.py b/yum/update_md.py
index d719be8..3b22995 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -452,7 +452,7 @@ class UpdateMetadata(object):
""" Add an UpdateNotice object. This should be fully populated with
data, esp. update_id and pkglist/packages. """
if not un or not un["update_id"]:
- return
+ return False
# This is "special", the main thing we want to deal with here is
# having one errata that has multiple packages in it rpmA and rpmB, but
@@ -463,7 +463,7 @@ class UpdateMetadata(object):
if un['update_id'] in self._notices:
oun = self._notices[un['update_id']]
if oun != un:
- return
+ return False
# Ok, main parts of errata are the same, so now merge references:
seen = set()
@@ -496,6 +496,8 @@ class UpdateMetadata(object):
no = self._no_cache.setdefault(filedata['name'], set())
no.add(un)
+ return True
+
def add(self, obj, mdtype='updateinfo'):
""" Parse a metadata from a given YumRepository, file, or filename. """
if not obj:
@@ -525,7 +527,8 @@ class UpdateMetadata(object):
print >> sys.stderr, "An update notice is broken, skipping."
# what else should we do?
continue
- self.add_notice(un)
+ if not self.add_notice(un):
+ print >> sys.stderr, "An update notice is broken, or duplicate, skipping:", un['update_id']
def __unicode__(self):
ret = u''
commit af0495fafd531e463b117ec460ad00656b639101
Author: James Antill <james at and.org>
Date: Mon Jan 7 16:14:34 2013 -0500
Add a metadata_expire_filter configuration, and use it in the shipped commands.
In theory this is never needed because everyone always runs yum-cron
and repos. are always upto date. In practise everyone complains because
yum hits the network due to that not being the case. This allows the
user to control a lot better how much out of data info. they don't mind
having for simple "yum search" type commands etc.
Not sure how useful the past/present distinction is, but it's easier to
ignore/remove it that to add it back in later.
diff --git a/cli.py b/cli.py
index 9225d5a..01b21e6 100755
--- a/cli.py
+++ b/cli.py
@@ -509,6 +509,12 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
except yum.Errors.YumBaseError, e:
return 1, [exception2msg(e)]
+ cacheReq = 'write'
+ if hasattr(cmd, 'cacheRequirement'):
+ cacheReq = cmd.cacheRequirement(self, self.basecmd, self.extcmds)
+ for repo in self.repos.listEnabled():
+ repo._metadata_cache_req = cacheReq
+
return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
def doTransaction(self):
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 029fa75..30ac844 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -499,6 +499,31 @@ It's also possible to use the word "never", meaning that the metadata will
never expire. Note that when using a metalink file the metalink must always
be newer than the metadata for the repository, due to the validation, so this
timeout also applies to the metalink file.
+Also note that "never" does not override "yum clean expire-cache"
+
+.IP
+\fBmetadata_expire_filter \fR
+Filter the metadata_expire time, allowing a trade of speed for accuracy if
+a command doesn't require it. Each yum command can specify that it requires a
+certain level of timeliness quality from the remote repos. from "I'm about to
+install/upgrade, so this better be current" to "Anything that's available
+is good enough".
+
+'never' - Nothing is filtered, always obey metadata_expire.
+
+'read-only:past' - Commands that only care about past information
+are filtered from metadata expiring.
+Eg. yum history info (if history needs to lookup anything about a previous
+transaction, then by definition the remote package was available in the past).
+
+'read-only:present' - Commands that are balanced between past and future.
+This is the default.
+Eg. yum list yum
+
+'read-only:future' - Commands that are likely to result in running other
+commands which will require the latest metadata. Eg. yum check-update
+
+Note that this option does not override "yum clean expire-cache".
.IP
\fBmirrorlist_expire \fR
@@ -911,6 +936,11 @@ Overrides the \fBmetadata_expire\fR option from the [main] section for this
repository.
.IP
+\fBmetadata_expire_filter \fR
+Overrides the \fBmetadata_expire_filter\fR option from the [main] section for
+this repository.
+
+.IP
\fBmirrorlist_expire \fR
Overrides the \fBmirrorlist_expire\fR option from the [main] section for this
repository.
diff --git a/yum/config.py b/yum/config.py
index 74be397..3cdb0fd 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -792,6 +792,10 @@ class YumConf(StartupConf):
http_caching = SelectionOption('all', ('none', 'packages', 'all'))
metadata_expire = SecondsOption(60 * 60 * 6) # Time in seconds (6h).
+ metadata_expire_filter = SelectionOption('read-only:present',
+ ('never', 'read-only:future',
+ 'read-only:present',
+ 'read-only:past'))
# 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
@@ -944,6 +948,7 @@ class RepoConf(BaseConfig):
http_caching = Inherit(YumConf.http_caching)
metadata_expire = Inherit(YumConf.metadata_expire)
+ metadata_expire_filter = Inherit(YumConf.metadata_expire_filter)
mirrorlist_expire = Inherit(YumConf.mirrorlist_expire)
# NOTE: metalink expire _must_ be the same as metadata_expire, due to the
# checksumming of the repomd.xml.
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 4f5f7a6..09b2534 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1068,7 +1068,7 @@ Insufficient space in download directory %s
self._metadataCurrent = False
return self._metadataCurrent
- def withinCacheAge(self, myfile, expiration_time):
+ def withinCacheAge(self, myfile, expiration_time, expire_req_filter=True):
"""check if any file is older than a certain amount of time. Used for
the cachecookie and the mirrorlist
return True if w/i the expiration time limit
@@ -1078,6 +1078,24 @@ Insufficient space in download directory %s
file. If any of them are newer then invalidate the cache
"""
+ # Never/write means we just skip this...
+ if (expire_req_filter and hasattr(self, '_metadata_cache_req') and
+ self._metadata_cache_req.startswith("read-only:") and
+ self.metadata_expire_filter.startswith("read-only:")):
+
+ cache_filt = self.metadata_expire_filter[len("read-only:"):]
+ cache_req = self._metadata_cache_req[len("read-only:"):]
+
+ if cache_filt == 'future':
+ assert cache_req in ('past', 'present', 'future')
+ expiration_time = -1
+ if cache_filt == 'present':
+ if cache_req in ('past', 'present'):
+ expiration_time = -1
+ if cache_filt == 'past':
+ if cache_req == 'past':
+ expiration_time = -1
+
# -1 is special and should never get refreshed
if expiration_time == -1 and os.path.exists(myfile):
return True
@@ -1850,7 +1868,8 @@ Insufficient space in download directory %s
fo = None
cacheok = False
- if self.withinCacheAge(self.mirrorlist_file, self.mirrorlist_expire):
+ if self.withinCacheAge(self.mirrorlist_file, self.mirrorlist_expire,
+ expire_req_filter=False):
cacheok = True
fo = open(self.mirrorlist_file, 'r')
url = 'file://' + self.mirrorlist_file # just to keep self._readMirrorList(fo,url) happy
diff --git a/yumcommands.py b/yumcommands.py
index a2e0b1b..14a1375 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -280,7 +280,35 @@ class YumCommand:
:return: True if a transaction set is needed, False otherwise
"""
return True
+
+ # Some of this is subjective, esp. between past/present, but roughly use:
+ #
+ # write = I'm using package data to alter the rpmdb in anyway.
+ # read-only:future = I'm providing data that is likely to result in a
+ # future write, so we might as well do it now.
+ # Eg. yum check-update && yum update -q -y
+ # read-only:present = I'm providing data about the present state of
+ # packages in the repo.
+ # Eg. yum list yum
+ # read-only:past = I'm providing context data about past writes, or just
+ # anything that is available is good enough for me
+ # (speed is much better than quality).
+ # Eg. yum history info
+ # Eg. TAB completion
+ #
+ # ...default is write, which does the same thing we always did (obey
+ # metadata_expire and live with it).
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'write'
+
class InstallCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
install command.
@@ -648,6 +676,19 @@ class InfoCommand(YumCommand):
return True
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ if len(extcmds) and extcmds[0] in ('updates', 'obsoletes'):
+ return 'read-only:future'
+ return 'read-only:present'
+
+
class ListCommand(InfoCommand):
"""A class containing methods needed by the cli to execute the
list command.
@@ -1349,6 +1390,17 @@ class ProvidesCommand(YumCommand):
except yum.Errors.YumBaseError, e:
return 1, [exception2msg(e)]
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'read-only:past'
+
+
class CheckUpdateCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
check-update command.
@@ -1440,6 +1492,17 @@ class CheckUpdateCommand(YumCommand):
else:
return result, []
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'read-only:future'
+
+
class SearchCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
search command.
@@ -1508,6 +1571,17 @@ class SearchCommand(YumCommand):
"""
return False
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'read-only:present'
+
+
class UpgradeCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
upgrade command.
@@ -1698,6 +1772,17 @@ class ResolveDepCommand(YumCommand):
except yum.Errors.YumBaseError, e:
return 1, [exception2msg(e)]
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'read-only:past'
+
+
class ShellCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
shell command.
@@ -1825,6 +1910,16 @@ class DepListCommand(YumCommand):
except yum.Errors.YumBaseError, e:
return 1, [exception2msg(e)]
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'read-only:past' # read-only ?
+
class RepoListCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
@@ -2141,6 +2236,16 @@ class RepoListCommand(YumCommand):
"""
return False
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'read-only:past'
+
class HelpCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
@@ -2583,6 +2688,16 @@ class VersionCommand(YumCommand):
return True
return vcmd in ('available', 'all', 'group-available', 'group-all')
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ return 'read-only:present'
+
class HistoryCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
@@ -2821,6 +2936,21 @@ class HistoryCommand(YumCommand):
vcmd = extcmds[0]
return vcmd in ('repeat', 'redo', 'undo', 'rollback')
+ def cacheRequirement(self, base, basecmd, extcmds):
+ """Return the cache requirements for the remote repos.
+
+ :param base: a :class:`yum.Yumbase` object
+ :param basecmd: the name of the command
+ :param extcmds: a list of arguments passed to *basecmd*
+ :return: Type of requirement: read-only:past, read-only:present, read-only:future, write
+ """
+ vcmd = 'list'
+ if extcmds:
+ vcmd = extcmds[0]
+ if vcmd in ('repeat', 'redo', 'undo', 'rollback'):
+ return 'write'
+ return 'read-only:past'
+
class CheckRpmdbCommand(YumCommand):
"""A class containing methods needed by the cli to execute the
More information about the Yum-commits
mailing list