[PATCH] Only check media if we really want it (#853404)

Jesse Keating jkeating at redhat.com
Thu Sep 6 00:09:35 UTC 2012


This provides a way to opt-out of the check for existing mounted media.
If a user has gone into the source spoke and picked a mirror, we
shouldn't ignore that choice by checking for valid mounted media.

In the case of a network stage2 that has a valid repo, we'll find that
when the hub / spokes are initialized.  If a user visits the source
spoke and just clicks back (leaving autodetect selected, but no media)
we just return from apply() so that initial discovery of working stage2
should remain.
---
 pyanaconda/packaging/yumpayload.py | 12 ++++++++----
 pyanaconda/ui/gui/spokes/source.py |  3 ++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 0d8e5cf..7352ae0 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -344,40 +344,41 @@ reposdir=%s
         repo_names = [BASE_REPO_NAME] + default_repos
         base_repo_name = None
         for repo_name in repo_names:
             if repo_name in self.repos and \
                self._yum.repos.getRepo(repo_name).enabled:
                 base_repo_name = repo_name
                 break
 
         return base_repo_name
 
-    def updateBaseRepo(self, storage, fallback=True, root=None):
+    def updateBaseRepo(self, storage, fallback=True, root=None,
+                       checkmount=True):
         """ Update the base repo based on self.data.method.
 
             - Tear down any previous base repo devices, symlinks, &c.
             - Reset the YumBase instance.
             - Try to convert the new method to a base repo.
             - If that fails, we'll use whatever repos yum finds in the config.
             - Set up addon repos.
             - Filter out repos that don't make sense to have around.
             - Get metadata for all enabled repos, disabling those for which the
               retrieval fails.
         """
         log.info("updating base repo")
 
         # start with a fresh YumBase instance
         self.reset(root=root)
 
         # see if we can get a usable base repo from self.data.method
         try:
-            self._configureBaseRepo(storage)
+            self._configureBaseRepo(storage, checkmount=checkmount)
         except PayloadError as e:
             if not fallback:
                 for repo in self._yum.repos.repos.values():
                     if repo.enabled:
                         self.disableRepo(repo.id)
                 raise
 
             # this preserves the method details while disabling it
             self.data.method.method = None
             self.install_device = None
@@ -492,28 +493,31 @@ reposdir=%s
                 while method.dir.startswith("/"):
                     # riduculous
                     method.dir = method.dir[1:]
         # Check to see if the device is already mounted, in which case
         # we don't need to mount it again
         elif method.method == "cdrom" and get_mount_paths(device.path):
                 return
         else:
             device.format.setup(mountpoint=INSTALL_TREE)
 
-    def _configureBaseRepo(self, storage):
+    def _configureBaseRepo(self, storage, checkmount=True):
         """ Configure the base repo.
 
             If self.data.method.method is set, failure to configure a base repo
             should generate a PayloadError exception.
 
             If self.data.method.method is unset, no exception should be raised
             and no repo should be configured.
+
+            If checkmount is true, check the dracut mount to see if we have
+            usable media mounted.
         """
         log.info("configuring base repo")
         # set up the main repo specified by method=, repo=, or ks method
         # XXX FIXME: does this need to handle whatever was set up by dracut?
         # XXX FIXME: most of this probably belongs up in Payload
         method = self.data.method
         sslverify = True
         url = None
 
         if method.method == "harddrive":
@@ -549,21 +553,21 @@ reposdir=%s
                                        ["--move", INSTALL_TREE, ISO_DIR],
                                        stderr="/dev/tty5", stdout="/dev/tty5")
                 # mount the ISO on a loop
                 image = os.path.normpath("%s/%s" % (ISO_DIR, image))
                 mountImage(image, INSTALL_TREE)
 
             url = "file://" + INSTALL_TREE
         elif method.method == "url":
             url = method.url
             sslverify = not (method.noverifyssl or flags.noverifyssl)
-        elif method.method == "cdrom" or not method.method:
+        elif method.method == "cdrom" or (checkmount and not method.method):
             # Did dracut leave the DVD mounted for us?
             device = get_mount_device("/run/install/repo")
             # Only look at the dracut mount if we don't already have a cdrom
             if device and not self.install_device:
                 self.install_device = storage.devicetree.getDeviceByPath(device)
                 url = "file:///run/install/repo"
                 if not method.method:
                     method.method = "cdrom"
             else:
                 # cdrom or no method specified -- check for media
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index 5010216..e9946a5 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -499,21 +499,22 @@ class SourceSpoke(NormalSpoke):
             self.data.method.opts = self.builder.get_object("nfsOptsEntry").get_text() or ""
 
             if (old_source.method == "nfs" and
                 old_source.server == self.data.method.server and
                 old_source.dir == self.data.method.dir and
                 old_source.opts == self.data.method.opts):
                 return
 
         communication.send_not_ready("SoftwareSelectionSpoke")
         try:
-            self.payload.updateBaseRepo(self.storage, fallback=False)
+            self.payload.updateBaseRepo(self.storage, fallback=False,
+                                        checkmount=False)
         except PayloadError as e:
             log.error("PayloadError: %s" % (e,))
             self._error = True
             communication.send_message(self.__class__.__name__,
                                        _("Failed to set up install source"))
             if not self.data.method.proxy:
                 self.window.set_info(Gtk.MessageType.WARNING, _("Failed to set up install source, check the repo url"))
             else:
                 self.window.set_info(Gtk.MessageType.WARNING, _("Failed to set up install source, check the repo url and proxy settings"))
         else:
-- 
1.7.11.4



More information about the anaconda-patches mailing list