From fd856ce20b0f6bd5c4280a666ed3b01c64b82381 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 25 Oct 2023 22:48:02 -0400 Subject: [PATCH 01/28] add support for SDDM in autologin config --- .../modules/auto_login_set.py | 75 +++++++++++++++++-- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/usr/share/system-installer/modules/auto_login_set.py b/usr/share/system-installer/modules/auto_login_set.py index 31c37e81..b3892aad 100755 --- a/usr/share/system-installer/modules/auto_login_set.py +++ b/usr/share/system-installer/modules/auto_login_set.py @@ -3,7 +3,7 @@ # # auto_login_set.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -24,7 +24,8 @@ """Set Autologin setting for the current user""" from __future__ import print_function from sys import stderr, argv -from os import remove +import os +import subprocess as sp def eprint(*args, **kwargs): """Make it easier for us to print to stderr""" @@ -35,32 +36,90 @@ def auto_login_set(login, username): """Set Auto-Login Setting for the current user""" eprint(" ### auto_login_set.py started ### ") new_conf = "" - with open("/etc/lightdm/lightdm.conf", "r") as conf: + accepted = ("lightdm", "sddm") + dm = determine_display_manager() + if dm not in accepted: + eprint("No supported DM found.") + eprint(f"DM found: {dm}") + return + eprint(f"DM in use: {dm}") + + # specifics for different DMs + if dm == accepted[0]: + file = "/etc/lightdm/lightdm.conf" + key = "autologin-user" + elif dm == accepted[1]: + if os.path.exists("/etc/sddm.conf.d/settings.conf"): + file = "/etc/sddm.conf.d/settings.conf" + elif os.path.exists("/etc/sddm.conf.d/kde_settings.conf"): + file = "/etc/sddm.conf.d/kde_settings.conf" + else: + eprint("SDDM in use but settings file not found.") + return + key = "User" + + # Generic settings handler + with open(file, "r") as conf: new_conf = conf.read() - remove("/etc/lightdm/lightdm.conf") + os.remove(file) new_conf = new_conf.split('\n') for each in enumerate(new_conf): if each[0] == 0: continue new_conf[each[0]] = new_conf[each[0]].split('=') + applied = False for each in enumerate(new_conf): if each[0] == 0: continue - if new_conf[each[0]][0] == "autologin-user": + if each[1][0] == key: if login in ("0", 0, False): + eprint(f"DISABLING AUTO-LOGIN for USER {username}") del new_conf[each[0]] else: + eprint(f"ENABLING AUTO-LOGIN for USER {username}") new_conf[each[0]][1] = username + applied = True break + for each in range(len(new_conf) - 1, -1, -1): + if new_conf[each] == [""]: + del new_conf[each] + if (not applied) and (login in ("1", 1, True)): + if dm == accepted[0]: + new_conf.append([key, username]) + elif dm == accepted[1]: + for each in enumerate(new_conf): + if "Autologin" in each[1]: + new_conf.insert(each[0] + 1, [key, username]) + break for each in enumerate(new_conf): if each[0] == 0: continue new_conf[each[0]] = "=".join(new_conf[each[0]]) - with open("/etc/lightdm/lightdm.conf", "w+") as file: + with open(file, "w+") as conf: for each in new_conf: - file.write(each) - file.write('\n') + conf.write(each) + conf.write('\n') eprint(" ### auto_login_set.py closed ### ") + +def determine_display_manager(): + """Determine which display manager is in use""" + # get known DMs + recognized_dms = ("gdm3", "lightdm", "sddm", "lxdm", "nodm", "wdm", "xdm") + dm_status = {} + for each in recognized_dms: + # get status of DMs + dm_status[each] = sp.check_output(["systemctl", "show", + "--no-pager", + each]).decode().split("\n") + for each1 in dm_status[each]: + if "ActiveState" in each1: + dm_status[each] = (each1.split("=")[1] == "active") + # return active DMs + for each in dm_status: + if dm_status[each]: + return each + + if __name__ == '__main__': auto_login_set(argv[1], argv[2]) From ba7ff7869f09186e4ff66c9502d15e8af6f43251 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 25 Oct 2023 23:10:33 -0400 Subject: [PATCH 02/28] Do not set Plymouth theme if it is already set correctly. --- usr/share/system-installer/modules/master.py | 34 +++++++++++--------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index 66e2d7ea..2fc4847c 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -221,21 +221,25 @@ def remove_launcher(USERNAME): def set_plymouth_theme(): """Ensure the plymouth theme is set correctly""" - subproc.Popen(["update-alternatives", "--install", - "/usr/share/plymouth/themes/default.plymouth", - "default.plymouth", - "/usr/share/plymouth/themes/drauger-theme/drauger-theme.plymouth", - "100", "--slave", - "/usr/share/plymouth/themes/default.grub", - "default.plymouth.grub", - "/usr/share/plymouth/themes/drauger-theme/drauger-theme.grub"], - stdout=stderr.buffer) - process = subproc.Popen(["update-alternatives", "--config", - "default.plymouth"], - stdout=stderr.buffer, - stdin=subproc.PIPE, - stderr=subproc.PIPE) - process.communicate(input=bytes("2\n", "utf-8")) + data = subproc.check_output(["update-alternatives","--query", + "default.plymouth"]).decode().split("\n") + data = [each for each in data if "Value:" in each][0].split()[1] + if "drauger-theme.plymouth" != data.split("/")[-1]: + subproc.Popen(["update-alternatives", "--install", + "/usr/share/plymouth/themes/default.plymouth", + "default.plymouth", + "/usr/share/plymouth/themes/drauger-theme/drauger-theme.plymouth", + "100", "--slave", + "/usr/share/plymouth/themes/default.grub", + "default.plymouth.grub", + "/usr/share/plymouth/themes/drauger-theme/drauger-theme.grub"], + stdout=stderr.buffer) + process = subproc.Popen(["update-alternatives", "--config", + "default.plymouth"], + stdout=stderr.buffer, + stdin=subproc.PIPE, + stderr=subproc.PIPE) + process.communicate(input=bytes("2\n", "utf-8")) def install_kernel(release): From 3a1ff7477818130b871146ff797635bacde9d726 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 29 Oct 2023 10:03:24 -0400 Subject: [PATCH 03/28] Update build script and dependancies --- DEBIAN/control | 4 ++-- build.sh | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 08c9ce3a..ccd71596 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,10 +1,10 @@ Package: system-installer -Version: 2.5.5 +Version: 2.5.6 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin Architecture: amd64 Priority: important -Depends: arch-install-scripts, python3 (>=3.6.7-1~18.04), bash, gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), coreutils (>=8.28-1ubuntu1), apt (>=1.6.11), squashfs-tools (>=1:4.3-6ubuntu0.18.04.1), zenity (>=3.28.1-1), grub2-common (>=2.02-2ubuntu8.13), initramfs-tools (>=0.130ubuntu3.8), systemd (>=237-3ubuntu10.24), locales (>=2.27-3ubuntu1), procps (>=2:3.3.12-3ubuntu1.1), grep (>=3.1-2), keyboard-configuration, util-linux (>=2.34-0.1ubuntu2), python3-parted (>=3.11.2), python3-psutil (>=5.5.0), python3-apt (>=2.0.0), python3-urllib3 (>=1.26.5-1~exp1), python3-gnupg (>=0.4.5), python3-xmltodict (>=0.11.0), python3-dnspython +Depends: arch-install-scripts, python3 (>=3.6.7-1~18.04), bash, gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), coreutils (>=8.28-1ubuntu1), apt (>=1.6.11), squashfs-tools (>=1:4.3-6ubuntu0.18.04.1), zenity (>=3.28.1-1), grub2-common (>=2.02-2ubuntu8.13), initramfs-tools (>=0.130ubuntu3.8), systemd (>=237-3ubuntu10.24), locales (>=2.27-3ubuntu1), procps (>=2:3.3.12-3ubuntu1.1), grep (>=3.1-2), keyboard-configuration, util-linux (>=2.34-0.1ubuntu2), python3-parted (>=3.11.2), python3-psutil (>=5.5.0), python3-apt (>=2.0.0), python3-urllib3 (>=1.26.5-1~exp1), python3-gnupg (>=0.4.5), python3-xmltodict (>=0.11.0), python3-dnspython, tzdata Description: System Installer for Drauger OS System Installer for Drauger OS diff --git a/build.sh b/build.sh index b999b1ca..e5b8df24 100755 --- a/build.sh +++ b/build.sh @@ -58,7 +58,24 @@ fi # Pshyc - we're compiling shit now cd usr/bin -g++ -fPIE -m64 -o system-installer system-installer.cxx $(python3.10-config --ldflags --cflags --embed) +echo "Would you like to build with Python 3.10 or 3.11?" +read -p "Python 3.10 [1], Python 3.11 [2], Exit [0]: " ans +if $(echo "${ans,,}" | grep -qE "1|one|first|3.10"); then + vert="3.10" +elif $(echo "${ans,,}" | grep -qE "2|two|second|3.11"); then + vert="3.11" +elif $(echo "${ans,,}" | grep -qE "exit|quit|leave|e|q|x|0|no|zero"); then + echo "Exiting as requested..." + exit 1 +else + echo "Input not recognized. Defaulting to Python 3.10" +fi +{ + g++ -fPIE -m64 -o system-installer system-installer.cxx $(python"${vert}"-config --ldflags --cflags --embed) +} || { + echo "Build failed. Try making sure you have 'python${vert}-dev' and 'libpython${vert}-dev' installed" 1>&2 + exit 2 +} cd ../.. ############################################################## # # From 4df6f2ba2517fca801061bbac5eaf7d978a2faf1 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 29 Oct 2023 10:16:44 -0400 Subject: [PATCH 04/28] Remove unneeded pre and post install scripts --- DEBIAN/control | 2 +- DEBIAN/postinst | 26 -------------------------- DEBIAN/postrm | 28 ---------------------------- usr/bin/system-installer.cxx | 2 +- 4 files changed, 2 insertions(+), 56 deletions(-) delete mode 100755 DEBIAN/postinst delete mode 100755 DEBIAN/postrm diff --git a/DEBIAN/control b/DEBIAN/control index ccd71596..741dcc83 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.5.6 +Version: 2.6.0 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/DEBIAN/postinst b/DEBIAN/postinst deleted file mode 100755 index 027f896d..00000000 --- a/DEBIAN/postinst +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -*- coding: utf-8 -*- -# -# postinst.sh -# -# Copyright 2023 Thomas Castleman -# -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# -if $(groups live | grep -vq "syslog"); then - usermod -aG syslog live -fi diff --git a/DEBIAN/postrm b/DEBIAN/postrm deleted file mode 100755 index 77d68127..00000000 --- a/DEBIAN/postrm +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -*- coding: utf-8 -*- -# -# postrm.sh -# -# Copyright 2023 Thomas Castleman -# -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# -if [ "$1" = "purge" ]; then - user=$(grep "1000" /etc/passwd | sed 's/:/ /g' | awk '{print $1}') - groups=$(groups $user | sed "s/$user : //" | sed 's/syslog//' | sed 's/ /,/g' | sed 's/,,/,/g') - usermod -G "$groups" "$user" -fi diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 01edafef..fdebff07 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.5.9"; +str VERSION = "2.6.0"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; From dbe9605df925ed1068273a0a679e2b7d00ba98fc Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 29 Oct 2023 11:19:30 -0400 Subject: [PATCH 05/28] Allow dynamic generation of regions --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/UI/main.py | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 741dcc83..2a32f936 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.6.0 +Version: 2.6.1 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index fdebff07..ef4e2cc6 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.0"; +str VERSION = "2.6.1"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/UI/main.py b/usr/share/system-installer/UI/main.py index cbd40f77..940e331f 100755 --- a/usr/share/system-installer/UI/main.py +++ b/usr/share/system-installer/UI/main.py @@ -2007,11 +2007,12 @@ def locale(self, button): time_zone = self.data["TIME_ZONE"].split("/") self.time_menu = Gtk.ComboBoxText.new() - zones = ["Africa", "America", "Antarctica", "Arctic", "Asia", - "Atlantic", "Australia", "Brazil", "Canada", "Chile", - "Europe", "Indian", "Mexico", "Pacific", "US"] - for each6 in zones: - self.time_menu.append(each6, each6) + zones_pre = os.listdir("/usr/share/zoneinfo") + zones = [] + for each in zones_pre: + if os.path.isdir(f"/usr/share/zoneinfo/{each}"): + if each not in ("right", "posix"): + self.time_menu.append(each, each) if len(time_zone) > 0: self.time_menu.set_active_id(time_zone[0]) self.time_menu.connect("changed", self.update_subregion) From 50b260fd8383e125442be63b5fdff4d79cd94c9b Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 19:03:28 -0400 Subject: [PATCH 06/28] fix user setup --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/modules/auto_login_set.py | 9 ++++++++- usr/share/system-installer/modules/make_user.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 2a32f936..ff2cb60c 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.6.1 +Version: 2.6.2 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index ef4e2cc6..e2af2d07 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.1"; +str VERSION = "2.6.2"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/modules/auto_login_set.py b/usr/share/system-installer/modules/auto_login_set.py index b3892aad..3eeda098 100755 --- a/usr/share/system-installer/modules/auto_login_set.py +++ b/usr/share/system-installer/modules/auto_login_set.py @@ -105,7 +105,14 @@ def auto_login_set(login, username): def determine_display_manager(): """Determine which display manager is in use""" # get known DMs - recognized_dms = ("gdm3", "lightdm", "sddm", "lxdm", "nodm", "wdm", "xdm") + allowed_dms = ("gdm3", "lightdm", "sddm", "lxdm", "wdm", "xdm") + installed_dms = sp.check_output(["dpkg", "-l", "*dm"]).decode().split('\n') + installed_dms = [each for each in installed_dms if each[:2] == "ii"] + installed_dms = [each.split()[1] for each in installed_dms] + recognized_dms = [] + for each in installed_dms: + if each in allowed_dms: + recognized_dms.append(each) dm_status = {} for each in recognized_dms: # get status of DMs diff --git a/usr/share/system-installer/modules/make_user.py b/usr/share/system-installer/modules/make_user.py index 5255da49..fb280707 100755 --- a/usr/share/system-installer/modules/make_user.py +++ b/usr/share/system-installer/modules/make_user.py @@ -90,7 +90,7 @@ def make_user(username): passwd_file.write("\n".join(passwd)) # Make sure groups are okay default_groups = ["adm", "sudo", "cdrom", "audio", - "dip", "plugdev", "lpadmin"] + "dip", "plugdev"] subprocess.check_output(["groupmod", "--new-name", username, "live"]) subprocess.check_output(["usermod", "-G", ",".join(default_groups), "-a", username]) From 672b7a2c3124898bc667e5ef8d26737b4239a6d6 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 19:14:22 -0400 Subject: [PATCH 07/28] update dependencies --- DEBIAN/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEBIAN/control b/DEBIAN/control index ff2cb60c..46c846ff 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -5,6 +5,6 @@ Homepage: https://github.com/drauger-os-development/system-installer Section: admin Architecture: amd64 Priority: important -Depends: arch-install-scripts, python3 (>=3.6.7-1~18.04), bash, gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), coreutils (>=8.28-1ubuntu1), apt (>=1.6.11), squashfs-tools (>=1:4.3-6ubuntu0.18.04.1), zenity (>=3.28.1-1), grub2-common (>=2.02-2ubuntu8.13), initramfs-tools (>=0.130ubuntu3.8), systemd (>=237-3ubuntu10.24), locales (>=2.27-3ubuntu1), procps (>=2:3.3.12-3ubuntu1.1), grep (>=3.1-2), keyboard-configuration, util-linux (>=2.34-0.1ubuntu2), python3-parted (>=3.11.2), python3-psutil (>=5.5.0), python3-apt (>=2.0.0), python3-urllib3 (>=1.26.5-1~exp1), python3-gnupg (>=0.4.5), python3-xmltodict (>=0.11.0), python3-dnspython, tzdata +Depends: arch-install-scripts, python3 (>=3.6.7-1~18.04), bash, gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), coreutils (>=8.28-1ubuntu1), apt (>=1.6.11), squashfs-tools (>=1:4.3-6ubuntu0.18.04.1), zenity (>=3.28.1-1), grub2-common (>=2.02-2ubuntu8.13), initramfs-tools (>=0.130ubuntu3.8), systemd (>=237-3ubuntu10.24), locales (>=2.27-3ubuntu1), procps (>=2:3.3.12-3ubuntu1.1), grep (>=3.1-2), keyboard-configuration, util-linux (>=2.34-0.1ubuntu2), python3-parted (>=3.11.2), python3-psutil (>=5.5.0), python3-apt (>=2.0.0), python3-urllib3 (>=1.26.5-1~exp1), python3-gnupg (>=0.4.5), python3-xmltodict (>=0.11.0), python3-dnspython, tzdata, laptop-detect (>=0.16) Description: System Installer for Drauger OS System Installer for Drauger OS From 105ccbfb848d509f8326419c028f698c7ebdab09 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 19:26:17 -0400 Subject: [PATCH 08/28] Handle laptop detection failure --- usr/share/system-installer/modules/master.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index 2fc4847c..36804550 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -513,9 +513,12 @@ def _check_for_laptop(): Returns True if it is a laptop, returns False otherwise. """ try: - subproc.check_call(["laptop-detect"]) + subproc.check_call(["/usr/bin/laptop-detect"]) except subproc.CalledProcessError: return False + except FileNotFoundError: + eprint("WARNING: Cannot determine if machine is laptop or desktop. Assuming Desktop...") + return False return True From 2885c92a159bcd148eec65c129bb73357f1ddd91 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 19:44:15 -0400 Subject: [PATCH 09/28] Minor update to DE support in de_control --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- .../dist-packages/de_control/_common.py | 28 +++++++++++++++++ .../dist-packages/de_control/modify.py | 31 ++++++++++++------- 4 files changed, 49 insertions(+), 14 deletions(-) create mode 100755 usr/lib/python3/dist-packages/de_control/_common.py diff --git a/DEBIAN/control b/DEBIAN/control index 46c846ff..9425fa7d 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.6.2 +Version: 2.6.3 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index e2af2d07..3ab07e0d 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.2"; +str VERSION = "2.6.3"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/lib/python3/dist-packages/de_control/_common.py b/usr/lib/python3/dist-packages/de_control/_common.py new file mode 100755 index 00000000..ab9b8095 --- /dev/null +++ b/usr/lib/python3/dist-packages/de_control/_common.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# _common.py +# +# Copyright 2023 Thomas Castleman +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# +"""Common internal functions for de_control""" +import os + +def get_de(): + return os.getenv("XDG_CURRENT_DESKTOP").upper() diff --git a/usr/lib/python3/dist-packages/de_control/modify.py b/usr/lib/python3/dist-packages/de_control/modify.py index 80b2917c..5f67bb78 100644 --- a/usr/lib/python3/dist-packages/de_control/modify.py +++ b/usr/lib/python3/dist-packages/de_control/modify.py @@ -24,6 +24,7 @@ """Modify DE/WM settings and configuration""" import sys import os +import _common def __eprint__(*args, **kwargs): @@ -36,18 +37,24 @@ def for_desktop(username): experience. """ __eprint__("DESKTOP DETECTED. EDITING PANEL ACCORDINGLY.") - try: - os.remove("/home/" + username + "/.config/xfce4/panel/battery-12.rc") - except FileNotFoundError: - pass - with open("/home/" + username + "/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml", "r") as file: - xml = file.read().split("\n") - for each in range(len(xml) - 1, -1, -1): - if "battery" in xml[each]: - del xml[each] - xml = "\n".join(xml) - with open("/home/" + username + "/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml", "w") as file: - file.write(xml) + de = _common.get_de() + if de == "XFCE": + try: + os.remove("/home/" + username + "/.config/xfce4/panel/battery-12.rc") + except FileNotFoundError: + pass + with open("/home/" + username + "/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml", "r") as file: + xml = file.read().split("\n") + for each in range(len(xml) - 1, -1, -1): + if "battery" in xml[each]: + del xml[each] + xml = "\n".join(xml) + with open("/home/" + username + "/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml", "w") as file: + file.write(xml) + elif de == "KDE": + __eprint__("WARNING: KDE detected. KDE support not yet implemented.") + else: + __eprint__(f"WARNING: { de } not a recognized DE.") def for_laptop(): From 70d7af301631a56005a312a70055aee1ceb5e278 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 19:48:58 -0400 Subject: [PATCH 10/28] further updates to de_control --- .../dist-packages/de_control/disable.py | 19 ++++++++++------ .../dist-packages/de_control/enable.py | 22 ++++++++++++------- .../dist-packages/de_control/modify.py | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/usr/lib/python3/dist-packages/de_control/disable.py b/usr/lib/python3/dist-packages/de_control/disable.py index 2b21e666..0ebce9d5 100644 --- a/usr/lib/python3/dist-packages/de_control/disable.py +++ b/usr/lib/python3/dist-packages/de_control/disable.py @@ -3,7 +3,7 @@ # # disable.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -27,10 +27,15 @@ def immersion(): """disable Immersion within DE. - This may involve enabliong desktop icons, re-adding panels, and more. + This may involve enabling desktop icons, re-adding panels, and more. """ - # restart panel - subprocess.Popen(["xfce4-panel"]) - # bring back desktop icons - subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop", - "--property", "/desktop-icons/style", "--set", "2"]) + de = _common.get_de() + if de == "XFCE": + # restart panel + subprocess.Popen(["xfce4-panel"]) + # bring back desktop icons + subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop", + "--property", "/desktop-icons/style", "--set", "2"]) + elif de == "KDE": + # TODO: Add KDE Support + pass diff --git a/usr/lib/python3/dist-packages/de_control/enable.py b/usr/lib/python3/dist-packages/de_control/enable.py index ac2dd0f7..15060657 100644 --- a/usr/lib/python3/dist-packages/de_control/enable.py +++ b/usr/lib/python3/dist-packages/de_control/enable.py @@ -3,7 +3,7 @@ # # enable.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -24,16 +24,22 @@ """Enable DE/WM or DE/WM features""" import subprocess import psutil +import _common def immersion(): """Enable Immersion within DE. This may involve disabling desktop icons, removing panels, and more. """ - subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop", - "--property", "/desktop-icons/style", "--set", "0"]) - # Kill Xfce4 Panel, makes this more emersive - for proc in psutil.process_iter(): - # check whether the process name matches - if proc.name() == "xfce4-panel": - proc.terminate() + de = _common.get_de() + if de == "XFCE": + subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop", + "--property", "/desktop-icons/style", "--set", "0"]) + # Kill Xfce4 Panel, makes this more emersive + for proc in psutil.process_iter(): + # check whether the process name matches + if proc.name() == "xfce4-panel": + proc.terminate() + elif de == "KDE": + # TODO: Add KDE Support + pass diff --git a/usr/lib/python3/dist-packages/de_control/modify.py b/usr/lib/python3/dist-packages/de_control/modify.py index 5f67bb78..2a602f6f 100644 --- a/usr/lib/python3/dist-packages/de_control/modify.py +++ b/usr/lib/python3/dist-packages/de_control/modify.py @@ -3,7 +3,7 @@ # # modify.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 38c85aca5bc3899a6a785422f0db4a8125d0ee7f Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 19:54:07 -0400 Subject: [PATCH 11/28] fix import error --- usr/lib/python3/dist-packages/de_control/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr/lib/python3/dist-packages/de_control/__init__.py b/usr/lib/python3/dist-packages/de_control/__init__.py index 3a893474..f4850b59 100644 --- a/usr/lib/python3/dist-packages/de_control/__init__.py +++ b/usr/lib/python3/dist-packages/de_control/__init__.py @@ -3,7 +3,7 @@ # # __init__.py # -# Copyright 2022 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -25,3 +25,4 @@ import de_control.enable as enable import de_control.disable as disable import de_control.modify as modify +import de_control._common as _common From 567e8494270d70ba9f20c737d1a6bb2a758fec4f Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 19:55:58 -0400 Subject: [PATCH 12/28] fix import errors --- usr/lib/python3/dist-packages/de_control/disable.py | 1 + usr/lib/python3/dist-packages/de_control/enable.py | 2 +- usr/lib/python3/dist-packages/de_control/modify.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/lib/python3/dist-packages/de_control/disable.py b/usr/lib/python3/dist-packages/de_control/disable.py index 0ebce9d5..014691d3 100644 --- a/usr/lib/python3/dist-packages/de_control/disable.py +++ b/usr/lib/python3/dist-packages/de_control/disable.py @@ -23,6 +23,7 @@ # """Disable DE/WM or DE/WM features""" import subprocess +import de_control._common def immersion(): """disable Immersion within DE. diff --git a/usr/lib/python3/dist-packages/de_control/enable.py b/usr/lib/python3/dist-packages/de_control/enable.py index 15060657..23d9de82 100644 --- a/usr/lib/python3/dist-packages/de_control/enable.py +++ b/usr/lib/python3/dist-packages/de_control/enable.py @@ -24,7 +24,7 @@ """Enable DE/WM or DE/WM features""" import subprocess import psutil -import _common +import de_control._common def immersion(): """Enable Immersion within DE. diff --git a/usr/lib/python3/dist-packages/de_control/modify.py b/usr/lib/python3/dist-packages/de_control/modify.py index 2a602f6f..e8ad6166 100644 --- a/usr/lib/python3/dist-packages/de_control/modify.py +++ b/usr/lib/python3/dist-packages/de_control/modify.py @@ -24,7 +24,7 @@ """Modify DE/WM settings and configuration""" import sys import os -import _common +import de_control._common def __eprint__(*args, **kwargs): From 43aa7f6ba9e11de3c0491fa59ecf16b14b17a789 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 20:00:21 -0400 Subject: [PATCH 13/28] fix more import errors --- usr/lib/python3/dist-packages/de_control/disable.py | 4 ++-- usr/lib/python3/dist-packages/de_control/enable.py | 4 ++-- usr/lib/python3/dist-packages/de_control/modify.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usr/lib/python3/dist-packages/de_control/disable.py b/usr/lib/python3/dist-packages/de_control/disable.py index 014691d3..e482f295 100644 --- a/usr/lib/python3/dist-packages/de_control/disable.py +++ b/usr/lib/python3/dist-packages/de_control/disable.py @@ -23,14 +23,14 @@ # """Disable DE/WM or DE/WM features""" import subprocess -import de_control._common +import de_control._common as com def immersion(): """disable Immersion within DE. This may involve enabling desktop icons, re-adding panels, and more. """ - de = _common.get_de() + de = com.get_de() if de == "XFCE": # restart panel subprocess.Popen(["xfce4-panel"]) diff --git a/usr/lib/python3/dist-packages/de_control/enable.py b/usr/lib/python3/dist-packages/de_control/enable.py index 23d9de82..b2beec35 100644 --- a/usr/lib/python3/dist-packages/de_control/enable.py +++ b/usr/lib/python3/dist-packages/de_control/enable.py @@ -24,14 +24,14 @@ """Enable DE/WM or DE/WM features""" import subprocess import psutil -import de_control._common +import de_control._common as com def immersion(): """Enable Immersion within DE. This may involve disabling desktop icons, removing panels, and more. """ - de = _common.get_de() + de = com.get_de() if de == "XFCE": subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop", "--property", "/desktop-icons/style", "--set", "0"]) diff --git a/usr/lib/python3/dist-packages/de_control/modify.py b/usr/lib/python3/dist-packages/de_control/modify.py index e8ad6166..2b803992 100644 --- a/usr/lib/python3/dist-packages/de_control/modify.py +++ b/usr/lib/python3/dist-packages/de_control/modify.py @@ -24,7 +24,7 @@ """Modify DE/WM settings and configuration""" import sys import os -import de_control._common +import de_control._common as com def __eprint__(*args, **kwargs): @@ -37,7 +37,7 @@ def for_desktop(username): experience. """ __eprint__("DESKTOP DETECTED. EDITING PANEL ACCORDINGLY.") - de = _common.get_de() + de = com.get_de() if de == "XFCE": try: os.remove("/home/" + username + "/.config/xfce4/panel/battery-12.rc") From 3e88742839a8f32e9e94f89123ca73ad2306322d Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 1 Nov 2023 20:24:29 -0400 Subject: [PATCH 14/28] Handle systemd-boot being it's own package --- usr/share/system-installer/modules/master.py | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index 36804550..dffb5a39 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -307,6 +307,7 @@ def _install_grub(root): def _install_systemd_boot(release, root, distro, compat_mode): """set up and install systemd-boot""" + install_command = ["dpkg", "--install"] try: os.makedirs("/boot/efi/loader/entries", exist_ok=True) except FileExistsError: @@ -347,16 +348,20 @@ def _install_systemd_boot(release, root, distro, compat_mode): "/boot/efi/EFI/systemd/systemd-bootx64.efi") except FileExistsError: pass - # with open("/boot/efi/loader/loader.conf", "w+") as loader_conf: - # loader_conf.write(f"default {distro}\n") - # loader_conf.write("timeout 5\nconsole-mode auto\neditor 1") - # try: - # subproc.check_call(["chattr", "-i", "/boot/efi/loader/loader.conf"], - # stdout=stderr.buffer) - # except subproc.CalledProcessError: - # eprint("CHATTR FAILED ON loader.conf, setting octal permissions to 444") - # os.chmod("/boot/efi/loader/loader.conf", 0o444) - install_command = ["dpkg", "--install"] + except FileNotFoundError: + # using new installation method + packages = [each for each in os.listdir("/repo") if ("systemd-boot" in each) and ("manager" not in each)] + os.chdir("/repo") + depends = subproc.check_output(["dpkg", "-f"] + packages + ["depends"]) + depends = depends.decode()[:-1].split(", ") + depends = [depends[each[0]].split(" ")[0] for each in enumerate(depends)] + for each in os.listdir(): + for each1 in depends: + if ((each1 in each) and (each not in packages)): + packages.append(each) + break + subproc.check_call(install_command + packages, + stdout=stderr.buffer) packages = [each for each in os.listdir("/repo") if "systemd-boot-manager" in each] os.chdir("/repo") depends = subproc.check_output(["dpkg", "-f"] + packages + ["depends"]) From 97afe7403d1819ea3c9716c44d3dedd6f475eae4 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 4 Nov 2023 23:44:49 -0400 Subject: [PATCH 15/28] Fix bootloader config Use systemd-boot-manager earlier, leverage it in setting up the bootloader in a more pythonic way --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/modules/master.py | 26 ++++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 9425fa7d..e01a9d33 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.6.3 +Version: 2.6.4 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 3ab07e0d..8a02feb8 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.3"; +str VERSION = "2.6.4"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index dffb5a39..ec2faaa0 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -379,22 +379,28 @@ def _install_systemd_boot(release, root, distro, compat_mode): subproc.check_call(install_command + packages, stdout=stderr.buffer) os.chdir("/") + # This lib didn't exist before we installed this package. + # So we can only now import it + import systemd_boot_manager as sdbm + eprint(f"INFO: Setting default boot entry to {distro}.conf") + sdbm.update_defaults_file(f"{distro}.conf") + with open(sdbm.ROOT_DEVICE_FILE, "w") as conf: + conf.write(root) + uuid = sdbm.get_UUID(uuid="uuid") + sdbm.set_settings("key", "uuid") + if not os.path.exists(sdb,.UUID_FILE): + with open(sdbm.UUID_FILE, "w+") as file: + file.write(uuid) if compat_mode: - subproc.check_call(["systemd-boot-manager", "--compat-mode=enable"], - stdout=stderr.buffer) + sdbm.set_settings("compat_mode", True, False) subproc.check_call(["systemd-boot-manager", "-e"], stdout=stderr.buffer) - subproc.check_call(["systemd-boot-manager", "--apply-loader-config"], - stdout=stderr.buffer) - subproc.check_call(["systemd-boot-manager", "-r"], - stdout=stderr.buffer) + if os.path.exists(sdbm.SD_LOADER_DIR + "/loader.conf"): + os.remove(sdbm.SD_LOADER_DIR + "/loader.conf") + sdbm.check_loader() subproc.check_call(["systemd-boot-manager", "--enforce-default-entry=enable"], stdout=stderr.buffer) - # This lib didn't exist before we installed this package. - # So we can only now import it - import systemd_boot_manager - systemd_boot_manager.update_defaults_file(distro + ".conf") subproc.check_call(["systemd-boot-manager", "-u"], stdout=stderr.buffer) check_systemd_boot(release, root, distro) From 8f73e2d78d043dab719bab0b71bfb3c3343f9d46 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 4 Nov 2023 23:49:53 -0400 Subject: [PATCH 16/28] typo correction --- usr/share/system-installer/modules/master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index ec2faaa0..5193e2d0 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -388,7 +388,7 @@ def _install_systemd_boot(release, root, distro, compat_mode): conf.write(root) uuid = sdbm.get_UUID(uuid="uuid") sdbm.set_settings("key", "uuid") - if not os.path.exists(sdb,.UUID_FILE): + if not os.path.exists(sdb.UUID_FILE): with open(sdbm.UUID_FILE, "w+") as file: file.write(uuid) if compat_mode: From d2070b7725215c7cae565ecd905bea11fa48b76d Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sat, 4 Nov 2023 23:55:27 -0400 Subject: [PATCH 17/28] disable Verbose mode for get_UUID() --- usr/share/system-installer/modules/master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index 5193e2d0..b1af61fa 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -386,7 +386,7 @@ def _install_systemd_boot(release, root, distro, compat_mode): sdbm.update_defaults_file(f"{distro}.conf") with open(sdbm.ROOT_DEVICE_FILE, "w") as conf: conf.write(root) - uuid = sdbm.get_UUID(uuid="uuid") + uuid = sdbm.get_UUID(uuid="uuid", False) sdbm.set_settings("key", "uuid") if not os.path.exists(sdb.UUID_FILE): with open(sdbm.UUID_FILE, "w+") as file: From b707976b92e9e1028e89c142d8e5069b964d32b0 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 5 Nov 2023 00:00:52 -0400 Subject: [PATCH 18/28] fix syntax error --- usr/share/system-installer/modules/master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index b1af61fa..865f5224 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -386,7 +386,7 @@ def _install_systemd_boot(release, root, distro, compat_mode): sdbm.update_defaults_file(f"{distro}.conf") with open(sdbm.ROOT_DEVICE_FILE, "w") as conf: conf.write(root) - uuid = sdbm.get_UUID(uuid="uuid", False) + uuid = sdbm.get_UUID(False, uuid="uuid") sdbm.set_settings("key", "uuid") if not os.path.exists(sdb.UUID_FILE): with open(sdbm.UUID_FILE, "w+") as file: From d16d9da77aa0abd2a13c38e9589f5647f4f8f390 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 5 Nov 2023 00:09:06 -0400 Subject: [PATCH 19/28] fix typo --- usr/share/system-installer/modules/master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index 865f5224..8e049e01 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -388,7 +388,7 @@ def _install_systemd_boot(release, root, distro, compat_mode): conf.write(root) uuid = sdbm.get_UUID(False, uuid="uuid") sdbm.set_settings("key", "uuid") - if not os.path.exists(sdb.UUID_FILE): + if not os.path.exists(sdbm.UUID_FILE): with open(sdbm.UUID_FILE, "w+") as file: file.write(uuid) if compat_mode: From 4358982fad52a58fa16d0e3a7ac7e647af66a912 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 5 Nov 2023 11:43:00 -0500 Subject: [PATCH 20/28] ensure efibootmgr gets installed --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/modules/master.py | 2 +- usr/share/system-installer/modules/verify_install.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index e01a9d33..53c696b9 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.6.4 +Version: 2.6.6 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 8a02feb8..4c15fe04 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.4"; +str VERSION = "2.6.6"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index 8e049e01..759135b6 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -362,7 +362,7 @@ def _install_systemd_boot(release, root, distro, compat_mode): break subproc.check_call(install_command + packages, stdout=stderr.buffer) - packages = [each for each in os.listdir("/repo") if "systemd-boot-manager" in each] + packages = [each for each in os.listdir("/repo") if ("systemd-boot-manager" in each) or ("efibootmgr" in each)] os.chdir("/repo") depends = subproc.check_output(["dpkg", "-f"] + packages + ["depends"]) depends = depends.decode()[:-1].split(", ") diff --git a/usr/share/system-installer/modules/verify_install.py b/usr/share/system-installer/modules/verify_install.py index e44aeaae..6d440c25 100755 --- a/usr/share/system-installer/modules/verify_install.py +++ b/usr/share/system-installer/modules/verify_install.py @@ -3,7 +3,7 @@ # # verify_install.py # -# Copyright 2023 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 b4b8529e5da2dbd38bd29286300ecbe58d899a4f Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Mon, 6 Nov 2023 20:08:18 -0500 Subject: [PATCH 21/28] fix minor bugs with manual partitioner --- DEBIAN/control | 4 ++-- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/UI/main.py | 6 ------ usr/share/system-installer/common.py | 0 4 files changed, 3 insertions(+), 9 deletions(-) mode change 100755 => 100644 usr/share/system-installer/common.py diff --git a/DEBIAN/control b/DEBIAN/control index 53c696b9..c5e0549f 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,6 +1,6 @@ Package: system-installer -Version: 2.6.6 -Maintainer: Thomas Castleman +Version: 2.6.7 +Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin Architecture: amd64 diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 4c15fe04..4562e6cf 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.6"; +str VERSION = "2.6.7"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/UI/main.py b/usr/share/system-installer/UI/main.py index 940e331f..8ecc045b 100755 --- a/usr/share/system-installer/UI/main.py +++ b/usr/share/system-installer/UI/main.py @@ -1324,7 +1324,6 @@ def update_possible_root_parts(self, root_drive_dropdown): if each["name"] == root_drive_dropdown.get_active_id(): if "children" in each: parts = each["children"] - break if parts == []: return setting = root_drive_dropdown.get_active_id() @@ -1358,12 +1357,9 @@ def update_possible_home_parts(self, home_drive_dropdown): parts = [] for each in drives: if each["name"] == home_drive_dropdown.get_active_id(): - if each["fstype"] is not None: - parts.append(each) if "children" in each: for each1 in each["children"]: parts.append(each1) - break setting = home_drive_dropdown.get_active_id() self.home_parts.set_active_id(None) self.home_parts.remove_all() @@ -1398,7 +1394,6 @@ def update_possible_swap_parts(self, swap_drive_dropdown): if each["name"] == swap_drive_dropdown.get_active_id(): if "children" in each: parts = each["children"] - break setting = swap_drive_dropdown.get_active_id() self.swap_parts.set_active_id(None) self.swap_parts.remove_all() @@ -1430,7 +1425,6 @@ def update_possible_efi_parts(self, efi_drive_dropdown): if each["name"] == efi_drive_dropdown.get_active_id(): if "children" in each: parts = each["children"] - break if parts == []: return setting = efi_drive_dropdown.get_active_id() diff --git a/usr/share/system-installer/common.py b/usr/share/system-installer/common.py old mode 100755 new mode 100644 From 77876ad6f27f871b3066cebeb0e8f7a0ea786589 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Mon, 6 Nov 2023 21:41:41 -0500 Subject: [PATCH 22/28] Update OEM install Leverage pre-existing files instead of having copies --- .../system-installer/oem/post_install/UI.py | 14 +-- .../post_install/configure/auto_login_set.py | 67 +------------- .../oem/post_install/configure/set_locale.py | 91 +------------------ .../oem/post_install/configure/set_time.py | 56 +----------- 4 files changed, 11 insertions(+), 217 deletions(-) mode change 100755 => 120000 usr/share/system-installer/oem/post_install/configure/auto_login_set.py mode change 100755 => 120000 usr/share/system-installer/oem/post_install/configure/set_locale.py mode change 100755 => 120000 usr/share/system-installer/oem/post_install/configure/set_time.py diff --git a/usr/share/system-installer/oem/post_install/UI.py b/usr/share/system-installer/oem/post_install/UI.py index e3f119eb..ad6d9fa1 100755 --- a/usr/share/system-installer/oem/post_install/UI.py +++ b/usr/share/system-installer/oem/post_install/UI.py @@ -3,7 +3,7 @@ # # main.py # -# Copyright 2023 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -258,11 +258,12 @@ def locale(self, button): self.grid.attach(label3, 2, 4, 1, 1) self.time_menu = Gtk.ComboBoxText.new() - zones = ["Africa", "America", "Antarctica", "Arctic", "Asia", - "Atlantic", "Australia", "Brazil", "Canada", "Chile", - "Europe", "Indian", "Mexico", "Pacific", "US"] - for each6 in zones: - self.time_menu.append(each6, each6) + zones_pre = os.listdir("/usr/share/zoneinfo") + zones = [] + for each in zones_pre: + if os.path.isdir(f"/usr/share/zoneinfo/{each}"): + if each not in ("right", "posix"): + self.time_menu.append(each, each) self.time_menu.connect("changed", self.update_subregion) self.time_menu = self._set_default_margins(self.time_menu) self.grid.attach(self.time_menu, 2, 5, 1, 1) @@ -360,6 +361,7 @@ def keyboard(self, button): model = keyboards["models"] for each8 in model: self.model_menu.append(model[each8], each8) + self.model_menu.set_active_id("pc105") self.model_menu = self._set_default_margins(self.model_menu) self.grid.attach(self.model_menu, 2, 2, 3, 1) diff --git a/usr/share/system-installer/oem/post_install/configure/auto_login_set.py b/usr/share/system-installer/oem/post_install/configure/auto_login_set.py deleted file mode 100755 index 31c37e81..00000000 --- a/usr/share/system-installer/oem/post_install/configure/auto_login_set.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# auto_login_set.py -# -# Copyright 2022 Thomas Castleman -# -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# -"""Set Autologin setting for the current user""" -from __future__ import print_function -from sys import stderr, argv -from os import remove - -def eprint(*args, **kwargs): - """Make it easier for us to print to stderr""" - print(*args, file=stderr, **kwargs) - - -def auto_login_set(login, username): - """Set Auto-Login Setting for the current user""" - eprint(" ### auto_login_set.py started ### ") - new_conf = "" - with open("/etc/lightdm/lightdm.conf", "r") as conf: - new_conf = conf.read() - remove("/etc/lightdm/lightdm.conf") - new_conf = new_conf.split('\n') - for each in enumerate(new_conf): - if each[0] == 0: - continue - new_conf[each[0]] = new_conf[each[0]].split('=') - for each in enumerate(new_conf): - if each[0] == 0: - continue - if new_conf[each[0]][0] == "autologin-user": - if login in ("0", 0, False): - del new_conf[each[0]] - else: - new_conf[each[0]][1] = username - break - for each in enumerate(new_conf): - if each[0] == 0: - continue - new_conf[each[0]] = "=".join(new_conf[each[0]]) - with open("/etc/lightdm/lightdm.conf", "w+") as file: - for each in new_conf: - file.write(each) - file.write('\n') - eprint(" ### auto_login_set.py closed ### ") - -if __name__ == '__main__': - auto_login_set(argv[1], argv[2]) diff --git a/usr/share/system-installer/oem/post_install/configure/auto_login_set.py b/usr/share/system-installer/oem/post_install/configure/auto_login_set.py new file mode 120000 index 00000000..212cccb1 --- /dev/null +++ b/usr/share/system-installer/oem/post_install/configure/auto_login_set.py @@ -0,0 +1 @@ +../../../modules/auto_login_set.py \ No newline at end of file diff --git a/usr/share/system-installer/oem/post_install/configure/set_locale.py b/usr/share/system-installer/oem/post_install/configure/set_locale.py deleted file mode 100755 index a39802ee..00000000 --- a/usr/share/system-installer/oem/post_install/configure/set_locale.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# set_locale.py -# -# Copyright 2022 Thomas Castleman -# -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# -"""Set system locale for a given langauage name""" -from __future__ import print_function -from sys import argv, stderr -from os import remove -from subprocess import check_call - - -def eprint(*args, **kwargs): - """Make it easier for us to print to stderr""" - print(*args, file=stderr, **kwargs) - - -def set_locale(lang_set): - """Figure out locale code for a given language name""" - eprint(" ### set_locale.py STARTED ### ") - # figure out what LANG to set - with open("/etc/locale.gen", "r") as locale_file: - data = locale_file.read() - data = data.split("\n") - for each in range(len(data) - 1, -1, -1): - if "UTF-8" not in data[each][-5:]: - del data[each] - continue - data[each] = data[each].split(" ") - if data[each][0] == "#": - data[each] = data[each][1][:-6] - else: - data[each] = data[each][0][:-6] - for each in range(len(data) - 1, -1, -1): - if (("@" in data[each]) or ("_" not in data[each]) or (data[each] == "")): - del data[each] - for each in range(len(data) - 1, -1, -1): - if lang_set + "_" not in data[each]: - del data[each] - _setlocale(data[0]) - - eprint(" ### set_locale.py STOPPED ### ") - - -def _setlocale(locale): - """Handle setting locale for a given locale code""" - # Edit /etc/locale.gen - with open("/etc/locale.gen", "r") as gen_file: - contents = gen_file.read() - contents = contents.split("\n") - code = locale.split("_")[0] - for each in enumerate(contents): - if ((code + "_" in contents[each[0]] - ) and (".UTF-8 UTF-8" in contents[each[0]])): - if contents[each[0]][0] == "#": - contents[each[0]] = contents[each[0]].split(" ") - del contents[each[0]][0] - contents[each[0]] = " ".join(contents[each[0]]) - # for each in enumerate(contents): - # if contents[each[0]] == ("# " + locale + ".UTF-8 UTF-8"): - # contents[each[0]] = locale + ".UTF-8 UTF-8" - # break - remove("/etc/locale.gen") - contents = "\n".join(contents) - with open("/etc/locale.gen", "w+") as new_gen: - new_gen.write(contents) - check_call(["locale-gen"], stdout=stderr.buffer) - check_call(["update-locale", "LANG=%s.UTF-8" % (locale), "LANGUAGE"]) - - -if __name__ == '__main__': - set_locale(argv[1]) diff --git a/usr/share/system-installer/oem/post_install/configure/set_locale.py b/usr/share/system-installer/oem/post_install/configure/set_locale.py new file mode 120000 index 00000000..3e74934c --- /dev/null +++ b/usr/share/system-installer/oem/post_install/configure/set_locale.py @@ -0,0 +1 @@ +../../../modules/set_locale.py \ No newline at end of file diff --git a/usr/share/system-installer/oem/post_install/configure/set_time.py b/usr/share/system-installer/oem/post_install/configure/set_time.py deleted file mode 100755 index fede388e..00000000 --- a/usr/share/system-installer/oem/post_install/configure/set_time.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# set_time.py -# -# Copyright 2022 Thomas Castleman -# -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# -"""Set system time""" -from os import symlink, system, remove -from sys import stderr, argv -from subprocess import Popen - - -def eprint(*args, **kwargs): - """Make it easier for us to print to stderr""" - print(*args, file=stderr, **kwargs) - - -def _link(location): - """Set time zone and localtime. Also, enable NTP sync.""" - remove("/etc/localtime") - symlink("/usr/share/zoneinfo/%s" % (location), "/etc/localtime") - remove("/etc/timezone") - with open("/etc/timezone", "w+") as timezone: - timezone.write(location) - Popen(["timedatectl", "set-ntp", "true"]) - - - -def set_time(time_zone): - """Set time zone and hardware clock""" - eprint(" ### set_time.py STARTED ### ") - _link(time_zone) - system("hwclock --systohc") - eprint(" ### set_time.py CLOSED ### ") - - -if __name__ == '__main__': - set_time(argv[1]) diff --git a/usr/share/system-installer/oem/post_install/configure/set_time.py b/usr/share/system-installer/oem/post_install/configure/set_time.py new file mode 120000 index 00000000..50db21f8 --- /dev/null +++ b/usr/share/system-installer/oem/post_install/configure/set_time.py @@ -0,0 +1 @@ +../../../modules/set_time.py \ No newline at end of file From e63bc767c7c4dbe74f7b136f3cac3fd30362b6a0 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Mon, 6 Nov 2023 21:44:53 -0500 Subject: [PATCH 23/28] update version --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index c5e0549f..e90dd8a6 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.6.7 +Version: 2.6.8 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 4562e6cf..1e40e866 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.7"; +str VERSION = "2.6.8"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; From 37b645bfa3664146f8e64eaea13aa9d1c75ce086 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Tue, 7 Nov 2023 22:52:37 -0500 Subject: [PATCH 24/28] Minor fixes to Quick Install --- DEBIAN/control | 2 +- etc/system-installer/quick-install-template.json | 1 + usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/UI/main.py | 6 ++++-- usr/share/system-installer/engine.py | 2 +- usr/share/system-installer/installer.py | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index e90dd8a6..799e6720 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.6.8 +Version: 2.7.0 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/etc/system-installer/quick-install-template.json b/etc/system-installer/quick-install-template.json index 735fff63..8629fc4d 100644 --- a/etc/system-installer/quick-install-template.json +++ b/etc/system-installer/quick-install-template.json @@ -13,6 +13,7 @@ "EXTRAS":true, "UPDATES":false, "LOGIN":false, + "COMPAT_MODE": false "MODEL":"Acer laptop", "LAYOUT":"English(US)", "VARIENT":"English(US) - English(US, euro on 5)", diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 1e40e866..17d24d16 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.6.8"; +str VERSION = "2.7.0"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/UI/main.py b/usr/share/system-installer/UI/main.py index 8ecc045b..c0aee4de 100755 --- a/usr/share/system-installer/UI/main.py +++ b/usr/share/system-installer/UI/main.py @@ -275,11 +275,13 @@ def select_config(self, widget): response = dialog.run() if response == Gtk.ResponseType.OK: self.data = dialog.get_filename() + dialog.destroy() + self.complete() elif response == Gtk.ResponseType.CANCEL: self.data = 1 + dialog.destroy() + self.exit("clicked") - dialog.destroy() - self.exit("clicked") def add_filters(self, dialog): """Add Filters to Quick Install File Selection Window""" diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index 445a0af3..24afb3f8 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -3,7 +3,7 @@ # # engine.py # -# Copyright 2023 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 diff --git a/usr/share/system-installer/installer.py b/usr/share/system-installer/installer.py index a1f2e2d5..de9e4f66 100755 --- a/usr/share/system-installer/installer.py +++ b/usr/share/system-installer/installer.py @@ -3,7 +3,7 @@ # # installer.py # -# Copyright 2023 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 ec6cf0373257eeda2111b6c1bb2623ba33f0eca2 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Tue, 7 Nov 2023 23:27:50 -0500 Subject: [PATCH 25/28] Add error handling for Quick Install Files --- DEBIAN/control | 2 +- .../quick-install-template.json | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/engine.py | 28 +++++++++++++++---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 799e6720..4935aed1 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.7.0 +Version: 2.7.1 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/etc/system-installer/quick-install-template.json b/etc/system-installer/quick-install-template.json index 8629fc4d..19b8bcda 100644 --- a/etc/system-installer/quick-install-template.json +++ b/etc/system-installer/quick-install-template.json @@ -13,7 +13,7 @@ "EXTRAS":true, "UPDATES":false, "LOGIN":false, - "COMPAT_MODE": false + "COMPAT_MODE": false, "MODEL":"Acer laptop", "LAYOUT":"English(US)", "VARIENT":"English(US) - English(US, euro on 5)", diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 17d24d16..a7c353ab 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.7.0"; +str VERSION = "2.7.1"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index 24afb3f8..56caede9 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -124,16 +124,34 @@ def copy_log_to_disk(): sys.exit(2) elif os.path.exists(SETTINGS): if SETTINGS.split("/")[-1][-5:] == ".json": - with open(SETTINGS, "r") as quick_install_file: - SETTINGS = json.load(quick_install_file) + try: + with open(SETTINGS, "r") as quick_install_file: + SETTINGS = json.load(quick_install_file) + except json.decoder.JSONDecodeError: + UI.error.show_error(""" +\tJSON File Error\t +\tWe're sorry. The Quick Install file you provided\t +\thas a JSON Syntax Error. Please correct this and try again.\t +\tIf your problem persists, please create an issue on our Github.\t +""") + sys.exit(2) elif SETTINGS.split("/")[-1][-7:] == ".tar.xz": tar_file = tar.open(name=SETTINGS) tar_file.extractall(path=work_dir) tar_file.close() if os.path.exists(work_dir + "/settings/installation-settings.json"): - with open(work_dir + "/settings/installation-settings.json", - "r") as quick_install_file: - SETTINGS = json.load(quick_install_file) + try: + with open(work_dir + "/settings/installation-settings.json", + "r") as quick_install_file: + SETTINGS = json.load(quick_install_file) + except json.decoder.JSONDecodeError: + UI.error.show_error(""" +\tJSON File Error\t +\tWe're sorry. The Quick Install file you provided\t +\thas a JSON Syntax Error. Please correct this and try again.\t +\tIf your problem persists, please create an issue on our Github.\t +""") + sys.exit(2) try: net_settings = os.listdir(work_dir + "/settings/network-settings") if len(net_settings) > 0: From fbe2b28751336806d6c30258ab2f08aff6eb7417 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Wed, 8 Nov 2023 20:32:57 -0500 Subject: [PATCH 26/28] Fix syntax error --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/engine.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 4935aed1..1e70441d 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.7.1 +Version: 2.7.2 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index a7c353ab..efacdfa5 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.7.1"; +str VERSION = "2.7.2"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index 56caede9..7366d103 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -134,7 +134,7 @@ def copy_log_to_disk(): \thas a JSON Syntax Error. Please correct this and try again.\t \tIf your problem persists, please create an issue on our Github.\t """) - sys.exit(2) + sys.exit(2) elif SETTINGS.split("/")[-1][-7:] == ".tar.xz": tar_file = tar.open(name=SETTINGS) tar_file.extractall(path=work_dir) From 4e68cc7154430484c4455ee34b5188b2bfe39e3e Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Fri, 17 Nov 2023 10:04:17 -0500 Subject: [PATCH 27/28] minor performance optimization --- usr/share/system-installer/common.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/usr/share/system-installer/common.py b/usr/share/system-installer/common.py index a31a1d35..f8c75040 100644 --- a/usr/share/system-installer/common.py +++ b/usr/share/system-installer/common.py @@ -29,13 +29,14 @@ def unique(starting_list): """Function to get a list down to only unique elements""" # initialize a null list - unique_list = [] + # unique_list = [] # traverse for all elements - for each in starting_list: + # for each in starting_list: # check if exists in unique_list or not - if each not in unique_list: - unique_list.append(each) - return unique_list + # if each not in unique_list: + # unique_list.append(each) + # return unique_list + return list(set(starting_list)) def eprint(*args, **kwargs): From 296f5f43b56c607209558784eaf44cec457d2a22 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 26 Nov 2023 12:25:32 -0500 Subject: [PATCH 28/28] fix preview not showing for installation report --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/UI/report.py | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 1e70441d..f1fef68e 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.7.2 +Version: 2.7.3 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index efacdfa5..0378a73c 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.7.2"; +str VERSION = "2.7.3"; str R = "\033[0;31m"; str G = "\033[0;32m"; str Y = "\033[1;33m"; diff --git a/usr/share/system-installer/UI/report.py b/usr/share/system-installer/UI/report.py index 6e9c5cdb..803e29d0 100755 --- a/usr/share/system-installer/UI/report.py +++ b/usr/share/system-installer/UI/report.py @@ -3,7 +3,7 @@ # # report.py # -# Copyright 2023 Thomas Castleman +# Copyright 2023 Thomas Castleman # # 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 @@ -374,8 +374,14 @@ def send_report(self, widget): def preview_message(self, widget): """Preview Installation Report""" self.clear_window() - with open(self.path, "r") as mail: - text = mail.read() + try: + with open(self.path, "r") as mail: + text = mail.read() + except FileNotFoundError: + # this is handled during file generation, so this should never be used + path = getenv("HOME") + "/installation_report.txt" + with open(path) as mail: + text = mail.read() if len(text.split("\n")) > 36: self.scrolling = True self.set_default_size(775, 700) @@ -419,7 +425,7 @@ def generate_message(self): """write installation report to disk""" report_code = time.time() output = {} - self.path = "/var/log/installation_report-%s.dosir" % (report_code) + self.path = "/tmp/installation_report-%s.dosir" % (report_code) output['Installation Report Code'] = report_code try: ver = check_output(["system-installer", "-v"]).decode().split("\n") @@ -469,7 +475,8 @@ def generate_message(self): with open(self.path, "w+") as message: json.dump(output, message, indent=1) except PermissionError: - with open(getenv("HOME") + "/installation_report.txt", "w+") as message: + self.path = getenv("HOME") + "/installation_report.txt" + with open(self.path, "w+") as message: json.dump(output, message, indent=1) def message_accept(self, widget):