[PATCH rhel7-branch] Allow specifying an environment in the kickstart file (#1050994).
Vratislav Podzimek
vpodzime at redhat.com
Tue Feb 4 07:55:18 UTC 2014
On Mon, 2014-02-03 at 16:01 -0500, Chris Lumens wrote:
> This is done without introducing any new kickstart syntax. We just check all
> the groups listed and if any is an environment, select it. This should work
> for deselecting environments too.
> ---
> pyanaconda/packaging/yumpayload.py | 38 ++++++++++++++++++++++++++++++++----
> pyanaconda/ui/gui/spokes/software.py | 10 +++++++++-
> 2 files changed, 43 insertions(+), 5 deletions(-)
>
> diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
> index 4b4a226..0cf380b 100644
> --- a/pyanaconda/packaging/yumpayload.py
> +++ b/pyanaconda/packaging/yumpayload.py
> @@ -1365,8 +1365,20 @@ reposdir=%s
> """
> self._selectYumGroup("core")
>
> - if self.data.packages.default and self.environments:
> - self.selectEnvironment(self.environments[0])
> + foundEnv = None
> +
> + if self.environments:
> + if self.data.packages.default:
> + self.selectEnvironment(self.environments[0])
> + else:
> + # Look through all groups listed in the kickstart file. If one
> + # is an environment, select it now and then mark which one it is
> + # so we don't later try to select it as a group, too.
> + for (ndx, grp) in enumerate(self.data.packages.groupList):
> + if grp.name in self.environments:
> + self.selectEnvironment(grp.name)
> + foundEnv = ndx
> + break
>
> for package in self.data.packages.packageList:
> try:
> @@ -1374,7 +1386,11 @@ reposdir=%s
> except NoSuchPackage as e:
> self._handleMissing(e)
>
> - for group in self.data.packages.groupList:
> + for (ndx, group) in enumerate(self.data.packages.groupList):
> + # Skip any previously selected environment.
> + if ndx == foundEnv:
> + continue
> +
> default = False
> optional = False
> if group.include == GROUP_DEFAULT:
> @@ -1394,7 +1410,21 @@ reposdir=%s
> except NoSuchPackage as e:
> self._handleMissing(e)
>
> - for group in self.data.packages.excludedGroupList:
> + # And then do the same thing for removing environments as we did for
> + # adding them earlier.
> + foundEnv = None
> + if self.environments:
> + for (ndx, grp) in enumerate(self.data.packages.excludedGroupList):
> + if grp.name in self.environments:
> + self.deselectEnvironment(grp.name)
> + foundEnv = ndx
> + break
> +
> + for (ndx, group) in enumerate(self.data.packages.excludedGroupList):
> + # Skip any previously selected environment.
> + if ndx == foundEnv:
> + continue
> +
> try:
> self._deselectYumGroup(group.name)
> except NoSuchGroup as e:
> diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
> index 1f92e3d..b35c5a0 100644
> --- a/pyanaconda/ui/gui/spokes/software.py
> +++ b/pyanaconda/ui/gui/spokes/software.py
> @@ -250,8 +250,16 @@ class SoftwareSelectionSpoke(NormalSpoke):
>
> self._environmentStore = self.builder.get_object("environmentStore")
> self._environmentStore.clear()
> +
> + # If we don't know what the environment is, perhaps it's listed in the
> + # kickstart file. Look in there to see.
> if self.environment not in self.payload.environments:
> - self.environment = None
> + for grp in self.data.packages.groupList:
> + if grp.name in self.payload.environments:
> + self.environment = grp.name
> + break
> + else:
> + self.environment = None
>
> clasess = []
> firstEnvironment = True
I think there should be a function like find_environment(environments,
groups) returning the environment and its index or (None, None). It
could be used in three places in this patch.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list