On Thu, Mar 31, 2011 at 12:01 AM, James Antill <ja...@and.org> wrote:
> --- > cli.py | 4 +- > yum/__init__.py | 58 > +++++++++++++++++++++++++++++++++++++++++------------- > yumcommands.py | 8 +++--- > 3 files changed, 50 insertions(+), 20 deletions(-) > > diff --git a/cli.py b/cli.py > index eca1812..1b7d7e6 100644 > --- a/cli.py > +++ b/cli.py > @@ -713,7 +713,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput): > return 1, [_('Nothing to do')] > return 0, [_('Nothing to do')] > > - def updatePkgs(self, userlist, quiet=0): > + def updatePkgs(self, userlist, quiet=0, update_to=False): > """take user commands and populate transaction wrapper with > packages to be updated""" > > @@ -740,7 +740,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput): > userlist.remove(item) > > for arg in userlist: > - if not self.update(pattern=arg): > + if not self.update(pattern=arg, update_to=update_to): > self._checkMaybeYouMeant(arg) > > if len(self.tsInfo) > oldcount: > diff --git a/yum/__init__.py b/yum/__init__.py > index d1f07d0..60c572d 100644 > --- a/yum/__init__.py > +++ b/yum/__init__.py > @@ -3005,9 +3005,28 @@ class YumBase(depsolve.Depsolve): > > if not depstring: > return [] > - results = self.pkgSack.searchProvides(depstring) > - return results > - > + > + # parse the string out > + # either it is 'dep (some operator) e:v-r' > + # or /file/dep > + # or packagename > + if type(depstring) == types.TupleType: > + (depname, depflags, depver) = depstring > + else: > + depname = depstring > + depflags = None > + depver = None > + > + if depstring[0] != '/': > + # not a file dep - look at it for being versioned > + dep_split = depstring.split() > + if len(dep_split) == 3: > + depname, flagsymbol, depver = dep_split > + if not flagsymbol in SYMBOLFLAGS: > + raise Errors.YumBaseError, _('Invalid version flag > from: %s') % str(depstring) > + depflags = SYMBOLFLAGS[flagsymbol] > + > + return self.pkgSack.getProvides(depname, depflags, depver).keys() > > def returnPackageByDep(self, depstring): > """Pass in a generic [build]require string and this function will > @@ -3563,7 +3582,7 @@ class YumBase(depsolve.Depsolve): > txmbr.reason = 'dep' > return txmbr > > - def update(self, po=None, requiringPo=None, **kwargs): > + def update(self, po=None, requiringPo=None, update_to=False, > **kwargs): > """try to mark for update the item(s) specified. > po is a package object - if that is there, mark it for update, > if possible > @@ -3634,26 +3653,37 @@ class YumBase(depsolve.Depsolve): > if kwargs['pattern'] and kwargs['pattern'][0] == '@': > return self._at_groupinstall(kwargs['pattern']) > > - (e, m, u) = self.rpmdb.matchPackageNames([kwargs['pattern']]) > - instpkgs.extend(e) > - instpkgs.extend(m) > + arg = kwargs['pattern'] > + if not update_to: > + instpkgs = self.rpmdb.returnPackages(patterns=[arg]) > + else: > + availpkgs = self.pkgSack.returnPackages(patterns=[arg]) > > - if u: > + if not instpkgs and not availpkgs: > depmatches = [] > - arg = u[0] > try: > - depmatches = self.returnInstalledPackagesByDep(arg) > + if update_to: > + depmatches = self.returnPackagesByDep(arg) > + else: > + depmatches = > self.returnInstalledPackagesByDep(arg) > except yum.Errors.YumBaseError, e: > self.logger.critical(_('%s') % e) > - > - instpkgs.extend(depmatches) > + > + if update_to: > + availpkgs.extend(depmatches) > + else: > + instpkgs.extend(depmatches) > > # Always look for available packages, it doesn't seem to do > any > # harm (apart from some time). And it fixes weird edge cases > where > # "update a" (which requires a new b) is different from "update > b" > try: > - pats = [kwargs['pattern']] > - m = self.pkgSack.returnNewestByNameArch(patterns=pats) > + if update_to: > + m = [] > + else: > + pats = [kwargs['pattern']] > + # pats += list(set([pkg.name for pkg in instpkgs])) > + m = self.pkgSack.returnNewestByNameArch(patterns=pats) > except Errors.PackageSackError: > m = [] > availpkgs.extend(m) > diff --git a/yumcommands.py b/yumcommands.py > index 41f0092..fd69f05 100644 > --- a/yumcommands.py > +++ b/yumcommands.py > @@ -207,7 +207,7 @@ class InstallCommand(YumCommand): > > class UpdateCommand(YumCommand): > def getNames(self): > - return ['update'] > + return ['update', 'update-to'] > > def getUsage(self): > return _("[PACKAGE...]") > @@ -223,7 +223,7 @@ class UpdateCommand(YumCommand): > def doCommand(self, base, basecmd, extcmds): > self.doneCommand(base, _("Setting up Update Process")) > try: > - return base.updatePkgs(extcmds) > + return base.updatePkgs(extcmds, update_to=(basecmd == > 'update-to')) > except yum.Errors.YumBaseError, e: > return 1, [str(e)] > > @@ -691,7 +691,7 @@ class SearchCommand(YumCommand): > > class UpgradeCommand(YumCommand): > def getNames(self): > - return ['upgrade'] > + return ['upgrade', 'upgrade-to'] > > def getUsage(self): > return 'PACKAGE...' > @@ -708,7 +708,7 @@ class UpgradeCommand(YumCommand): > base.conf.obsoletes = 1 > self.doneCommand(base, _("Setting up Upgrade Process")) > try: > - return base.updatePkgs(extcmds) > + return base.updatePkgs(extcmds, update_to=(basecmd == > 'upgrade-to')) > except yum.Errors.YumBaseError, e: > return 1, [str(e)] > > -- > 1.7.3.4 > > _______________________________________________ > Yum-devel mailing list > Yum-devel@lists.baseurl.org > http://lists.baseurl.org/mailman/listinfo/yum-devel Do we need a separate command for this, is it not better to just fix 'yum update foo-1.2' to do what 'yum update-to foo-1.2', if I understand it right then 'yum update foo-1.2' will update to the newest version of foo > 1.2, if foo-1.2 is already installed. This is kind of wrong in my book. If I do a 'yum install foo-1.2' I expect foo-1.2 to get installed and get a foo-1.2 is already installed if foo-1.2 is already installed. yum update foo-1.2 should work the same way. Tim
_______________________________________________ Yum-devel mailing list Yum-devel@lists.baseurl.org http://lists.baseurl.org/mailman/listinfo/yum-devel