[yum-commits] 5 commits - completion-helper.py docs/yum.8 yumcommands.py yum/__init__.py

James Antill james at osuosl.org
Tue May 21 20:32:14 UTC 2013


 completion-helper.py |    5 +
 docs/yum.8           |   18 +++++-
 yum/__init__.py      |   10 +++
 yumcommands.py       |  142 ++++++++++++++++-----------------------------------
 4 files changed, 74 insertions(+), 101 deletions(-)

New commits:
commit fe0513de7e73f67c6db79fc0d9593dd738d99e77
Author: James Antill <james at and.org>
Date:   Tue May 21 15:29:43 2013 -0400

    Also catch RepoError in completion. BZ 827759.

diff --git a/completion-helper.py b/completion-helper.py
index 1102fd6..c0e5a28 100755
--- a/completion-helper.py
+++ b/completion-helper.py
@@ -23,7 +23,7 @@ import sys
 
 import cli
 import yumcommands
-from yum.Errors import GroupsError, ConfigError
+from yum.Errors import GroupsError, ConfigError, RepoError
 
 
 class GroupsCompletionCommand(yumcommands.GroupsCommand):
@@ -85,7 +85,8 @@ def main(args):
         for repo in base.repos.listEnabled():
             repo.skip_if_unavailable = True
         base.doCommands()
-    except (GroupsError, ConfigError), e:
+    except (GroupsError, ConfigError, RepoError), e:
+    # Any reason to not just catch YumBaseError ?
         base.logger.error(e)
 
 if __name__ == "__main__":
commit 808c96529934242af14560a0f5e28e244ab11560
Author: James Antill <james at and.org>
Date:   Mon May 20 15:45:43 2013 -0400

    Make returnInstalledPackagesByDep() behave the same as returnPackagesByDep().

diff --git a/yum/__init__.py b/yum/__init__.py
index df08bc6..5ea797e 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4120,6 +4120,10 @@ much more problems).
                         raise Errors.YumBaseError, _('Invalid version flag from: %s') % str(depstring)
                     depflags = SYMBOLFLAGS[flagsymbol]
 
+        if depflags is None: # This does wildcards...
+            return self.rpmdb.searchProvides(depstring)
+
+        # This does flags+versions, but no wildcards...
         return self.rpmdb.getProvides(depname, depflags, depver).keys()
 
     def returnInstalledPackageByDep(self, depstring):
commit ef6d1209d8954b936d319afbd45f8779a09295fd
Author: James Antill <james at and.org>
Date:   Mon May 20 15:44:25 2013 -0400

    Fix the returnPackagesByDep() API, revert install to use it again. BZ 965695.

diff --git a/yum/__init__.py b/yum/__init__.py
index c2d255c..df08bc6 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4053,6 +4053,10 @@ much more problems).
                         raise Errors.YumBaseError, _('Invalid version flag from: %s') % str(depstring)
                     depflags = SYMBOLFLAGS[flagsymbol]
 
+        if depflags is None: # This does wildcards...
+            return self.pkgSack.searchProvides(depstring)
+
+        # This does flags+versions, but no wildcards...
         return self.pkgSack.getProvides(depname, depflags, depver).keys()
 
     def returnPackageByDep(self, depstring):
@@ -4569,7 +4573,7 @@ much more problems).
                     self.verbose_logger.debug(_('Checking for virtual provide or file-provide for %s'), 
                         arg)
 
-                    mypkgs = self.pkgSack.searchProvides(arg)
+                    mypkgs = self.pkgSack.returnPackagesByDep(arg)
                     if not misc.re_glob(arg):
                         mypkgs = self.bestPackagesFromList(mypkgs,
                                                            single_name=True,
commit c7061b13a6b702e6c916445ea51a89cda8765558
Author: James Antill <james at and.org>
Date:   Mon May 20 15:30:24 2013 -0400

     Remove all the local YumBaseError catches, yummain handles it better.
    
     Mainly we want the NoMoreMirrors, aka. RepoError, failures to call
    cleanExpireCache() ... this doesn't happen now as it's all hidden by the
    commands.
     The only possible downside I can see is "yum shell", but we can start
    catching these there if it's better to not exit the shell (not obvious).
    
     Note that a lot of stuff uses "if True:" so we don't have a huge number
    of whitespace changes.

diff --git a/yumcommands.py b/yumcommands.py
index 308bf90..700e76c 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -423,10 +423,7 @@ class InstallCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         self.doneCommand(base, _("Setting up Install Process"))
-        try:
-            return base.installPkgs(extcmds, basecmd=basecmd)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        return base.installPkgs(extcmds, basecmd=basecmd)
 
 
 class UpdateCommand(YumCommand):
@@ -485,12 +482,9 @@ class UpdateCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         self.doneCommand(base, _("Setting up Update Process"))
-        try:
-            ret = base.updatePkgs(extcmds, update_to=(basecmd == 'update-to'))
-            updateinfo.remove_txmbrs(base)
-            return ret
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        ret = base.updatePkgs(extcmds, update_to=(basecmd == 'update-to'))
+        updateinfo.remove_txmbrs(base)
+        return ret
 
 class DistroSyncCommand(YumCommand):
     """A class containing methods needed by the cli to execute the
@@ -547,13 +541,10 @@ class DistroSyncCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         self.doneCommand(base, _("Setting up Distribution Synchronization Process"))
-        try:
-            base.conf.obsoletes = 1
-            ret = base.distroSyncPkgs(extcmds)
-            updateinfo.remove_txmbrs(base)
-            return ret
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        base.conf.obsoletes = 1
+        ret = base.distroSyncPkgs(extcmds)
+        updateinfo.remove_txmbrs(base)
+        return ret
 
 def _add_pkg_simple_list_lens(data, pkg, indent=''):
     """ Get the length of each pkg's column. Add that to data.
@@ -630,7 +621,7 @@ class InfoCommand(YumCommand):
         else:
             updateinfo.exclude_all(base)
 
-        try:
+        if True: # Try, YumBase...
             highlight = base.term.MODE['bold']
             #  If we are doing: "yum info installed blah" don't do the highlight
             # because the usability of not accessing the repos. is still higher
@@ -639,9 +630,7 @@ class InfoCommand(YumCommand):
                 highlight = False
             ypl = base.returnPkgLists(extcmds, installed_available=highlight,
                                       repoid=repoid)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
-        else:
+
             update_pkgs = {}
             inst_pkgs   = {}
             local_pkgs  = {}
@@ -860,10 +849,7 @@ class EraseCommand(YumCommand):
                     extcmds.append(pkg)
 
         self.doneCommand(base, _("Setting up Remove Process"))
-        try:
-            ret = base.erasePkgs(extcmds, pos=pos, basecmd=basecmd)
-        except yum.Errors.YumBaseError, e:
-            ret = (1, [exception2msg(e)])
+        ret = base.erasePkgs(extcmds, pos=pos, basecmd=basecmd)
 
         return ret
 
@@ -931,7 +917,7 @@ class GroupsCommand(YumCommand):
         except yum.Errors.GroupsError:
             return 1, [_('No Groups on which to run command')]
         except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+            raise
 
     def _grp_cmd(self, basecmd, extcmds):
         if basecmd in self.direct_commands:
@@ -1034,7 +1020,7 @@ class GroupsCommand(YumCommand):
         if cmd == 'list':
             return base.returnGroupLists(extcmds)
 
-        try:
+        if True: # Try, YumBase...
             if cmd == 'info':
                 return base.returnGroupInfo(extcmds)
             if cmd == 'install':
@@ -1218,10 +1204,6 @@ class GroupsCommand(YumCommand):
                 return 0, ['Marked remove: ' + ','.join(extcmds)]
 
 
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
-
-
     def needTs(self, base, basecmd, extcmds):
         """Return whether a transaction set must be set up before this
         command can run.
@@ -1330,7 +1312,7 @@ class MakeCacheCommand(YumCommand):
         if extcmds and extcmds[0] == 'fast':
             fast = True
 
-        try:
+        if True: # Try, YumBase...
             for repo in base.repos.findRepos('*'):
                 repo.metadata_expire = 0
                 if not fast:
@@ -1365,8 +1347,6 @@ class MakeCacheCommand(YumCommand):
                                              fname_map[MD],
                                              cached=repo.cache)
 
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
         return 0, [_('Metadata Cache Created')]
 
     def needTs(self, base, basecmd, extcmds):
@@ -1510,11 +1490,8 @@ class ProvidesCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         base.logger.debug("Searching Packages: ")
-        try:
-            updateinfo.exclude_updates(base)
-            return base.provides(extcmds)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        updateinfo.exclude_updates(base)
+        return base.provides(extcmds)
 
     def cacheRequirement(self, base, basecmd, extcmds):
         """Return the cache requirements for the remote repos.
@@ -1582,7 +1559,7 @@ class CheckUpdateCommand(YumCommand):
         obscmds = ['obsoletes'] + extcmds
         base.extcmds.insert(0, 'updates')
         result = 0
-        try:
+        if True:
             ypl = base.returnPkgLists(extcmds)
             if (base.conf.obsoletes or
                 base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)):
@@ -1620,10 +1597,7 @@ class CheckUpdateCommand(YumCommand):
                 def _msg(x):
                     base.verbose_logger.info("%s", x)
                 updateinfo._check_running_kernel(base, base.upinfo, _msg)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
-        else:
-            return result, []
+        return result, []
 
     def cacheRequirement(self, base, basecmd, extcmds):
         """Return the cache requirements for the remote repos.
@@ -1688,11 +1662,8 @@ class SearchCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         base.logger.debug(_("Searching Packages: "))
-        try:
-            updateinfo.exclude_updates(base)
-            return base.search(extcmds)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        updateinfo.exclude_updates(base)
+        return base.search(extcmds)
 
     def needTs(self, base, basecmd, extcmds):
         """Return whether a transaction set must be set up before this
@@ -1772,12 +1743,9 @@ class UpgradeCommand(YumCommand):
         """
         base.conf.obsoletes = 1
         self.doneCommand(base, _("Setting up Upgrade Process"))
-        try:
-            ret = base.updatePkgs(extcmds, update_to=(basecmd == 'upgrade-to'))
-            updateinfo.remove_txmbrs(base)
-            return ret
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        ret = base.updatePkgs(extcmds, update_to=(basecmd == 'upgrade-to'))
+        updateinfo.remove_txmbrs(base)
+        return ret
 
 class LocalInstallCommand(YumCommand):
     """A class containing methods needed by the cli to execute the
@@ -1841,10 +1809,7 @@ class LocalInstallCommand(YumCommand):
         self.doneCommand(base, _("Setting up Local Package Process"))
 
         updateonly = basecmd == 'localupdate'
-        try:
-            return base.localInstall(filelist=extcmds, updateonly=updateonly)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        return base.localInstall(filelist=extcmds, updateonly=updateonly)
 
     def needTs(self, base, basecmd, extcmds):
         """Return whether a transaction set must be set up before this
@@ -1903,11 +1868,8 @@ class ResolveDepCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         base.logger.debug(_("Searching Packages for Dependency:"))
-        try:
-            updateinfo.exclude_updates(base)
-            return base.resolveDepCli(extcmds)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        updateinfo.exclude_updates(base)
+        return base.resolveDepCli(extcmds)
 
     def cacheRequirement(self, base, basecmd, extcmds):
         """Return the cache requirements for the remote repos.
@@ -1972,10 +1934,7 @@ class ShellCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         self.doneCommand(base, _('Setting up Yum Shell'))
-        try:
-            return base.doShell()
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        return base.doShell()
 
     def needTs(self, base, basecmd, extcmds):
         """Return whether a transaction set must be set up before this
@@ -2042,11 +2001,8 @@ class DepListCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         self.doneCommand(base, _("Finding dependencies: "))
-        try:
-            updateinfo.exclude_updates(base)
-            return base.deplist(extcmds)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        updateinfo.exclude_updates(base)
+        return base.deplist(extcmds)
 
     def cacheRequirement(self, base, basecmd, extcmds):
         """Return the cache requirements for the remote repos.
@@ -2546,11 +2502,7 @@ class ReInstallCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         self.doneCommand(base, _("Setting up Reinstall Process"))
-        try:
-            return base.reinstallPkgs(extcmds)
-            
-        except yum.Errors.YumBaseError, e:
-            return 1, [to_unicode(e)]
+        return base.reinstallPkgs(extcmds)
 
     def getSummary(self):
         """Return a one line summary of this command.
@@ -2621,10 +2573,7 @@ class DowngradeCommand(YumCommand):
             2 = we've got work yet to do, onto the next stage
         """
         self.doneCommand(base, _("Setting up Downgrade Process"))
-        try:
-            return base.downgradePkgs(extcmds)
-        except yum.Errors.YumBaseError, e:
-            return 1, [exception2msg(e)]
+        return base.downgradePkgs(extcmds)
 
     def getSummary(self):
         """Return a one line summary of this command.
@@ -2754,7 +2703,7 @@ class VersionCommand(YumCommand):
         ba  = base.conf.yumvar['basearch']
         cols = []
         if vcmd in ('installed', 'all', 'group-installed', 'group-all'):
-            try:
+            if True: # Try, YumBase...
                 data = base.rpmdb.simpleVersion(not verbose, groups=groups)
                 lastdbv = base.history.last()
                 if lastdbv is not None:
@@ -2773,10 +2722,9 @@ class VersionCommand(YumCommand):
                         cols.append(("%s %s" % (_("Group-Installed:"), grp),
                                      str(data[2][grp])))
                         _append_repos(cols, data[3][grp])
-            except yum.Errors.YumBaseError, e:
-                return 1, [exception2msg(e)]
+
         if vcmd in ('available', 'all', 'group-available', 'group-all'):
-            try:
+            if True: # Try, YumBase...
                 data = base.pkgSack.simpleVersion(not verbose, groups=groups)
                 if vcmd not in ('group-available', 'group-all'):
                     cols.append(("%s %s/%s" % (_("Available:"), rel, ba),
@@ -2792,8 +2740,6 @@ class VersionCommand(YumCommand):
                                      str(data[2][grp])))
                         if verbose:
                             _append_repos(cols, data[3][grp])
-            except yum.Errors.YumBaseError, e:
-                return 1, [exception2msg(e)]
 
         data = {'rid' : {}, 'ver' : {}}
         for (rid, ver) in cols:
@@ -3312,10 +3258,7 @@ class LoadTransactionCommand(YumCommand):
 
         self.doneCommand(base, _("loading transaction from %s") % load_file)
         
-        try:
-            base.load_ts(load_file)
-        except yum.Errors.YumBaseError, e:
-            return 1, [to_unicode(e)]
+        base.load_ts(load_file)
         return 2, [_('Transaction loaded from %s with %s members') % (load_file, len(base.tsInfo.getMembers()))]
 
 
commit 437044e49a7eae4361d5d7a6f3ff40ed02c8b130
Author: James Antill <james at and.org>
Date:   Fri May 17 15:12:05 2013 -0400

    Try to make group as object conversion better, add documentation about info.

diff --git a/docs/yum.8 b/docs/yum.8
index 8c156f0..76bbdd5 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -279,6 +279,19 @@ groups own packages need updating). If you pass the \-v option, to enable verbos
 mode, then the package names are matched against installed/available packages
 similar to the list command.
 
+When using group_command=objects, the info command will display markers next
+to each package saying how that pacakge relates to the group object. The
+meaning of these markers is:
+
+.br
+"-" = Pacakge isn't installed, and won't be installed as part of the group (Eg. group install foo -pkgA … this will have pkgA marked as '-')
+.br
+"+" = Package isn't installed, but will be the next time you run "yum upgrade" or "yum group upgrade foo"
+.br
+" " = Package is installed, but wasn't installed via. the group (so "group remove foo" won't remove it).
+.br
+"=" = Package is installed, and was installed via. the group.
+
 "\fBgroup summary\fP" is used to give a quick summary of how many groups
 are installed and available.
 
@@ -287,8 +300,9 @@ in group_command=objects mode. These commands then allow you to alter yum's idea
 of which groups are installed, and the packages that belong to them.
 
 "\fBgroup mark install\fP" mark the group as installed. When
-installed "\fByum upgrade\fP" and "\fByum group upgrade\fP" will installing new
-packages for the group.
+installed "\fByum upgrade\fP" and "\fByum group upgrade\fP" will install new
+packages for the group (only those packages already installed will be marked as
+members of the installed group to start with).
 
 "\fBgroup mark remove\fP" the opposite of mark install.
 
diff --git a/yumcommands.py b/yumcommands.py
index f193cee..308bf90 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1053,7 +1053,10 @@ class GroupsCommand(YumCommand):
                     base.igroups.add_environment(evgrp.environmentid,
                                                  evgrp.allgroups)
                 for grp in grps:
-                    base.igroups.add_group(grp.groupid, grp.packages)
+                    pkg_names = set() # Only see names that are installed.
+                    for pkg in base.rpmdb.searchNames(grp.packages):
+                        pkg_names.add(pkg.name)
+                    base.igroups.add_group(grp.groupid, pkg_names)
                 base.igroups.save()
                 return 0, ['Marked install: ' + ','.join(extcmds)]
 
@@ -1158,13 +1161,17 @@ class GroupsCommand(YumCommand):
                 def _convert_grp(grp):
                     if not grp.installed:
                         return
-                    pkg_names = grp.packages
-                    base.igroups.add_group(grp.groupid, pkg_names)
-
+                    pkg_names = []
                     for pkg in base.rpmdb.searchNames(pkg_names):
                         if 'group_member' in pkg.yumdb_info:
                             continue
                         pkg.yumdb_info.group_member = grp.groupid
+                        pkg_names.append(pkg.name)
+
+                    #  We only mark the packages installed as a known part of
+                    # the group. This way "group update" will work and install
+                    # any remaining packages, as it would before the conversion.
+                    base.igroups.add_group(grp.groupid, pkg_names)
 
                 # Blank everything.
                 for gid in base.igroups.groups.keys():


More information about the Yum-commits mailing list