Jeremy Katz wrote:
We show groups that don't have any of their mandatory packages available
which is less than ideal as, eg, xfce-desktop gets shown just because
gdm is on the dvd. So make our filtering a little bit stronger.
And make sure that text mode is using the same filtering
Looks good,
Regards,
Hans
---
iw/GroupSelector.py | 23 +++--------------------
textw/grpselect_text.py | 2 ++
yuminstall.py | 29 +++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/iw/GroupSelector.py b/iw/GroupSelector.py
index 18df2ee..a8df9fa 100644
--- a/iw/GroupSelector.py
+++ b/iw/GroupSelector.py
@@ -120,28 +120,11 @@ def _selectPackage(ayum, group, pkg):
else:
map(lambda x: x.groups.append(grpid), txmbrs)
-def _groupHasPackages(grp, ayum):
- # this checks to see if the given group has any packages available
- # (ie, already installed or in the sack of available packages)
- # so that we don't show empty groups
- for p in grp.packages:
- try:
- pkgs = ayum.pkgSack.returnNewestByName(p)
- return True
- except yum.Errors.PackageSackError:
- pass
- try:
- pkgs = ayum.rpmdb.returnNewestByName(p)
- return True
- except (IndexError, yum.Errors.PackageSackError):
- pass
- return False
-
def _catHasGroupWithPackages(cat, ayum):
grps = map(lambda x: ayum.comps.return_group(x),
filter(lambda x: ayum.comps.has_group(x), cat.groups))
for g in grps:
- if _groupHasPackages(g, ayum):
+ if ayum._groupHasPackages(g):
return True
return False
@@ -373,7 +356,7 @@ class GroupSelector:
filter(lambda x: self.ayum.comps.has_group(x), groups))
grps.sort(ui_comps_sort)
for grp in grps:
- if not _groupHasPackages(grp, self.ayum):
+ if not self.ayum._groupHasPackages(grp):
continue
s = "<span size=\"large\" weight=\"bold\">%s</span>" % xmltrans(grp.name, grp.translated_name)
@@ -488,7 +471,7 @@ class GroupSelector:
# conceivably should be handled by yum
grps = {}
for g in self.ayum.comps.groups:
- if g.user_visible and _groupHasPackages(g, self.ayum):
+ if g.user_visible and self.ayum._groupHasPackages(g):
grps[g.groupid] = g
for cat in self.ayum.comps.categories:
diff --git a/textw/grpselect_text.py b/textw/grpselect_text.py
index ff4a402..fe98e37 100644
--- a/textw/grpselect_text.py
+++ b/textw/grpselect_text.py
@@ -75,6 +75,8 @@ class GroupSelectionWindow:
# FIXME: this is very yum backend specific...
groups = filter(lambda x: x.user_visible,
anaconda.backend.ayum.comps.groups)
+ groups = filter(lambda x: anaconda.backend.ayum.._groupHasPackages(x),
+ groups)
groups.sort(ui_comps_sort)
ct = CheckboxTree(height = 6, scroll = (len(groups) > 6))
for grp in groups:
diff --git a/yuminstall.py b/yuminstall.py
index 3cf5f95..8a56fcb 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -901,6 +901,35 @@ class AnacondaYum(YumSorter):
return True
return False
+ def _pkgExists(self, pkg):
+ """Whether or not a given package exists in our universe."""
+ try:
+ pkgs = self.pkgSack.returnNewestByName(pkg)
+ return True
+ except yum.Errors.PackageSackError:
+ pass
+ try:
+ pkgs = self.rpmdb.returnNewestByName(pkg)
+ return True
+ except (IndexError, yum.Errors.PackageSackError):
+ pass
+ return False
+
+ def _groupHasPackages(self, grp):
+ # this checks to see if the given group has any packages available
+ # (ie, already installed or in the sack of available packages)
+ # so that we don't show empty groups. also, if there are mandatory
+ # packages and we have none of them, don't show
+ for pkg in grp.mandatory_packages.keys():
+ if self._pkgExists(pkg):
+ return True
+ if len(grp.mandatory_packages) > 0:
+ return False
+ for pkg in grp.default_packages.keys() + grp.optional_packages.keys():
+ if self._pkgExists(pkg):
+ return True
+ return False
+
class YumBackend(AnacondaBackend):
def __init__ (self, anaconda):
AnacondaBackend.__init__(self, anaconda)
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list