[gnome-boxes] fedora: Use ISOExtractor



commit 6db557f13a9e46e31a660787cd307e96d6a23ead
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Thu Jul 5 14:29:21 2012 +0200

    fedora: Use ISOExtractor
    
    This removes some duplicated code between FedoraInstaller and
    ISOExtractor
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679752

 src/fedora-installer.vala     |   59 ++++++----------------------------------
 src/unattended-installer.vala |    4 ---
 2 files changed, 9 insertions(+), 54 deletions(-)
---
diff --git a/src/fedora-installer.vala b/src/fedora-installer.vala
index 52ae178..f7a0f36 100644
--- a/src/fedora-installer.vala
+++ b/src/fedora-installer.vala
@@ -7,9 +7,6 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
         }
     }
 
-    private bool mounted;
-
-    private File source_dir;
     private File kernel_file;
     private File initrd_file;
 
@@ -43,18 +40,20 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
         os.set_cmdline ("ks=hd:sda:/ks.cfg");
     }
 
-    protected override async void prepare_direct_boot (Cancellable? cancellable) throws GLib.Error {
+    public override async void prepare_for_installation (string vm_name, Cancellable? cancellable) throws GLib.Error {
+        yield base.prepare_for_installation (vm_name, cancellable);
+
         if (!express_toggle.active)
             return;
 
         if (os_media.kernel_path == null || os_media.initrd_path == null)
             return;
 
-        yield mount_media (cancellable);
+        var extractor = new ISOExtractor (device_file);
 
-        yield extract_boot_files (cancellable);
+        yield extractor.mount_media (cancellable);
 
-        yield normal_clean_up (cancellable);
+        yield extract_boot_files (extractor, cancellable);
     }
 
     protected override void clean_up () throws GLib.Error {
@@ -77,52 +76,12 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
         return kbd_regex.replace (str, str.length, 0, kbd);
     }
 
-    private async void normal_clean_up (Cancellable? cancellable) throws GLib.Error {
-        if (!mounted)
-            return;
-
-        debug ("Unmounting '%s'..", mount_point);
-        string[] argv = { "fusermount", "-u", mount_point };
-        yield exec (argv, cancellable);
-        mounted = false;
-        debug ("Unmounted '%s'.", mount_point);
-
-        source_dir.delete ();
-        debug ("Removed '%s'.", mount_point);
-        mount_point = null;
-    }
-
-    private async void mount_media (Cancellable? cancellable) throws GLib.Error {
-        if (mount_point != null) {
-            source_dir = File.new_for_path (mount_point);
-
-            return;
-        }
-
-        mount_point = get_user_unattended ();
-        var dir = File.new_for_path (mount_point);
-        try {
-            dir.make_directory (null);
-        } catch (IOError.EXISTS error) {}
-        source_dir = dir;
-
-        debug ("Mounting '%s' on '%s'..", device_file, mount_point);
-        string[] argv = { "fuseiso", device_file, mount_point };
-        yield exec (argv, cancellable);
-        debug ("'%s' now mounted on '%s'.", device_file, mount_point);
-
-        mounted = true;
-    }
-
-    private async void extract_boot_files (Cancellable? cancellable) throws GLib.Error {
-        if (!mounted)
-            return;
-
-        string src_path = Path.build_filename (mount_point, os_media.kernel_path);
+    private async void extract_boot_files (ISOExtractor extractor, Cancellable? cancellable) throws GLib.Error {
+        string src_path = extractor.get_absolute_path (os_media.kernel_path);
         string dest_path = get_user_unattended ("kernel");
         kernel_file = yield copy_file (src_path, dest_path, cancellable);
 
-        src_path = Path.build_filename (mount_point, os_media.initrd_path);
+        src_path = extractor.get_absolute_path (os_media.initrd_path);
         dest_path = get_user_unattended ("initrd");
         initrd_file = yield copy_file (src_path, dest_path, cancellable);
     }
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index bf7ef2f..08cfe7c 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -138,8 +138,6 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
 
             foreach (var unattended_file in unattended_files)
                 yield unattended_file.copy (cancellable);
-
-            yield prepare_direct_boot (cancellable);
         } catch (GLib.Error error) {
             clean_up ();
 
@@ -277,8 +275,6 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
         }
     }
 
-    protected virtual async void prepare_direct_boot (Cancellable? cancellable) throws GLib.Error {}
-
     protected virtual DomainDisk? get_unattended_disk_config () {
         if (!express_toggle.active)
             return null;



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