[gnome-boxes/add-opt-in-efi-support: 1/3] build, config: Add API to detect UEFI support




commit 9b94c529f4a5e67c7d5e39bfa41970b0f8a784a7
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Dec 23 12:30:49 2021 +0100

    build, config: Add API to detect UEFI support

 data/ui/assistant/pages/review-page.ui | 16 ++++++++++++++++
 meson.build                            |  1 +
 meson_options.txt                      |  4 ++--
 src/app.vala                           | 18 ++++++++++++++++++
 src/config.vapi                        |  1 +
 src/meson.build                        |  4 ----
 6 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/data/ui/assistant/pages/review-page.ui b/data/ui/assistant/pages/review-page.ui
index 5bcdd6a2..1d1c2139 100644
--- a/data/ui/assistant/pages/review-page.ui
+++ b/data/ui/assistant/pages/review-page.ui
@@ -122,6 +122,22 @@ Check your BIOS settings to enable them.</property>
             </child>
           </object>
         </child>
+
+        <child>
+          <object class="HdyActionRow" id="uefi_row">
+            <property name="visible">False</property>
+            <property name="title" translatable="yes">Enable EFI</property>
+
+            <child>
+              <object class="GtkSwitch" id="uefi_switch">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <signal name="notify::active" handler="on_uefi_switch_toggled"/>
+              </object>
+            </child>
+          </object>
+        </child>
+
       </object>
     </child>
   </template>
diff --git a/meson.build b/meson.build
index ab81f75b..b2e9a53c 100644
--- a/meson.build
+++ b/meson.build
@@ -36,6 +36,7 @@ conf.set('PACKAGE_URL', '"https://wiki.gnome.org/Apps/Boxes";')
 conf.set_quoted ('DATADIR', data_dir)
 conf.set_quoted ('CACHEDIR', '/var/cache')
 conf.set_quoted ('LOCALEDIR', locale_dir)
+conf.set10 ('UEFI_INSTALLS_SUPPORTED', get_option ('uefi'))
 conf.set('PACKAGE_BUGREPORT', '"http://gitlab.gnome.org/gnome/gnome-boxes/issues";')
 
 if get_option ('profile') == 'development'
diff --git a/meson_options.txt b/meson_options.txt
index 05c1f570..ebd86b47 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -30,7 +30,7 @@ option ('profile',
   value: 'default'
 )
 
-option ('gnome-os-uefi',
+option ('uefi',
         type: 'boolean',
         value: true,
-        description: 'Use UEFI whenever it is possible')
+        description: 'Allow installing operating systems with UEFI')
diff --git a/src/app.vala b/src/app.vala
index fd0d3bdd..dc138526 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -703,4 +703,22 @@ public static bool is_running_in_flatpak () {
 
         return is_flatpak;
     }
+
+    public bool supports_uefi_installs () {
+        if (!Config.UEFI_INSTALLS_SUPPORTED)
+            return false;
+
+        try {
+            var domain_capabilities =
+                default_connection.get_domain_capabilities (null, null, null, null, 0);
+            foreach (var firmware in domain_capabilities.get_os ().get_firmwares ()) {
+                if (firmware == GVirConfig.DomainOsFirmware.EFI)
+                    return true;
+            }
+        } catch (GLib.Error error) {
+            warning ("Failed to obtain domain capabilities: %s", error.message);
+        }
+
+        return false;
+    }
 }
diff --git a/src/config.vapi b/src/config.vapi
index e4c40c74..f6144e59 100644
--- a/src/config.vapi
+++ b/src/config.vapi
@@ -14,4 +14,5 @@ namespace Config {
         public const string APPLICATION_ID;
         public const string NAME_SUFFIX;
         public const string VERSION;
+        public const bool UEFI_INSTALLS_SUPPORTED;
 }
diff --git a/src/meson.build b/src/meson.build
index c858ce90..835998b5 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -183,10 +183,6 @@ else
   dependencies += libovf.get_variable('govf_vapi')
 endif
 
-if get_option('gnome-os-uefi')
-    vala_args += '--define=USE_UEFI'
-endif
-
 executable ('gnome-boxes', vala_sources + resources,
             include_directories: config_h_dir,
             vala_args: vala_args,


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