[gnome-boxes] iso-extractor: Don't use fuseiso



commit e0d170caef7d4b7bad574a8f4ee97a89c29089d2
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Dec 11 16:14:08 2013 +0000

    iso-extractor: Don't use fuseiso
    
    Instead of using unmaintained fuseiso for extracting files from ISOs,
    use iso-read command instead. This also saves us from having to mount
    and unmount the ISO.
    
    This implies that we now depend on libcdio[1]. The library itself is
    GPLv3 so we can't link to it from our LGPLv2 app so we launch an external
    utility provided (iso-read) by this library to avoid licensing issues.
    
    [1] http://www.gnu.org/software/libcdio/

 src/iso-extractor.vala        |   39 ++++-----------------------------------
 src/unattended-installer.vala |   13 +++----------
 2 files changed, 7 insertions(+), 45 deletions(-)
---
diff --git a/src/iso-extractor.vala b/src/iso-extractor.vala
index 56ca565..9682eeb 100644
--- a/src/iso-extractor.vala
+++ b/src/iso-extractor.vala
@@ -3,46 +3,15 @@
 // Helper class to extract files from an ISO image
 private class Boxes.ISOExtractor: GLib.Object {
     private string device_file;
-    private string mount_point;
-    private bool mounted;
 
     public ISOExtractor (string iso_path) {
         this.device_file = iso_path;
     }
 
-    ~ISOExtractor () {
-        if (!mounted)
-            return;
-
-        debug ("Unmounting '%s'..", mount_point);
-        string[] argv = { "fusermount", "-u", mount_point };
-        exec.begin (argv, null);
-        debug ("Unmounted '%s'.", mount_point);
-    }
-
-    public async void mount_media (Cancellable? cancellable) throws GLib.Error {
-        if (mounted)
-            return;
-
-        string iso_name = File.new_for_path (device_file).get_basename ();
-
-        string temp_name = get_user_pkgcache (iso_name + "-XXXXXX");
-        string? mount_point = GLib.DirUtils.mkdtemp (temp_name);
-        if (mount_point == null)
-            throw (GLib.IOError) new GLib.Error (G_IO_ERROR, g_io_error_from_errno (errno), "Failed to 
create temporary mountpoint %s", temp_name);
-        this.mount_point = mount_point;
-
-        debug ("Mounting '%s' on '%s'..", device_file, mount_point);
-        // the -p option tells fuseiso to rmdir the mountpoint on unmount
-        string[] argv = { "fuseiso", "-p", device_file, mount_point };
+    public async void extract (string path, string output_path, Cancellable? cancellable) throws GLib.Error {
+        debug ("Extracting '%s' from '%s' at path '%s'..", path, device_file, output_path);
+        string[] argv = { "iso-read", "-i", device_file, "-e", path, "-o", output_path };
         yield exec (argv, cancellable);
-        debug ("'%s' now mounted on '%s'.", device_file, mount_point);
-
-        mounted = true;
-    }
-
-    public string get_absolute_path (string relative_path) throws GLib.Error
-                                     requires (mounted) {
-        return Path.build_filename (mount_point, relative_path);
+        debug ("Extracted '%s' from '%s' at path '%s'.", path, device_file, output_path);
     }
 }
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index c6a79a1..d7abaac 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -197,8 +197,6 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
             if (os_media.kernel_path != null && os_media.initrd_path != null) {
                 var extractor = new ISOExtractor (device_file);
 
-                yield extractor.mount_media (cancellable);
-
                 yield extract_boot_files (extractor, cancellable);
             }
         } catch (GLib.Error error) {
@@ -663,14 +661,9 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
         }
     }
 
-    private async void extract_boot_files (ISOExtractor extractor, Cancellable cancellable) throws 
GLib.Error {
-        string src_path = extractor.get_absolute_path (os_media.kernel_path);
-        var src_file = File.new_for_path (src_path);
-        yield copy_file (src_file, kernel_file, cancellable);
-
-        src_path = extractor.get_absolute_path (os_media.initrd_path);
-        src_file = File.new_for_path (src_path);
-        yield copy_file (src_file, initrd_file, cancellable);
+    private async void extract_boot_files (ISOExtractor extractor, Cancellable? cancellable) throws 
GLib.Error {
+        yield extractor.extract (os_media.kernel_path, kernel_file.get_path (), cancellable);
+        yield extractor.extract (os_media.initrd_path, initrd_file.get_path (), cancellable);
     }
 
     private string? get_product_key_format () {


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