[PATCH 1/2] Allow specifying pre-defined repos via kickstart with dnf backend (#1177988).

David Shea dshea at redhat.com
Thu Jan 8 20:36:09 UTC 2015


On 01/08/2015 11:58 AM, Chris Lumens wrote:
> This is the thing where your kickstart can say:
>
>      repo --name=updates
>
> and anaconda will figure out that you want to use the repo already defined in
> /etc/anaconda.repos.d.  It works with yum, so it also need to work with dnf.
> ---
>   pyanaconda/packaging/dnfpayload.py | 28 +++++++++++++++++++++-------
>   1 file changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
> index 7a91c26..fab258f 100644
> --- a/pyanaconda/packaging/dnfpayload.py
> +++ b/pyanaconda/packaging/dnfpayload.py
> @@ -691,6 +691,16 @@ class DNFPayload(packaging.PackagePayload):
>                                                                 checkmount)
>           method = self.data.method
>   
> +        # Read in all the repos from the installation environment, make a note of which
> +        # are enabled, and then disable them all.  If the user gave us a method, we want
> +        # to use that instead of the default repos.
> +        self._base.read_all_repos()
> +
> +        enabled = []
> +        for repo in self._base.repos.iter_enabled():
> +            enabled.append(repo.name)
> +            repo.disable()
> +
>           if method.method:
>               try:
>                   self._base.conf.releasever = self._getReleaseVersion(url)
> @@ -716,15 +726,19 @@ class DNFPayload(packaging.PackagePayload):
>                   # this preserves the method details while disabling it
>                   method.method = None
>                   self.install_device = None
> -
> -        if not method.method:
> -            # only when there's no repo set via method use the repos from the
> -            # install image itself:
> -            log.info('Loading repositories config on the filesystem.')
> -            self._base.read_all_repos()
> +        else:
> +            for (name, repo) in self._base.repos.iteritems():
> +                if name in enabled:
> +                    repo.enable()

This breaks the closest mirror method, since closest mirror works by 
unsetting ksdata.method.method.


More information about the anaconda-patches mailing list