[gnome-boxes] installed-media: Special gnome-continuous images support



commit 223539c87e8dbed3ca03556b9a609e2fcc409e89
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Sep 12 20:26:00 2013 +0300

    installed-media: Special gnome-continuous images support
    
    This patch links gnome-continuous images to appr. libosinfo's OS entry
    so that Boxes gives it a nice name and assign supported devices. This
    also fixes the issue of nonfunctional networking in VM created for these
    images.
    
    Ideally we shouldn't need to do this ourselves and libosinfo should do
    the detection/mapping or we should look into libguestfs for this but
    that would be a lot of work and it will not be very useful when we add
    support for OVF files and gnome-continuous start to produce those. So
    for now we go with this hack, which is not a that bad.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706012

 src/installed-media.vala |   16 ++++++++++++++--
 src/media-manager.vala   |    4 ++--
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/installed-media.vala b/src/installed-media.vala
index e707232..aeb209d 100644
--- a/src/installed-media.vala
+++ b/src/installed-media.vala
@@ -36,7 +36,7 @@ private class Boxes.InstalledMedia : Boxes.InstallerMedia {
         }
     }
 
-    public InstalledMedia (string path) throws GLib.Error {
+    public async InstalledMedia (string path, MediaManager media_manager) throws GLib.Error {
         var supported = false;
         foreach (var extension in supported_extensions) {
             supported = path.has_suffix (extension);
@@ -50,7 +50,19 @@ private class Boxes.InstalledMedia : Boxes.InstallerMedia {
         device_file = path;
         from_image = true;
 
-        resources = OSDatabase.get_default_resources ();
+        if (path.contains ("gnome-continuous") || path.contains ("gnome-ostree")) {
+            try {
+                os = yield media_manager.os_db.get_os_by_id ("http://gnome.org/continuous/3.10";);
+            } catch (OSDatabaseError.UNKNOWN_OS_ID error) {
+                debug ("gnome-continuous definition not found in libosinfo db");
+            } catch (OSDatabaseError error) {
+                throw error;
+            }
+        }
+
+        resources = (os != null)? media_manager.os_db.get_resources_for_os (os, architecture) :
+                                  OSDatabase.get_default_resources ();
+
         label_setup ();
     }
 
diff --git a/src/media-manager.vala b/src/media-manager.vala
index ad4f5f1..d38bf1c 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -30,7 +30,7 @@ private class Boxes.MediaManager : Object {
         if (is_mime_type (path, "application/x-cd-image"))
             media = yield new InstallerMedia.for_path (path, this, cancellable);
         else
-            media = new InstalledMedia (path);
+            media = yield new InstalledMedia (path, this);
 
         return create_installer_media_from_media (media);
     }
@@ -42,7 +42,7 @@ private class Boxes.MediaManager : Object {
 
         if (VMConfigurator.is_import_config (config))
             try {
-                return new InstalledMedia (path);
+                return yield new InstalledMedia (path, this);
             } catch (GLib.Error error) {
                 debug ("%s", error.message);
 


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