[PATCH] Allow a .iso file to be specified instead of a directory (#707846)

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

 



Add the ability to specify a full path to the .iso to be mounted instead
of just the path to a directory with the single iso in it.

This also changes findFirstIsoImage to return the full path instead of
just the filename.

Resolves: rhbz#707846
---
 pyanaconda/image.py |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/pyanaconda/image.py b/pyanaconda/image.py
index ed74976..701fc92 100644
--- a/pyanaconda/image.py
+++ b/pyanaconda/image.py
@@ -30,10 +30,21 @@ log = logging.getLogger("anaconda")
 _arch = iutil.getArch()
 
 def findFirstIsoImage(path, messageWindow):
+    """
+    Find the first iso image in path
+    This also supports specifying a specific .iso image
+
+    Returns the full path to the image
+    """
     flush = os.stat(path)
-    files = os.listdir(path)
     arch = _arch
 
+    if os.path.isfile(path) and path.endswith(".iso"):
+        files = [os.path.basename(path)]
+        path = os.path.dirname(path)
+    else:
+        files = os.listdir(path)
+
     for file in files:
         what = path + '/' + file
         log.debug("Checking %s" % (what))
@@ -86,7 +97,7 @@ def findFirstIsoImage(path, messageWindow):
 
                 log.info("Found disc at %s" % file)
                 isys.umount("/mnt/cdimage", removeDir=False)
-                return file
+                return what
         except SystemError:
             pass
 
@@ -105,6 +116,10 @@ def getMediaId(path):
 # This mounts the directory containing the iso images, and places the
 # mount point in /mnt/isodir.
 def mountDirectory(methodstr, messageWindow):
+    # No need to mount it again.
+    if os.path.ismount("/mnt/isodir"):
+        return
+
     if methodstr.startswith("hd:"):
         method = methodstr[3:]
         options = ''
@@ -119,15 +134,13 @@ def mountDirectory(methodstr, messageWindow):
             device = "/dev/%s" % device
     elif methodstr.startswith("nfsiso:"):
         (options, host, path) = iutil.parseNfsUrl(methodstr)
+        if path.endswith(".iso"):
+            path = os.path.dirname(path)
         device = "%s:%s" % (host, path)
         fstype = "nfs"
     else:
         return
 
-    # No need to mount it again.
-    if os.path.ismount("/mnt/isodir"):
-        return
-
     while True:
         try:
             isys.mount(device, "/mnt/isodir", fstype=fstype, options=options)
@@ -157,8 +170,7 @@ def mountImage(isodir, tree, messageWindow):
 
     while True:
         try:
-            isoImage = "%s/%s" % (isodir, image)
-            isys.mount(isoImage, tree, fstype = 'iso9660', readOnly = True)
+            isys.mount(image, tree, fstype = 'iso9660', readOnly = True)
             break
         except:
             ans = messageWindow(_("Missing ISO 9660 Image"),
-- 
1.7.4.4

_______________________________________________
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