From 70fd1ed5e150f884c43f87504e1ace1be0345daf Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 15 Jan 2023 00:51:46 -0500 Subject: [PATCH 1/7] simplify code, fix bug --- usr/share/system-installer/UI/confirm.py | 2 +- usr/share/system-installer/UI/main.py | 21 +++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/usr/share/system-installer/UI/confirm.py b/usr/share/system-installer/UI/confirm.py index 61474a1..a7d27a7 100755 --- a/usr/share/system-installer/UI/confirm.py +++ b/usr/share/system-installer/UI/confirm.py @@ -162,7 +162,7 @@ def __init__(self, settings): self.grid.attach(label31, 4, 6, 1, 1) label32 = Gtk.Label() - label32.set_markup(settings["COMPAT_MODE"]) + label32.set_markup(str(settings["COMPAT_MODE"])) label32.set_justify(Gtk.Justification.CENTER) label32 = self._set_default_margins(label32) self.grid.attach(label32, 5, 6, 1, 1) diff --git a/usr/share/system-installer/UI/main.py b/usr/share/system-installer/UI/main.py index 32fc404..a6552f5 100755 --- a/usr/share/system-installer/UI/main.py +++ b/usr/share/system-installer/UI/main.py @@ -1693,22 +1693,11 @@ def options(self, button): def options_next(self, button): """Set update and extras settings""" - if self.extras.get_active(): - self.data["EXTRAS"] = 1 - else: - self.data["EXTRAS"] = 0 - # if self.updates.get_active(): - # self.data["UPDATES"] = 1 - # else: - self.data["UPDATES"] = 0 - if self.login.get_active(): - self.data["LOGIN"] = 1 - else: - self.data["LOGIN"] = 0 - if self.compat_mode.get_active(): - self.data["COMPAT_MODE"] = 1 - else: - self.data["COMPAT_MODE"] = 0 + self.data["EXTRAS"] = self.extras.get_active() + # self.data["UPDATES"] = self.updates.get_active() + self.data["UPDATES"] = False + self.data["LOGIN"] = self.login.get_active() + self.data["COMPAT_MODE"] = self.compat_mode.get_active() global OPTIONS_COMPLETION OPTIONS_COMPLETION = "COMPLETED" self.main_menu("clicked") From f7733b983197e660b5d099bb6abbc6dcea2c6e3f Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 15 Jan 2023 03:48:43 -0500 Subject: [PATCH 2/7] fix installation reporting issues --- DEBIAN/control | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/UI/report.py | 8 ++++---- usr/share/system-installer/engine.py | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index f7de195..6940a2b 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.4.6 +Version: 2.4.7 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 6a54cd7..aea6502 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.4.6"; +str VERSION = "2.4.7"; 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 77468db..8a3c276 100755 --- a/usr/share/system-installer/UI/report.py +++ b/usr/share/system-installer/UI/report.py @@ -313,7 +313,7 @@ def send_report(self, widget): self.show_all() try: - copyfile(self.path, "/mnt/var/mail/installation_report.txt") + copyfile(self.path, "/mnt/var/log/installation_report.txt") except: pass @@ -419,7 +419,7 @@ def generate_message(self): """write installation report to disk""" report_code = time.time() output = {} - self.path = "/var/mail/installation_report-%s.dosir" % (report_code) + self.path = "/var/log/installation_report-%s.dosir" % (report_code) output['Installation Report Code'] = report_code try: output['system-installer Version'] = check_output(["system-installer", "-v"]).decode() @@ -445,7 +445,7 @@ def generate_message(self): if self.log.get_active(): try: with open("/tmp/system-installer.log", "r") as log: - output['INSTALLATION LOG'] = log.read() + output['INSTALLATION LOG'] = log.read().split("\n") except FileNotFoundError: output['INSTALLATION LOG'] = 'Log does not exist.' else: @@ -467,7 +467,7 @@ def generate_message(self): with open(self.path, "w+") as message: json.dump(output, message, indent=1) except PermissionError: - with open(home + "/installation_report.txt", "w+") as message: + with open(getenv("HOME") + "/installation_report.txt", "w+") as message: json.dump(output, message, indent=1) def message_accept(self, widget): diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index a0a1fc0..6396092 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -167,7 +167,8 @@ def copy_log_to_disk(): shutil.rmtree("/mnt/repo") common.eprint(f" ### {sys.argv[0]} CLOSED ### ") copy_log_to_disk() - subprocess.Popen(["su", "live", "-c", + subprocess.check_call(["/usr/bin/xhost", "+si:localuser:system-installer"]) + subprocess.Popen(["su", "system-installer", "-c", f"/usr/share/system-installer/success.py \'{json.dumps(SETTINGS)}\'"]) os.kill(pid, 15) except Exception as error: From 8b048170ccacaa33ac9a9b740dc0c5b152bbe2b5 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 15 Jan 2023 03:52:50 -0500 Subject: [PATCH 3/7] add new post(inst,rm) scripts --- DEBIAN/postinst.sh | 28 ++++++++++++++++++++++++++++ DEBIAN/postrm.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 DEBIAN/postinst.sh create mode 100755 DEBIAN/postrm.sh diff --git a/DEBIAN/postinst.sh b/DEBIAN/postinst.sh new file mode 100755 index 0000000..26bac6b --- /dev/null +++ b/DEBIAN/postinst.sh @@ -0,0 +1,28 @@ +#!/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. +# +# +users=$(cat /etc/passwd | sed 's/:/ /g' | awk '{print $1}') +if $(echo "$users" | grep -vq "system-installer"); then + adduser --disabled-password --quiet --system --home /nonexistent --no-create-home --group system-installer --shell /bin/false + usermod -aG syslog system-installer +fi diff --git a/DEBIAN/postrm.sh b/DEBIAN/postrm.sh new file mode 100755 index 0000000..881f178 --- /dev/null +++ b/DEBIAN/postrm.sh @@ -0,0 +1,26 @@ +#!/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 + deluser --quiet --system system-installer > /dev/null || true +fi From 878415366cd97e3f743b0eda383b6cd5a97d29fd Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 15 Jan 2023 04:36:23 -0500 Subject: [PATCH 4/7] fix post(inst,rm) scripts --- DEBIAN/{postrm.sh => postinst} | 6 +++--- DEBIAN/{postinst.sh => postrm} | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) rename DEBIAN/{postrm.sh => postinst} (88%) rename DEBIAN/{postinst.sh => postrm} (73%) diff --git a/DEBIAN/postrm.sh b/DEBIAN/postinst similarity index 88% rename from DEBIAN/postrm.sh rename to DEBIAN/postinst index 881f178..027f896 100755 --- a/DEBIAN/postrm.sh +++ b/DEBIAN/postinst @@ -1,7 +1,7 @@ #!/bin/bash # -*- coding: utf-8 -*- # -# postrm.sh +# postinst.sh # # Copyright 2023 Thomas Castleman # @@ -21,6 +21,6 @@ # MA 02110-1301, USA. # # -if [ "$1" = "purge" ]; then - deluser --quiet --system system-installer > /dev/null || true +if $(groups live | grep -vq "syslog"); then + usermod -aG syslog live fi diff --git a/DEBIAN/postinst.sh b/DEBIAN/postrm similarity index 73% rename from DEBIAN/postinst.sh rename to DEBIAN/postrm index 26bac6b..77d6812 100755 --- a/DEBIAN/postinst.sh +++ b/DEBIAN/postrm @@ -1,7 +1,7 @@ #!/bin/bash # -*- coding: utf-8 -*- # -# postinst.sh +# postrm.sh # # Copyright 2023 Thomas Castleman # @@ -21,8 +21,8 @@ # MA 02110-1301, USA. # # -users=$(cat /etc/passwd | sed 's/:/ /g' | awk '{print $1}') -if $(echo "$users" | grep -vq "system-installer"); then - adduser --disabled-password --quiet --system --home /nonexistent --no-create-home --group system-installer --shell /bin/false - usermod -aG syslog system-installer +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 From 0834f388520b937a61e42a68a458bcbd6f1df598 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 15 Jan 2023 04:36:53 -0500 Subject: [PATCH 5/7] instead of giving system-installer it's own user, add live to the `syslog` group --- usr/share/system-installer/engine.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index 6396092..a0a1fc0 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -167,8 +167,7 @@ def copy_log_to_disk(): shutil.rmtree("/mnt/repo") common.eprint(f" ### {sys.argv[0]} CLOSED ### ") copy_log_to_disk() - subprocess.check_call(["/usr/bin/xhost", "+si:localuser:system-installer"]) - subprocess.Popen(["su", "system-installer", "-c", + subprocess.Popen(["su", "live", "-c", f"/usr/share/system-installer/success.py \'{json.dumps(SETTINGS)}\'"]) os.kill(pid, 15) except Exception as error: From 6d2d7ea2c2120ee94f5d1a048d7bcaba3acb1d62 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 15 Jan 2023 14:48:46 -0500 Subject: [PATCH 6/7] fix error 1010 when downloading GPG keys --- DEBIAN/control | 4 ++-- etc/system-installer/settings.json | 2 +- usr/bin/system-installer.cxx | 2 +- usr/share/system-installer/UI/report.py | 10 +++++----- usr/share/system-installer/engine.py | 4 +++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/DEBIAN/control b/DEBIAN/control index 6940a2b..691556c 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,10 +1,10 @@ Package: system-installer -Version: 2.4.7 +Version: 2.4.8 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-pycurl, python3-gnupg (>=0.4.5), python3-xmltodict (>=0.11.0) +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) Description: System Installer for Drauger OS System Installer for Drauger OS diff --git a/etc/system-installer/settings.json b/etc/system-installer/settings.json index 40bf2b2..6d05996 100644 --- a/etc/system-installer/settings.json +++ b/etc/system-installer/settings.json @@ -3,7 +3,7 @@ "local_repo": "/run/live/medium/repo", "distro": "Drauger OS", "report": { - "recv_keys": "https://download-optimizer.draugeros.org/keys/public_keys.asc", + "recv_keys": "https://download.draugeros.org/keys/public_keys.asc", "upload": "rsync://rsync.draugeros.org/reports-upload" }, "ping servers": [ diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index aea6502..ef4ba48 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.4.7"; +str VERSION = "2.4.8"; 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 8a3c276..f9608ba 100755 --- a/usr/share/system-installer/UI/report.py +++ b/usr/share/system-installer/UI/report.py @@ -30,7 +30,7 @@ import json import gnupg import gi -import curl +import urllib3 # Configuration required to use some of these libs gi.require_version('Gtk', '3.0') @@ -319,12 +319,12 @@ def send_report(self, widget): try: # Get keys - cURL = curl.Curl() - with open("../../../etc/system-installer/settings.json", + http = urllib3.PoolManager() + with open("/etc/system-installer/settings.json", "r") as config: URL = json.load(config)["report"] - cURL.set_url(URL["recv_keys"]) - key = cURL.get().decode() + data = http.request("GET", URL["recv_keys"]).data + key = data.decode() # Import keys result = gpg.import_keys(key) # Encrypt file using newly imported keys diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index a0a1fc0..3a34a8c 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -168,7 +168,9 @@ def copy_log_to_disk(): common.eprint(f" ### {sys.argv[0]} CLOSED ### ") copy_log_to_disk() subprocess.Popen(["su", "live", "-c", - f"/usr/share/system-installer/success.py \'{json.dumps(SETTINGS)}\'"]) + f"/usr/share/system-installer/success.py \'{json.dumps(SETTINGS)}\'", + "1>/tmp/system-installer.log", + "2>/tmp/system-installer.log"], shell=True) os.kill(pid, 15) except Exception as error: os.kill(pid, 15) From 346c370fed525b056117593ac720b8bb542f36a0 Mon Sep 17 00:00:00 2001 From: Thomas Castleman Date: Sun, 15 Jan 2023 15:01:33 -0500 Subject: [PATCH 7/7] update engine.py --- usr/share/system-installer/engine.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index 3a34a8c..a0a1fc0 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -168,9 +168,7 @@ def copy_log_to_disk(): common.eprint(f" ### {sys.argv[0]} CLOSED ### ") copy_log_to_disk() subprocess.Popen(["su", "live", "-c", - f"/usr/share/system-installer/success.py \'{json.dumps(SETTINGS)}\'", - "1>/tmp/system-installer.log", - "2>/tmp/system-installer.log"], shell=True) + f"/usr/share/system-installer/success.py \'{json.dumps(SETTINGS)}\'"]) os.kill(pid, 15) except Exception as error: os.kill(pid, 15)