[PATCH] Handle hd iso leavings by dracut (#876897)

Jesse Keating jkeating at redhat.com
Mon Nov 19 19:43:52 UTC 2012


Re-arranges a bit of code and handles dracut mounted hd isos.
Also handles a None type on self._currentIsoFile better.
---
 pyanaconda/packaging/yumpayload.py | 38 +++++++++++++++++++++++---------
 pyanaconda/ui/gui/spokes/source.py | 44 +++++++++++++++++++++++++++-----------
 2 files changed, 60 insertions(+), 22 deletions(-)

diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index b52fb67..6569110 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -497,8 +497,17 @@ reposdir=%s
 
     @property
     def ISOImage(self):
-        if self.data.method.method == "harddrive":
-            return get_mount_device(INSTALL_TREE)[len(ISO_DIR)+1:]
+        if not self.data.method.method == "harddrive":
+            return None
+        # This could either be mounted to INSTALL_TREE or on
+        # DRACUT_REPODIR if dracut did the mount.
+        dev = get_mount_device(INSTALL_TREE)
+        if dev:
+            return dev[len(ISO_DIR)+1:]
+        dev = get_mount_device(DRACUT_REPODIR)
+        if dev:
+            return dev[len(DRACUT_ISODIR)+1:]
+        return None
 
     def _setUpMedia(self, device):
         method = self.data.method
@@ -560,6 +569,9 @@ reposdir=%s
         method = self.data.method
         sslverify = True
         url = None
+        # See if we already have stuff mounted due to dracut
+        isodev = get_mount_device(DRACUT_ISODIR)
+        device = get_mount_device(DRACUT_REPODIR)
 
         if method.method == "harddrive":
             if method.biospart:
@@ -567,15 +579,21 @@ reposdir=%s
                 devspec = method.biospart
             else:
                 devspec = method.partition
-
-            device = storage.devicetree.resolveDevice(devspec)
-            self._setUpMedia(device)
-            self.install_device = device
-            url = "file://" + INSTALL_TREE
+                needmount = True
+                # See if we used this method for stage2, thus dracut left it
+                if isodev and method.partition and method.partition in isodev \
+                and DRACUT_ISODIR in device:
+                    # Everything should be setup
+                    url = "file://" + DRACUT_REPODIR
+                    needmount = False
+                    # We don't setup an install_device here
+                    # because we can't tear it down
+            isodevice = storage.devicetree.resolveDevice(devspec)
+            if needmount:
+                self._setUpMedia(isodevice)
+                url = "file://" + INSTALL_TREE
+                self.install_device = isodevice
         elif method.method == "nfs":
-            # See if we already have stuff mounted due to dracut
-            isodev = get_mount_device(DRACUT_ISODIR)
-            device = get_mount_device(DRACUT_REPODIR)
             # See if dracut dealt with nfsiso
             if isodev:
                 options, host, path = iutil.parseNfsUrl('nfs:%s' % isodev)
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index f570700..9551ace 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -41,12 +41,11 @@ from pyanaconda.ui.gui.utils import enlightbox, gtk_thread_wait
 from pyanaconda.iutil import ProxyString, ProxyStringError
 from pyanaconda.ui.gui.utils import gtk_call_once
 from pyanaconda.threads import threadMgr, AnacondaThread
-from pyanaconda.packaging import PayloadError
+from pyanaconda.packaging import PayloadError, get_mount_paths
+from pyanaconda.constants import DRACUT_ISODIR, ISO_DIR
 
 __all__ = ["SourceSpoke"]
 
-MOUNTPOINT = "/mnt/install/isodir"
-
 BASEREPO_SETUP_MESSAGE = N_("Setting up installation source...")
 METADATA_DOWNLOAD_MESSAGE = N_("Downloading package metadata...")
 METADATA_ERROR_MESSAGE = N_("Error downloading package metadata...")
@@ -208,20 +207,28 @@ class IsoChooser(GUIObject):
         GUIObject.refresh(self)
         self._chooser = self.builder.get_object("isoChooser")
         self._chooser.connect("current-folder-changed", self.on_folder_changed)
-        self._chooser.set_filename(MOUNTPOINT + "/" + currentFile)
+        self._chooser.set_filename(ISO_DIR + "/" + currentFile)
 
     def run(self, dev):
         retval = None
 
+        import pdb
+        pdb.set_trace()
         unmount = not dev.format.status
-        dev.format.mount(mountpoint=MOUNTPOINT)
+        mounts = get_mount_paths(dev.path)
+        # We have to check both ISO_DIR and the DRACUT_ISODIR because we
+        # still reference both, even though /mnt/install is a symlink to
+        # /run/install.  Finding mount points doesn't handle the symlink
+        if ISO_DIR not in mounts and DRACUT_ISODIR not in mounts:
+            # We're not mounted to either location, so do the mount
+            dev.format.mount(mountpoint=ISO_DIR)
 
         # If any directory was chosen, return that.  Otherwise, return None.
         rc = self.window.run()
         if rc:
             f = self._chooser.get_filename()
             if f:
-                retval = f.replace(MOUNTPOINT, "")
+                retval = f.replace(ISO_DIR, "")
 
         if unmount:
             dev.format.unmount()
@@ -238,8 +245,8 @@ class IsoChooser(GUIObject):
         if not d:
             return
 
-        if not d.startswith(MOUNTPOINT):
-            chooser.set_current_folder(MOUNTPOINT)
+        if not d.startswith(ISO_DIR):
+            chooser.set_current_folder(ISO_DIR)
 
 class AdditionalReposDialog(GUIObject):
     builderObjects = ["additionalReposDialog", "peopleRepositories", "peopleRepositoriesFilter"]
@@ -579,6 +586,8 @@ class SourceSpoke(NormalSpoke):
         elif self.data.method.method == "cdrom":
             return _("CD/DVD drive")
         elif self.data.method.method == "harddrive":
+            if not self._currentIsoFile:
+                return _("Error setting up software source")
             return os.path.basename(self._currentIsoFile)
         elif self.payload.baseRepo:
             return _("Closest mirror")
@@ -646,7 +655,7 @@ class SourceSpoke(NormalSpoke):
             cdrom = self.payload.install_device
             chosen = True
         else:
-            cdrom = opticalInstallMedia(self.storage.devicetree, mountpoint=MOUNTPOINT)
+            cdrom = opticalInstallMedia(self.storage.devicetree)
 
         if cdrom:
             @gtk_thread_wait
@@ -737,8 +746,13 @@ class SourceSpoke(NormalSpoke):
             self.builder.get_object("nfsOptsEntry").set_text(self.data.method.opts or "")
         elif self.data.method.method == "harddrive":
             self._isoButton.set_active(True)
+            self._isoBox.set_sensitive(True)
+            self._verifyIsoButton.set_sensitive(True)
 
-            self._isoChooserButton.set_label(os.path.basename(self._currentIsoFile))
+            if self._currentIsoFile:
+                self._isoChooserButton.set_label(os.path.basename(self._currentIsoFile))
+            else:
+                self._isoChooserButton.set_label("")
             self._isoChooserButton.set_use_underline(False)
         else:
             # No method was given in advance, so now we need to make a sensible
@@ -837,8 +851,14 @@ class SourceSpoke(NormalSpoke):
         dialog = MediaCheckDialog(self.data)
         with enlightbox(self.window, dialog.window):
             unmount = not p.format.status
-            p.format.mount(mountpoint=MOUNTPOINT)
-            dialog.run(MOUNTPOINT + "/" + f)
+            mounts = get_mount_paths(p.path)
+            # We have to check both ISO_DIR and the DRACUT_ISODIR because we
+            # still reference both, even though /mnt/install is a symlink to
+            # /run/install.  Finding mount points doesn't handle the symlink
+            if ISO_DIR not in mounts and DRACUT_ISODIR not in mounts:
+                # We're not mounted to either location, so do the mount
+                p.format.mount(mountpoint=ISO_DIR)
+            dialog.run(ISO_DIR + "/" + f)
             if unmount:
                 p.format.unmount()
 
-- 
1.8.0



More information about the anaconda-patches mailing list