[master 1/1] Set the GUI-selected environment in the ksdata (#1192100)

dashea installerbot-noreply at redhat.com
Wed May 6 18:16:13 UTC 2015


From: David Shea <dshea at 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.

PackagePayload.selectEnvironment now only sets the environment in the
ksdata and does not modify the group lists. The PackagePayload
implementations must instead apply the ksdata environment to the
internal package selections when ksdata selections are applied.
---
 pyanaconda/packaging/__init__.py   |  7 ++-----
 pyanaconda/packaging/dnfpayload.py |  9 ++++++++-
 pyanaconda/packaging/yumpayload.py | 14 +++++++++++++-
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index ba2a181..13672cb 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -1032,14 +1032,11 @@ 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 = []
 
-        # Select each group within the environment, as long as that group was
-        # not explicitly excluded by the user.
-        for groupid in set(self.environmentGroups(environmentid, optional=False)) - set(excluded):
-            self.selectGroup(groupid)
-
     def environmentGroups(self, environmentid, optional=True):
         raise NotImplementedError()
 
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index c102687..1d94030 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -292,7 +292,7 @@ def _apply_selections(self):
 
         if env:
             try:
-                self.selectEnvironment(env, excludedGroups)
+                self._select_environment(env, excludedGroups)
                 log.info("selected env: %s", env)
             except packaging.NoSuchGroup as e:
                 self._miss(e)
@@ -444,6 +444,13 @@ 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, excluded):
+        # dnf.base.environment_install excludes on packages instead of groups,
+        # which is unhelpful. Instead, use group_install for each group in
+        # the environment so we can skip the ones that are excluded.
+        for groupid in set(self.environmentGroups(env_id, optional=False)) - set(excluded):
+            self._select_group(groupid)
+
     def _select_kernel_package(self):
         kernels = self.kernelPackages
         for kernel in kernels:
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index aa9019f..06382a1 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -1092,6 +1092,18 @@ def _selectYumGroup(self, groupid, default=True, optional=False, required=False)
             except yum.Errors.GroupsError:
                 raise NoSuchGroup(groupid, required=required)
 
+    def _selectYumEnvironment(self, envid):
+        # select the environment in comps
+        pkg_types = ['mandatory', 'default']
+
+        log.debug("select environment %s", envid)
+
+        with _yum_lock:
+            try:
+                self._yum.selectEnvironment(envid, pkg_types)
+            except yum.Errors.GroupsError:
+                raise NoSuchGroup(envid, required=False)
+
     def _deselectYumGroup(self, groupid):
         # deselect the group in comps
         log.debug("deselect group %s", groupid)
@@ -1214,7 +1226,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/b36778313afbd40126575992d1bb7deaf8a52293


More information about the anaconda-patches mailing list