From: David Shea <dshea(a)redhat.com>
This way an environment selected in the GUI and an environment selected
in kickstart are treated in the same way. This fixes the problem where
changing payloads forgets the previous environment selection, and it
changes the generated %packages section of anaconda-ks.cfg to contain
the environment information instead of a list of the groups in the
environment.
This commit restores the dnf _select_environment method removed in
602f47dcd5d7543f66dc6833685d0e810595acb5, but modifies it so that the
environment is both selected in dnf and in the kickstart data.
---
pyanaconda/packaging/__init__.py | 8 +++++++-
pyanaconda/packaging/dnfpayload.py | 20 ++++++++++++++++++++
pyanaconda/packaging/yumpayload.py | 19 ++++++++++++++++++-
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index ba2a181..5e67140 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -290,7 +290,11 @@ def selectGroup(self, groupid, default=True, optional=False):
if grp in self.data.packages.excludedGroupList:
self.data.packages.excludedGroupList.remove(grp)
- self.data.packages.groupList.append(grp)
+ # If the group is part of the environment, no need to duplicate it in
+ # the group list
+ if self.data.packages.environment and \
+ groupid not in self.environmentGroups(self.data.packages.environment):
+ self.data.packages.groupList.append(grp)
def deselectGroup(self, groupid):
grp = Group(groupid)
@@ -1032,6 +1036,8 @@ def selectEnvironment(self, environmentid, excluded=None):
if environmentid not in self.environments:
raise NoSuchGroup(environmentid)
+ self.data.packages.environment = environmentid
+
if excluded is None:
excluded = []
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index 097d76e..fd1b99e 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -431,6 +431,22 @@ def _select_group(self, group_id, default=True, optional=False,
required=False):
# DNF raises this when it is already selected
log.debug(e)
+ def _select_environment(self, env_id, default=True, optional=False, required=False):
+ env = self._base.comps.environment_by_pattern(env_id)
+ if env is None:
+ raise packaging.NoSuchGroup(env_id, required=required)
+ types = {'mandatory'}
+ if default:
+ types.add('default')
+ if optional:
+ types.add('optional')
+ exclude = self.data.packages.excludedList
+ try:
+ self._base.environment_install(env, types, exclude=exclude)
+ except dnf.exceptions.CompsError as e:
+ # DNF raises this when it is already selected
+ log.debug(e)
+
def _select_kernel_package(self):
kernels = self.kernelPackages
for kernel in kernels:
@@ -678,6 +694,10 @@ def reset(self):
self.txID = None
self._base.reset(sack=True, repos=True)
+ def selectEnvironment(self, env_id, excluded=None):
+ super(DNFPayload, self).selectEnvironment(env_id, excluded)
+ self._select_environment(env_id)
+
def updateBaseRepo(self, fallback=True, checkmount=True):
log.info('configuring base repo')
self.reset()
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index aa9019f..03783a6 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -1092,6 +1092,23 @@ def _selectYumGroup(self, groupid, default=True, optional=False,
required=False)
except yum.Errors.GroupsError:
raise NoSuchGroup(groupid, required=required)
+ def _selectYumEnvironment(self, envid, default=True, optional=False,
required=False):
+ # select the environment in comps
+ pkg_types = ['mandatory']
+ if default:
+ pkg_types.append("default")
+
+ if optional:
+ pkg_types.append("optional")
+
+ log.debug("select environment %s", envid)
+
+ with _yum_lock:
+ try:
+ self._yum.selectEnvironment(envid, pkg_types)
+ except yum.Errors.GroupsError:
+ raise NoSuchGroup(envid, required=required)
+
def _deselectYumGroup(self, groupid):
# deselect the group in comps
log.debug("deselect group %s", groupid)
@@ -1214,7 +1231,7 @@ def _applyYumSelections(self):
if env:
try:
- self.selectEnvironment(env)
+ self._selectYumEnvironment(env)
except NoSuchGroup as e:
self._handleMissing(e)
--
To view this commit on github, visit
https://github.com/rhinstaller/anaconda/commit/9c9e899e30ba62ceed6a173351...