[Yum-devel] [PATCH 4/4] Add -pkgname to install etc., so we can test tsInfo.deselect()

James Antill james at and.org
Mon Apr 19 20:00:26 UTC 2010


---
 docs/yum.8      |    7 ++++++-
 yum/__init__.py |   38 +++++++++++++++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/docs/yum.8 b/docs/yum.8
index 6761f1c..1089b7d 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -89,7 +89,9 @@ group of packages while ensuring that all dependencies are
 satisfied\&.  (See \fBSpecifying package names\fP for more information) 
 If no package matches the given package name(s), they are assumed to be a shell 
 glob and any matches are then installed\&. If the name starts with an 
-@ character the rest of the name is used as though passed to the groupinstall command\&. If the name is a file, then install works
+@ character the rest of the name is used as though passed to the groupinstall
+command\&. If the name starts with a - character, then a search is done within
+the transaction and any matches are removed. If the name is a file, then install works
 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
@@ -127,6 +129,9 @@ is done by either obsoleting, upgrading or downgrading as appropriate. This will
 "normally" do the same thing as the upgrade command however if you have the
 package FOO installed at version 4, and the latest available is only
 version 3, then this command will \fBdowngrade\fP FOO to version 3.
+
+This command does not perform operations on groups, local packages or negative
+selections.
 .IP 
 .IP "\fBremove\fP or \fBerase\fP"
 Are used to remove the specified packages from the system
diff --git a/yum/__init__.py b/yum/__init__.py
index 34f2de7..4fee2c7 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2663,7 +2663,9 @@ class YumBase(depsolve.Depsolve):
     def returnPackagesByDep(self, depstring):
         """Pass in a generic [build]require string and this function will 
            pass back the packages it finds providing that dep."""
-        
+
+        if not depstring:
+            return []
         results = self.pkgSack.searchProvides(depstring)
         return results
         
@@ -2693,6 +2695,9 @@ class YumBase(depsolve.Depsolve):
         """Pass in a generic [build]require string and this function will 
            pass back the installed packages it finds providing that dep."""
         
+        if not depstring:
+            return []
+
         # parse the string out
         #  either it is 'dep (some operator) e:v-r'
         #  or /file/dep
@@ -2866,6 +2871,17 @@ class YumBase(depsolve.Depsolve):
             pkgnames.update(thisgroup.packages)
         return self.pkgSack.searchNames(pkgnames)
 
+    def _minus_deselect(self, pattern):
+        """ Remove things from the transaction, like kickstart. """
+        assert pattern[0] == '-'
+        pat = pattern[1:]
+
+        if pat and pat[0] == '@':
+            pat = pat[1:]
+            return self.deselectGroup(pat)
+
+        return self.tsInfo.deselect(pat)
+
     def _find_obsoletees(self, po):
         """ Return the pkgs. that are obsoleted by the po we pass in. """
         if not isinstance(po, YumLocalPackage):
@@ -2906,7 +2922,10 @@ class YumBase(depsolve.Depsolve):
                 raise Errors.InstallError, _('Nothing specified to install')
 
             if 'pattern' in kwargs:
-                if kwargs['pattern'][0] == '@':
+                if kwargs['pattern'] and kwargs['pattern'][0] == '-':
+                    return self._minus_deselect(kwargs['pattern'])
+
+                if kwargs['pattern'] and kwargs['pattern'][0] == '@':
                     return self._at_groupinstall(kwargs['pattern'])
 
                 was_pattern = True
@@ -3218,7 +3237,10 @@ class YumBase(depsolve.Depsolve):
                 
                 
         elif 'pattern' in kwargs:
-            if kwargs['pattern'][0] == '@':
+            if kwargs['pattern'] and kwargs['pattern'][0] == '-':
+                return self._minus_deselect(kwargs['pattern'])
+
+            if kwargs['pattern'] and kwargs['pattern'][0] == '@':
                 return self._at_groupinstall(kwargs['pattern'])
 
             (e, m, u) = self.rpmdb.matchPackageNames([kwargs['pattern']])
@@ -3399,7 +3421,10 @@ class YumBase(depsolve.Depsolve):
             pkgs = [po]  
         else:
             if 'pattern' in kwargs:
-                if kwargs['pattern'][0] == '@':
+                if kwargs['pattern'] and kwargs['pattern'][0] == '-':
+                    return self._minus_deselect(kwargs['pattern'])
+
+                if kwargs['pattern'] and kwargs['pattern'][0] == '@':
                     return self._at_groupremove(kwargs['pattern'])
 
                 (e,m,u) = self.rpmdb.matchPackageNames([kwargs['pattern']])
@@ -3693,7 +3718,10 @@ class YumBase(depsolve.Depsolve):
         if po:
             apkgs = [po]
         elif 'pattern' in kwargs:
-            if kwargs['pattern'][0] == '@':
+            if kwargs['pattern'] and kwargs['pattern'][0] == '-':
+                return self._minus_deselect(kwargs['pattern'])
+
+            if kwargs['pattern'] and kwargs['pattern'][0] == '@':
                 apkgs = self._at_groupdowngrade(kwargs['pattern'])
                 doing_group_pkgs = True # Don't warn. about some things
             else:
-- 
1.6.6.1



More information about the Yum-devel mailing list