From c0ceb34d240e6f99cf5f4def03304d17299ef9e2 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Mon, 30 Apr 2018 23:08:37 -0600 Subject: [PATCH 01/12] WIP --- src/Views/CheckView.vala | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index c662944bf..4869232ac 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -160,6 +160,30 @@ public class Installer.CheckView : AbstractInstallerView { return upower.on_battery; } + private static bool get_vm () { + try { + var dmiout = ""; + var dmierror = ""; + var dmiexit = 0; + + var dmidecode = new GLib.Subprocess.newv ({"dmidecode -s system-product-name"}, GLib.SubprocessFlags.NONE); + Process.spawn_command_line_sync ( + "dmidecode -s system-product-name", + out dmiout, + out dmierror, + out dmiexit + ); + + if (dmiout.contains ("virtual")) { + return true; + } + + return false; + } catch (GLib.Error error) { + critical ("could not get system name"); + } + } + private void show_next () { State next_state = State.NONE; switch (current_state) { From 4eb2180391773b32210c02208d023f22f0f83f4a Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Mon, 30 Apr 2018 23:57:53 -0600 Subject: [PATCH 02/12] Add VM, comment out some magic --- src/MainWindow.vala | 10 +++---- src/Views/CheckView.vala | 58 +++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index eb227a35f..05d4ef29f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -31,7 +31,7 @@ public class Installer.MainWindow : Gtk.Dialog { private SuccessView success_view; private EncryptView encrypt_view; private ErrorView error_view; - private bool check_ignored = false; + // private bool check_ignored = false; private uint64 minimum_disk_size; @@ -111,9 +111,9 @@ public class Installer.MainWindow : Gtk.Dialog { stack.add (check_view); check_view.status_changed.connect ((met_requirements) => { - if (!check_ignored) { + // if (!check_ignored) { set_check_view_visible (!met_requirements); - } + // } }); check_view.cancel.connect (() => { @@ -123,11 +123,11 @@ public class Installer.MainWindow : Gtk.Dialog { }); check_view.next_step.connect (() => { - check_ignored = true; + // check_ignored = true; set_check_view_visible (false); }); - set_check_view_visible (!check_ignored && !check_view.check_requirements ()); + set_check_view_visible (/*!check_ignored &&*/ !check_view.check_requirements ()); } private void load_encrypt_view () { diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index 4869232ac..665c3a4ab 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -32,7 +32,8 @@ public class Installer.CheckView : AbstractInstallerView { public signal void status_changed (bool met_requirements); bool enough_space = true; - bool enough_power = true; + bool minimum_specs = true; + bool vm = false; bool powered = true; int frequency = 0; @@ -45,6 +46,7 @@ public class Installer.CheckView : AbstractInstallerView { NONE, SPACE, SPECS, + VM, POWERED } @@ -76,17 +78,19 @@ public class Installer.CheckView : AbstractInstallerView { frequency = get_frequency (); if (frequency < MINIMUM_FREQUENCY && frequency > 0) { - enough_power = false; + minimum_specs = false; } memory = get_mem_info (); if (memory < MINIMUM_MEMORY) { - enough_power = false; + minimum_specs = false; } powered = !get_is_on_battery (); - bool result = enough_space && enough_power && powered; + vm = get_vm (); + + bool result = enough_space && minimum_specs && !vm && powered; if (result == false) { show_next (); } @@ -166,7 +170,6 @@ public class Installer.CheckView : AbstractInstallerView { var dmierror = ""; var dmiexit = 0; - var dmidecode = new GLib.Subprocess.newv ({"dmidecode -s system-product-name"}, GLib.SubprocessFlags.NONE); Process.spawn_command_line_sync ( "dmidecode -s system-product-name", out dmiout, @@ -174,14 +177,18 @@ public class Installer.CheckView : AbstractInstallerView { out dmiexit ); - if (dmiout.contains ("virtual")) { + debug ("DMI: %s".printf (dmiout)); + + if (dmiout.ascii_down ().contains ("gal")) { + debug ("We're in a vm"); return true; } - - return false; } catch (GLib.Error error) { critical ("could not get system name"); } + + debug ("We're on bare metal"); + return false; } private void show_next () { @@ -190,8 +197,10 @@ public class Installer.CheckView : AbstractInstallerView { case State.NONE: if (!enough_space) { next_state = State.SPACE; - } else if (!enough_power) { + } else if (!minimum_specs) { next_state = State.SPECS; + } else if (vm) { + next_state = State.VM; } else if (!powered) { next_state = State.POWERED; } else { @@ -200,8 +209,10 @@ public class Installer.CheckView : AbstractInstallerView { break; case State.SPACE: - if (!enough_power) { + if (!minimum_specs) { next_state = State.SPECS; + } else if (vm) { + next_state = State.VM; } else if (!powered) { next_state = State.POWERED; } else { @@ -210,6 +221,16 @@ public class Installer.CheckView : AbstractInstallerView { break; case State.SPECS: + if (vm) { + next_state = State.VM; + } else if (!powered) { + next_state = State.POWERED; + } else { + return; + } + + break; + case State.VM: if (!powered) { next_state = State.POWERED; } else { @@ -251,6 +272,22 @@ public class Installer.CheckView : AbstractInstallerView { stack.set_visible_child (grid); break; + case State.VM: + var grid = setup_grid ( + _("Virtual Machine"), + _("You appear to be installing in a virtual machine. It's recommended to install on real hardware to achieve full performance and experience. Some parts of %s may not function properly in a virtual machine.").printf (Utils.get_pretty_name ()), + "utilities-system-monitor" + ); + grid.show_all (); + + if (ignore_button.parent == null) { + action_area.add (ignore_button); + } + + stack.add (grid); + stack.set_visible_child (grid); + break; + case State.POWERED: var grid = setup_grid ( _("Connect to a Power Source"), @@ -367,3 +404,4 @@ public class Installer.CheckView : AbstractInstallerView { public interface UPower : GLib.Object { public abstract bool on_battery { owned get; set; } } + From 41408ad7aa74e960b855c99258e23853e4fa24f0 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 00:00:12 -0600 Subject: [PATCH 03/12] Better copy --- src/Views/CheckView.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index 665c3a4ab..1eee556b9 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -275,7 +275,7 @@ public class Installer.CheckView : AbstractInstallerView { case State.VM: var grid = setup_grid ( _("Virtual Machine"), - _("You appear to be installing in a virtual machine. It's recommended to install on real hardware to achieve full performance and experience. Some parts of %s may not function properly in a virtual machine.").printf (Utils.get_pretty_name ()), + _("You appear to be installing in a virtual machine. Some parts of %s may run slowly, freeze, or not function properly in a virtual machine. It's recommended to install on real hardware.").printf (Utils.get_pretty_name ()), "utilities-system-monitor" ); grid.show_all (); From 35dba8da704e15415a0355a1e7a8144fb1bb958d Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 00:14:31 -0600 Subject: [PATCH 04/12] Revert more magic --- src/MainWindow.vala | 74 ++++++++++++++-------------------------- src/Views/CheckView.vala | 14 ++++---- 2 files changed, 32 insertions(+), 56 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 05d4ef29f..8f685d0e3 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -89,17 +89,7 @@ public class Installer.MainWindow : Gtk.Dialog { stack.add (try_install_view); stack.visible_child = try_install_view; - try_install_view.next_step.connect (() => load_disk_view ()); - } - - private void set_check_view_visible (bool show) { - if (show) { - check_view.previous_view = stack.visible_child; - stack.visible_child = check_view; - } else if (check_view.previous_view != null) { - stack.visible_child = check_view.previous_view; - check_view.previous_view = null; - } + try_install_view.next_step.connect (() => load_check_view ()); } private void load_check_view () { @@ -107,46 +97,17 @@ public class Installer.MainWindow : Gtk.Dialog { check_view.destroy (); } - check_view = new Installer.CheckView (minimum_disk_size); - stack.add (check_view); - - check_view.status_changed.connect ((met_requirements) => { - // if (!check_ignored) { - set_check_view_visible (!met_requirements); - // } - }); - - check_view.cancel.connect (() => { - stack.visible_child = try_install_view; - check_view.previous_view = null; - check_view.destroy (); - }); - - check_view.next_step.connect (() => { - // check_ignored = true; - set_check_view_visible (false); - }); + check_view = new CheckView (minimum_disk_size); + check_view.previous_view = try_install_view; - set_check_view_visible (/*!check_ignored &&*/ !check_view.check_requirements ()); - } - - private void load_encrypt_view () { - if (encrypt_view != null) { - encrypt_view.destroy (); + if (check_view.check_requirements ()) { + load_disk_view (); + } else { + stack.add (check_view); + stack.visible_child = check_view; } - encrypt_view = new EncryptView (); - encrypt_view.previous_view = disk_view; - stack.add (encrypt_view); - stack.visible_child = encrypt_view; - - load_check_view (); - - encrypt_view.cancel.connect (() => { - stack.visible_child = try_install_view; - }); - - encrypt_view.next_step.connect (() => load_progress_view ()); + check_view.next_step.connect (() => load_disk_view ()); } private void load_disk_view () { @@ -186,6 +147,23 @@ public class Installer.MainWindow : Gtk.Dialog { }); } + private void load_encrypt_view () { + if (encrypt_view != null) { + encrypt_view.destroy (); + } + + encrypt_view = new EncryptView (); + encrypt_view.previous_view = disk_view; + stack.add (encrypt_view); + stack.visible_child = encrypt_view; + + encrypt_view.cancel.connect (() => { + stack.visible_child = try_install_view; + }); + + encrypt_view.next_step.connect (() => load_progress_view ()); + } + private void load_progress_view () { if (progress_view != null) { progress_view.destroy (); diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index 1eee556b9..fd427a086 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -67,7 +67,7 @@ public class Installer.CheckView : AbstractInstallerView { ignore_button = new Gtk.Button.with_label (_("Ignore")); ignore_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); - ignore_button.clicked.connect (() => next_step ()); + ignore_button.clicked.connect (() => show_next ()); show_all (); } @@ -148,13 +148,6 @@ public class Installer.CheckView : AbstractInstallerView { if (upower == null) { try { upower = Bus.get_proxy_sync (BusType.SYSTEM, "org.freedesktop.UPower", "/org/freedesktop/UPower", GLib.DBusProxyFlags.GET_INVALIDATED_PROPERTIES); - - (upower as DBusProxy).g_properties_changed.connect ((changed, invalid) => { - var _on_battery = changed.lookup_value ("OnBattery", GLib.VariantType.BOOLEAN); - if (_on_battery != null) { - status_changed (check_requirements ()); - } - }); } catch (Error e) { warning (e.message); return false; @@ -204,6 +197,7 @@ public class Installer.CheckView : AbstractInstallerView { } else if (!powered) { next_state = State.POWERED; } else { + next_step (); return; } @@ -216,6 +210,7 @@ public class Installer.CheckView : AbstractInstallerView { } else if (!powered) { next_state = State.POWERED; } else { + next_step (); return; } @@ -226,6 +221,7 @@ public class Installer.CheckView : AbstractInstallerView { } else if (!powered) { next_state = State.POWERED; } else { + next_step (); return; } @@ -234,11 +230,13 @@ public class Installer.CheckView : AbstractInstallerView { if (!powered) { next_state = State.POWERED; } else { + next_step (); return; } break; case State.POWERED: + next_step (); return; } From 3ab04e4e27c0760a64e1110e689fcde462a167af Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 00:15:04 -0600 Subject: [PATCH 05/12] Check for virtual instead of galago --- src/Views/CheckView.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index fd427a086..df5fae000 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -172,7 +172,7 @@ public class Installer.CheckView : AbstractInstallerView { debug ("DMI: %s".printf (dmiout)); - if (dmiout.ascii_down ().contains ("gal")) { + if (dmiout.ascii_down ().contains ("virtual")) { debug ("We're in a vm"); return true; } From f04bbb584c4d814dbc491ea82a8fef0e500b9ae2 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 00:20:48 -0600 Subject: [PATCH 06/12] Clean up comment and copyright date --- src/MainWindow.vala | 4 ++-- src/Views/CheckView.vala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8f685d0e3..ea403be09 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1,6 +1,6 @@ // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- /*- - * Copyright (c) 2016-2017 elementary LLC. (https://elementary.io) + * Copyright (c) 2016–2018 elementary LLC. (https://elementary.io) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,6 @@ public class Installer.MainWindow : Gtk.Dialog { private SuccessView success_view; private EncryptView encrypt_view; private ErrorView error_view; - // private bool check_ignored = false; private uint64 minimum_disk_size; @@ -204,3 +203,4 @@ public class Installer.MainWindow : Gtk.Dialog { public override void close () {} } + diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index df5fae000..8fab92b1f 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -1,6 +1,6 @@ // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- /*- - * Copyright (c) 2016-2017 elementary LLC. (https://elementary.io) + * Copyright (c) 2016–2018 elementary LLC. (https://elementary.io) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From fd3774e006805ce350c1b4d351703d8aad0319cc Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 00:33:13 -0600 Subject: [PATCH 07/12] Fix cancelling the check view --- src/MainWindow.vala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index ea403be09..c27a9a3d2 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -106,6 +106,10 @@ public class Installer.MainWindow : Gtk.Dialog { stack.visible_child = check_view; } + check_view.cancel.connect (() => { + stack.visible_child = try_install_view; + }); + check_view.next_step.connect (() => load_disk_view ()); } From 62e8f9ef220ccda514ea01a020fab11caccdeb77 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 00:34:42 -0600 Subject: [PATCH 08/12] Remove extra debugs --- src/Views/CheckView.vala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index 8fab92b1f..ec640fd8f 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -173,14 +173,12 @@ public class Installer.CheckView : AbstractInstallerView { debug ("DMI: %s".printf (dmiout)); if (dmiout.ascii_down ().contains ("virtual")) { - debug ("We're in a vm"); return true; } } catch (GLib.Error error) { critical ("could not get system name"); } - debug ("We're on bare metal"); return false; } From 1f0a8d694e4dea588cd6cb6b414ee81a3290feda Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 11:59:49 -0600 Subject: [PATCH 09/12] Check cpuinfo instead of dmi info --- src/Views/CheckView.vala | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index ec640fd8f..87e5a967b 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -158,25 +158,18 @@ public class Installer.CheckView : AbstractInstallerView { } private static bool get_vm () { + File file = File.new_for_path ("/proc/cpuinfo"); try { - var dmiout = ""; - var dmierror = ""; - var dmiexit = 0; - - Process.spawn_command_line_sync ( - "dmidecode -s system-product-name", - out dmiout, - out dmierror, - out dmiexit - ); - - debug ("DMI: %s".printf (dmiout)); - - if (dmiout.ascii_down ().contains ("virtual")) { - return true; + DataInputStream dis = new DataInputStream (file.read ()); + string? line; + string name = "hypervisor"; + while ((line = dis.read_line (null,null)) != null) { + if (line.has_prefix (name)) { + return true; + } } - } catch (GLib.Error error) { - critical ("could not get system name"); + } catch (Error e) { + critical (e.message); } return false; From 2a42cca42b4efd66f53908c202e5916f9b9bb930 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 1 May 2018 12:06:01 -0600 Subject: [PATCH 10/12] Actually check the right line --- src/Views/CheckView.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index 87e5a967b..45eb9574e 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -162,9 +162,8 @@ public class Installer.CheckView : AbstractInstallerView { try { DataInputStream dis = new DataInputStream (file.read ()); string? line; - string name = "hypervisor"; while ((line = dis.read_line (null,null)) != null) { - if (line.has_prefix (name)) { + if (line.has_prefix ("flags") && line.contains ("hypervisor")) { return true; } } From 6bca0d407d405c8b2a7fa84c0e6bd53ef7249e8d Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Fri, 15 Jun 2018 16:56:15 -0600 Subject: [PATCH 11/12] Update MainWindow.vala --- src/MainWindow.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 3b74a57aa..30faf8d89 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -89,7 +89,7 @@ public class Installer.MainWindow : Gtk.Dialog { stack.visible_child = try_install_view; try_install_view.custom_step.connect (() => load_partitioning_view ()); - try_install_view.next_step.connect (() => load_disk_view ()); + try_install_view.next_step.connect (() => load_check_view ()); } private void load_check_view () { From 86576dc19021fccc4db09ecdcd1b5fb09f49a6e6 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Fri, 15 Jun 2018 17:56:04 -0600 Subject: [PATCH 12/12] Support multiple views --- src/MainWindow.vala | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 30faf8d89..76f8655b2 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -88,11 +88,16 @@ public class Installer.MainWindow : Gtk.Dialog { stack.add (try_install_view); stack.visible_child = try_install_view; - try_install_view.custom_step.connect (() => load_partitioning_view ()); - try_install_view.next_step.connect (() => load_check_view ()); + try_install_view.custom_step.connect (() => { + load_check_view ("custom"); + }); + + try_install_view.next_step.connect (() => { + load_check_view ("clean"); + }); } - private void load_check_view () { + private void load_check_view (string next_view) { if (check_view != null) { check_view.destroy (); } @@ -100,8 +105,14 @@ public class Installer.MainWindow : Gtk.Dialog { check_view = new CheckView (minimum_disk_size); check_view.previous_view = try_install_view; + if (next_view == "custom") { + check_view.next_step.connect (() => load_partitioning_view ()); + } else { + check_view.next_step.connect (() => load_disk_view ()); + } + if (check_view.check_requirements ()) { - load_disk_view (); + check_view.next_step (); } else { stack.add (check_view); stack.visible_child = check_view; @@ -110,8 +121,6 @@ public class Installer.MainWindow : Gtk.Dialog { check_view.cancel.connect (() => { stack.visible_child = try_install_view; }); - - check_view.next_step.connect (() => load_disk_view ()); } private void load_disk_view () {