[gnome-boxes] media-manager: Only express-install supported medias
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] media-manager: Only express-install supported medias
- Date: Mon, 4 Mar 2019 11:55:01 +0000 (UTC)
commit dad569046084ecbf459ecbd456c0aac2d011bf07
Author: Fabiano FidĂȘncio <fidencio redhat com>
Date: Thu Feb 7 16:16:49 2019 +0100
media-manager: Only express-install supported medias
libosinfo has realised that having installer scripts tied to an OS may
be a mistake and have added those bits to the medias themselves (since
1.4.0).
Trying to work around this very same issue, libosinfo has also added a
new API on OsinfoMedia level that tells whether a media supports an
installer script (since 1.3.0).
Now, with those two new APIs and with the new representation Boxes can
be more accurate on offering express-installations for its users, based
on whether the media itself support the installer script for that
specific profile.
Of course, we're not breaking any kind of compatibility in case we're
running against distros which do not have a newer enough version of
osinfo-db or libosinfo. On those cases, the old (and kind of broken)
behaviour will be kept the same.
Signed-off-by: Fabiano FidĂȘncio <fidencio redhat com>
src/media-manager.vala | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/src/media-manager.vala b/src/media-manager.vala
index 427ce874..b8977deb 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -162,16 +162,35 @@ else if (VMConfigurator.is_libvirt_cloning_config (config))
return list;
}
- public InstallerMedia create_installer_media_from_media (InstallerMedia media) throws GLib.Error {
- if (media.os == null)
- return media;
+ private static InstallerMedia create_unattended_installer (InstallerMedia media) throws GLib.Error {
+ InstallerMedia install_media = media;
- var install_scripts = media.os.get_install_script_list ();
var filter = new Filter ();
filter.add_constraint (INSTALL_SCRIPT_PROP_PROFILE, INSTALL_SCRIPT_PROFILE_DESKTOP);
- install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
- InstallerMedia install_media = media;
+ // In case scripts are set as part of the media, let's use them as this
+ // info is more accurate than having the scripts set as part of the OS.
+ var install_scripts = media.os_media.get_install_script_list ();
+ if (install_scripts.get_length () > 0) {
+
+ // Find out whether the media supports a script for DESKTOP profile
+ install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
+
+ if (install_scripts.get_length () > 0) {
+ try {
+ install_media = new UnattendedInstaller.from_media (media, install_scripts);
+ } catch (GLib.IOError.NOT_SUPPORTED e) {
+ debug ("Unattended installer setup failed: %s", e.message);
+ }
+ }
+
+ return install_media;
+ }
+
+ // In case scripts are not set as part of the media, let's use the ones
+ // set as part of the OS.
+ install_scripts = media.os.get_install_script_list ();
+ install_scripts = (install_scripts as Osinfo.List).new_filtered (filter) as InstallScriptList;
if (install_scripts.get_length () > 0) {
try {
install_media = new UnattendedInstaller.from_media (media, install_scripts);
@@ -183,6 +202,16 @@ public InstallerMedia create_installer_media_from_media (InstallerMedia media) t
return install_media;
}
+ public InstallerMedia create_installer_media_from_media (InstallerMedia media) throws GLib.Error {
+ if (media.os == null)
+ return media;
+
+ if (!media.os_media.supports_installer_script ())
+ return media;
+
+ return create_unattended_installer (media);
+ }
+
private MediaManager () {
#if !FLATPAK
client = new GUdev.Client ({"block"});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]