[Yum-devel] [PATCH] Add simple install-n etc. functions for rel-eng. Takes giant yum shell install lists from ~12 seconds to ~2.

James Antill james at and.org
Fri Nov 18 18:30:52 UTC 2011


 Test Eg.

repoquery -gl base core gnome-desktop xfce-desktop | \
  perl -pe 's//install-n /' | \
  yum shell
---
 cli.py          |   18 ++++++++++++++++--
 docs/yum.8      |    5 +++++
 yum/__init__.py |    2 +-
 yumcommands.py  |    4 ++--
 4 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/cli.py b/cli.py
index bbe8e55..8d8bc75 100755
--- a/cli.py
+++ b/cli.py
@@ -780,7 +780,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
 
         return ret
 
-    def installPkgs(self, userlist):
+    def installPkgs(self, userlist, basecmd='install'):
         """Attempt to take the user specified list of packages or
         wildcards and install them, or if they are installed, update
         them to a newer version. If a complete version number is
@@ -815,7 +815,21 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
                 continue # it was something on disk and it ended in rpm 
                          # no matter what we don't go looking at repos
             try:
-                txmbrs = self.install(pattern=arg)
+                if False: pass
+                elif basecmd == 'install-n':
+                    txmbrs = self.install(name=arg)
+                elif basecmd == 'install-na':
+                    n,a = arg.split('.')
+                    txmbrs = self.install(name=n, arch=a)
+                elif basecmd == 'install-nevra':
+                    nevr,a = arg.rsplit('.', 2)
+                    n,ev,r = nevr.rsplit('-', 3)
+                    e,v    = ev.split(':', 2)
+                    txmbrs = self.install(name=n,
+                                          epoch=e, version=v, release=r, arch=a)
+                else:
+                    assert basecmd == 'install', basecmd
+                    txmbrs = self.install(pattern=arg)
             except yum.Errors.InstallError:
                 self.verbose_logger.log(yum.logginglevels.INFO_2,
                                         _('No package %s%s%s available.'),
diff --git a/docs/yum.8 b/docs/yum.8
index 499da41..f36d382 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -97,6 +97,11 @@ like localinstall\&. If the name doesn't match a package, then package
 "provides" are searched (Eg. "_sqlitecache.so()(64bit)") as are
 filelists (Eg. "/usr/bin/yum"). Also note that for filelists, wildcards will
 match multiple packages\&.
+
+Because install does a lot of work to make it as easy as possible to use, there
+are also a few specific install commands "\fBinstall-n\fP", "\fBinstall-na\fP"
+and "\fBinstall-nevra\fP". These only work on package names, and do not process
+wildcards etc.
 .IP 
 .IP "\fBupdate\fP"
 If run without any packages, update will update every currently
diff --git a/yum/__init__.py b/yum/__init__.py
index b07bbb2..2c9a3da 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4088,7 +4088,7 @@ class YumBase(depsolve.Depsolve):
            be run if it will update the given package to the given
            version.  For example, if the package foo-1-2 is installed,::
 
-             updatePkgs(["foo-1-2], update_to=False)
+             updatePkgs(["foo-1-2"], update_to=False)
            will work identically to::
             
              updatePkgs(["foo"])
diff --git a/yumcommands.py b/yumcommands.py
index 172c40d..a3e50d2 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -290,7 +290,7 @@ class InstallCommand(YumCommand):
 
         :return: a list containing the names of this command
         """
-        return ['install']
+        return ['install', 'install-n', 'install-na', 'install-nevra']
 
     def getUsage(self):
         """Return a usage string for this command.
@@ -337,7 +337,7 @@ class InstallCommand(YumCommand):
         """
         self.doneCommand(base, _("Setting up Install Process"))
         try:
-            return base.installPkgs(extcmds)
+            return base.installPkgs(extcmds, basecmd=basecmd)
         except yum.Errors.YumBaseError, e:
             return 1, [str(e)]
 
-- 
1.7.6.4



More information about the Yum-devel mailing list