diff --git a/DEBIAN/control b/DEBIAN/control index 1d7a0271..48cce0c8 100644 --- a/DEBIAN/control +++ b/DEBIAN/control @@ -1,5 +1,5 @@ Package: system-installer -Version: 2.2.6 +Version: 2.3.1 Maintainer: Thomas Castleman Homepage: https://github.com/drauger-os-development/system-installer Section: admin diff --git a/build.sh b/build.sh index 40bab416..eabf9f67 100755 --- a/build.sh +++ b/build.sh @@ -55,7 +55,7 @@ fi # Pshyc - we're compiling shit now cd usr/bin -g++ -fPIE -m64 -o system-installer system-installer.cxx $(python3.9-config --ldflags --cflags --embed) +g++ -fPIE -m64 -o system-installer system-installer.cxx $(python3.10-config --ldflags --cflags --embed) cd ../.. ############################################################## # # diff --git a/etc/system-installer/settings.json b/etc/system-installer/settings.json index d36df440..de4b7b56 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.draugeros.org/keys/public_keys.asc", + "recv_keys": "https://download-optimizer.draugeros.org/keys/public_keys.asc", "upload": "rsync://download.draugeros.org/reports-upload" }, "ping servers": [ @@ -15,20 +15,21 @@ "partitioning": { "EFI": { "START": 0, - "END": 200 + "END": 500 }, "ROOT":{ - "START": 201, + "START": 501, "END": "40%", - "fs": "ext4" + "fs": "btrfs" }, "HOME":{ "START": "40%", "END": "100%", - "fs": "ext4" + "fs": "btrfs" }, "min root size": 23000, "mdswh": 128 }, - "run_post_oem": ["/usr/share/drauger-welcome/main_ui.py"] + "run_post_oem": ["/usr/share/drauger-welcome/main_ui.py"], + "kernel_meta_pkg": "linux-drauger" } diff --git a/usr/bin/system-installer.cxx b/usr/bin/system-installer.cxx index 4210db94..97b8b4ea 100644 --- a/usr/bin/system-installer.cxx +++ b/usr/bin/system-installer.cxx @@ -46,7 +46,7 @@ using namespace std; -str VERSION = "2.2.6"; +str VERSION = "2.3.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 d87fa081..2b738946 100755 --- a/usr/share/system-installer/UI/main.py +++ b/usr/share/system-installer/UI/main.py @@ -550,7 +550,7 @@ def auto_partition(self, button): # Get a list of disks and their capacity self.devices = json.loads(subprocess.check_output(["lsblk", "-n", "-i", "--json", - "-o", "NAME,SIZE,TYPE"]).decode()) + "-o", "NAME,SIZE,TYPE,FSTYPE"]).decode()) self.devices = self.devices["blockdevices"] dev = [] for each2 in enumerate(self.devices): @@ -989,9 +989,17 @@ def auto_home_setup2(self, widget): if test_child not in new_dev_list: # make sure child object is not already in dev_list new_dev_list.append(test_child) + elif device["fstype"] != None: + # if the drive has no partition table, just a file system, + # add it + if device["fstype"] != "squashfs": + # don't add it, beacuse it's a squashfs file system + new_device = {"name": device["name"], "size": device["size"]} + new_dev_list.append(new_device) elif "type" not in device.keys(): # if it doesn't have a label, skip continue - elif device['type'] != 'part': # if it isn't labeled partition, skip + elif device['type'] != 'part': + # if it isn't labeled partition, skip continue else: new_device = {'name': device['name'], 'size': device['size']} @@ -1011,7 +1019,8 @@ def auto_home_setup2(self, widget): # properly format device names and add to combo box for device in new_dev_list: - device['name'] = "/dev/%s" % device['name'] + if device["name"][:5] != "/dev/": + device['name'] = "/dev/%s" % device['name'] home_cmbbox.append(device['name'], "%s Size: %s" % (device['name'], device['size'])) diff --git a/usr/share/system-installer/check_kernel_versions.py b/usr/share/system-installer/check_kernel_versions.py index a908d3ba..c7e9c131 100755 --- a/usr/share/system-installer/check_kernel_versions.py +++ b/usr/share/system-installer/check_kernel_versions.py @@ -31,7 +31,7 @@ import common -def __get_file_version__(local_repo): +def __get_file_version__(local_repo, kernel_meta_pkg): """Get kernel version in included kernel archive""" if not os.path.exists(local_repo): try: @@ -49,7 +49,7 @@ def __get_file_version__(local_repo): else: files[each] = files[each].split("/")[-1] files[each] = files[each].split("_") - if files[each][0] == "linux-xanmod": + if files[each][0] == kernel_meta_pkg: del files[each][0] if files[each][-1] == "amd64.deb": del files[each][-1] @@ -72,10 +72,10 @@ def __get_installed_version__(): return subprocess.check_output(["uname", "--release"]).decode("utf-8")[:-1] -def check_kernel_versions(local_repo): +def check_kernel_versions(local_repo, kernel_meta_pkg): """Compare kernel versions""" common.eprint("CHECKING KERNEL VERSIONS") - file_version = __get_file_version__(local_repo) + file_version = __get_file_version__(local_repo, kernel_meta_pkg) installed_version = __get_installed_version__() if file_version == installed_version: common.eprint("KERNEL VERSIONS MATCH: SUCCESS") diff --git a/usr/share/system-installer/engine.py b/usr/share/system-installer/engine.py index 8ab68aff..cb30903f 100755 --- a/usr/share/system-installer/engine.py +++ b/usr/share/system-installer/engine.py @@ -74,7 +74,8 @@ if len(DISK) < 1: UI.error.show_error("\n\tNo 32 GB or Larger Drives detected\t\n") sys.exit(2) -if not check_kernel_versions.check_kernel_versions(CONFIG["local_repo"]): +if not check_kernel_versions.check_kernel_versions(CONFIG["local_repo"], + CONFIG["kernel_meta_pkg"]): UI.error.show_error(""" \tKernel Version Mismatch.\t \tPlease reboot and retry installation.\t diff --git a/usr/share/system-installer/modules/master.py b/usr/share/system-installer/modules/master.py index bd8833ce..210bf18f 100755 --- a/usr/share/system-installer/modules/master.py +++ b/usr/share/system-installer/modules/master.py @@ -292,12 +292,13 @@ def _install_grub(root): def _install_systemd_boot(release, root, distro): """set up and install systemd-boot""" try: - os.mkdir("/boot/efi") + os.makedirs("/boot/efi/loader/entries", exist_ok=True) + except FileExistsError: + pass + try: + os.mkdir(f"/boot/efi/{distro}") except FileExistsError: pass - os.mkdir("/boot/efi/loader") - os.mkdir("/boot/efi/loader/entries") - os.mkdir(f"/boot/efi/{distro}") os.environ["SYSTEMD_RELAX_ESP_CHECKS"] = "1" with open("/etc/environment", "a") as envi: envi.write("export SYSTEMD_RELAX_ESP_CHECKS=1") @@ -309,11 +310,7 @@ def _install_systemd_boot(release, root, distro): eprint(e) eprint("Performing manual installation of systemd-boot.") try: - os.mkdir("/boot/efi/EFI") - except FileExistsError: - pass - try: - os.mkdir("/boot/efi/EFI/systemd") + os.makedirs("/boot/efi/EFI/systemd", exist_ok=True) except FileExistsError: pass try: diff --git a/usr/share/system-installer/modules/verify_install.py b/usr/share/system-installer/modules/verify_install.py index 71c0341c..5086e968 100755 --- a/usr/share/system-installer/modules/verify_install.py +++ b/usr/share/system-installer/modules/verify_install.py @@ -29,7 +29,7 @@ import subprocess import apt -import modules.purge as purge +from modules import purge def __eprint__(*args, **kwargs): @@ -47,9 +47,9 @@ def add_boot_entry(root, distro): part = root[8:] subprocess.check_call(["efibootmgr", "--create", "--disk", disk, "--part", - part, "--loader", "\EFI\systemd\systemd-bootx64.efi", - "--label", distro], stdout=stderr.buffer, - stderr=stderr.buffer) + part, "--loader", + r"\EFI\systemd\systemd-bootx64.efi", "--label", + distro], stdout=stderr.buffer, stderr=stderr.buffer) def set_default_entry(distro): @@ -124,13 +124,15 @@ def verify(username, root, distro): cache = apt.cache.Cache() cache.open() if username != "drauger-user": - if (("system-installer" in cache) and cache["system-installer"].is_installed): - cache["system-installer"].mark_delete() + if "system-installer" in cache: + if cache["system-installer"].is_installed: + cache["system-installer"].mark_delete() if path.isdir("/sys/firmware/efi"): with cache.actiongroup(): for each in cache: if (("grub" in each.name) and each.is_installed): - each.mark_delete() + if "common" not in each.name: + each.mark_delete() cache.commit() purge.autoremove(cache) cache.close() diff --git a/usr/share/system-installer/oem/post_install/UI.py b/usr/share/system-installer/oem/post_install/UI.py index 26d0f30b..5478962e 100755 --- a/usr/share/system-installer/oem/post_install/UI.py +++ b/usr/share/system-installer/oem/post_install/UI.py @@ -30,17 +30,14 @@ import multiprocessing import subprocess import gi + gi.require_version('Gtk', '3.0') + from gi.repository import Gtk import oem.post_install.configure as configure -def eprint(*args, **kwargs): - """Make it easier for us to print to stderr""" - print(*args, file=sys.stderr, **kwargs) - - def has_special_character(input_string): """Check for special characters""" regex = re.compile(r'[@_!#$%^&*()<>?/\|}{~:]') @@ -52,10 +49,8 @@ def has_special_character(input_string): try: with open("/etc/system-installer/settings.json") as config_file: DISTRO = json.loads(config_file.read())["distro"] - -except FileNotFoundError: - eprint("/etc/system-installer/settings.json does not exist. In testing?") - DISTRO = "Drauger OS" +except (FileNotFoundError, KeyError): + DISTRO = "Linux" DEFAULT = """ @@ -336,13 +331,13 @@ def keyboard(self, button): """Keyboard Settings Dialog""" self.clear_window() - self.label = Gtk.Label() - self.label.set_markup(""" + label = Gtk.Label() + label.set_markup(""" Choose your Keyboard layout\t """) - self.label.set_justify(Gtk.Justification.CENTER) - self.label = self._set_default_margins(self.label) - self.grid.attach(self.label, 1, 1, 4, 1) + label.set_justify(Gtk.Justification.CENTER) + label = self._set_default_margins(label) + self.grid.attach(label, 1, 1, 4, 1) model_label = Gtk.Label() model_label.set_markup("""Model: """) diff --git a/usr/share/system-installer/oem/pre_install.py b/usr/share/system-installer/oem/pre_install.py index 3bc18df4..160956df 100755 --- a/usr/share/system-installer/oem/pre_install.py +++ b/usr/share/system-installer/oem/pre_install.py @@ -27,15 +27,12 @@ import re import json import os -from subprocess import Popen, check_output, DEVNULL +import subprocess import gi -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk +gi.require_version('Gtk', '3.0') -def eprint(*args, **kwargs): - """Make it easier for us to print to stderr""" - print(*args, file=sys.stderr, **kwargs) +from gi.repository import Gtk def has_special_character(input_string): @@ -89,8 +86,8 @@ def auto_partition(self, button): self.clear_window() # Get a list of disks and their capacity - self.devices = json.loads(check_output(["lsblk", "-n", "-i", "--json", - "-o", "NAME,SIZE,TYPE"]).decode()) + self.devices = json.loads(subprocess.check_output(["lsblk", "-n", "-i", "--json", + "-o", "NAME,SIZE,TYPE,FSTYPE"]).decode()) self.devices = self.devices["blockdevices"] dev = [] for each2 in enumerate(self.devices): @@ -391,38 +388,65 @@ def auto_home_setup(self, widget): def auto_home_setup2(self, widget): """Provide options for prexisting home partitions""" if widget.get_active() == 1: - dev = [] - for each5 in enumerate(self.device): - if ("loop" in self.device[each5[0]]) or ("disk" in self.device[each5[0]]): - continue - dev.append(self.device[each5[0]]) - devices = [] - for each5 in dev: - devices.append(each5.split()) - devices = [x for x in devices if x != []] - for each5 in devices: - if each5[0] == "sr0": - devices.remove(each5) - for each5 in enumerate(devices): - devices[each5[0]].remove(devices[each5[0]][2]) - for each5 in enumerate(devices): - devices[each5[0]][0] = list(devices[each5[0]][0]) - del devices[each5[0]][0][0] - del devices[each5[0]][0][0] - devices[each5[0]][0] = "".join(devices[each5[0]][0]) - for each5 in enumerate(devices): - devices[each5[0]][0] = "/dev/%s" % ("".join(devices[each5[0]][0])) - - parts = Gtk.ComboBoxText.new() - for each5 in enumerate(devices): - parts.append("%s" % (devices[each5[0]][0]), - "%s Size: %s" % (devices[each5[0]][0], - devices[each5[0]][1])) + dev_list = tuple(self.devices) + new_dev_list = [] # this will be the final list that is displayed for the user + + # todo: account for BTRFS drives that have no partitions + for device in dev_list: # we will iterate through the dev list and add devices to the new list + try: + if device == []: # if the device is empty, we skip + continue + elif 'children' in device: + for child in device['children']: + if "type" not in child.keys(): # if it doesn't have a label, skip + continue + elif not child['type'] == 'part': # if it isn't labeled partition, skip + continue + + test_child = {'name': child['name'], 'size': child['size']} + + if test_child not in new_dev_list: # make sure child object is not already in dev_list + new_dev_list.append(test_child) + elif device["fstype"] != None: + # if the drive has no partition table, just a file system, + # add it + if device["fstype"] != "squashfs": + # don't add it, beacuse it's a squashfs file system + new_device = {"name": device["name"], "size": device["size"]} + new_dev_list.append(new_device) + elif "type" not in device.keys(): # if it doesn't have a label, skip + continue + elif device['type'] != 'part': + # if it isn't labeled partition, skip + continue + else: + new_device = {'name': device['name'], 'size': device['size']} + + new_dev_list.append(new_device) + except KeyError: + common.eprint(traceback.format_exc()) + print(json.dumps(device, indent=2)) + + # TEMPORARY: Remove the ability to use a home partition on the same + # drive as where the root partition is + for each in range(len(new_dev_list) - 1, -1, -1): + if self.data["ROOT"][5:] in new_dev_list[each]["name"]: + del new_dev_list[each] + + home_cmbbox = Gtk.ComboBoxText.new() + + # properly format device names and add to combo box + for device in new_dev_list: + if device["name"][:5] != "/dev/": + device['name'] = "/dev/%s" % device['name'] + + home_cmbbox.append(device['name'], "%s Size: %s" % (device['name'], device['size'])) + if self.data["HOME"] != "": - parts.set_active_id(self.data["HOME"]) - parts.connect("changed", self.select_home_part) - parts = self._set_default_margins(parts) - self.grid.attach(parts, 1, 5, 2, 1) + home_cmbbox.set_active_id(self.data["HOME"]) + home_cmbbox.connect("changed", self.select_home_part) + parts = self._set_default_margins(home_cmbbox) + self.grid.attach(home_cmbbox, 1, 5, 2, 1) else: self.data["HOME"] = "MAKE"