[PATCH 4/7] Generate an installer yum config for package install.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have to switch yum over from the configuration-time installroot to
the install-time installroot. This, of course, is not as simple as
changing an attribute of the YumBase instance. Instead, it requires
that we create a new instance of YumBase with the new configuration.
Instead of calling updateBaseRepo again to start from scratch and try
to establish an install-time repo set like we do during configuration,
write out the configuration we want for install time based on what
was configured and then tell the install-time YumBase to use it.
---
 pyanaconda/constants.py            |    2 +-
 pyanaconda/install.py              |    2 +-
 pyanaconda/packaging/__init__.py   |    2 +-
 pyanaconda/packaging/yumpayload.py |   43 +++++++++++++++++++++++++++++++++--
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index 6757a87..822427b 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -74,4 +74,4 @@ ROOT_PATH = "/mnt/sysimage"
 MOUNT_DIR = "/mnt/install"
 ISO_DIR = MOUNT_DIR + "/isodir"
 INSTALL_TREE = MOUNT_DIR + "/source"
-BASE_REPO_NAME = "Installation Repo"
+BASE_REPO_NAME = "anaconda"
diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index 6951c51..11dcb47 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -48,7 +48,7 @@ def doInstall(storage, payload, ksdata, instClass):
     turnOnFilesystems(storage, errorHandler)
 
     # Do packaging.
-    payload.preInstall(storage)
+    payload.preInstall()
     payload.install()
     payload.postInstall()
 
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index bc4b792..1a2fc06 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -426,7 +426,7 @@ class Payload(object):
     ###
     ### METHODS FOR INSTALLING THE PAYLOAD
     ###
-    def preInstall(self, storage):
+    def preInstall(self):
         """ Perform pre-installation tasks. """
         # XXX this should be handled already
         iutil.mkdirChain(ROOT_PATH + "/root")
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index bd6efe4..2292cc3 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -197,6 +197,43 @@ reposdir=%s
         root = self._yum.conf.installroot
         self._yum.conf.cachedir = self._yum.conf.cachedir[len(root):]
 
+    def _writeInstallConfig(self):
+        """ Write out the yum config that will be used to install packages.
+
+            Write out repo config files for all enabled repos, then
+            create a new YumBase instance with the new filesystem tree as its
+            install root.
+        """
+        self._repos_dir = "/tmp/yum.repos.d"
+        if not os.path.isdir(self._repos_dir):
+            os.mkdir(self._repos_dir)
+
+        for repo in self._yum.repos.listEnabled():
+            cfg_path = "%s/%s.repo" % (self._repos_dir, repo.id)
+            with open(cfg_path, "w") as f:
+                f.write("[%s]\n" % repo.id)
+                f.write("name=Install - %s\n" % repo.id)
+                f.write("enabled=1\n")
+                if repo.baseurl:
+                    f.write("baseurl=%s\n" % repo.baseurl[0])
+                elif repo.mirrorlist:
+                    f.write("mirrorlist=%s" % repo.mirrorlist)
+                else:
+                    log.error("repo %s has no baseurl or mirrorlist" % repo.id)
+                    f.close()
+                    os.unlink(cfg_path)
+                    continue
+
+        self._writeYumConfig()
+        self._resetYum(root=ROOT_PATH)
+
+        self._yumCacheDirHack()
+        self._yum.repos.populateSack(which='enabled', mdtype='all')
+
+        # trigger setup of self._yum.config
+        log.debug("installation yum config repos: %s"
+                  % ",".join([r.id for r in self._yum.repos.listEnabled()]))
+
     def release(self):
         self._yum.close()
 
@@ -767,11 +804,11 @@ reposdir=%s
 
             self._removeTxSaveFile()
 
-    def preInstall(self, storage):
+    def preInstall(self):
         """ Perform pre-installation tasks. """
-        super(YumPayload, self).preInstall(storage)
+        super(YumPayload, self).preInstall()
 
-        self.updateBaseRepo(None, root=ROOT_PATH)
+        self._writeInstallConfig()
         self.checkSoftwareSelection()
         log.info("about to install %d packages totalling %s"
                  % (len(self._yum.tsInfo.getMembers()), self.spaceRequired))
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux