[yum-commits] 4 commits - cli.py docs/yum.8 yumcommands.py

James Antill james at osuosl.org
Fri Dec 6 16:08:01 UTC 2013


 cli.py         |   19 ++++++++++---------
 docs/yum.8     |    3 +++
 yumcommands.py |   21 +++++++++++++++------
 3 files changed, 28 insertions(+), 15 deletions(-)

New commits:
commit 84876b27c49056a8d86112020a9ec4ec7a13e852
Author: James Antill <james at and.org>
Date:   Fri Dec 6 11:04:31 2013 -0500

     Fix cacheReq manipulation. BZ 1039028.
    
     Only look at enabled repos. for cacheReq cookie comparisons. BZ 1039028.
    
     Move all the cacheReq repo. setting into a function.
    
     Use the function everywhere so we don't overwrite the manipulated value with
    the generic value.

diff --git a/cli.py b/cli.py
index 7f6643f..180ba99 100755
--- a/cli.py
+++ b/cli.py
@@ -390,6 +390,13 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
                                   self.basecmd, sys.argv[0])
             raise CliError
     
+        self._set_repos_cache_req()
+
+        self.yum_cli_commands[self.basecmd].doCheck(self, self.basecmd, self.extcmds)
+
+    def _set_repos_cache_req(self, warning=True):
+        """ Set the cacheReq attribute from the commands to the repos. """
+
         cmd = self.yum_cli_commands[self.basecmd]
         cacheReq = 'write'
         if hasattr(cmd, 'cacheRequirement'):
@@ -404,7 +411,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         # they are _really_ old.
         ts_min = None
         ts_max = None
-        for repo in self.repos.sort():
+        for repo in self.repos.listEnabled():
             if not os.path.exists(repo.metadata_cookie):
                 ts_min = None
                 break
@@ -428,14 +435,12 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
 
         if not ts_min:
             cacheReq = 'write'
-        elif (time.time() - ts_max) > (60 * 60 * 24 * 14):
+        elif warning and (time.time() - ts_max) > (60 * 60 * 24 * 14):
             self.logger.warning(_("Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast"))
 
         for repo in self.repos.sort():
             repo._metadata_cache_req = cacheReq
 
-        self.yum_cli_commands[self.basecmd].doCheck(self, self.basecmd, self.extcmds)
-
     def _shell_history_write(self):
         if not hasattr(self, '_shell_history_cmds'):
             return
@@ -560,11 +565,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
 
         #  This should already have been done at doCheck() time, but just in
         # case repos. got added or something do it again.
-        cacheReq = 'write'
-        if hasattr(cmd, 'cacheRequirement'):
-            cacheReq = cmd.cacheRequirement(self, self.basecmd, self.extcmds)
-        for repo in self.repos.sort():
-            repo._metadata_cache_req = cacheReq
+        self._set_repos_cache_req(warning=False)
 
         return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
 
commit ade4e34d1578ad4046b5efe3c3a97ca6bc1791f5
Author: James Antill <james at and.org>
Date:   Thu Dec 5 16:37:07 2013 -0500

    Add check-update sub-command to repo-pkgs.

diff --git a/docs/yum.8 b/docs/yum.8
index 0914765..dff88af 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -423,6 +423,9 @@ only shows packages from the given repository.
 "repository\-packages <repo> info" - Works like the "yum info" command, but
 only shows packages from the given repository.
 
+"repository\-packages <repo> check-update" - Works like the
+"yum check-update" command, but only shows packages from the given repository.
+
 "repository\-packages <repo> install" - Install all of the packages in the
 repository, basically the same as: yum install $(repoquery --repoid=<repo> -a).
 Specific packages/wildcards can be specified.
diff --git a/yumcommands.py b/yumcommands.py
index 3412a60..b346128 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1558,7 +1558,7 @@ class CheckUpdateCommand(YumCommand):
         """
         checkEnabledRepo(base)
 
-    def doCommand(self, base, basecmd, extcmds):
+    def doCommand(self, base, basecmd, extcmds, repoid=None):
         """Execute this command.
 
         :param base: a :class:`yum.Yumbase` object
@@ -1577,10 +1577,10 @@ class CheckUpdateCommand(YumCommand):
         base.extcmds.insert(0, 'updates')
         result = 0
         if True:
-            ypl = base.returnPkgLists(extcmds)
+            ypl = base.returnPkgLists(extcmds, repoid=repoid)
             if (base.conf.obsoletes or
                 base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)):
-                typl = base.returnPkgLists(obscmds)
+                typl = base.returnPkgLists(obscmds, repoid=repoid)
                 ypl.obsoletes = typl.obsoletes
                 ypl.obsoletesTuples = typl.obsoletesTuples
 
@@ -1606,7 +1606,7 @@ class CheckUpdateCommand(YumCommand):
                 for obtup in sorted(ypl.obsoletesTuples,
                                     key=operator.itemgetter(0)):
                     base.updatesObsoletesList(obtup, 'obsoletes',
-                                              columns=columns)
+                                              columns=columns, repoid=repoid)
                 result = 100
 
             # Add check_running_kernel call, if updateinfo is available.
@@ -3516,6 +3516,9 @@ class RepoPkgsCommand(YumCommand):
                  'remove-or-distribution-synchronization' : 'remove-or-sync',
                  'upgrade' : 'update', # Hack, but meh.
                  'upgrade-to' : 'update-to', # Hack, but meh.
+                 'check-upgrade' : 'check-update', # Hack, but meh.
+                 'check-upgrades' : 'check-update', # Hack, but meh.
+                 'check-updates' : 'check-update', # Hack, but meh.
                  }
         cmd = remap.get(cmd, cmd)
 
@@ -3524,6 +3527,8 @@ class RepoPkgsCommand(YumCommand):
             return ListCommand().doCommand(base, cmd, args, repoid=repoid)
         elif cmd == 'info':
             return InfoCommand().doCommand(base, cmd, args, repoid=repoid)
+        elif cmd == 'check-update':
+            return CheckUpdateCommand().doCommand(base, cmd, args,repoid=repoid)
 
         elif cmd == 'install': # install is simpler version of installPkgs...
             for arg in args:
@@ -3730,6 +3735,9 @@ class RepoPkgsCommand(YumCommand):
             cmd = extcmds[1]
         if cmd in ('info', 'list'):
             return InfoCommand().cacheRequirement(base, cmd, extcmds[2:])
+        if cmd in ('check-update', 'check-upgrade',
+                   'check-updates', 'check-upgrades'):
+            return CheckUpdateCommand().cacheRequirement(base, cmd, extcmds[2:])
         return 'write'
 
 # Using this a lot, so make it easier...
commit 88a93e8de73066a796bbb698c5c6f59b66174448
Author: James Antill <james at and.org>
Date:   Thu Dec 5 16:36:54 2013 -0500

    Add command variation aliases to check-update.

diff --git a/yumcommands.py b/yumcommands.py
index db1b9d3..3412a60 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1531,7 +1531,8 @@ class CheckUpdateCommand(YumCommand):
 
         :return: a list containing the names of this command
         """
-        return ['check-update']
+        return ['check-update',  'check-updates',
+                'check-upgrade', 'check-upgrades']
 
     def getUsage(self):
         """Return a usage string for this command.
commit 32e2da9c3e068722f82ae346c761a55ac9d969c9
Author: James Antill <james at and.org>
Date:   Thu Dec 5 16:31:02 2013 -0500

    Fix needTs check with repo-pkgs list/info.

diff --git a/yumcommands.py b/yumcommands.py
index 2b1c9c0..db1b9d3 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -3712,7 +3712,7 @@ class RepoPkgsCommand(YumCommand):
         if len(extcmds) > 1:
             cmd = extcmds[1]
         if cmd in ('info', 'list'):
-            return InfoCommand().cacheRequirement(base, cmd, extcmds[2:])
+            return InfoCommand().needTs(base, cmd, extcmds[2:])
 
         return True
 


More information about the Yum-commits mailing list