From 51eb05691a5845652a9dc583de05519f095961f3 Mon Sep 17 00:00:00 2001 From: Hamad Al Marri Date: Wed, 7 Jul 2021 18:38:55 +0300 Subject: Fix encryption + grub both in UEFI and BIOS systems. We need to have two partitions in BIOS one for boot (grub) and the other for root (/). The format of the boot partition is ext2 (so it is added). If disk is chosen to be encrypted, `then /etc/default/grub` is edited as the followings: https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#Configuring_GRUB_2 Issue: https://github.com/archlinux/archinstall/issues/586 This work is done while working on CachyOS which is Arch based and it is using customized archinstaller. To test these changes you can try CachyOS installer which supports encrypted disk with grub (https://wiki.cachyos.org/). Hamad --- archinstall/lib/disk.py | 23 ++++++++++++++++++----- archinstall/lib/installer.py | 18 ++++++++++++------ examples/guided.py | 5 ++--- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index de39bafd..954dc732 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -347,6 +347,11 @@ class Partition: raise DiskError(f'Could not format {path} with {filesystem} because: {b"".join(handle)}') self.filesystem = 'ext4' + elif filesystem == 'ext2': + if (handle := SysCommand(f'/usr/bin/mkfs.ext2 -F {path}')).exit_code != 0: + raise DiskError(f'Could not format {path} with {filesystem} because: {b"".join(handle)}') + self.filesystem = 'ext2' + elif filesystem == 'xfs': if (handle := SysCommand(f'/usr/bin/mkfs.xfs -f {path}')).exit_code != 0: raise DiskError(f'Could not format {path} with {filesystem} because: {b"".join(handle)}') @@ -518,12 +523,20 @@ class Filesystem: self.blockdevice.partition[0].allow_formatting = True self.blockdevice.partition[1].allow_formatting = True else: - # we don't need a seprate boot partition it would be a waste of space - self.add_partition('primary', start='1MB', end='100%') - self.blockdevice.partition[0].filesystem = root_filesystem_type - log(f"Set the root partition {self.blockdevice.partition[0]} to use filesystem {root_filesystem_type}.", level=logging.DEBUG) - self.blockdevice.partition[0].target_mountpoint = '/' + self.add_partition('primary', start='1MiB', end='513MiB', partition_format='ext2') + self.set(0, 'boot on') + self.add_partition('primary', start='513MiB', end='100%') + + self.blockdevice.partition[0].filesystem = 'ext2' + self.blockdevice.partition[1].filesystem = root_filesystem_type + + log(f"Set the root partition {self.blockdevice.partition[1]} to use filesystem {root_filesystem_type}.", level=logging.DEBUG) + + self.blockdevice.partition[0].target_mountpoint = '/boot' + self.blockdevice.partition[1].target_mountpoint = '/' + self.blockdevice.partition[0].allow_formatting = True + self.blockdevice.partition[1].allow_formatting = True def add_partition(self, partition_type, start, end, partition_format=None): log(f'Adding partition to {self.blockdevice}', level=logging.INFO) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index da6f6a9b..25b5331a 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -409,7 +409,7 @@ class Installer: return True - def add_bootloader(self, bootloader='systemd-bootctl'): + def add_bootloader(self, _device, bootloader='systemd-bootctl'): for plugin in plugins.values(): if hasattr(plugin, 'on_add_bootloader'): # Allow plugins to override the boot-loader handling. @@ -500,7 +500,16 @@ class Installer: self.helper_flags['bootloader'] = bootloader elif bootloader == "grub-install": - self.pacstrap('grub') + self.pacstrap('grub') # no need? + + if real_device := self.detect_encryption(root_partition): + _file = "/etc/default/grub" + root_uuid = SysCommand(f"blkid -s UUID -o value {real_device.path}").decode().rstrip() + add_to_CMDLINE_LINUX = f"sed -i 's/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=UUID={root_uuid}:cryptlvm\"/'" + enable_CRYPTODISK = "sed -i 's/#GRUB_ENABLE_CRYPTODISK=y/GRUB_ENABLE_CRYPTODISK=y/'" + + SysCommand(f"/usr/bin/arch-chroot {self.target} {add_to_CMDLINE_LINUX} {_file}") + SysCommand(f"/usr/bin/arch-chroot {self.target} {enable_CRYPTODISK} {_file}") if has_uefi(): self.pacstrap('efibootmgr') @@ -509,10 +518,7 @@ class Installer: self.helper_flags['bootloader'] = True return True else: - root_device = subprocess.check_output(f'basename "$(readlink -f /sys/class/block/{root_partition.path.replace("/dev/", "")}/..)"', shell=True).decode().strip() - if root_device == "block": - root_device = f"{root_partition.path}" - o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc /dev/{root_device}')) + o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc --recheck {_device.path}')) SysCommand('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') self.helper_flags['bootloader'] = True else: diff --git a/examples/guided.py b/examples/guided.py index aebebcfa..17732f1b 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -322,8 +322,7 @@ def perform_installation_steps(): else: fs.find_partition('/').mount(archinstall.storage.get('MOUNT_POINT', '/mnt')) - if has_uefi(): - fs.find_partition('/boot').mount(archinstall.storage.get('MOUNT_POINT', '/mnt') + '/boot') + fs.find_partition('/boot').mount(archinstall.storage.get('MOUNT_POINT', '/mnt') + '/boot') perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt')) @@ -352,7 +351,7 @@ def perform_installation(mountpoint): installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium if archinstall.arguments["bootloader"] == "grub-install" and has_uefi(): installation.add_additional_packages("grub") - installation.add_bootloader(archinstall.arguments["bootloader"]) + installation.add_bootloader(archinstall.arguments["harddrive"], archinstall.arguments["bootloader"]) # If user selected to copy the current ISO network configuration # Perform a copy of the config -- cgit v1.2.3-70-g09d2 From 3d4f58a04e06ef4bdd023effc52d4cb33b49080c Mon Sep 17 00:00:00 2001 From: monosans Date: Fri, 16 Jul 2021 10:42:29 +0300 Subject: Replace for loops with comprehensions --- archinstall/lib/general.py | 5 +---- archinstall/lib/hardware.py | 5 ++++- archinstall/lib/mirrors.py | 4 +--- archinstall/lib/packages.py | 15 ++++++--------- docs/conf.py | 4 +--- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index b9dc66ab..5200033a 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -98,10 +98,7 @@ class JsonEncoder: elif isinstance(obj, (datetime, date)): return obj.isoformat() elif isinstance(obj, (list, set, tuple)): - r = [] - for item in obj: - r.append(json.loads(json.dumps(item, cls=JSON))) - return r + return [json.loads(json.dumps(item, cls=JSON)) for item in obj] else: return obj diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index a63155f5..b1ac516d 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -131,7 +131,10 @@ def product_name() -> Optional[str]: def mem_info(): # This implementation is from https://stackoverflow.com/a/28161352 - return dict((i.split()[0].rstrip(':'), int(i.split()[1])) for i in open('/proc/meminfo').readlines()) + return { + i.split()[0].rstrip(':'): int(i.split()[1]) + for i in open('/proc/meminfo').readlines() + } def mem_available() -> Optional[str]: diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index 95fb5ac6..1b62a61b 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -59,9 +59,7 @@ def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', so :param regions: A series of country codes separated by `,`. For instance `SE,US` for sweden and United States. :type regions: str """ - region_list = [] - for region in regions.split(','): - region_list.append(f'country={region}') + region_list = [f'country={region}' for region in regions.split(',')] response = urllib.request.urlopen(urllib.request.Request(f"https://archlinux.org/mirrorlist/?{'&'.join(region_list)}&protocol=https&protocol=http&ip_version=4&ip_version=6&use_mirror_status=on'", headers={'User-Agent': 'ArchInstall'})) new_list = response.read().replace(b"#Server", b"Server") diff --git a/archinstall/lib/packages.py b/archinstall/lib/packages.py index 0ea195d2..0178d257 100644 --- a/archinstall/lib/packages.py +++ b/archinstall/lib/packages.py @@ -46,10 +46,7 @@ def find_packages(*names): The function itself is rather slow, so consider not sending to many packages to the search query. """ - result = {} - for package in names: - result[package] = find_package(package) - return result + return {package: find_package(package) for package in names} def validate_package_list(packages: list): @@ -57,11 +54,11 @@ def validate_package_list(packages: list): Validates a list of given packages. Raises `RequirementError` if one or more packages are not found. """ - invalid_packages = [] - for package in packages: - if not find_package(package)['results'] and not find_group(package): - invalid_packages.append(package) - + invalid_packages = [ + package + for package in packages + if not find_package(package)['results'] and not find_group(package) + ] if invalid_packages: raise RequirementError(f"Invalid package names: {invalid_packages}") diff --git a/docs/conf.py b/docs/conf.py index add1c5e7..33aeeae8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,9 +7,7 @@ sys.path.insert(0, os.path.abspath('..')) def process_docstring(app, what, name, obj, options, lines): spaces_pat = re.compile(r"( {8})") - ll = [] - for line in lines: - ll.append(spaces_pat.sub(" ", line)) + ll = [spaces_pat.sub(" ", line) for line in lines] lines[:] = ll -- cgit v1.2.3-70-g09d2 From d55b1786c5797c191cfbaad79c33b1079d1d53c5 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 01:28:41 +0530 Subject: created load_config() to load configuration --- archinstall/lib/user_interaction.py | 3 +- examples/guided.py | 70 +++++++++++++++---------------------- 2 files changed, 31 insertions(+), 42 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 2c5810ae..44dabbe6 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -710,7 +710,8 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): if has_nvidia_graphics(): print('For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.') - arguments['gfx_driver'] = generic_select(drivers, input_text="Select your graphics card driver: ") + if not arguments.get('gfx_driver', None): + arguments['gfx_driver'] = generic_select(drivers, input_text="Select a graphics driver or leave blank to install all open-source drivers: ") if arguments.get('gfx_driver', None) is None: arguments['gfx_driver'] = "All open-source (default)" diff --git a/examples/guided.py b/examples/guided.py index aebebcfa..0ec9834f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -26,6 +26,29 @@ archinstall.log(f"Graphics devices detected: {archinstall.graphics_devices().key # For support reasons, we'll log the disk layout pre installation to match against post-installation layout archinstall.log(f"Disk states before installing: {archinstall.disk_layouts()}", level=logging.DEBUG) +def load_config(): + if archinstall.arguments.get('harddrive', None) is not None: + archinstall.arguments['harddrive'] = archinstall.BlockDevice(path=archinstall.arguments['harddrive']['path']) + # Temporarily disabling keep_partitions if config file is loaded + archinstall.arguments['harddrive'].keep_partitions = False + # Temporary workaround to make Desktop Environments work + if archinstall.arguments.get('profile', None) is not None: + if type(archinstall.arguments.get('profile', None)) is dict: + archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)['path']) + else: + archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) + if archinstall.arguments.get('mirror-region', None) is not None: + if type(archinstall.arguments.get('mirror-region', None)) is dict: + archinstall.arguments['mirror-region'] = archinstall.arguments.get('mirror-region', None) + else: + selected_region = archinstall.arguments.get('mirror-region', None) + archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} + if archinstall.arguments.get('sys-language', None) is not None: + archinstall.arguments['sys-language'] = archinstall.arguments.get('sys-language', 'en_US') + if archinstall.arguments.get('sys-encoding', None) is not None: + archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') + if archinstall.arguments.get('gfx_driver', None) is not None: + archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) def ask_user_questions(): """ @@ -54,9 +77,6 @@ def ask_user_questions(): break except archinstall.RequirementError as e: archinstall.log(e, fg="red") - else: - selected_region = archinstall.arguments['mirror-region'] - archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} if not archinstall.arguments.get('sys-language', None) and archinstall.arguments.get('advanced', False): archinstall.arguments['sys-language'] = input("Enter a valid locale (language) for your OS, (Default: en_US): ").strip() @@ -69,9 +89,7 @@ def ask_user_questions(): archinstall.arguments['sys-encoding'] = 'utf-8' # Ask which harddrive/block-device we will install to - if archinstall.arguments.get('harddrive', None): - archinstall.arguments['harddrive'] = archinstall.BlockDevice(archinstall.arguments['harddrive']) - else: + if not archinstall.arguments.get('harddrive', None): archinstall.arguments['harddrive'] = archinstall.select_disk(archinstall.all_disks()) if archinstall.arguments['harddrive'] is None: archinstall.arguments['target-mount'] = archinstall.storage.get('MOUNT_POINT', '/mnt') @@ -188,20 +206,15 @@ def ask_user_questions(): archinstall.arguments['!root-password'] = archinstall.get_password(prompt='Enter root password (Recommendation: leave blank to leave root disabled): ') # Ask for additional users (super-user if root pw was not set) - archinstall.arguments['users'] = {} - archinstall.arguments['superusers'] = {} - if not archinstall.arguments.get('!root-password', None): + if not archinstall.arguments.get('!root-password', None) and not archinstall.arguments.get('superusers', None): archinstall.arguments['superusers'] = archinstall.ask_for_superuser_account('Create a required super-user with sudo privileges: ', forced=True) - - users, superusers = archinstall.ask_for_additional_users('Enter a username to create a additional user (leave blank to skip & continue): ') - archinstall.arguments['users'] = users - archinstall.arguments['superusers'] = {**archinstall.arguments['superusers'], **superusers} + users, superusers = archinstall.ask_for_additional_users('Enter a username to create a additional user (leave blank to skip & continue): ') + archinstall.arguments['users'] = users + archinstall.arguments['superusers'] = {**archinstall.arguments['superusers'], **superusers} # Ask for archinstall-specific profiles (such as desktop environments etc) if not archinstall.arguments.get('profile', None): archinstall.arguments['profile'] = archinstall.select_profile() - else: - archinstall.arguments['profile'] = Profile(installer=None, path=archinstall.arguments['profile']) # Check the potentially selected profiles preparations to get early checks if some additional questions are needed. if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_prep_function(): @@ -437,33 +450,8 @@ if not check_mirror_reachable(): archinstall.log(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.", level=logging.INFO, fg="red") exit(1) +load_config() if not archinstall.arguments.get('silent'): ask_user_questions() -else: - # Workarounds if config is loaded from a file - # The harddrive section should be moved to perform_installation_steps, where it's actually being performed - # Blockdevice object should be created in perform_installation_steps - # This needs to be done until then - archinstall.arguments['harddrive'] = archinstall.BlockDevice(path=archinstall.arguments['harddrive']['path']) - # Temporarily disabling keep_partitions if config file is loaded - archinstall.arguments['harddrive'].keep_partitions = False - # Temporary workaround to make Desktop Environments work - if archinstall.arguments.get('profile', None) is not None: - if type(archinstall.arguments.get('profile', None)) is dict: - archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)['path']) - else: - archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) - else: - archinstall.arguments['profile'] = None - if archinstall.arguments.get('mirror-region', None) is not None: - if type(archinstall.arguments.get('mirror-region', None)) is dict: - archinstall.arguments['mirror-region'] = archinstall.arguments.get('mirror-region', None) - else: - selected_region = archinstall.arguments.get('mirror-region', None) - archinstall.arguments['mirror-region'] = {selected_region: archinstall.list_mirrors()[selected_region]} - archinstall.arguments['sys-language'] = archinstall.arguments.get('sys-language', 'en_US') - archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') - if archinstall.arguments.get('gfx_driver', None) is not None: - archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) perform_installation_steps() -- cgit v1.2.3-70-g09d2 From b1998ddebf5bb73ae944c021e910c4fcb08878ec Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 16:37:02 +0530 Subject: fix for #602, running mklabel before formatting --- archinstall/lib/disk.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index de39bafd..be0e6518 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -519,6 +519,8 @@ class Filesystem: self.blockdevice.partition[1].allow_formatting = True else: # we don't need a seprate boot partition it would be a waste of space + if not self.parted_mklabel(self.blockdevice.device, "msdos"): + raise KeyError(f"Could not create a MSDOS label on {self}") self.add_partition('primary', start='1MB', end='100%') self.blockdevice.partition[0].filesystem = root_filesystem_type log(f"Set the root partition {self.blockdevice.partition[0]} to use filesystem {root_filesystem_type}.", level=logging.DEBUG) @@ -539,11 +541,9 @@ class Filesystem: if partitioning: start_wait = time.time() - while previous_partitions == self.blockdevice.partitions: - time.sleep(0.025) # Let the new partition come up in the kernel - if time.time() - start_wait > 10: - raise DiskError(f"New partition never showed up after adding new partition on {self} (timeout 10 seconds).") - + time.sleep(0.025) # Let the new partition come up in the kernel + if time.time() - start_wait > 20: + raise DiskError(f"New partition never showed up after adding new partition on {self} (timeout 10 seconds).") return True def set_name(self, partition: int, name: str): -- cgit v1.2.3-70-g09d2 From b2476313a7284fedc7a29ec17fc5090a1c985ae9 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 21:17:20 +0530 Subject: added new key for desktop-environment --- examples/guided.py | 1 + profiles/desktop.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 0ec9834f..6054387a 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -37,6 +37,7 @@ def load_config(): archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)['path']) else: archinstall.arguments['profile'] = archinstall.Profile(None, archinstall.arguments.get('profile', None)) + archinstall.storage['_desktop_profile'] = archinstall.arguments.get('desktop-environment', None) if archinstall.arguments.get('mirror-region', None) is not None: if type(archinstall.arguments.get('mirror-region', None)) is dict: archinstall.arguments['mirror-region'] = archinstall.arguments.get('mirror-region', None) diff --git a/profiles/desktop.py b/profiles/desktop.py index eaf145c2..457283e9 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -52,10 +52,8 @@ def _prep_function(*args, **kwargs): # the next time it gets executed. if '_desktop_profile' not in archinstall.storage.keys(): archinstall.storage['_desktop_profile'] = desktop - + archinstall.arguments['desktop-environment'] = desktop profile = archinstall.Profile(None, desktop) - # Set the resolved profile path to the actual desktop environment - archinstall.arguments['profile'] = profile # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. with profile.load_instructions(namespace=f"{desktop}.py") as imported: if hasattr(imported, '_prep_function'): -- cgit v1.2.3-70-g09d2 From b60e8dfd10d4d4c2b2918bad8df2b8354a7f4996 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 21:45:24 +0530 Subject: changed dry_run to dry-run --- archinstall/__init__.py | 2 +- examples/guided.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 84595528..2eec1ce6 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -64,7 +64,7 @@ def initialize_arguments(): config[key] = val config["script"] = args.script if args.dry_run is not None: - config["dry_run"] = args.dry_run + config["dry-run"] = args.dry_run return config diff --git a/examples/guided.py b/examples/guided.py index 6054387a..6cb80190 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -280,7 +280,7 @@ def perform_installation_steps(): config_file.write(user_configuration) print() - if archinstall.arguments.get('dry_run'): + if archinstall.arguments.get('dry-run'): exit(0) if not archinstall.arguments.get('silent'): -- cgit v1.2.3-70-g09d2 From a67a2693dbda2f8c4e75a39f73bd6c9e38257b4d Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Sun, 18 Jul 2021 22:41:18 +0530 Subject: fixed profile selection --- profiles/desktop.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profiles/desktop.py b/profiles/desktop.py index 457283e9..b9174ac5 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -50,9 +50,10 @@ def _prep_function(*args, **kwargs): # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. - if '_desktop_profile' not in archinstall.storage.keys(): + if not archinstall.storage.get('_desktop_profile', None): archinstall.storage['_desktop_profile'] = desktop - archinstall.arguments['desktop-environment'] = desktop + if not archinstall.arguments.get('desktop-environment', None): + archinstall.arguments['desktop-environment'] = desktop profile = archinstall.Profile(None, desktop) # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. with profile.load_instructions(namespace=f"{desktop}.py") as imported: -- cgit v1.2.3-70-g09d2 From b0aa5dcbbb779a72e06132be41f087c93f44e6d9 Mon Sep 17 00:00:00 2001 From: j-james Date: Mon, 19 Jul 2021 16:05:59 -0700 Subject: Mention GNOME and KDE's soft dependency on NetworkManager in the install --- archinstall/lib/user_interaction.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 3c1ba04f..d34025a2 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -388,13 +388,13 @@ def ask_to_configure_network(): # {MAC: Ifname} interfaces = { 'ISO-CONFIG': 'Copy ISO network configuration to installation', - 'NetworkManager': 'Use NetworkManager to control and manage your internet connection', + 'NetworkManager': 'Use NetworkManager (necessary to configure internet graphically in GNOME and KDE)', **list_interfaces() } nic = generic_select(interfaces, "Select one network interface to configure (leave blank to skip): ") if nic and nic != 'Copy ISO network configuration to installation': - if nic == 'Use NetworkManager to control and manage your internet connection': + if nic == 'Use NetworkManager (necessary to configure internet graphically in GNOME and KDE)': return {'nic': nic, 'NetworkManager': True} # Current workaround: @@ -700,7 +700,7 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): """ drivers = sorted(list(options)) - + if drivers: arguments = storage.get('arguments', {}) if has_amd_graphics(): @@ -711,10 +711,10 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): print('For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.') arguments['gfx_driver'] = generic_select(drivers, input_text="Select a graphics driver or leave blank to install all open-source drivers: ") - + if arguments.get('gfx_driver', None) is None: arguments['gfx_driver'] = "All open-source (default)" - + return options.get(arguments.get('gfx_driver')) raise RequirementError("Selecting drivers require a least one profile to be given as an option.") -- cgit v1.2.3-70-g09d2 From bbce3aa26afc3d55831954231579a5456b0da61a Mon Sep 17 00:00:00 2001 From: CYPT71 <51490865+CYPT71@users.noreply.github.com> Date: Thu, 22 Jul 2021 11:47:56 +0200 Subject: Update hardware.py Rewrite some function if condition is True then return true else return false, transform in return condition directly Also I don't understand why we need a try/except at line 151 and why we not write return condition ?? --- archinstall/lib/hardware.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index a63155f5..d040c19a 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -69,10 +69,7 @@ def has_amd_cpu() -> bool: def has_intel_cpu() -> bool: - if subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode(): - return True - return False - + return subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode() def has_uefi() -> bool: return os.path.isdir('/sys/firmware/efi') @@ -106,7 +103,7 @@ def cpu_vendor() -> Optional[str]: for info in cpu_info: if info.get('field', None) == "Vendor ID:": return info.get('data', None) - return None + return def cpu_model() -> Optional[str]: @@ -116,7 +113,7 @@ def cpu_model() -> Optional[str]: for info in cpu_info: if info.get('field', None) == "Model name:": return info.get('data', None) - return None + return def sys_vendor() -> Optional[str]: @@ -151,6 +148,8 @@ def virtualization() -> Optional[str]: def is_vm() -> bool: + return b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower() + """ try: # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine if b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower(): @@ -159,5 +158,7 @@ def is_vm() -> bool: pass return False + + """ # TODO: Add more identifiers -- cgit v1.2.3-70-g09d2 From a1667a25f1e1e133a2058220964907c511e52850 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Sat, 24 Jul 2021 20:41:35 +0800 Subject: Remove lightdm packages from Deepin profile As of deepin-session-shell 5.4.42-2 (which is in the deepin group), lightdm is added as a dependency because of lightdm-deepin-greeter. A configuration (usr/share/lightdm/lightdm.conf.d/60-deepin.conf) in startdde (also in the deepin group) should override default lightdm configuration to use lightdm-deepin-greeter instead of the gtk greeter. Thus these two packages could be removed from the profile now. This effectively reverts #441 --- profiles/deepin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/profiles/deepin.py b/profiles/deepin.py index 5bc18285..09b05ed5 100644 --- a/profiles/deepin.py +++ b/profiles/deepin.py @@ -8,8 +8,6 @@ __packages__ = [ "deepin", "deepin-terminal", "deepin-editor", - "lightdm", - "lightdm-gtk-greeter", ] -- cgit v1.2.3-70-g09d2 From 64e6b7b4565f3f8e72cadd53b82744588c641d68 Mon Sep 17 00:00:00 2001 From: Lucas Pinto <30878914+luckspt@users.noreply.github.com> Date: Wed, 28 Jul 2021 01:35:26 +0100 Subject: Typo Fix a tiny typo --- archinstall/lib/disk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index de39bafd..485d5d5c 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -531,7 +531,7 @@ class Filesystem: previous_partitions = self.blockdevice.partitions if self.mode == MBR: if len(self.blockdevice.partitions) > 3: - DiskError("Too many partitions on disk, MBR disks can only have 3 parimary partitions") + DiskError("Too many partitions on disk, MBR disks can only have 3 primary partitions") if partition_format: partitioning = self.parted(f'{self.blockdevice.device} mkpart {partition_type} {partition_format} {start} {end}') == 0 else: -- cgit v1.2.3-70-g09d2 From 339e9f8a427d2f9c4f9a09fd17760dd2aedf15ea Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Thu, 5 Aug 2021 15:23:50 +0800 Subject: Add back lightdm, be more explicit --- profiles/deepin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/profiles/deepin.py b/profiles/deepin.py index 09b05ed5..8196bc4b 100644 --- a/profiles/deepin.py +++ b/profiles/deepin.py @@ -8,6 +8,8 @@ __packages__ = [ "deepin", "deepin-terminal", "deepin-editor", + "lightdm", + "lightdm-deepin-greeter", ] -- cgit v1.2.3-70-g09d2 From 71ec22a3490524cf52567bdff5b7a0dfcd617acb Mon Sep 17 00:00:00 2001 From: RustyRaptor Date: Tue, 17 Aug 2021 13:54:26 -0600 Subject: fixed the git checkout non-existent branch It looks like the `torxed-v2.2.0` branch doesnt exist anymore and I assume its now just `v2.2.0` instead so I changed this command in Using a live ISO --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c430ac0e..16b81509 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ you can replace the version of archinstall with a new version and run that with 3. Uninstall the previous version of archinstall with `pip uninstall archinstall` 4. Now clone the latest repository with `git clone https://github.com/archlinux/archinstall` 5. Enter the repository with `cd archinstall` - *At this stage, you can choose to check out a feature branch for instance with `git checkout torxed-v2.2.0`* + *At this stage, you can choose to check out a feature branch for instance with `git checkout v2.2.0`* 6. Build the project and install it using `python setup.py install` After this, running archinstall with `python -m archinstall` will run against whatever branch you chose in step 5. -- cgit v1.2.3-70-g09d2 From 79f70cee21c3ed74b2a7c274dee34843aa54f2c7 Mon Sep 17 00:00:00 2001 From: ギャラ Date: Wed, 18 Aug 2021 20:52:10 +0900 Subject: Update guided.py Fix wrong default in kernels. --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index aebebcfa..91d0357c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -334,7 +334,7 @@ def perform_installation(mountpoint): Only requirement is that the block devices are formatted and setup prior to entering this function. """ - with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', 'linux')) as installation: + with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', ['linux'])) as installation: # if len(mirrors): # Certain services might be running that affects the system during installation. # Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist -- cgit v1.2.3-70-g09d2 From 6d462ac1ccfe3ec74f70e000465d422c31d9e634 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 20 Aug 2021 03:34:50 +0530 Subject: added servers key --- examples/guided.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index 6cb80190..7a9f8b47 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -8,6 +8,7 @@ from archinstall.lib.general import run_custom_user_commands from archinstall.lib.hardware import * from archinstall.lib.networking import check_mirror_reachable from archinstall.lib.profiles import Profile, is_desktop_profile +from archinstall.lib.profiles.server import available_servers if archinstall.arguments.get('help'): print("See `man archinstall` for help.") @@ -50,7 +51,9 @@ def load_config(): archinstall.arguments['sys-encoding'] = archinstall.arguments.get('sys-encoding', 'utf-8') if archinstall.arguments.get('gfx_driver', None) is not None: archinstall.storage['gfx_driver_packages'] = AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None) - + if archinstall.arguments.get('servers', None) is not None: + archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None) + def ask_user_questions(): """ First, we'll ask the user for a bunch of user input. -- cgit v1.2.3-70-g09d2 From 78bbf26c1aa02f34366020ec4d9212836fafc3dd Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 20 Aug 2021 03:48:13 +0530 Subject: Update guided.py --- examples/guided.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/guided.py b/examples/guided.py index 7a9f8b47..273fcadf 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -8,7 +8,6 @@ from archinstall.lib.general import run_custom_user_commands from archinstall.lib.hardware import * from archinstall.lib.networking import check_mirror_reachable from archinstall.lib.profiles import Profile, is_desktop_profile -from archinstall.lib.profiles.server import available_servers if archinstall.arguments.get('help'): print("See `man archinstall` for help.") -- cgit v1.2.3-70-g09d2 From c461cc49e756332578e99404fa757a5610f0992c Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 20 Aug 2021 03:54:23 +0530 Subject: only prompt if _selected_servers is not set --- profiles/server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profiles/server.py b/profiles/server.py index 79aa9481..731d2005 100644 --- a/profiles/server.py +++ b/profiles/server.py @@ -26,8 +26,9 @@ def _prep_function(*args, **kwargs): Magic function called by the importing installer before continuing any further. """ - selected_servers = archinstall.generic_multi_select(available_servers, "Choose which servers to install and enable (leave blank for a minimal installation): ") - archinstall.storage['_selected_servers'] = selected_servers + if not archinstall.storage.get('_selected_servers', None): + selected_servers = archinstall.generic_multi_select(available_servers, "Choose which servers to install and enable (leave blank for a minimal installation): ") + archinstall.storage['_selected_servers'] = selected_servers return True -- cgit v1.2.3-70-g09d2 From b8ede1b333e3dd4d2a6c3553685e5026dfd2c346 Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Fri, 20 Aug 2021 18:13:23 +0200 Subject: Add cpuinfo() --- archinstall/lib/hardware.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index a63155f5..56a9fa11 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -1,7 +1,8 @@ import json import os import subprocess -from typing import Optional +from pathlib import Path +from typing import Iterator, Optional from .general import SysCommand from .networking import list_interfaces, enrich_iface_types @@ -57,6 +58,24 @@ AVAILABLE_GFX_DRIVERS = { "VMware / VirtualBox (open-source)": ["mesa", "xf86-video-vmware"], } +CPUINFO = Path("/proc/cpuinfo") + + +def cpuinfo() -> Iterator[dict[str, str]]: + """Yields information about the CPUs of the system.""" + + cpu = {} + + with CPUINFO.open() as file: + for line in file: + if not (line := line.strip()): + yield cpu + cpu = {} + continue + + key, value = line.split(":", maxsplit=1) + cpu[key.strip()] = value.strip() + def has_wifi() -> bool: return 'WIRELESS' in enrich_iface_types(list_interfaces().values()).values() -- cgit v1.2.3-70-g09d2 From 61947ab944aec76d60ee921ff3c451b7d02a5df2 Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Fri, 20 Aug 2021 18:16:00 +0200 Subject: Rewrite CPU vendor detection functions Use cpuinfo() function rather than a subprocess. --- archinstall/lib/hardware.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index 56a9fa11..eaf01f40 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -1,6 +1,5 @@ import json import os -import subprocess from pathlib import Path from typing import Iterator, Optional @@ -82,15 +81,11 @@ def has_wifi() -> bool: def has_amd_cpu() -> bool: - if subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode(): - return True - return False + return any(cpu.get("vendor_id") == "AuthenticAMD" for cpu in cpuinfo()) def has_intel_cpu() -> bool: - if subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode(): - return True - return False + return any(cpu.get("vendor_id") == "GenuineIntel" for cpu in cpuinfo()) def has_uefi() -> bool: -- cgit v1.2.3-70-g09d2 From a5a56728f155f689bed5826bbd30532a56450cf3 Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Fri, 20 Aug 2021 18:16:45 +0200 Subject: Remove excess newline --- archinstall/lib/hardware.py | 1 - 1 file changed, 1 deletion(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index eaf01f40..1299a6b4 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -62,7 +62,6 @@ CPUINFO = Path("/proc/cpuinfo") def cpuinfo() -> Iterator[dict[str, str]]: """Yields information about the CPUs of the system.""" - cpu = {} with CPUINFO.open() as file: -- cgit v1.2.3-70-g09d2 From 5fe752cf7223cc9ff1cf1a50ad5f7873594f83c1 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 6 Sep 2021 13:22:53 +0000 Subject: No need for try/catch any longer. The old behavior of SysCommand was that exit codes raised an exception, which needed to be handled by each individual caller. We now utilize `.exit_code` instead to manually detect faulty commands and raise exceptions where needed. --- archinstall/lib/hardware.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index d040c19a..f38d46da 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -149,16 +149,5 @@ def virtualization() -> Optional[str]: def is_vm() -> bool: return b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower() - """ - try: - # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine - if b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower(): - return True - except: - pass - - return False - - """ # TODO: Add more identifiers -- cgit v1.2.3-70-g09d2 From 8d7ccde1626afbf358e38caa2733aff554b51ea9 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 6 Sep 2021 13:40:45 +0000 Subject: Added exception handling to check_output I tweaked the optimized return of check_output. Worth mentioning that `check_output()` will raise an exception `subprocess.CalledProcessError: Command 'lscpu | grep AMD' returned non-zero exit status 1.`. --- archinstall/lib/hardware.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index f38d46da..c64d21a9 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -63,13 +63,19 @@ def has_wifi() -> bool: def has_amd_cpu() -> bool: - if subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode(): - return True + try: + return subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode() + except: + pass return False def has_intel_cpu() -> bool: - return subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode() + try: + return subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode() + except: + pass + return False def has_uefi() -> bool: return os.path.isdir('/sys/firmware/efi') -- cgit v1.2.3-70-g09d2