(Apologies for the cross-post, but the patches go together.)
There have been multiple requests that environments in anaconda be able to be 'default-selected'. The general use cases are:
- to select the office suite by default when installing desktops, while allowing users to deselect it - to split some applications out of the desktop groups so users can choose to have a more minimal desktop installation, while remaining selected for the simple choice
These two patches implement it; first by allowing 'default=true' to be set for the group and parsed by the yum comps module, and then by changing anaconda to honor it.
Bill
(This depends on a yum.comps change to parse and store this attribute.) --- pyanaconda/packaging/yumpayload.py | 14 ++++++++++++++ pyanaconda/ui/gui/spokes/software.py | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py index de2c348..01bc80c 100644 --- a/pyanaconda/packaging/yumpayload.py +++ b/pyanaconda/packaging/yumpayload.py @@ -1023,6 +1023,20 @@ reposdir=%s return True return False
+ def environmentOptionIsDefault(self, environmentid, grpid): + groups = self._yumGroups + if not groups: + return False + + with _yum_lock: + if not groups.has_environment(environmentid): + raise NoSuchGroup(environmentid) + + environment = groups.return_environment(environmentid) + if grpid in environment.defaultoptions: + return True + return False + def environmentDescription(self, environmentid): """ Return name/description tuple for the environment specified by id. """ groups = self._yumGroups diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py index b409aea..8b7837b 100644 --- a/pyanaconda/ui/gui/spokes/software.py +++ b/pyanaconda/ui/gui/spokes/software.py @@ -76,6 +76,9 @@ class SoftwareSelectionSpoke(NormalSpoke): return
addons = self._get_selected_addons() + for group in addons: + if group not in self.selectedGroups: + self.selectedGroups.append(group)
self._selectFlag = False self.payload.data.packages.groupList = [] @@ -270,7 +273,11 @@ class SoftwareSelectionSpoke(NormalSpoke):
def _addAddon(self, grp): (name, desc) = self.payload.groupDescription(grp) - selected = grp in self.selectedGroups + # If no groups are selected, select the default groups + if not self._origEnvironment: + selected = self.payload.environmentOptionIsDefault(self.environment, grp) + else: + selected = grp in self.selectedGroups
self._addonStore.append([selected, "<b>%s</b>\n%s" % (name, desc), grp, False])
pyanaconda/packaging/yumpayload.py | 14 ++++++++++++++ pyanaconda/ui/gui/spokes/software.py | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
From an anaconda perspective, this looks fine. My only other suggestion would be to update the version of yum in anaconda.spec.in after you know which upstream version will include the yum patch.
- Chris
Chris Lumens (clumens@redhat.com) said:
pyanaconda/packaging/yumpayload.py | 14 ++++++++++++++ pyanaconda/ui/gui/spokes/software.py | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
From an anaconda perspective, this looks fine. My only other suggestion would be to update the version of yum in anaconda.spec.in after you know which upstream version will include the yum patch.
The yum version that contained the yum side of the changes is now in stable after the beta freeze. Still OK for F19 branch?
Bill
From an anaconda perspective, this looks fine. My only other suggestion would be to update the version of yum in anaconda.spec.in after you know which upstream version will include the yum patch.
The yum version that contained the yum side of the changes is now in stable after the beta freeze. Still OK for F19 branch?
Yes, I think it is fine.
One other thing I just came up with is that you ought to add environmentOptionIsDefault to pyanaconda/packaging/__init__.py as a stub, as well.
- Chris
--- yum/comps.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/yum/comps.py b/yum/comps.py index fe5649d..04e002a 100755 --- a/yum/comps.py +++ b/yum/comps.py @@ -295,6 +295,7 @@ class Environment(CompsObj): self.installed = False self._groups = {} self._options = {} + self._defaultoptions = {}
if elem: self.parse(elem) @@ -316,6 +317,11 @@ class Environment(CompsObj):
options = property(_optioniter)
+ def _defaultoptioniter(self): + return self._defaultoptions.keys() + + defaultoptions = property(_defaultoptioniter) + def parse(self, elem): for child in elem: if child.tag == 'id': @@ -366,6 +372,9 @@ class Environment(CompsObj): if child.tag == 'groupid': optionid = child.text self._options[optionid] = 1 + default = child.attrib.get('default') + if default: + self._defaultoptions[optionid] = 1
def add(self, obj): """Add another category object to this object""" @@ -373,6 +382,9 @@ class Environment(CompsObj): for grp in obj.groups: self._groups[grp] = 1
+ for grp in obj.defaultoptions: + self._defaultoptions[grp] = 1 + for grp in obj.options: self._options[grp] = 1
@@ -406,7 +418,10 @@ class Environment(CompsObj): msg += """ </grouplist>\n""" msg += """ <optionlist>\n""" for grp in self.options: - msg += """ <groupid>%s</groupid>\n""" % grp + if grp in self.defaultoptions: + msg += """ <groupid default="true">%s</groupid>\n""" % grp + else: + msg += """ <groupid>%s</groupid>\n""" % grp msg += """ </optionlist>\n""" msg += """ </environment>\n"""
On Tue, 2013-04-30 at 15:42 -0400, Bill Nottingham wrote:
yum/comps.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
It looks mostly fine, except:
diff --git a/yum/comps.py b/yum/comps.py index fe5649d..04e002a 100755 --- a/yum/comps.py +++ b/yum/comps.py @@ -366,6 +372,9 @@ class Environment(CompsObj): if child.tag == 'groupid': optionid = child.text self._options[optionid] = 1
default = child.attrib.get('default')
if default:
self._defaultoptions[optionid] = 1
[...]
def add(self, obj): """Add another category object to this object"""
@@ -406,7 +418,10 @@ class Environment(CompsObj): msg += """ </grouplist>\n""" msg += """ <optionlist>\n""" for grp in self.options:
msg += """ <groupid>%s</groupid>\n""" % grp
if grp in self.defaultoptions:
msg += """ <groupid default="true">%s</groupid>\n""" % grp
else:
msg += """ <groupid>%s</groupid>\n""" % grp
...it'd be better to have no argument on the attribute, or also parse out default="false" ... or someone is going to get confused at some point.
James Antill (james@fedoraproject.org) said:
On Tue, 2013-04-30 at 15:42 -0400, Bill Nottingham wrote:
yum/comps.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
It looks mostly fine, except:
diff --git a/yum/comps.py b/yum/comps.py index fe5649d..04e002a 100755 --- a/yum/comps.py +++ b/yum/comps.py @@ -366,6 +372,9 @@ class Environment(CompsObj): if child.tag == 'groupid': optionid = child.text self._options[optionid] = 1
default = child.attrib.get('default')
if default:
self._defaultoptions[optionid] = 1
[...]
Oof, right. Overassumption of boolean status here. How about the attached?
Bill
On Tue, 2013-04-30 at 17:21 -0400, Bill Nottingham wrote:
James Antill (james@fedoraproject.org) said:
On Tue, 2013-04-30 at 15:42 -0400, Bill Nottingham wrote:
yum/comps.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
It looks mostly fine, except:
diff --git a/yum/comps.py b/yum/comps.py index fe5649d..04e002a 100755 --- a/yum/comps.py +++ b/yum/comps.py @@ -366,6 +372,9 @@ class Environment(CompsObj): if child.tag == 'groupid': optionid = child.text self._options[optionid] = 1
default = child.attrib.get('default')
if default:
self._defaultoptions[optionid] = 1
[...]
Oof, right. Overassumption of boolean status here. How about the attached?
Yeh, looks fine to me. Pushed, and building -88 in rawhide.
James Antill (james@fedoraproject.org) said:
Yeh, looks fine to me. Pushed, and building -88 in rawhide.
Here's the fix I'm building as -89. Sorry about that.
Bill
anaconda-patches@lists.fedorahosted.org