From 51286f2a6509c708fa44066ada03116698c0dc05 Mon Sep 17 00:00:00 2001 From: Ruslan Kiyanchuk Date: Sat, 3 Apr 2021 14:44:45 -0700 Subject: Fix undefined variables in installer --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a4321893..663288e5 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -98,7 +98,7 @@ class Installer(): self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) for step in missing_steps: self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning) - self.log(f"Detailed error logs can be found at: {log_path}", level=LOG_LEVELS.Warning) + self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=LOG_LEVELS.Warning) self.log(f"Submit this zip file as an issue to https://github.com/Torxed/archinstall/issues", level=LOG_LEVELS.Warning) self.sync_log_to_install_medium() return False @@ -149,7 +149,7 @@ class Installer(): fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{o}') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n') return True -- cgit v1.2.3-54-g00ecf From 2b5b1ad83da34b73ae50dcccbf6e7f291e38b06b Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 4 Apr 2021 11:28:54 -0300 Subject: Fix misspellings --- archinstall/lib/disk.py | 10 +++++----- archinstall/lib/installer.py | 6 +++--- archinstall/lib/networking.py | 4 ++-- archinstall/lib/output.py | 4 ++-- archinstall/lib/profiles.py | 14 +++++++------- archinstall/lib/storage.py | 2 +- archinstall/lib/user_interaction.py | 2 +- docs/installing/guided.rst | 4 ++-- examples/guided.py | 12 ++++++------ profiles/desktop.py | 8 ++++---- profiles/kde-wayland.py | 2 +- profiles/kde.py | 2 +- 12 files changed, 35 insertions(+), 35 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 10d4ef5a..2ca2f4b0 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -25,7 +25,7 @@ class BlockDevice(): self.path = path self.info = info self.part_cache = OrderedDict() - # TODO: Currently disk encryption is a BIT missleading. + # TODO: Currently disk encryption is a BIT misleading. # It's actually partition-encryption, but for future-proofing this # I'm placing the encryption password on a BlockDevice level. self.encryption_passwoed = None @@ -284,10 +284,10 @@ class Partition(): handle = luks2(self, None, None) return handle.encrypt(self, *args, **kwargs) - def format(self, filesystem=None, path=None, allow_formatting=None, log_formating=True): + def format(self, filesystem=None, path=None, allow_formatting=None, log_formatting=True): """ Format can be given an overriding path, for instance /dev/null to test - the formating functionality and in essence the support for the given filesystem. + the formatting functionality and in essence the support for the given filesystem. """ if filesystem is None: filesystem = self.filesystem @@ -305,7 +305,7 @@ class Partition(): if not allow_formatting: raise PermissionError(f"{self} is not formatable either because instance is locked ({self.allow_formatting}) or a blocking flag was given ({allow_formatting})") - if log_formating: + if log_formatting: log(f'Formatting {path} -> {filesystem}', level=LOG_LEVELS.Info) if filesystem == 'btrfs': @@ -400,7 +400,7 @@ class Partition(): 2. UnknownFilesystemFormat that indicates that we don't support the given filesystem type """ try: - self.format(self.filesystem, '/dev/null', log_formating=False, allow_formatting=True) + self.format(self.filesystem, '/dev/null', log_formatting=False, allow_formatting=True) except SysCallError: pass # We supported it, but /dev/null is not formatable as expected so the mkfs call exited with an error code except UnknownFilesystemFormat as err: diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a4321893..857e5c4f 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -73,7 +73,7 @@ class Installer(): return self def __exit__(self, *args, **kwargs): - # b''.join(sys_command(f'sync')) # No need to, since the underlaying fs() object will call sync. + # b''.join(sys_command(f'sync')) # No need to, since the underlying fs() object will call sync. # TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager if len(args) >= 2 and args[1]: @@ -268,7 +268,7 @@ class Installer(): return True def minimal_installation(self): - ## Add nessecary packages if encrypting the drive + ## Add necessary packages if encrypting the drive ## (encrypted partitions default to btrfs for now, so we need btrfs-progs) ## TODO: Perhaps this should be living in the function which dictates ## the partitioning. Leaving here for now. @@ -401,7 +401,7 @@ class Installer(): # The tricky thing with doing the import archinstall.session instead is that # profiles might be run from a different chroot, and there's no way we can # guarantee file-path safety when accessing the installer object that way. - # Doing the __builtins__ replacement, ensures that the global vriable "installation" + # Doing the __builtins__ replacement, ensures that the global variable "installation" # is always kept up to date. It's considered a nasty hack - but it's a safe way # of ensuring 100% accuracy of archinstall session variables. __builtins__['installation'] = self diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py index 882bcff3..2dc8be9b 100644 --- a/archinstall/lib/networking.py +++ b/archinstall/lib/networking.py @@ -56,7 +56,7 @@ def wirelessScan(interface): storage['_WIFI'][interface]['scanning'] = True -# TOOD: Full WiFi experience might get evolved in the future, pausing for now 2021-01-25 +# TODO: Full WiFi experience might get evolved in the future, pausing for now 2021-01-25 def getWirelessNetworks(interface): # TODO: Make this oneliner pritter to check if the interface is scanning or not. if not '_WIFI' in storage or interface not in storage['_WIFI'] or storage['_WIFI'][interface].get('scanning', False) is False: @@ -65,4 +65,4 @@ def getWirelessNetworks(interface): time.sleep(5) for line in sys_command(f"iwctl station {interface} get-networks"): - print(line) \ No newline at end of file + print(line) diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py index 537fb695..dfc6959d 100644 --- a/archinstall/lib/output.py +++ b/archinstall/lib/output.py @@ -6,7 +6,7 @@ from pathlib import Path from .storage import storage # TODO: use logging's built in levels instead. -# Altough logging is threaded and I wish to avoid that. +# Although logging is threaded and I wish to avoid that. # It's more Pythonistic or w/e you want to call it. class LOG_LEVELS: Critical = 0b001 @@ -130,4 +130,4 @@ def log(*args, **kwargs): # We use sys.stdout.write()+flush() instead of print() to try and # fix issue #94 sys.stdout.write(f"{string}\n") - sys.stdout.flush() \ No newline at end of file + sys.stdout.flush() diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 08b1d618..4ef6c533 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -112,11 +112,11 @@ class Script(): if f"{self.profile}" in self.examples: return self.localize_path(self.examples[self.profile]['path']) - # TODO: Redundant, the below block shouldnt be needed as profiles are stripped of their .py, but just in case for now: + # TODO: Redundant, the below block shouldn't be needed as profiles are stripped of their .py, but just in case for now: elif f"{self.profile}.py" in self.examples: return self.localize_path(self.examples[f"{self.profile}.py"]['path']) - # Path was not found in any known examples, check if it's an abolute path + # Path was not found in any known examples, check if it's an absolute path if os.path.isfile(self.profile): return self.profile @@ -156,7 +156,7 @@ class Profile(Script): def install(self): # Before installing, revert any temporary changes to the namespace. - # This ensures that the namespace during installation is the original initation namespace. + # This ensures that the namespace during installation is the original initiation namespace. # (For instance awesome instead of aweosme.py or app-awesome.py) self.namespace = self.original_namespace return self.execute() @@ -194,11 +194,11 @@ class Application(Profile): if f"{self.profile}" in self.examples: return self.localize_path(self.examples[self.profile]['path']) - # TODO: Redundant, the below block shouldnt be needed as profiles are stripped of their .py, but just in case for now: + # TODO: Redundant, the below block shouldn't be needed as profiles are stripped of their .py, but just in case for now: elif f"{self.profile}.py" in self.examples: return self.localize_path(self.examples[f"{self.profile}.py"]['path']) - # Path was not found in any known examples, check if it's an abolute path + # Path was not found in any known examples, check if it's an absolute path if os.path.isfile(self.profile): return os.path.basename(self.profile) @@ -210,7 +210,7 @@ class Application(Profile): def install(self): # Before installing, revert any temporary changes to the namespace. - # This ensures that the namespace during installation is the original initation namespace. + # This ensures that the namespace during installation is the original initiation namespace. # (For instance awesome instead of aweosme.py or app-awesome.py) self.namespace = self.original_namespace - return self.execute() \ No newline at end of file + return self.execute() diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py index 9bda017d..dfbcd8c7 100644 --- a/archinstall/lib/storage.py +++ b/archinstall/lib/storage.py @@ -15,7 +15,7 @@ storage = { #os.path.abspath(f'{os.path.dirname(__file__)}/../examples') ], 'UPSTREAM_URL' : 'https://raw.githubusercontent.com/Torxed/archinstall/master/profiles', - 'PROFILE_DB' : None, # Used in cases when listing profiles is desired, not mandatory for direct profile grabing. + 'PROFILE_DB' : None, # Used in cases when listing profiles is desired, not mandatory for direct profile grabbing. 'LOG_PATH' : '/var/log/archinstall', 'LOG_FILE' : 'install.log', 'MOUNT_POINT' : '/mnt' diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 630862ee..8cdbbe8c 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -151,7 +151,7 @@ def ask_for_main_filesystem_format(): def generic_select(options, input_text="Select one of the above by index or absolute value: ", sort=True): """ A generic select function that does not output anything - other than the options and their indexs. As an example: + other than the options and their indexes. As an example: generic_select(["first", "second", "third option"]) 1: first diff --git a/docs/installing/guided.rst b/docs/installing/guided.rst index 7ce081ca..2e1cda09 100644 --- a/docs/installing/guided.rst +++ b/docs/installing/guided.rst @@ -66,7 +66,7 @@ Default is :code:`auto detect best mirror` As an example: - * :code:`Sweden` *(wich a capital :code:`S`)* will only use mirrors from Sweden. + * :code:`Sweden` *(with a capital :code:`S`)* will only use mirrors from Sweden. Selection of drive ------------------ @@ -175,4 +175,4 @@ After which you can press :code:`Enter` can be pressed in order to start the for Post installation ----------------- -Once the installation is complete, green text should appear saying that it's safe to `reboot`, which is also the command you use to reboot. \ No newline at end of file +Once the installation is complete, green text should appear saying that it's safe to `reboot`, which is also the command you use to reboot. diff --git a/examples/guided.py b/examples/guided.py index 723eed5b..246a386c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -58,7 +58,7 @@ def ask_user_questions(): if archinstall.arguments['harddrive'].has_partitions(): archinstall.log(f"{archinstall.arguments['harddrive']} contains the following partitions:", fg='yellow') - # We curate a list pf supported paritions + # We curate a list pf supported partitions # and print those that we don't support. partition_mountpoints = {} for partition in archinstall.arguments['harddrive']: @@ -69,7 +69,7 @@ def ask_user_questions(): except archinstall.UnknownFilesystemFormat as err: archinstall.log(f" {partition} (Filesystem not supported)", fg='red') - # We then ask what to do with the paritions. + # We then ask what to do with the partitions. if (option := archinstall.ask_for_disk_layout()) == 'abort': archinstall.log(f"Safely aborting the installation. No changes to the disk or system has been made.") exit(1) @@ -89,7 +89,7 @@ def ask_user_questions(): mountpoint = input(f"Enter a mount-point for {partition}: ").strip(' ') if len(mountpoint): - # Get a valid & supported filesystem for the parition: + # Get a valid & supported filesystem for the partition: while 1: new_filesystem = input(f"Enter a valid filesystem for {partition} (leave blank for {partition.filesystem}): ").strip(' ') if len(new_filesystem) <= 0: @@ -120,7 +120,7 @@ def ask_user_questions(): # But that means our .format() function supported it. break - # When we've selected all three criterias, + # When we've selected all three criteria, # We can safely mark the partition for formatting and where to mount it. # TODO: allow_formatting might be redundant since target_mountpoint should only be # set if we actually want to format it anyway. @@ -170,7 +170,7 @@ def ask_user_questions(): else: archinstall.arguments['profile'] = archinstall.list_profiles()[archinstall.arguments['profile']] - # Check the potentially selected profiles preperations to get early checks if some additional questions are needed. + # 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(): with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported: if not imported._prep_function(): @@ -342,4 +342,4 @@ def perform_installation(device, boot_partition, language, mirrors): ask_user_questions() -perform_installation_steps() \ No newline at end of file +perform_installation_steps() diff --git a/profiles/desktop.py b/profiles/desktop.py index 869cf0a0..41a2ad8b 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -13,8 +13,8 @@ def _prep_function(*args, **kwargs): supported_desktops = ['gnome', 'kde', 'awesome'] desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ') - # Temporarly store the selected desktop profile - # in a session-safe location, since this module will get re-loaded + # Temporarily store the selected desktop profile + # in a session-safe location, since this module will get reloaded # the next time it gets executed. archinstall.storage['_desktop_profile'] = desktop @@ -29,7 +29,7 @@ def _prep_function(*args, **kwargs): if __name__ == 'desktop': """ This "profile" is a meta-profile. - There are no specific desktop-steps, it simply routes + There are no desktop-specific steps, it simply routes the installer to whichever desktop environment/window manager was chosen. Maybe in the future, a network manager or similar things *could* be added here. @@ -37,7 +37,7 @@ if __name__ == 'desktop': it trying to be a turn-key desktop distribution. There are plenty of desktop-turn-key-solutions based on Arch Linux, - this is therefor just a helper to get started + this is therefore just a helper to get started """ # TODO: Remove magic variable 'installation' and place it diff --git a/profiles/kde-wayland.py b/profiles/kde-wayland.py index 31226952..e21f62c8 100644 --- a/profiles/kde-wayland.py +++ b/profiles/kde-wayland.py @@ -1,4 +1,4 @@ -# A desktop environement using "KDE". +# A desktop environment using "KDE". import archinstall, os # TODO: Remove hard dependency of bash (due to .bash_profile) diff --git a/profiles/kde.py b/profiles/kde.py index 752a08d2..32819bd5 100644 --- a/profiles/kde.py +++ b/profiles/kde.py @@ -1,4 +1,4 @@ -# A desktop environement using "KDE". +# A desktop environment using "KDE". import archinstall, os -- cgit v1.2.3-54-g00ecf From 5a321d6ce540d89b1464743738e43d4ac3205832 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sun, 4 Apr 2021 11:52:51 -0300 Subject: Update repo to archlinux/archinstall --- CONTRIBUTING.md | 2 +- PKGBUILD | 2 +- PKGBUILDs/archinstall-bin/PKGBUILD | 4 ++-- PKGBUILDs/archinstall/PKGBUILD | 4 ++-- PKGBUILDs/python-archinstall/PKGBUILD | 4 ++-- README.md | 6 +++--- archinstall/lib/installer.py | 4 ++-- archinstall/lib/storage.py | 2 +- docs/examples/binary.rst | 2 +- docs/help/discord.rst | 2 +- docs/help/issues.rst | 2 +- docs/installing/binary.rst | 2 +- docs/installing/python.rst | 2 +- docs/pull_request_template.md | 2 +- examples/guided.py | 2 +- setup.py | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 59bc3eff..48cc14d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ Therefore guidelines and style changes to the code might come into affect as wel ## Discussions -Currently, questions, bugs and suggestions should be reported through [GitHub issue tracker](https://github.com/Torxed/archinstall/issues).
+Currently, questions, bugs and suggestions should be reported through [GitHub issue tracker](https://github.com/archlinux/archinstall/issues).
For less formal discussions there are also a [archinstall Discord server](https://discord.gg/cqXU88y). ## Coding convention diff --git a/PKGBUILD b/PKGBUILD index 7e073666..77e6b512 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -8,7 +8,7 @@ pkgver=$(git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g') pkgrel=1 pkgdesc="Just another guided/automated Arch Linux installer with a twist" arch=('any') -url="https://github.com/Torxed/archinstall" +url="https://github.com/archlinux/archinstall" license=('GPL') depends=('python') makedepends=('python-setuptools') diff --git a/PKGBUILDs/archinstall-bin/PKGBUILD b/PKGBUILDs/archinstall-bin/PKGBUILD index 855d19a5..25d4b15d 100644 --- a/PKGBUILDs/archinstall-bin/PKGBUILD +++ b/PKGBUILDs/archinstall-bin/PKGBUILD @@ -5,11 +5,11 @@ pkgname="archinstall-bin" pkgver="2.1.3" pkgdesc="Installs a pre-built binary of ${pkgname}" pkgrel=1 -url="https://github.com/Torxed/archinstall" +url="https://github.com/archlinux/archinstall" license=('GPLv3') provides=("${pkgname}") arch=('x86_64') -source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/Torxed/archinstall/archive/v$pkgver.tar.gz") +source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/archlinux/archinstall/archive/v$pkgver.tar.gz") #depends=('python>=3.8') makedepends=('python>=3.8' 'nuitka') optdepends=('pyttsx3: Adds text-to-speach support for log/screen output.') diff --git a/PKGBUILDs/archinstall/PKGBUILD b/PKGBUILDs/archinstall/PKGBUILD index 961ee79c..7b1c4947 100644 --- a/PKGBUILDs/archinstall/PKGBUILD +++ b/PKGBUILDs/archinstall/PKGBUILD @@ -5,11 +5,11 @@ pkgname="archinstall" pkgver="2.1.3" pkgdesc="Installs launcher scripts for archinstall" pkgrel=1 -url="https://github.com/Torxed/archinstall" +url="https://github.com/archlinux/archinstall" license=('GPLv3') provides=("${pkgname}") arch=('x86_64') -source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/Torxed/archinstall/archive/v$pkgver.tar.gz") +source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/archlinux/archinstall/archive/v$pkgver.tar.gz") depends=('python-archinstall') sha256sums=('53c00f7e7ad245cd2cbbf041b5a735df2fc29454c24b1d369f678cc0610b7cea') diff --git a/PKGBUILDs/python-archinstall/PKGBUILD b/PKGBUILDs/python-archinstall/PKGBUILD index 3a735ac9..1c3876f5 100644 --- a/PKGBUILDs/python-archinstall/PKGBUILD +++ b/PKGBUILDs/python-archinstall/PKGBUILD @@ -5,8 +5,8 @@ pkgname="python-archinstall" pkgver="2.1.3" pkgdesc="Installs ${pkgname} as a python library." pkgrel=1 -url="https://github.com/Torxed/archinstall" -source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/Torxed/archinstall/archive/v$pkgver.tar.gz") +url="https://github.com/archlinux/archinstall" +source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/archlinux/archinstall/archive/v$pkgver.tar.gz") license=('GPLv3') provides=("${pkgname}") arch=('x86_64') diff --git a/README.md b/README.md index c1ec746e..9037a5d3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# drawing +# drawing Just another guided/automated [Arch Linux](https://wiki.archlinux.org/index.php/Arch_Linux) installer with a twist. The installer also doubles as a python library to install Arch Linux and manage services, packages and other things inside the installed system *(Usually from a live medium)*. @@ -62,7 +62,7 @@ This installer will perform the following: * Installs a basic instance of Arch Linux *(base base-devel linux linux-firmware btrfs-progs efibootmgr)* * Installs and configures a bootloader to partition 0. * Install additional packages *(nano, wget, git)* - * Installs a network-profile called [awesome](https://github.com/Torxed/archinstall/blob/master/profiles/awesome.py) *(more on network profiles in the documentation)* + * Installs a network-profile called [awesome](https://github.com/archlinux/archinstall/blob/master/profiles/awesome.py) *(more on network profiles in the documentation)* > **Creating your own ISO with this script on it:** Follow [ArchISO](https://wiki.archlinux.org/index.php/archiso)'s guide on how to create your own ISO or use a pre-built [guided ISO](https://hvornum.se/archiso/) to skip the python installation step, or to create auto-installing ISO templates. Further down are examples and cheat sheets on how to create different live ISO's. @@ -87,5 +87,5 @@ This will create a *5GB* `testimage.img` and create a loop device which we can u `archinstall` is installed and executed in [guided mode](#docs-todo). Once the installation is complete,
~~you can use qemu/kvm to boot the test media.~~ *(You'd actually need to do some EFI magic in order to point the EFI vars to the partition 0 in the test medium so this won't work entirely out of the box, but gives you a general idea of what we're going for here)* -There's also a [Building and Testing](https://github.com/Torxed/archinstall/wiki/Building-and-Testing) guide.
+There's also a [Building and Testing](https://github.com/archlinux/archinstall/wiki/Building-and-Testing) guide.
It will go through everything from packaging, building and running *(with qemu)* the installer against a dev branch. diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a4321893..c0d174ff 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -85,7 +85,7 @@ class Installer(): # We avoid printing /mnt/ because that might confuse people if they note it down # and then reboot, and a identical log file will be found in the ISO medium anyway. print(f"[!] A log file has been created here: {os.path.join(storage['LOG_PATH'], storage['LOG_FILE'])}") - print(f" Please submit this issue (and file) to https://github.com/Torxed/archinstall/issues") + print(f" Please submit this issue (and file) to https://github.com/archlinux/archinstall/issues") raise args[1] self.genfstab() @@ -99,7 +99,7 @@ class Installer(): for step in missing_steps: self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning) self.log(f"Detailed error logs can be found at: {log_path}", level=LOG_LEVELS.Warning) - self.log(f"Submit this zip file as an issue to https://github.com/Torxed/archinstall/issues", level=LOG_LEVELS.Warning) + self.log(f"Submit this zip file as an issue to https://github.com/archlinux/archinstall/issues", level=LOG_LEVELS.Warning) self.sync_log_to_install_medium() return False diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py index 9bda017d..43d088bb 100644 --- a/archinstall/lib/storage.py +++ b/archinstall/lib/storage.py @@ -14,7 +14,7 @@ storage = { os.path.join(os.path.dirname(os.path.abspath(__file__)), 'profiles'), #os.path.abspath(f'{os.path.dirname(__file__)}/../examples') ], - 'UPSTREAM_URL' : 'https://raw.githubusercontent.com/Torxed/archinstall/master/profiles', + 'UPSTREAM_URL' : 'https://raw.githubusercontent.com/archlinux/archinstall/master/profiles', 'PROFILE_DB' : None, # Used in cases when listing profiles is desired, not mandatory for direct profile grabing. 'LOG_PATH' : '/var/log/archinstall', 'LOG_FILE' : 'install.log', diff --git a/docs/examples/binary.rst b/docs/examples/binary.rst index 6940d591..c73b3a5d 100644 --- a/docs/examples/binary.rst +++ b/docs/examples/binary.rst @@ -11,7 +11,7 @@ It's compiled using `nuitka `_ with the flag `--standalone` Executing the binary -------------------- -As an example we'll use the `guided `_ installer. +As an example we'll use the `guided `_ installer. To run the `guided` installed, all you have to do *(after installing or compiling the binary)*, is run: diff --git a/docs/help/discord.rst b/docs/help/discord.rst index 609fbecb..ce15766a 100644 --- a/docs/help/discord.rst +++ b/docs/help/discord.rst @@ -3,7 +3,7 @@ Discord ======= -There's a discord channel which is frequent by some `contributors `_. +There's a discord channel which is frequent by some `contributors `_. To join the server, head over to `https://discord.gg/cqXU88y `_'s server and join in. There's not many rules other than common sense and treat others with respect. diff --git a/docs/help/issues.rst b/docs/help/issues.rst index f29b18cc..d4f71b70 100644 --- a/docs/help/issues.rst +++ b/docs/help/issues.rst @@ -3,7 +3,7 @@ Issue tracker & bugs ==================== -Issues and bugs should be reported over at `https://github.com/Torxed/archinstall/issues `_. +Issues and bugs should be reported over at `https://github.com/archlinux/archinstall/issues `_. General questions, enhancements and security issues can be reported over there too. For quick issues or if you need help, head over the to the Discord server which has a help channel. diff --git a/docs/installing/binary.rst b/docs/installing/binary.rst index c51fb2c0..9156a1bf 100644 --- a/docs/installing/binary.rst +++ b/docs/installing/binary.rst @@ -21,7 +21,7 @@ Archinstall is on the `official repositories `_ contains a binary `PKGBUILD `_ which can be either copied straight off the website. Or cloned using `git clone https://github.com/Torxed/archinstall`. +The `source `_ contains a binary `PKGBUILD `_ which can be either copied straight off the website. Or cloned using `git clone https://github.com/Torxed/archinstall`. Once you've obtained the `PKGBUILD`, building it is pretty straight forward. diff --git a/docs/installing/python.rst b/docs/installing/python.rst index 94cfb243..68365753 100644 --- a/docs/installing/python.rst +++ b/docs/installing/python.rst @@ -54,7 +54,7 @@ Or you can clone it, we'll clone it here but both methods work the same. .. code-block:: console - git clone https://github.com/Torxed/archinstall + git clone https://github.com/archlinux/archinstall Either you can move the folder into your project and simply do diff --git a/docs/pull_request_template.md b/docs/pull_request_template.md index 886ea244..6da175ae 100644 --- a/docs/pull_request_template.md +++ b/docs/pull_request_template.md @@ -1,6 +1,6 @@ # Pull Request Template -Make sure you've checked out the [contribution guideline](https://github.com/Torxed/archinstall/blob/master/CONTRIBUTING.md).
+Make sure you've checked out the [contribution guideline](https://github.com/archlinux/archinstall/blob/master/CONTRIBUTING.md).
Most of the guidelines are not enforced, but is heavily encouraged. ## Description diff --git a/examples/guided.py b/examples/guided.py index 723eed5b..5803e13f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -112,7 +112,7 @@ def ask_user_questions(): try: partition.format(new_filesystem, path='/dev/null', log_formating=False, allow_formatting=True) except archinstall.UnknownFilesystemFormat: - archinstall.log(f"Selected filesystem is not supported yet. If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/Torxed/archinstall/issues.") + archinstall.log(f"Selected filesystem is not supported yet. If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.") archinstall.log(f"Until then, please enter another supported filesystem.") continue except archinstall.SysCallError: diff --git a/setup.py b/setup.py index 02029a70..35d51025 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setuptools.setup( description="Arch Linux installer - guided, templates etc.", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/Torxed/archinstall", + url="https://github.com/archlinux/archinstall", packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3.8", -- cgit v1.2.3-54-g00ecf From 0888ca592aab78e629ac5bdcdf60f3e059155ba7 Mon Sep 17 00:00:00 2001 From: Zach Osman Date: Mon, 5 Apr 2021 13:10:35 -0400 Subject: allow multiple services to be enabled at once --- archinstall/lib/exceptions.py | 2 ++ archinstall/lib/installer.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/exceptions.py b/archinstall/lib/exceptions.py index a320eef6..49913980 100644 --- a/archinstall/lib/exceptions.py +++ b/archinstall/lib/exceptions.py @@ -18,4 +18,6 @@ class HardwareIncompatibilityError(BaseException): class PermissionError(BaseException): pass class UserError(BaseException): + pass +class ServiceException(BaseException): pass \ No newline at end of file diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 0fc9f969..49716ac5 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -189,9 +189,11 @@ class Installer(): if self.enable_service('ntpd'): return True - def enable_service(self, service): - self.log(f'Enabling service {service}', level=LOG_LEVELS.Info) - return self.arch_chroot(f'systemctl enable {service}').exit_code == 0 + def enable_service(self, *services): + for service in services: + self.log(f'Enabling service {service}', level=LOG_LEVELS.Info) + if (output := self.arch_chroot(f'systemctl enable {service}')).exit_code != 0: + raise ServiceException(f"Unable to start service {service}: {output}") def run_command(self, cmd, *args, **kwargs): return sys_command(f'/usr/bin/arch-chroot {self.mountpoint} {cmd}') @@ -256,14 +258,12 @@ class Installer(): # If we haven't installed the base yet (function called pre-maturely) if self.helper_flags.get('base', False) is False: def post_install_enable_networkd_resolved(*args, **kwargs): - self.enable_service('systemd-networkd') - self.enable_service('systemd-resolved') - + self.enable_service('systemd-networkd', 'systemd-resolved') self.post_base_install.append(post_install_enable_networkd_resolved) # Otherwise, we can go ahead and enable the services else: - self.enable_service('systemd-networkd') - self.enable_service('systemd-resolved') + self.enable_service('systemd-networkd', 'systemd-resolved') + return True -- cgit v1.2.3-54-g00ecf From 1da9e52d52b1f88d5069392da29b8893377009e3 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 5 Apr 2021 22:06:25 +0200 Subject: Corrected for keymap before encrypt hook Also think that we should patch mkinitcpio, not replace it. Especially in the btrfs case where we simply just want to add `btrfs` to the `MODULES` section. --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 0fc9f969..d80f8aa6 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -306,14 +306,14 @@ class Installer(): mkinit.write('MODULES=(btrfs)\n') mkinit.write('BINARIES=(/usr/bin/btrfs)\n') mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect modconf block encrypt filesystems keymap keyboard fsck)\n') + mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') elif self.partition.encrypted: with open(f'{self.mountpoint}/etc/mkinitcpio.conf', 'w') as mkinit: mkinit.write('MODULES=()\n') mkinit.write('BINARIES=()\n') mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect modconf block encrypt filesystems keymap keyboard fsck)\n') + mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') self.helper_flags['base'] = True -- cgit v1.2.3-54-g00ecf From 3da4dc8e3015479e64603987ae229f75e2146548 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 6 Apr 2021 18:30:20 +0200 Subject: Update installer.py --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 663288e5..9681f1ea 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -149,7 +149,7 @@ class Installer(): fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}') return True -- cgit v1.2.3-54-g00ecf From 275e60e1ddb5da281aab394492c68bed8d5abdcb Mon Sep 17 00:00:00 2001 From: Insanemal Date: Wed, 7 Apr 2021 13:44:04 +1000 Subject: Fix newline issue on fstab writes Forced the newline char fstab writes as Python appears to be selecting the incorrect newlines --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 8673bbee..1d277bc6 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -147,7 +147,7 @@ class Installer(): self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info) fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log - with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh: + with open(f"{self.mountpoint}/etc/fstab", 'ab',newline='\n') as fstab_fh: fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): -- cgit v1.2.3-54-g00ecf From 36bad8254f4097a080c29ef54cf98ee80620639e Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 7 Apr 2021 17:21:31 +0530 Subject: added support to automatically add ucode to initrd --- archinstall/lib/installer.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a99bc944..d9a36859 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -9,7 +9,7 @@ from .mirrors import * from .systemd import Networkd from .output import log, LOG_LEVELS from .storage import storage - +from .hardware import * # Any package that the Installer() is responsible for (optional and the default ones) __packages__ = ["base", "base-devel", "linux", "linux-firmware", "efibootmgr", "nano", "ntp", "iwd"] __base_packages__ = __packages__[:6] @@ -288,7 +288,14 @@ class Installer(): self.pacstrap(self.base_packages) self.helper_flags['base-strapped'] = True #self.genfstab() - + if not isVM(): + vendor = cpuVendor() + if vendor == "AuthenticAMD": + self.base_packages.append("amd-ucode") + elif vendor == "GenuineIntel": + self.base_packages.append("intel-ucode") + else: + self.log("unknown cpu vendor not installing ucode") with open(f"{self.mountpoint}/etc/fstab", "a") as fstab: fstab.write( "\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n" @@ -364,13 +371,20 @@ class Installer(): ## For some reason, blkid and /dev/disk/by-uuid are not getting along well. ## And blkid is wrong in terms of LUKS. #UUID = sys_command('blkid -s PARTUUID -o value {drive}{partition_2}'.format(**args)).decode('UTF-8').strip() - # Setup the loader entry with open(f'{self.mountpoint}/boot/loader/entries/{self.init_time}.conf', 'w') as entry: entry.write(f'# Created by: archinstall\n') entry.write(f'# Created on: {self.init_time}\n') entry.write(f'title Arch Linux\n') entry.write(f'linux /vmlinuz-linux\n') + if not isVM(): + vendor = cpuVendor() + if vendor == "AuthenticAMD": + entry.write("initrd /amd-ucode.img") + elif vendor == "GenuineIntel": + entry.write("initrd /amd-ucode.img") + else: + self.log("unknow cpu vendor, not adding ucode to systemd-boot config") entry.write(f'initrd /initramfs-linux.img\n') ## blkid doesn't trigger on loopback devices really well, ## so we'll use the old manual method until we get that sorted out. -- cgit v1.2.3-54-g00ecf From d6a92df7896f850a3c7f36c9d299f15a70ee50f7 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 7 Apr 2021 14:52:15 +0200 Subject: Reverted a change with newline to open --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index c99d0017..e02bbf75 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -153,11 +153,11 @@ class Installer(): self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info) fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log - with open(f"{self.mountpoint}/etc/fstab", 'ab',newline='\n') as fstab_fh: + with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh: fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{fstab}') return True -- cgit v1.2.3-54-g00ecf From 8ad22004414f141897bbfe959b4864ffc29070a1 Mon Sep 17 00:00:00 2001 From: nullrequest <30698906+advaithm@users.noreply.github.com> Date: Wed, 7 Apr 2021 21:12:43 +0530 Subject: Fixed typos --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index d9a36859..8938b371 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -380,9 +380,9 @@ class Installer(): if not isVM(): vendor = cpuVendor() if vendor == "AuthenticAMD": - entry.write("initrd /amd-ucode.img") + entry.write("initrd /amd-ucode.img\n") elif vendor == "GenuineIntel": - entry.write("initrd /amd-ucode.img") + entry.write("initrd /intel-ucode.img\n") else: self.log("unknow cpu vendor, not adding ucode to systemd-boot config") entry.write(f'initrd /initramfs-linux.img\n') -- cgit v1.2.3-54-g00ecf From e70aa5244bd07cdaa299df528f8ebd099b00bf64 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 8 Apr 2021 10:36:42 +0200 Subject: Corrected the new-line parameter --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 1d277bc6..16d48183 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -147,11 +147,11 @@ class Installer(): self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info) fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log - with open(f"{self.mountpoint}/etc/fstab", 'ab',newline='\n') as fstab_fh: + with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh: fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{fstab}') return True -- cgit v1.2.3-54-g00ecf From b178dc7267ec6a6e425ea50f6847467f09bd5782 Mon Sep 17 00:00:00 2001 From: Ruslan Kiyanchuk Date: Sat, 3 Apr 2021 14:44:45 -0700 Subject: Fix undefined variables in installer --- archinstall/lib/installer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 0fc9f969..5293e009 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -98,8 +98,8 @@ class Installer(): self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) for step in missing_steps: self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning) - self.log(f"Detailed error logs can be found at: {log_path}", level=LOG_LEVELS.Warning) - self.log(f"Submit this zip file as an issue to https://github.com/archlinux/archinstall/issues", level=LOG_LEVELS.Warning) + self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=LOG_LEVELS.Warning) + self.log(f"Submit this zip file as an issue to https://github.com/Torxed/archinstall/issues", level=LOG_LEVELS.Warning) self.sync_log_to_install_medium() return False @@ -149,7 +149,7 @@ class Installer(): fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{o}') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n') return True -- cgit v1.2.3-54-g00ecf From d771d35076a00737842debd313f9bdb506881905 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 6 Apr 2021 18:30:20 +0200 Subject: Update installer.py --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 5293e009..a37d3ee8 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -149,7 +149,7 @@ class Installer(): fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}') return True -- cgit v1.2.3-54-g00ecf From 5134fb75c6b06ee85c94dc3c3858687a2b937dca Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 5 Apr 2021 22:06:25 +0200 Subject: Corrected for keymap before encrypt hook Also think that we should patch mkinitcpio, not replace it. Especially in the btrfs case where we simply just want to add `btrfs` to the `MODULES` section. --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a37d3ee8..7094adc0 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -306,14 +306,14 @@ class Installer(): mkinit.write('MODULES=(btrfs)\n') mkinit.write('BINARIES=(/usr/bin/btrfs)\n') mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect modconf block encrypt filesystems keymap keyboard fsck)\n') + mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') elif self.partition.encrypted: with open(f'{self.mountpoint}/etc/mkinitcpio.conf', 'w') as mkinit: mkinit.write('MODULES=()\n') mkinit.write('BINARIES=()\n') mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect modconf block encrypt filesystems keymap keyboard fsck)\n') + mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') self.helper_flags['base'] = True -- cgit v1.2.3-54-g00ecf From c6e7bb4595423cb99b4357ca497d9639c3347fc7 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 8 Apr 2021 10:36:42 +0200 Subject: Corrected the new-line parameter --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 7094adc0..76950099 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -149,7 +149,7 @@ class Installer(): fstab_fh.write(fstab) if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): - raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}') + raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{fstab}') return True -- cgit v1.2.3-54-g00ecf From 44574d19215492e2d4983e2881474f2a17dcf586 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 2 Apr 2021 11:38:42 +0200 Subject: Fixing glitch in variable use after moving to __packages__ definition. --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 76950099..92daee2b 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -52,7 +52,7 @@ class Installer(): 'user' : False # Root counts as a user, if additional users are skipped. } - self.base_packages = base_packages.split(' ') + self.base_packages = base_packages.split(' ') if type(base_packages) is str else base_packages self.post_base_install = [] storage['session'] = self -- cgit v1.2.3-54-g00ecf From be208990da6920fb78f5bd1c45dfd93b30912787 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 8 Apr 2021 14:00:57 -0400 Subject: Remove nano from base packages --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 66cac12c..b7fe5e9d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -34,7 +34,7 @@ class Installer(): :type hostname: str, optional """ - def __init__(self, partition, boot_partition, *, base_packages='base base-devel linux linux-firmware efibootmgr nano', profile=None, mountpoint='/mnt', hostname='ArchInstalled', logdir=None, logfile=None): + def __init__(self, partition, boot_partition, *, base_packages='base base-devel linux linux-firmware efibootmgr', profile=None, mountpoint='/mnt', hostname='ArchInstalled', logdir=None, logfile=None): self.profile = profile self.hostname = hostname self.mountpoint = mountpoint -- cgit v1.2.3-54-g00ecf From e717a72a10907a02bc485b763f195cddcc68bbe0 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 8 Apr 2021 22:47:13 +0200 Subject: Starting implementing #124. The installer will be detatched from block devices and partitions. Instead it will rely on a given destination to pacstrap to. From there, it should be able to do reverse-lookups on the target and base it's information and choises from there. This removes any form of partitioning logic, hardware logic and other things from the initialization of the installer. These things should be explicitly called from the installers functions instead. Such as .set_hostname() instead of passing it as a initiation variable. --- archinstall/lib/installer.py | 6 ++---- examples/minimal.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index b7fe5e9d..c6734a1a 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -34,10 +34,8 @@ class Installer(): :type hostname: str, optional """ - def __init__(self, partition, boot_partition, *, base_packages='base base-devel linux linux-firmware efibootmgr', profile=None, mountpoint='/mnt', hostname='ArchInstalled', logdir=None, logfile=None): - self.profile = profile - self.hostname = hostname - self.mountpoint = mountpoint + def __init__(self, target, *, base_packages='base base-devel linux linux-firmware efibootmgr', logdir=None, logfile=None): + self.target = target self.init_time = time.strftime('%Y-%m-%d_%H-%M-%S') self.milliseconds = int(str(time.time()).split('.')[1]) diff --git a/examples/minimal.py b/examples/minimal.py index 367574b5..afd64a2e 100644 --- a/examples/minimal.py +++ b/examples/minimal.py @@ -12,12 +12,13 @@ if archinstall.arguments.get('help', None): archinstall.arguments['harddrive'] = archinstall.select_disk(archinstall.all_disks()) archinstall.arguments['harddrive'].keep_partitions = False -def install_on(root, boot): - # We kick off the installer by telling it where the root and boot lives - with archinstall.Installer(root, boot_partition=boot, hostname='minimal-arch') as installation: +def install_on(mountpoint): + # We kick off the installer by telling it where the + with archinstall.Installer(mountpoint) as installation: # Strap in the base system, add a boot loader and configure # some other minor details as specified by this profile and user. if installation.minimal_installation(): + installation.set_hostname('minimal-arch') installation.add_bootloader() # Optionally enable networking: @@ -57,8 +58,10 @@ with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) with archinstall.luks2(root, 'luksloop', archinstall.arguments.get('!encryption-password', None)) as unlocked_root: unlocked_root.format(root.filesystem) - - install_on(unlocked_root) + unlocked_root.mount('/mnt') else: root.format(root.filesystem) - install_on(root, boot) \ No newline at end of file + root.mount('/mnt') + + boot.mount('/mnt/boot') + install_on('/mnt') \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 08cf788eaad2ec9ecdfd2c1da1da70bfd4180984 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 8 Apr 2021 22:58:45 +0200 Subject: Reworked the mkinitcpio configuration to be more robust according to the logic behind #91 and in prep for #145. Also in prep for #124 the lookup of partitions have been prepared here. We now need a reverse-lookup function. --- archinstall/lib/installer.py | 67 ++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 37 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index c6734a1a..11f75f99 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -34,28 +34,21 @@ class Installer(): :type hostname: str, optional """ - def __init__(self, target, *, base_packages='base base-devel linux linux-firmware efibootmgr', logdir=None, logfile=None): + def __init__(self, target, *, base_packages='base base-devel linux linux-firmware efibootmgr'): self.target = target self.init_time = time.strftime('%Y-%m-%d_%H-%M-%S') self.milliseconds = int(str(time.time()).split('.')[1]) - if logdir: - storage['LOG_PATH'] = logdir - if logfile: - storage['LOG_FILE'] = logfile - self.helper_flags = { - 'bootloader' : False, 'base' : False, - 'user' : False # Root counts as a user, if additional users are skipped. + 'bootloader' : False } self.base_packages = base_packages.split(' ') if type(base_packages) is str else base_packages self.post_base_install = [] - storage['session'] = self - self.partition = partition - self.boot_partition = boot_partition + storage['session'] = self + self.partitions = get_partitions_in_use(self.target) def log(self, *args, level=LOG_LEVELS.Debug, **kwargs): """ @@ -65,9 +58,6 @@ class Installer(): log(*args, level=level, **kwargs) def __enter__(self, *args, **kwargs): - self.partition.mount(self.mountpoint) - os.makedirs(f'{self.mountpoint}/boot', exist_ok=True) - self.boot_partition.mount(f'{self.mountpoint}/boot') return self def __exit__(self, *args, **kwargs): @@ -272,18 +262,25 @@ class Installer(): ## (encrypted partitions default to btrfs for now, so we need btrfs-progs) ## TODO: Perhaps this should be living in the function which dictates ## the partitioning. Leaving here for now. - if self.partition.filesystem == 'btrfs': - #if self.partition.encrypted: - self.base_packages.append('btrfs-progs') - if self.partition.filesystem == 'xfs': - self.base_packages.append('xfsprogs') - if self.partition.filesystem == 'f2fs': - self.base_packages.append('f2fs-tools') + MODULES = [] + BINARIES = [] + FILES = [] + HOOKS = ["base", "udev", "autodetect", "keyboard", "keymap", "modconf", "block", "filesystems", "fsck"] + + for partition in self.partitions: + if partition.filesystem == 'btrfs': + #if partition.encrypted: + self.base_packages.append('btrfs-progs') + if partition.filesystem == 'xfs': + self.base_packages.append('xfsprogs') + if partition.filesystem == 'f2fs': + self.base_packages.append('f2fs-tools') + self.pacstrap(self.base_packages) self.helper_flags['base-strapped'] = True #self.genfstab() - with open(f"{self.mountpoint}/etc/fstab", "a") as fstab: + with open(f"{self.target}/etc/fstab", "a") as fstab: fstab.write( "\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n" ) # Redundant \n at the start? who knows? @@ -296,25 +293,21 @@ class Installer(): self.set_locale('en_US') # TODO: Use python functions for this - sys_command(f'/usr/bin/arch-chroot {self.mountpoint} chmod 700 /root') + sys_command(f'/usr/bin/arch-chroot {self.target} chmod 700 /root') # Configure mkinitcpio to handle some specific use cases. - # TODO: Yes, we should not overwrite the entire thing, but for now this should be fine - # since we just installed the base system. if self.partition.filesystem == 'btrfs': - with open(f'{self.mountpoint}/etc/mkinitcpio.conf', 'w') as mkinit: - mkinit.write('MODULES=(btrfs)\n') - mkinit.write('BINARIES=(/usr/bin/btrfs)\n') - mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') - sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') + MODULES.append('btrfs') + BINARIES.append('/usr/bin/btrfs') elif self.partition.encrypted: - with open(f'{self.mountpoint}/etc/mkinitcpio.conf', 'w') as mkinit: - mkinit.write('MODULES=()\n') - mkinit.write('BINARIES=()\n') - mkinit.write('FILES=()\n') - mkinit.write('HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)\n') - sys_command(f'/usr/bin/arch-chroot {self.mountpoint} mkinitcpio -p linux') + HOOKS.patch('encrypt', before='filesystems') + + with open(f'{self.target}/etc/mkinitcpio.conf', 'w') as mkinit: + mkinit.write(f"MODULES=({' '.join(MODULES)})\n") + mkinit.write(f"BINARIES=({' '.join(BINARIES)})\n") + mkinit.write(f"FILES=({' '.join(FILES)})\n") + mkinit.write(f"HOOKS=({' '.join(HOOKS)})\n") + sys_command(f'/usr/bin/arch-chroot {self.target} mkinitcpio -p linux') self.helper_flags['base'] = True -- cgit v1.2.3-54-g00ecf From eb0ae8b1c35e421f88b7eabcc445d1069969ba76 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 11:53:54 +0200 Subject: Added disk helper function get_partitions_in_use(). Which returns which partions are being used at a given mount location, including children. --- archinstall/lib/disk.py | 18 ++++++++++++++++++ archinstall/lib/installer.py | 1 + 2 files changed, 19 insertions(+) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index f0fe7181..af40e36f 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -574,6 +574,24 @@ def get_mount_info(path): return output['filesystems'][0] +def get_partitions_in_use(mountpoint): + try: + output = b''.join(sys_command(f'/usr/bin/findmnt --json -R {path}')) + except SysCallError: + return {} + + mounts = [] + + output = output.decode('UTF-8') + output = json.loads(output) + for target in output.get('filesystems', []): + mounts.append(Partition(target['source'], filesystem=target.get('fstype', None), mountpoint=target['target'])) + + for child in target.get('children', []): + mounts.append(Partition(child['source'], filesystem=child.get('fstype', None), mountpoint=child['target'])) + + return mounts + def get_filesystem_type(path): try: handle = sys_command(f"blkid -o value -s TYPE {path}") diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 11f75f99..d17ee77c 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -49,6 +49,7 @@ class Installer(): storage['session'] = self self.partitions = get_partitions_in_use(self.target) + print(self.partitions) def log(self, *args, level=LOG_LEVELS.Debug, **kwargs): """ -- cgit v1.2.3-54-g00ecf From 7f6220528175a15606c329638ffcd961ad771df6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 11:58:12 +0200 Subject: Reworked Installation() to have self.target instead of self.mountpoint, to be more consistent and remove the hits that it has anything to do with partitions/hardware. --- archinstall/lib/installer.py | 66 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index d17ee77c..173f4666 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -122,7 +122,7 @@ class Installer(): self.log(f'Installing packages: {packages}', level=LOG_LEVELS.Info) if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0: - if (pacstrap := sys_command(f'/usr/bin/pacstrap {self.mountpoint} {" ".join(packages)}', **kwargs)).exit_code == 0: + if (pacstrap := sys_command(f'/usr/bin/pacstrap {self.target} {" ".join(packages)}', **kwargs)).exit_code == 0: return True else: self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=LOG_LEVELS.Info) @@ -130,42 +130,42 @@ class Installer(): self.log(f'Could not sync mirrors: {sync_mirrors.exit_code}', level=LOG_LEVELS.Info) def set_mirrors(self, mirrors): - return use_mirrors(mirrors, destination=f'{self.mountpoint}/etc/pacman.d/mirrorlist') + return use_mirrors(mirrors, destination=f'{self.target}/etc/pacman.d/mirrorlist') def genfstab(self, flags='-pU'): - self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info) + self.log(f"Updating {self.target}/etc/fstab", level=LOG_LEVELS.Info) - fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log - with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh: + fstab = sys_command(f'/usr/bin/genfstab {flags} {self.target}').trace_log + with open(f"{self.target}/etc/fstab", 'ab') as fstab_fh: fstab_fh.write(fstab) - if not os.path.isfile(f'{self.mountpoint}/etc/fstab'): + if not os.path.isfile(f'{self.target}/etc/fstab'): raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{fstab}') return True def set_hostname(self, hostname=None, *args, **kwargs): if not hostname: hostname = self.hostname - with open(f'{self.mountpoint}/etc/hostname', 'w') as fh: + with open(f'{self.target}/etc/hostname', 'w') as fh: fh.write(self.hostname + '\n') def set_locale(self, locale, encoding='UTF-8', *args, **kwargs): if not len(locale): return True - with open(f'{self.mountpoint}/etc/locale.gen', 'a') as fh: + with open(f'{self.target}/etc/locale.gen', 'a') as fh: fh.write(f'{locale}.{encoding} {encoding}\n') - with open(f'{self.mountpoint}/etc/locale.conf', 'w') as fh: + with open(f'{self.target}/etc/locale.conf', 'w') as fh: fh.write(f'LANG={locale}.{encoding}\n') - return True if sys_command(f'/usr/bin/arch-chroot {self.mountpoint} locale-gen').exit_code == 0 else False + return True if sys_command(f'/usr/bin/arch-chroot {self.target} locale-gen').exit_code == 0 else False def set_timezone(self, zone, *args, **kwargs): if not zone: return True if not len(zone): return True # Redundant if (pathlib.Path("/usr")/"share"/"zoneinfo"/zone).exists(): - (pathlib.Path(self.mountpoint)/"etc"/"localtime").unlink(missing_ok=True) - sys_command(f'/usr/bin/arch-chroot {self.mountpoint} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') + (pathlib.Path(self.target)/"etc"/"localtime").unlink(missing_ok=True) + sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') return True else: self.log( @@ -185,7 +185,7 @@ class Installer(): return self.arch_chroot(f'systemctl enable {service}').exit_code == 0 def run_command(self, cmd, *args, **kwargs): - return sys_command(f'/usr/bin/arch-chroot {self.mountpoint} {cmd}') + return sys_command(f'/usr/bin/arch-chroot {self.target} {cmd}') def arch_chroot(self, cmd, *args, **kwargs): return self.run_command(cmd) @@ -205,15 +205,15 @@ class Installer(): conf = Networkd(Match={"Name": nic}, Network=network) - with open(f"{self.mountpoint}/etc/systemd/network/10-{nic}.network", "a") as netconf: + with open(f"{self.target}/etc/systemd/network/10-{nic}.network", "a") as netconf: netconf.write(str(conf)) def copy_ISO_network_config(self, enable_services=False): # Copy (if any) iwd password and config files if os.path.isdir('/var/lib/iwd/'): if (psk_files := glob.glob('/var/lib/iwd/*.psk')): - if not os.path.isdir(f"{self.mountpoint}/var/lib/iwd"): - os.makedirs(f"{self.mountpoint}/var/lib/iwd") + if not os.path.isdir(f"{self.target}/var/lib/iwd"): + os.makedirs(f"{self.target}/var/lib/iwd") if enable_services: # If we haven't installed the base yet (function called pre-maturely) @@ -233,15 +233,15 @@ class Installer(): self.enable_service('iwd') for psk in psk_files: - shutil.copy2(psk, f"{self.mountpoint}/var/lib/iwd/{os.path.basename(psk)}") + shutil.copy2(psk, f"{self.target}/var/lib/iwd/{os.path.basename(psk)}") # Copy (if any) systemd-networkd config files if (netconfigurations := glob.glob('/etc/systemd/network/*')): - if not os.path.isdir(f"{self.mountpoint}/etc/systemd/network/"): - os.makedirs(f"{self.mountpoint}/etc/systemd/network/") + if not os.path.isdir(f"{self.target}/etc/systemd/network/"): + os.makedirs(f"{self.target}/etc/systemd/network/") for netconf_file in netconfigurations: - shutil.copy2(netconf_file, f"{self.mountpoint}/etc/systemd/network/{os.path.basename(netconf_file)}") + shutil.copy2(netconf_file, f"{self.target}/etc/systemd/network/{os.path.basename(netconf_file)}") if enable_services: # If we haven't installed the base yet (function called pre-maturely) @@ -287,8 +287,8 @@ class Installer(): ) # Redundant \n at the start? who knows? ## TODO: Support locale and timezone - #os.remove(f'{self.mountpoint}/etc/localtime') - #sys_command(f'/usr/bin/arch-chroot {self.mountpoint} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') + #os.remove(f'{self.target}/etc/localtime') + #sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') #sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime') self.set_hostname() self.set_locale('en_US') @@ -328,11 +328,11 @@ class Installer(): # And in which case we should do some clean up. # Install the boot loader - sys_command(f'/usr/bin/arch-chroot {self.mountpoint} bootctl --no-variables --path=/boot install') + sys_command(f'/usr/bin/arch-chroot {self.target} bootctl --no-variables --path=/boot install') # Modify or create a loader.conf - if os.path.isfile(f'{self.mountpoint}/boot/loader/loader.conf'): - with open(f'{self.mountpoint}/boot/loader/loader.conf', 'r') as loader: + if os.path.isfile(f'{self.target}/boot/loader/loader.conf'): + with open(f'{self.target}/boot/loader/loader.conf', 'r') as loader: loader_data = loader.read().split('\n') else: loader_data = [ @@ -340,7 +340,7 @@ class Installer(): f"timeout 5" ] - with open(f'{self.mountpoint}/boot/loader/loader.conf', 'w') as loader: + with open(f'{self.target}/boot/loader/loader.conf', 'w') as loader: for line in loader_data: if line[:8] == 'default ': loader.write(f'default {self.init_time}\n') @@ -352,7 +352,7 @@ class Installer(): #UUID = sys_command('blkid -s PARTUUID -o value {drive}{partition_2}'.format(**args)).decode('UTF-8').strip() # Setup the loader entry - with open(f'{self.mountpoint}/boot/loader/entries/{self.init_time}.conf', 'w') as entry: + with open(f'{self.target}/boot/loader/entries/{self.init_time}.conf', 'w') as entry: entry.write(f'# Created by: archinstall\n') entry.write(f'# Created on: {self.init_time}\n') entry.write(f'title Arch Linux\n') @@ -383,7 +383,7 @@ class Installer(): self.helper_flags['bootloader'] = bootloader return True - raise RequirementError(f"Could not identify the UUID of {self.partition}, there for {self.mountpoint}/boot/loader/entries/arch.conf will be broken until fixed.") + raise RequirementError(f"Could not identify the UUID of {self.partition}, there for {self.target}/boot/loader/entries/arch.conf will be broken until fixed.") else: raise RequirementError(f"Unknown (or not yet implemented) bootloader added to add_bootloader(): {bootloader}") @@ -408,19 +408,19 @@ class Installer(): def enable_sudo(self, entity :str, group=False): self.log(f'Enabling sudo permissions for {entity}.', level=LOG_LEVELS.Info) - with open(f'{self.mountpoint}/etc/sudoers', 'a') as sudoers: + with open(f'{self.target}/etc/sudoers', 'a') as sudoers: sudoers.write(f'{"%" if group else ""}{entity} ALL=(ALL) ALL\n') return True def user_create(self, user :str, password=None, groups=[], sudo=False): self.log(f'Creating user {user}', level=LOG_LEVELS.Info) - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} useradd -m -G wheel {user}')) + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} useradd -m -G wheel {user}')) if password: self.user_set_pw(user, password) if groups: for group in groups: - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} gpasswd -a {user} {group}')) + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} gpasswd -a {user} {group}')) if sudo and self.enable_sudo(user): self.helper_flags['user'] = True @@ -432,12 +432,12 @@ class Installer(): # This means the root account isn't locked/disabled with * in /etc/passwd self.helper_flags['user'] = True - o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.mountpoint} sh -c \"echo '{user}:{password}' | chpasswd\"")) + o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.target} sh -c \"echo '{user}:{password}' | chpasswd\"")) pass def set_keyboard_language(self, language): if len(language.strip()): - with open(f'{self.mountpoint}/etc/vconsole.conf', 'w') as vconsole: + with open(f'{self.target}/etc/vconsole.conf', 'w') as vconsole: vconsole.write(f'KEYMAP={language}\n') vconsole.write(f'FONT=lat9w-16\n') return True -- cgit v1.2.3-54-g00ecf From 276414079bff0249d1d788eb64534bbbe66ad8a4 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 12:00:51 +0200 Subject: Reworked Installation() to have self.target instead of self.mountpoint, to be more consistent and remove the hits that it has anything to do with partitions/hardware. --- archinstall/lib/installer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 173f4666..593a812d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -101,18 +101,18 @@ class Installer(): if (filename := storage.get('LOG_FILE', None)): absolute_logfile = os.path.join(storage.get('LOG_PATH', './'), filename) - if not os.path.isdir(f"{self.mountpoint}/{os.path.dirname(absolute_logfile)}"): - os.makedirs(f"{self.mountpoint}/{os.path.dirname(absolute_logfile)}") + if not os.path.isdir(f"{self.target}/{os.path.dirname(absolute_logfile)}"): + os.makedirs(f"{self.target}/{os.path.dirname(absolute_logfile)}") - shutil.copy2(absolute_logfile, f"{self.mountpoint}/{absolute_logfile}") + shutil.copy2(absolute_logfile, f"{self.target}/{absolute_logfile}") return True def mount(self, partition, mountpoint, create_mountpoint=True): - if create_mountpoint and not os.path.isdir(f'{self.mountpoint}{mountpoint}'): - os.makedirs(f'{self.mountpoint}{mountpoint}') + if create_mountpoint and not os.path.isdir(f'{self.target}{mountpoint}'): + os.makedirs(f'{self.target}{mountpoint}') - partition.mount(f'{self.mountpoint}{mountpoint}') + partition.mount(f'{self.target}{mountpoint}') def post_install_check(self, *args, **kwargs): return [step for step, flag in self.helper_flags.items() if flag is False] -- cgit v1.2.3-54-g00ecf From 59e3408de838206bad24fa0d8ca34b47f71e17aa Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 12:28:52 +0200 Subject: Fixed set_hostname() default. --- archinstall/lib/installer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 593a812d..d242f1ee 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -144,8 +144,7 @@ class Installer(): return True - def set_hostname(self, hostname=None, *args, **kwargs): - if not hostname: hostname = self.hostname + def set_hostname(self, hostname :str, *args, **kwargs): with open(f'{self.target}/etc/hostname', 'w') as fh: fh.write(self.hostname + '\n') @@ -290,7 +289,7 @@ class Installer(): #os.remove(f'{self.target}/etc/localtime') #sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') #sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime') - self.set_hostname() + self.set_hostname('archinstall') self.set_locale('en_US') # TODO: Use python functions for this -- cgit v1.2.3-54-g00ecf From 5c8d210f5f2024723b69af6f260f055a98ce9903 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 12:43:14 +0200 Subject: Wrong use of hostname in the set_hostname() function. --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index d242f1ee..5af3c226 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -146,7 +146,7 @@ class Installer(): def set_hostname(self, hostname :str, *args, **kwargs): with open(f'{self.target}/etc/hostname', 'w') as fh: - fh.write(self.hostname + '\n') + fh.write(hostname + '\n') def set_locale(self, locale, encoding='UTF-8', *args, **kwargs): if not len(locale): return True -- cgit v1.2.3-54-g00ecf From ee89c55466ec5181b938a03282c0cececd813d58 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 13:01:01 +0200 Subject: Started patching HOOKS and MODULES based on partition iteration. Also fixed some pseudo code. --- archinstall/lib/installer.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 5af3c226..d8021e05 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -276,6 +276,16 @@ class Installer(): if partition.filesystem == 'f2fs': self.base_packages.append('f2fs-tools') + # Configure mkinitcpio to handle some specific use cases. + if partition.filesystem == 'btrfs' + if 'btrfs' not in MODULES: + MODULES.append('btrfs') + if '/usr/bin/btrfs-progs' not in BINARIES: + BINARIES.append('/usr/bin/btrfs') + + elif partition.encrypted and 'encrypt' not in HOOKS: + HOOKS.insert(HOOKS.find('filesystems'), 'encrypt') + self.pacstrap(self.base_packages) self.helper_flags['base-strapped'] = True #self.genfstab() @@ -295,13 +305,6 @@ class Installer(): # TODO: Use python functions for this sys_command(f'/usr/bin/arch-chroot {self.target} chmod 700 /root') - # Configure mkinitcpio to handle some specific use cases. - if self.partition.filesystem == 'btrfs': - MODULES.append('btrfs') - BINARIES.append('/usr/bin/btrfs') - elif self.partition.encrypted: - HOOKS.patch('encrypt', before='filesystems') - with open(f'{self.target}/etc/mkinitcpio.conf', 'w') as mkinit: mkinit.write(f"MODULES=({' '.join(MODULES)})\n") mkinit.write(f"BINARIES=({' '.join(BINARIES)})\n") -- cgit v1.2.3-54-g00ecf From fdcaeae6f2243ff401409cc869a4c02430aa89c3 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 13:01:22 +0200 Subject: Syntax error --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index d8021e05..02c63a11 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -277,7 +277,7 @@ class Installer(): self.base_packages.append('f2fs-tools') # Configure mkinitcpio to handle some specific use cases. - if partition.filesystem == 'btrfs' + if partition.filesystem == 'btrfs': if 'btrfs' not in MODULES: MODULES.append('btrfs') if '/usr/bin/btrfs-progs' not in BINARIES: -- cgit v1.2.3-54-g00ecf From 56239d89b58a6ee7bc3d0c299833a8aa6635ae79 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 13:06:47 +0200 Subject: Fixed some log output logic for the boot partition. --- archinstall/lib/installer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 02c63a11..4c617582 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -322,7 +322,15 @@ class Installer(): return True def add_bootloader(self, bootloader='systemd-bootctl'): - self.log(f'Adding bootloader {bootloader} to {self.boot_partition}', level=LOG_LEVELS.Info) + # This logic is only for debug/log purposes: + # (it could be completely ommitted if we just print /mnt instead) + boot_partition = None + for partition in self.partitions: + if partition.mountpoint == self.target+'/boot' + boot_partition = partition + break + + self.log(f'Adding bootloader {bootloader} to {boot_partition}', level=LOG_LEVELS.Info) if bootloader == 'systemd-bootctl': # TODO: Ideally we would want to check if another config -- cgit v1.2.3-54-g00ecf From 72ad1ad5e0765f12fef5ea27a5c8dcb290c5b682 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 13:07:08 +0200 Subject: Fixed some log output logic for the boot partition. --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 4c617582..3fd6cfe3 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -326,7 +326,7 @@ class Installer(): # (it could be completely ommitted if we just print /mnt instead) boot_partition = None for partition in self.partitions: - if partition.mountpoint == self.target+'/boot' + if partition.mountpoint == self.target+'/boot': boot_partition = partition break -- cgit v1.2.3-54-g00ecf From 9ebd8b8719d9f2643a4b503b9e9aca02edeee0bd Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 13:13:14 +0200 Subject: Change of variables to support new partition lookup. --- archinstall/lib/installer.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 3fd6cfe3..48ef7259 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -322,13 +322,13 @@ class Installer(): return True def add_bootloader(self, bootloader='systemd-bootctl'): - # This logic is only for debug/log purposes: - # (it could be completely ommitted if we just print /mnt instead) boot_partition = None + root_partition = None for partition in self.partitions: if partition.mountpoint == self.target+'/boot': boot_partition = partition - break + elif partition.mountpoint == self.target: + root_partition = partition self.log(f'Adding bootloader {bootloader} to {boot_partition}', level=LOG_LEVELS.Info) @@ -372,14 +372,14 @@ class Installer(): ## so we'll use the old manual method until we get that sorted out. - if self.partition.encrypted: - log(f"Identifying root partition by DISK-UUID on {self.partition}, looking for '{os.path.basename(self.partition.real_device)}'.", level=LOG_LEVELS.Debug) + if root_partition.encrypted: + log(f"Identifying root partition by DISK-UUID on {root_partition}, looking for '{os.path.basename(root_partition.real_device)}'.", level=LOG_LEVELS.Debug) for root, folders, uids in os.walk('/dev/disk/by-uuid'): for uid in uids: real_path = os.path.realpath(os.path.join(root, uid)) - log(f"Checking root partition match {os.path.basename(real_path)} against {os.path.basename(self.partition.real_device)}: {os.path.basename(real_path) == os.path.basename(self.partition.real_device)}", level=LOG_LEVELS.Debug) - if not os.path.basename(real_path) == os.path.basename(self.partition.real_device): continue + log(f"Checking root partition match {os.path.basename(real_path)} against {os.path.basename(root_partition.real_device)}: {os.path.basename(real_path) == os.path.basename(root_partition.real_device)}", level=LOG_LEVELS.Debug) + if not os.path.basename(real_path) == os.path.basename(root_partition.real_device): continue entry.write(f'options cryptdevice=UUID={uid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n') @@ -387,13 +387,13 @@ class Installer(): return True break else: - log(f"Identifying root partition by PART-UUID on {self.partition}, looking for '{os.path.basename(self.partition.path)}'.", level=LOG_LEVELS.Debug) - entry.write(f'options root=PARTUUID={self.partition.uuid} rw intel_pstate=no_hwp\n') + log(f"Identifying root partition by PART-UUID on {root_partition}, looking for '{os.path.basename(root_partition.path)}'.", level=LOG_LEVELS.Debug) + entry.write(f'options root=PARTUUID={root_partition.uuid} rw intel_pstate=no_hwp\n') self.helper_flags['bootloader'] = bootloader return True - raise RequirementError(f"Could not identify the UUID of {self.partition}, there for {self.target}/boot/loader/entries/arch.conf will be broken until fixed.") + raise RequirementError(f"Could not identify the UUID of {root_partition}, there for {self.target}/boot/loader/entries/arch.conf will be broken until fixed.") else: raise RequirementError(f"Unknown (or not yet implemented) bootloader added to add_bootloader(): {bootloader}") -- cgit v1.2.3-54-g00ecf From 5099376dcdf59cbfcd146f3c2fa92872b2b1920c Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 21:50:53 +0200 Subject: Attempting to fix auto-detection of encrypted drives. So that #124 can perform reverse detection on partitions and detect encryption. --- archinstall/lib/disk.py | 4 ++++ archinstall/lib/installer.py | 5 +++-- examples/minimal.py | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index f6dc16eb..fe06ac00 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -214,6 +214,10 @@ class Partition(): self._encrypted = value + @property + def parent(self): + return self.real_device + @property def real_device(self): if not self._encrypted: diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 48ef7259..7fd775b1 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -283,8 +283,9 @@ class Installer(): if '/usr/bin/btrfs-progs' not in BINARIES: BINARIES.append('/usr/bin/btrfs') - elif partition.encrypted and 'encrypt' not in HOOKS: - HOOKS.insert(HOOKS.find('filesystems'), 'encrypt') + elif (partition.encrypted or Partition(partition.parent, None).filesystem == 'crypto_LUKS'): + if 'encrypt' not in HOOKS: + HOOKS.insert(HOOKS.find('filesystems'), 'encrypt') self.pacstrap(self.base_packages) self.helper_flags['base-strapped'] = True diff --git a/examples/minimal.py b/examples/minimal.py index 90bd9227..de896d48 100644 --- a/examples/minimal.py +++ b/examples/minimal.py @@ -1,5 +1,9 @@ import archinstall +# Unmount and close previous runs +archinstall.sys_command(f'umount -R /mnt', suppress_errors=True) +archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', suppress_errors=True) + # Select a harddrive and a disk password archinstall.log(f"Minimal only supports:") archinstall.log(f" * Being installed to a single disk") -- cgit v1.2.3-54-g00ecf From c7b213337613ed586bed24486440b4635054b57d Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 22:58:41 +0200 Subject: Attempting to correct some inconsitencies in disk-parent reporting. --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 7fd775b1..a60955b7 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -283,7 +283,7 @@ class Installer(): if '/usr/bin/btrfs-progs' not in BINARIES: BINARIES.append('/usr/bin/btrfs') - elif (partition.encrypted or Partition(partition.parent, None).filesystem == 'crypto_LUKS'): + if (partition.encrypted or Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS'): if 'encrypt' not in HOOKS: HOOKS.insert(HOOKS.find('filesystems'), 'encrypt') -- cgit v1.2.3-54-g00ecf From e49b73cef41b39e0046a8dc10fddfc4337255a5b Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 23:12:47 +0200 Subject: Attempting to correct some inconsitencies in disk-parent reporting. --- archinstall/lib/disk.py | 3 +++ archinstall/lib/installer.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 1f0e584a..d0d7d4ea 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -166,6 +166,9 @@ class Partition(): self.mountpoint = target if not self.filesystem and autodetect_filesystem: + print(f'Auto-detecting filesystem for: {path}') + print('Mount information:', mount_information.get('fstype', None)) + print('Real device:', get_filesystem_type(self.real_device)) if (fstype := mount_information.get('fstype', get_filesystem_type(self.real_device))): self.filesystem = fstype diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a60955b7..8adc3515 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -283,7 +283,7 @@ class Installer(): if '/usr/bin/btrfs-progs' not in BINARIES: BINARIES.append('/usr/bin/btrfs') - if (partition.encrypted or Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS'): + if (partition.encrypted or (partition.parent not in partition.path and Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS')): if 'encrypt' not in HOOKS: HOOKS.insert(HOOKS.find('filesystems'), 'encrypt') -- cgit v1.2.3-54-g00ecf From f031bb077ce8e4eee3745f4f109b451856aab372 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 23:18:59 +0200 Subject: List function call error. --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 8adc3515..74978ef6 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -285,7 +285,7 @@ class Installer(): if (partition.encrypted or (partition.parent not in partition.path and Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS')): if 'encrypt' not in HOOKS: - HOOKS.insert(HOOKS.find('filesystems'), 'encrypt') + HOOKS.insert(HOOKS.index('filesystems'), 'encrypt') self.pacstrap(self.base_packages) self.helper_flags['base-strapped'] = True -- cgit v1.2.3-54-g00ecf From 99c18d5d663453d792683464ce6b077333ec7775 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Fri, 9 Apr 2021 23:26:16 +0200 Subject: Removed some debugging. --- archinstall/lib/disk.py | 3 --- archinstall/lib/installer.py | 1 - 2 files changed, 4 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 15071c00..e5aa9a85 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -166,9 +166,6 @@ class Partition(): self.mountpoint = target if not self.filesystem and autodetect_filesystem: - print(f'Auto-detecting filesystem for: {path}') - print('Mount information:', mount_information.get('fstype', None)) - print('Real device:', get_filesystem_type(path)) if (fstype := mount_information.get('fstype', get_filesystem_type(path))): self.filesystem = fstype diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 74978ef6..c4e4e515 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -49,7 +49,6 @@ class Installer(): storage['session'] = self self.partitions = get_partitions_in_use(self.target) - print(self.partitions) def log(self, *args, level=LOG_LEVELS.Debug, **kwargs): """ -- cgit v1.2.3-54-g00ecf From e7ad4038bda9fb5906c4708eb8b48babe9778387 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 10 Apr 2021 00:06:25 +0200 Subject: Fixing UUID on encrypted partitions. --- archinstall/lib/installer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index c4e4e515..af973227 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -256,6 +256,9 @@ class Installer(): return True + def detect_encryption(self, partition): + return partition.encrypted or (partition.parent not in partition.path and Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS') + def minimal_installation(self): ## Add necessary packages if encrypting the drive ## (encrypted partitions default to btrfs for now, so we need btrfs-progs) @@ -282,7 +285,7 @@ class Installer(): if '/usr/bin/btrfs-progs' not in BINARIES: BINARIES.append('/usr/bin/btrfs') - if (partition.encrypted or (partition.parent not in partition.path and Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS')): + if self.detect_encryption(partition): if 'encrypt' not in HOOKS: HOOKS.insert(HOOKS.index('filesystems'), 'encrypt') @@ -372,7 +375,7 @@ class Installer(): ## so we'll use the old manual method until we get that sorted out. - if root_partition.encrypted: + if self.detect_encryption(root_partition): log(f"Identifying root partition by DISK-UUID on {root_partition}, looking for '{os.path.basename(root_partition.real_device)}'.", level=LOG_LEVELS.Debug) for root, folders, uids in os.walk('/dev/disk/by-uuid'): for uid in uids: -- cgit v1.2.3-54-g00ecf From 1e0770e582b8a32175dfda224a153bf19522fb03 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 10 Apr 2021 10:14:15 +0200 Subject: Modified encrypted partitions to use partuuid for now. --- archinstall/lib/disk.py | 12 ++++++++++++ archinstall/lib/installer.py | 30 ++++++++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index e5aa9a85..1a2dc4dc 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -126,6 +126,18 @@ class BlockDevice(): def partition_table_type(self): return GPT + @property + def uuid(self): + log(f'BlockDevice().uuid is untested!', level=LOG_LEVELS.Warning, fg='yellow') + """ + Returns the disk UUID as returned by lsblk. + This is more reliable than relying on /dev/disk/by-partuuid as + it doesn't seam to be able to detect md raid partitions. + """ + lsblk = b''.join(sys_command(f'lsblk -J -o+UUID {self.path}')) + for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']: + return partition.get('uuid', None) + def has_partitions(self): return len(self.partitions) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index af973227..0c622129 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -257,7 +257,12 @@ class Installer(): return True def detect_encryption(self, partition): - return partition.encrypted or (partition.parent not in partition.path and Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS') + if partition.encrypted: + return partition + elif partition.parent not in partition.path and Partition(partition.parent, None, autodetect_filesystem=True).filesystem == 'crypto_LUKS': + return Partition(partition.parent, None, autodetect_filesystem=True) + + return False def minimal_installation(self): ## Add necessary packages if encrypting the drive @@ -375,26 +380,15 @@ class Installer(): ## so we'll use the old manual method until we get that sorted out. - if self.detect_encryption(root_partition): - log(f"Identifying root partition by DISK-UUID on {root_partition}, looking for '{os.path.basename(root_partition.real_device)}'.", level=LOG_LEVELS.Debug) - for root, folders, uids in os.walk('/dev/disk/by-uuid'): - for uid in uids: - real_path = os.path.realpath(os.path.join(root, uid)) - - log(f"Checking root partition match {os.path.basename(real_path)} against {os.path.basename(root_partition.real_device)}: {os.path.basename(real_path) == os.path.basename(root_partition.real_device)}", level=LOG_LEVELS.Debug) - if not os.path.basename(real_path) == os.path.basename(root_partition.real_device): continue - - entry.write(f'options cryptdevice=UUID={uid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n') - - self.helper_flags['bootloader'] = bootloader - return True - break + if (real_device := self.detect_encryption(root_partition)): + log(f"Identifying root partition by PART-UUID on {real_device}: '{real_device.uuid}'.", level=LOG_LEVELS.Debug) + entry.write(f'options cryptdevice=PARTUUID={real_device.uuid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n') else: - log(f"Identifying root partition by PART-UUID on {root_partition}, looking for '{os.path.basename(root_partition.path)}'.", level=LOG_LEVELS.Debug) + log(f"Identifying root partition by PART-UUID on {root_partition}, looking for '{root_partition.uuid}'.", level=LOG_LEVELS.Debug) entry.write(f'options root=PARTUUID={root_partition.uuid} rw intel_pstate=no_hwp\n') - self.helper_flags['bootloader'] = bootloader - return True + self.helper_flags['bootloader'] = bootloader + return True raise RequirementError(f"Could not identify the UUID of {root_partition}, there for {self.target}/boot/loader/entries/arch.conf will be broken until fixed.") else: -- cgit v1.2.3-54-g00ecf From d9fc8abf02c70ad8177048f85a06294d63e41faf Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 10 Apr 2021 10:25:59 +0200 Subject: Added a #TODO --- archinstall/lib/installer.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 0c622129..92e89f26 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -381,6 +381,8 @@ class Installer(): if (real_device := self.detect_encryption(root_partition)): + # TODO: We need to detect if the encrypted device is a whole disk encryption, + # or simply a partition encryption. Right now we assume it's a partition (and we always have) log(f"Identifying root partition by PART-UUID on {real_device}: '{real_device.uuid}'.", level=LOG_LEVELS.Debug) entry.write(f'options cryptdevice=PARTUUID={real_device.uuid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n') else: -- cgit v1.2.3-54-g00ecf From 78aba78db7a30a97550e4683d1ed33ced5b86205 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Sat, 10 Apr 2021 12:09:02 -0400 Subject: Fix issue #263 --- archinstall/lib/installer.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index e9343cd1..5523b1e1 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -10,6 +10,8 @@ from .systemd import Networkd from .output import log, LOG_LEVELS from .storage import storage from .hardware import * +from .gfx_drivers import * + # Any package that the Installer() is responsible for (optional and the default ones) __packages__ = ["base", "base-devel", "linux", "linux-firmware", "efibootmgr", "nano", "ntp", "iwd"] __base_packages__ = __packages__[:6] -- cgit v1.2.3-54-g00ecf From 1292c07796b763b926fd5edb21905a663eaef8f0 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 11 Apr 2021 10:20:33 +0200 Subject: Fixed PR #273. Moved the graphic drivers into hardware since they are hardware specific, in the long run maybe we move them into 'drivers' or something. And moved the user interaction from gfx_drivers into user_interactions. And removed the import from installer.py to __init__.py since we don't want to import 'global functions' in extension imports. --- archinstall/lib/hardware.py | 19 +++++++++++ archinstall/lib/installer.py | 1 - archinstall/lib/user_interaction.py | 67 +++++++++++++++++++++++++++++++++++++ profiles/sway.py | 2 +- profiles/xorg.py | 2 +- 5 files changed, 88 insertions(+), 3 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index 3da333de..047b3491 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -2,6 +2,25 @@ import os, subprocess, json from .general import sys_command from .networking import list_interfaces, enrichIfaceTypes from typing import Optional + +AVAILABLE_GFX_DRIVERS = { + # Sub-dicts are layer-2 options to be selected + # and lists are a list of packages to be installed + 'AMD / ATI' : { + 'amd' : ['xf86-video-amdgpu'], + 'ati' : ['xf86-video-ati'] + }, + 'intel' : ['xf86-video-intel'], + 'nvidia' : { + 'open source' : ['xf86-video-nouveau'], + 'proprietary' : ['nvidia'] + }, + 'mesa' : ['mesa'], + 'fbdev' : ['xf86-video-fbdev'], + 'vesa' : ['xf86-video-vesa'], + 'vmware' : ['xf86-video-vmware'] +} + def hasWifi()->bool: return 'WIRELESS' in enrichIfaceTypes(list_interfaces().values()).values() diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 5523b1e1..484e7407 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -10,7 +10,6 @@ from .systemd import Networkd from .output import log, LOG_LEVELS from .storage import storage from .hardware import * -from .gfx_drivers import * # Any package that the Installer() is responsible for (optional and the default ones) __packages__ = ["base", "base-devel", "linux", "linux-firmware", "efibootmgr", "nano", "ntp", "iwd"] diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index b94bf3f5..d17691de 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -5,6 +5,8 @@ from .locale_helpers import search_keyboard_layout from .output import log, LOG_LEVELS from .storage import storage from .networking import list_interfaces +from .general import sys_command +from .hardware import AVAILABLE_GFX_DRIVERS ## TODO: Some inconsistencies between the selection processes. ## Some return the keys from the options, some the values? @@ -363,3 +365,68 @@ def select_mirror_regions(mirrors, show_top_mirrors=True): return selected_mirrors raise RequirementError("Selecting mirror region require a least one region to be given as an option.") + +def select_driver(options=AVAILABLE_GFX_DRIVERS): + """ + Some what convoluted function, which's job is simple. + Select a graphics driver from a pre-defined set of popular options. + + (The template xorg is for beginner users, not advanced, and should + there for appeal to the general public first and edge cases later) + """ + drivers = sorted(list(options)) + + if len(drivers) >= 1: + for index, driver in enumerate(drivers): + print(f"{index}: {driver}") + + print(' -- The above list are supported graphic card drivers. --') + print(' -- You need to select (and read about) which one you need. --') + + lspci = sys_command(f'/usr/bin/lspci') + for line in lspci.trace_log.split(b'\r\n'): + if b' vga ' in line.lower(): + if b'nvidia' in line.lower(): + print(' ** nvidia card detected, suggested driver: nvidia **') + elif b'amd' in line.lower(): + print(' ** AMD card detected, suggested driver: AMD / ATI **') + + selected_driver = input('Select your graphics card driver: ') + initial_option = selected_driver + + # Disabled search for now, only a few profiles exist anyway + # + #print(' -- You can enter ? or help to search for more drivers --') + #if selected_driver.lower() in ('?', 'help'): + # filter_string = input('Search for layout containing (example: "sv-"): ') + # new_options = search_keyboard_layout(filter_string) + # return select_language(new_options) + if selected_driver.isdigit() and (pos := int(selected_driver)) <= len(drivers)-1: + selected_driver = options[drivers[pos]] + elif selected_driver in options: + selected_driver = options[options.index(selected_driver)] + elif len(selected_driver) == 0: + raise RequirementError("At least one graphics driver is needed to support a graphical environment. Please restart the installer and try again.") + else: + raise RequirementError("Selected driver does not exist.") + + if type(selected_driver) == dict: + driver_options = sorted(list(selected_driver)) + for index, driver_package_group in enumerate(driver_options): + print(f"{index}: {driver_package_group}") + + selected_driver_package_group = input(f'Which driver-type do you want for {initial_option}: ') + if selected_driver_package_group.isdigit() and (pos := int(selected_driver_package_group)) <= len(driver_options)-1: + selected_driver_package_group = selected_driver[driver_options[pos]] + elif selected_driver_package_group in selected_driver: + selected_driver_package_group = selected_driver[selected_driver.index(selected_driver_package_group)] + elif len(selected_driver_package_group) == 0: + raise RequirementError(f"At least one driver package is required for a graphical environment using {selected_driver}. Please restart the installer and try again.") + else: + raise RequirementError(f"Selected driver-type does not exist for {initial_option}.") + + return selected_driver_package_group + + return selected_driver + + raise RequirementError("Selecting drivers require a least one profile to be given as an option.") \ No newline at end of file diff --git a/profiles/sway.py b/profiles/sway.py index 10e30753..f1d2c1f1 100644 --- a/profiles/sway.py +++ b/profiles/sway.py @@ -10,7 +10,7 @@ def _prep_function(*args, **kwargs): for more input before any other installer steps start. """ - __builtins__['_gfx_driver_packages'] = archinstall.lib.gfx_drivers.select_driver() + __builtins__['_gfx_driver_packages'] = archinstall.select_driver() return True diff --git a/profiles/xorg.py b/profiles/xorg.py index 6ee72487..42597a37 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -12,7 +12,7 @@ def _prep_function(*args, **kwargs): for more input before any other installer steps start. """ - __builtins__['_gfx_driver_packages'] = archinstall.lib.gfx_drivers.select_driver() + __builtins__['_gfx_driver_packages'] = archinstall.select_driver() # TODO: Add language section and/or merge it with the locale selected # earlier in for instance guided.py installer. -- cgit v1.2.3-54-g00ecf From 6cc546887d6054c02d4f287f936ba7bf1fc24e04 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 11 Apr 2021 16:04:03 -0400 Subject: If user does not change keyboard language, log it. --- archinstall/lib/installer.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 4ff9e80a..3b218dff 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -449,4 +449,6 @@ class Installer(): with open(f'{self.target}/etc/vconsole.conf', 'w') as vconsole: vconsole.write(f'KEYMAP={language}\n') vconsole.write(f'FONT=lat9w-16\n') + else: + self.log(f'Keyboard language was not changed from default (no language specified).', level=LOG_LEVELS.Info) return True -- cgit v1.2.3-54-g00ecf From de693b70807bd5bc35be9e446ac9a8d9f3121ecd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 11 Apr 2021 16:51:07 -0400 Subject: Make it yellow --- archinstall/lib/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 3b218dff..7aa64816 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -450,5 +450,5 @@ class Installer(): vconsole.write(f'KEYMAP={language}\n') vconsole.write(f'FONT=lat9w-16\n') else: - self.log(f'Keyboard language was not changed from default (no language specified).', level=LOG_LEVELS.Info) + self.log(f'Keyboard language was not changed from default (no language specified).', fg="yellow", level=LOG_LEVELS.Info) return True -- cgit v1.2.3-54-g00ecf From b44c0e51976ed3c177341c78da49ccec4cd81b5b Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Mon, 12 Apr 2021 09:10:00 -0400 Subject: Implement chroot prompt after successful installation Try os.subprocess Revert to subprocess.check_call --- archinstall/lib/installer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 7aa64816..7c3ee051 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1,4 +1,4 @@ -import os, stat, time, shutil, pathlib +import os, stat, time, shutil, pathlib, subprocess from .exceptions import * from .disk import * @@ -81,6 +81,13 @@ class Installer(): if not (missing_steps := self.post_install_check()): self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=LOG_LEVELS.Info) self.sync_log_to_install_medium() + self.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") + choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ") + if choice.lower() in ("y", ""): + try: + subprocess.check_call(f"arch-chroot {self.target}", shell=True) + except: + pass return True else: self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) -- cgit v1.2.3-54-g00ecf From 3034def365a0f139a41b20c8933e61e86f298eaf Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Mon, 12 Apr 2021 10:09:37 -0400 Subject: Move logic to guided --- archinstall/lib/installer.py | 11 ++++------- examples/guided.py | 8 ++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 7c3ee051..c50b2ac7 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -81,13 +81,7 @@ class Installer(): if not (missing_steps := self.post_install_check()): self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=LOG_LEVELS.Info) self.sync_log_to_install_medium() - self.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") - choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ") - if choice.lower() in ("y", ""): - try: - subprocess.check_call(f"arch-chroot {self.target}", shell=True) - except: - pass + return True else: self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) @@ -197,6 +191,9 @@ class Installer(): def arch_chroot(self, cmd, *args, **kwargs): return self.run_command(cmd) + def drop_to_shell(self): + subprocess.check_call(f"/usr/bin/arch-chroot {self.target}", shell=True) + def configure_nic(self, nic, dhcp=True, ip=None, gateway=None, dns=None, *args, **kwargs): if dhcp: conf = Networkd(Match={"Name": nic}, Network={"DHCP": "yes"}) diff --git a/examples/guided.py b/examples/guided.py index beb577c8..d50063f3 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -327,3 +327,11 @@ def perform_installation(mountpoint): ask_user_questions() perform_installation_steps() + +installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") +choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ") +if choice.lower() in ("y", ""): + try: + installation.drop_to_shell() + except: + pass -- cgit v1.2.3-54-g00ecf From f6d6e0328eb95a29ebbc0f4a6f596831aed28227 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 12 Apr 2021 16:06:50 -0400 Subject: Implement function to set the shell for a user (#291) --- archinstall/lib/installer.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 7aa64816..f21287c3 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -443,6 +443,12 @@ class Installer(): o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.target} sh -c \"echo '{user}:{password}' | chpasswd\"")) pass + + def user_set_shell(self, user, shell): + self.log(f'Setting shell for {user} to {shell}', level=LOG_LEVELS.Info) + + o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\"")) + pass def set_keyboard_language(self, language): if len(language.strip()): -- cgit v1.2.3-54-g00ecf