[Fedora-livecd-list] [PATCH] Fix a bug with getting groups with options (@foo --optional).

Jesse Keating jkeating at redhat.com
Tue Oct 7 23:42:44 UTC 2008


New yum api (in 3.2.x) allows us to pass into selectGroups what set we
want from the group.  The default is mandatory and default.
Use that unless we have options from kickstart for either
optional packages (IE everything in the group) or just the
default packages of the group.

This also allows us to just get the right packages the first time
rather than getting packages and then pruning/adding as necessary.
Less trips through the yum stack, which is a good thing.
---
 imgcreate/yuminst.py |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/imgcreate/yuminst.py b/imgcreate/yuminst.py
index a7b04b6..b89a6ed 100644
--- a/imgcreate/yuminst.py
+++ b/imgcreate/yuminst.py
@@ -110,11 +110,14 @@ class LiveCDYum(yum.YumBase):
             logging.warn("No such package %s to remove" %(pkg,))
 
     def selectGroup(self, grp, include = pykickstart.parser.GROUP_DEFAULT):
-        yum.YumBase.selectGroup(self, grp)
+        # default to getting mandatory and default packages from a group
+        # unless we have specific options from kickstart
+        package_types = ['mandatory', 'default']
         if include == pykickstart.parser.GROUP_REQUIRED:
-            map(lambda p: self.deselectPackage(p), grp.default_packages.keys())
+            package_types.remove('default')
         elif include == pykickstart.parser.GROUP_ALL:
-            map(lambda p: self.selectPackage(p), grp.optional_packages.keys())
+            package_types.append('optional')
+        yum.YumBase.selectGroup(self, grp, group_package_types=package_types)
 
     def addRepository(self, name, url = None, mirrorlist = None):
         def _varSubstitute(option):
-- 
1.6.0.1




More information about the Fedora-livecd-list mailing list