[yum-cvs] yum/yum comps.py,1.7,1.8 __init__.py,1.171,1.172

Jeremy Katz katzj at linux.duke.edu
Thu Jan 5 01:32:48 UTC 2006


Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv14945/yum

Modified Files:
	comps.py __init__.py 
Log Message:
* fix determination of package groups being installed to not require all the
  default packages to be there, just the mandatory
* add support for reverting a groupRemove (ie, a groupUnremove)


Index: comps.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/comps.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- comps.py	11 Dec 2005 00:38:38 -0000	1.7
+++ comps.py	5 Jan 2006 01:32:46 -0000	1.8
@@ -49,6 +49,7 @@
         self.groupid = None
         self.display_order = 1024
         self.installed = False
+        self.toremove = False
         
 
         if elem:
@@ -354,23 +355,27 @@
         
 
         for group in self.groups:
-            # if it has any mandatory or default packages in the group, then
-            # make sure they're all installed, if any are missing then
-            # the group is not installed.
-            if len(group.mandatory_packages.keys()) > 0 or len(group.default_packages.keys()) > 0:
-                check_pkgs = group.mandatory_packages.keys() + group.default_packages.keys()
+            # if there are mandatory packages in the group, then make sure
+            # they're all installed.  if any are missing, then the group
+            # isn't installed.
+            if len(group.mandatory_packages.keys()) > 0:
+                check_pkgs = group.mandatory_packages.keys()
                 group.installed = True
                 for pkgname in check_pkgs:
                     if not inst_pkg_names.has_key(pkgname):
                         group.installed = False
+                        break
             # if it doesn't have any of those then see if it has ANY of the
-            # optional packages installed. If so - then the group is installed
+            # optional/default packages installed.
+            # If so - then the group is installed
             else:
-                check_pkgs = group.optional_packages.keys()
+                check_pkgs = group.optional_packages.keys() + group.default_packages.keys()
                 group.installed = False
                 for pkgname in check_pkgs:
                     if inst_pkg_names.has_key(pkgname):
+                        print "%s is installed because of %s" %(group.name, pkgname)
                         group.installed = True
+                        break
         
         self.compiled = True
 

Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -r1.171 -r1.172
--- __init__.py	17 Dec 2005 04:02:59 -0000	1.171
+++ __init__.py	5 Jan 2006 01:32:46 -0000	1.172
@@ -1252,14 +1252,38 @@
         thisgroup = self.comps.return_group(grpid)
         if not thisgroup:
             raise Errors.GroupsError, "No Group named %s exists" % grpid
-            
+
+        thisgroup.toremove = True
         pkgs = thisgroup.packages
         for pkg in thisgroup.packages:
             txmbrs = self.remove(name=pkg)
             txmbrs_used.extend(txmbrs)
         
         return txmbrs_used
+
+    def groupUnremove(self, grpid):
+        """unmark any packages in the group from being removed"""
         
+        self.doGroupSetup()
+
+        thisgroup = self.comps.return_group(grpid)
+        if not thisgroup:
+            raise Errors.GroupsError, "No Group named %s exists" % grpid
+
+        thisgroup.toremove = False
+        pkgs = thisgroup.packages
+        for pkg in thisgroup.packages:
+            for txmbr in self.tsInfo:
+                if txmbr.po.name == pkg and txmbr.po.state in TS_INSTALL_STATES:
+                    try:
+                        txmbr.groups.remove(grpid)
+                    except ValueError:
+                        self.log(4, "package %s was not marked in group %s" % (po, grpid))
+                        continue
+                    
+                    # if there aren't any other groups mentioned then remove the pkg
+                    if len(txmbr.groups) == 0:
+                        self.tsInfo.remove(txmbr.po.pkgtup)
         
         
     def selectGroup(self, grpid):




More information about the Yum-cvs-commits mailing list