[Yum-devel] [PATCH] Add distro-sync command, to "force update" to the latest versions.

James Antill james at fedoraproject.org
Fri Mar 5 00:18:04 UTC 2010


On Thu, 2010-03-04 at 18:07 -0500, Dennis Gregorovic wrote:
> On Thu, 2010-03-04 at 17:22 -0500, James Antill wrote: 
> > This should be safe to go in for 3.2.27, as it's an entirely self
> > contained command ... I've tried it here going on multiple directions,
> > and it WMF(tm).
> 
> Just a couple nitpicks inline. 

 Sure, n/p :)

> > ---
> >  cli.py         |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  yumcommands.py |   25 ++++++++++++++++++++++
> >  2 files changed, 88 insertions(+), 0 deletions(-)
> > 
> > diff --git a/cli.py b/cli.py
> > index f5ed53d..584dcf1 100644
> > --- a/cli.py
> > +++ b/cli.py
> > @@ -100,6 +100,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
> >          self.registerCommand(yumcommands.VersionCommand())
> >          self.registerCommand(yumcommands.HistoryCommand())
> >          self.registerCommand(yumcommands.CheckRpmdbCommand())
> > +        self.registerCommand(yumcommands.DistroSyncCommand())
> >  
> >      def registerCommand(self, command):
> >          for name in command.getNames():
> > @@ -649,6 +650,68 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
> >          else:
> >              return 0, [_('No Packages marked for Update')]
> >  
> > +    def distroSyncPkgs(self, userlist):
> > +        """ This does either upgrade/downgrade, depending on if the latest
> > +            installed version is older or newer. We allow "selection" but not
> > +            local packages (use tmprepo, or something). """
> > +
> > +        dupdates = []
> > +        ipkgs = {}
> > +        iapkgs = {}
> > +        for pkg in sorted(self.rpmdb.returnPackages(patterns=userlist)):
> > +            ipkgs[pkg.name] = pkg
> > +            iapkgs.setdefault(pkg.name, set()).add(pkg)
> iapkgs isn't used elsewhere.  Can it be removed? 

 Yeh, I'd implemented it a bunch of different ways before I found
something that seemed to work well ... this is just a leftover from when
I was doing crazy arch stuff.

> > +        obsoletes = []
> > +        if self.conf.obsoletes:
> > +            obsoletes = self.up.getObsoletesTuples(newest=1)
> > +
> > +        for (obsoleting, installed) in obsoletes:
> > +            if installed[0] not in ipkgs:
> > +                continue
> > +            dupdates.extend(self.update(pkgtup=installed))
> > +        for (obsoleting, installed) in obsoletes:
> > +            if installed[0] not in ipkgs:
> > +                continue
> > +            del ipkg[installed[0]]
> > +
> > +        apkgs = {}
> > +        for pkg in self.pkgSack.returnNewestByName():
> > +            if pkg.name not in ipkgs:
> > +                continue
> > +            apkgs[pkg.name] = pkg
> > +
> > +        for ipkgname in ipkgs:
> > +            if ipkgname not in apkgs:
> > +                continue
> > +
> > +            ipkg = ipkgs[ipkgname]
> > +            apkg = apkgs[ipkgname]
> > +            if ipkg.verEQ(apkg):
> > +                continue
> > +            if self.allowedMultipleInstalls(apkg):
> > +                found = False
> > +                for napkg in self.rpmdb.searchNames([apkg.name]):
> > +                    if napkg.verEQ(apkg):
> > +                        found = True
> > +                    elif napkg.verGT(apkg):
> > +                        dupdates.extend(self.remove(po=napkg))
> > +                if found:
> > +                    continue
> > +                dupdates.extend(self.install(pattern=ipkg.name))
> That should be apkg.name.

 It doesn't actually matter ... ipkg.name == apkg.name == ipkgname, but
I'm happy to make it the same and maybe not confuse myself 6 months from
now :).



More information about the Yum-devel mailing list