[yum-commits] Branch 'yum-3_2_X' - 2 commits - cli.py yum/__init__.py yumcommands.py
James Antill
james at osuosl.org
Wed May 13 21:18:59 UTC 2009
cli.py | 24 ++++++++++++++++++++++++
yum/__init__.py | 48 ++++++++++++++++++++++++++++++++++++++++++++----
yumcommands.py | 10 +---------
3 files changed, 69 insertions(+), 13 deletions(-)
New commits:
commit d06e08d7b72ed4446e47ae454233b2e7aef8c6ea
Author: James Antill <james at and.org>
Date: Wed May 13 17:07:05 2009 -0400
Add reinstall of local rpms
diff --git a/cli.py b/cli.py
index 772fae5..7c4047a 100644
--- a/cli.py
+++ b/cli.py
@@ -673,6 +673,30 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
return 2, [_('Package(s) to downgrade')]
return 0, [_('Nothing to do')]
+ def reinstallPkgs(self, userlist):
+ """Attempts to take the user specified list of packages/wildcards
+ and reinstall them. """
+
+ oldcount = len(self.tsInfo)
+
+ for arg in userlist:
+ if arg.endswith('.rpm') and os.path.exists(arg):
+ self.reinstallLocal(arg)
+ continue # it was something on disk and it ended in rpm
+ # no matter what we don't go looking at repos
+
+ try:
+ self.reinstall(pattern=arg)
+ except yum.Errors.ReinstallError:
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+ _('No package %s%s%s available.'),
+ self.term.MODE['bold'], arg,
+ self.term.MODE['normal'])
+ self._maybeYouMeant(arg)
+ if len(self.tsInfo) > oldcount:
+ return 2, [_('Package(s) to reinstall')]
+ return 0, [_('Nothing to do')]
+
def localInstall(self, filelist, updateonly=0):
"""handles installs/updates of rpms provided on the filesystem in a
local dir (ie: not from a repo)"""
diff --git a/yum/__init__.py b/yum/__init__.py
index e72216c..b5515f2 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -3151,6 +3151,43 @@ class YumBase(depsolve.Depsolve):
return tx_return
+ def reinstallLocal(self, pkg, po=None):
+ """
+ handles reinstall of rpms provided on the filesystem in a
+ local dir (ie: not from a repo)
+
+ Return the added transaction members.
+
+ @param pkg: a path to an rpm file on disk.
+ @param po: A YumLocalPackage
+ """
+
+ if not po:
+ try:
+ po = YumLocalPackage(ts=self.rpmdb.readOnlyTS(), filename=pkg)
+ except Errors.MiscError:
+ self.logger.critical(_('Cannot open file: %s. Skipping.'), pkg)
+ return []
+ self.verbose_logger.log(logginglevels.INFO_2,
+ _('Examining %s: %s'), po.localpath, po)
+
+ if po.arch not in rpmUtils.arch.getArchList():
+ self.logger.critical(_('Cannot add package %s to transaction. Not a compatible architecture: %s'), pkg, po.arch)
+ return []
+
+ # handle excludes for a local reinstall
+ toexc = []
+ if len(self.conf.exclude) > 0:
+ exactmatch, matched, unmatched = \
+ parsePackages([po], self.conf.exclude, casematch=1)
+ toexc = exactmatch + matched
+
+ if po in toexc:
+ self.verbose_logger.debug(_('Excluding %s'), po)
+ return []
+
+ return self.reinstall(po=po)
+
def reinstall(self, po=None, **kwargs):
"""Setup the problem filters to allow a reinstall to work, then
pass everything off to install"""
@@ -3182,8 +3219,12 @@ class YumBase(depsolve.Depsolve):
# pkgs that are obsolete.
old_conf_obs = self.conf.obsoletes
self.conf.obsoletes = False
- members = self.install(name=item.name, arch=item.arch,
- ver=item.version, release=item.release, epoch=item.epoch)
+ if isinstance(po, YumLocalPackage):
+ members = self.install(po=po)
+ else:
+ members = self.install(name=item.name, arch=item.arch,
+ ver=item.version, release=item.release,
+ epoch=item.epoch)
self.conf.obsoletes = old_conf_obs
if len(members) == 0:
self.tsInfo.remove(item.pkgtup)
diff --git a/yumcommands.py b/yumcommands.py
index 9d34055..706d908 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1006,16 +1006,8 @@ class ReInstallCommand(YumCommand):
def doCommand(self, base, basecmd, extcmds):
self.doneCommand(base, _("Setting up Reinstall Process"))
- oldcount = len(base.tsInfo)
try:
- # FIXME: Due to not having reinstallPkgs() we don't get
- # localreinstall and maybe_you_meant features.
- for item in extcmds:
- base.reinstall(pattern=item)
-
- if len(base.tsInfo) > oldcount:
- return 2, [_('Package(s) to reinstall')]
- return 0, [_('Nothing to do')]
+ return base.reinstallPkgs(extcmds)
except yum.Errors.YumBaseError, e:
return 1, [to_unicode(e)]
commit feedba767289c932ba7d591df79b6ee0bd26db40
Author: James Antill <james at and.org>
Date: Wed May 13 16:59:58 2009 -0400
Fix downgrade local, when we have excludes
diff --git a/yum/__init__.py b/yum/__init__.py
index e988236..e72216c 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -3222,8 +3222,7 @@ class YumBase(depsolve.Depsolve):
toexc = []
if len(self.conf.exclude) > 0:
exactmatch, matched, unmatched = \
- parsePackages(installpkgs + map(lambda x: x[0], updatepkgs),
- self.conf.exclude, casematch=1)
+ parsePackages([po], self.conf.exclude, casematch=1)
toexc = exactmatch + matched
if po in toexc:
More information about the Yum-commits
mailing list