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

Chris Lumens clumens at redhat.com
Thu Jan 8 16:58:37 UTC 2015


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()
 
         for ksrepo in self.data.repo.dataList():
-            self._add_repo(ksrepo)
+            # This is a repo we already have a config file in /etc/anaconda.repos.d,
+            # so we just need to enable it here.  See the kickstart docs for the repo
+            # command.
+            if not ksrepo.baseurl and not ksrepo.mirrorlist:
+                self._base.repos[ksrepo.name].enable()
+            else:
+                self._add_repo(ksrepo)
 
         ksnames = [r.name for r in self.data.repo.dataList()]
         ksnames.append(constants.BASE_REPO_NAME)
-- 
1.9.3



More information about the anaconda-patches mailing list