index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | archinstall/lib/disk.py | 37 | ||||
-rw-r--r-- | archinstall/lib/general.py | 5 | ||||
-rw-r--r-- | archinstall/lib/hardware.py | 31 | ||||
-rw-r--r-- | archinstall/lib/installer.py | 18 | ||||
-rw-r--r-- | archinstall/lib/mirrors.py | 4 | ||||
-rw-r--r-- | archinstall/lib/packages.py | 15 | ||||
-rw-r--r-- | archinstall/lib/user_interaction.py | 13 |
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index de39bafd..17ffe762 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,24 @@ 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 = '/' + 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='1MiB', end='513MiB', partition_format='ext4') + self.set(0, 'boot on') + self.add_partition('primary', start='513MiB', end='100%') + + self.blockdevice.partition[0].filesystem = 'ext4' # TODO: Up for debate weither or not this should be user-supplied: https://github.com/archlinux/archinstall/pull/595/files + self.blockdevice.partition[1].filesystem = root_filesystem_type + + log(f"Set the boot partition {self.blockdevice.partition[0]} to use filesystem {'ext4'}.", level=logging.DEBUG) + 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) @@ -531,7 +548,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: @@ -539,11 +556,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): 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..03335e45 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -63,17 +63,20 @@ 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: - if subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode(): - return True + 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') @@ -106,7 +109,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 +119,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]: @@ -131,7 +134,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]: @@ -151,13 +157,6 @@ def virtualization() -> Optional[str]: def is_vm() -> bool: - 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 + return b"none" not in b"".join(SysCommand("systemd-detect-virt")).lower() # TODO: Add more identifiers 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/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/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 3c1ba04f..cebb2775 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(): @@ -710,11 +710,12 @@ 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 a graphics driver or leave blank to install all open-source drivers: ") - + 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)" - + return options.get(arguments.get('gfx_driver')) raise RequirementError("Selecting drivers require a least one profile to be given as an option.") |