From ee3c48c965b2e7a2ed9427c2b5179318d52887c0 Mon Sep 17 00:00:00 2001 From: advaithm Date: Fri, 12 Mar 2021 12:02:03 +0530 Subject: updated examples --- examples/minimal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/minimal.py b/examples/minimal.py index 664bad0d..b5bb34e0 100644 --- a/examples/minimal.py +++ b/examples/minimal.py @@ -8,7 +8,7 @@ archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', suppress_error harddrive = archinstall.select_disk(archinstall.all_disks()) disk_password = getpass.getpass(prompt='Disk password (won\'t echo): ') -with archinstall.Filesystem(harddrive, archinstall.GPT) as fs: +with archinstall.Filesystem(harddrive) as fs: # Use the entire disk instead of setting up partitions on your own fs.use_entire_disk('luks2') -- cgit v1.2.3-54-g00ecf From b974b93004efa9912e404f5d3fca7c44a58dc0e3 Mon Sep 17 00:00:00 2001 From: advaithm Date: Fri, 2 Apr 2021 10:08:16 +0530 Subject: fixed some issues with the changes --- archinstall/lib/disk.py | 7 ++----- archinstall/lib/installer.py | 12 +++++++++++- examples/guided.py | 8 +++++++- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index fbc11ca3..8e9e0234 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -390,12 +390,9 @@ class Filesystem(): # TODO: # When instance of a HDD is selected, check all usages and gracefully unmount them # as well as close any crypto handles. - def __init__(self, blockdevice): + def __init__(self, blockdevice,mode): self.blockdevice = blockdevice - if hasUEFI(): - self.mode = GPT - else: - self.mode = MBR + self.mode = mode def __enter__(self, *args, **kwargs): if self.blockdevice.keep_partitions is False: diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index d161c3b7..492d7715 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 * @@ -398,6 +398,16 @@ class Installer(): break 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.") + elif bootloader == "grub-install": + if hasUEFI(): + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB')) + sys_command('/usr/bin/arch-chroot grub-mkconfig -o /boot/grub/grub.cfg') + else: + root_device = subprocess.check_output(f'basename "$(readlink -f "/sys/class/block/{self.partition.path.strip("/dev/")}/..")',shell=True).decode().strip() + if root_device == "block": + root_device = f"{self.partition.path}" + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} grub-install --target=--target=i386-pc /dev/{root_device}')) + sys_command('/usr/bin/arch-chroot grub-mkconfig -o /boot/grub/grub.cfg') else: raise RequirementError(f"Unknown (or not yet implemented) bootloader added to add_bootloader(): {bootloader}") diff --git a/examples/guided.py b/examples/guided.py index 71e1e01d..f374a41c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,5 +1,6 @@ import getpass, time, json, sys, signal, os import archinstall +from archinstall.lib.hardware import hasUEFI """ This signal-handler chain (and global variable) @@ -244,7 +245,12 @@ def perform_installation_steps(): Setup the blockdevice, filesystem (and optionally encryption). Once that's done, we'll hand over to perform_installation() """ - with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs: + # maybe we can ask the user what they would prefer on uefi systems? + if hasUEFI(): + mode = archinstall.GPT + else: + mode = archinstall.MBR + with archinstall.Filesystem(archinstall.arguments['harddrive'],mode) as fs: # Wipe the entire drive if the disk flag `keep_partitions`is False. if archinstall.arguments['harddrive'].keep_partitions is False: fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get('filesystem', 'btrfs')) -- cgit v1.2.3-54-g00ecf From ae5f9b08c4a670d2c020923a042fdcbaa5c2a1d6 Mon Sep 17 00:00:00 2001 From: advaithm Date: Sun, 4 Apr 2021 07:33:17 +0530 Subject: updated guided.py to allow network manager as nic --- examples/guided.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index f374a41c..ec66e892 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -317,7 +317,8 @@ def perform_installation(device, boot_partition, language, mirrors): # Perform a copy of the config if archinstall.arguments.get('nic', None) == 'Copy ISO network configuration to installation': installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. - + elif archinstall.arguments.get('NetworkManager',None) == True: + installation.enable_service('NetworkManager.service') # Otherwise, if a interface was selected, configure that interface elif archinstall.arguments.get('nic', None): installation.configure_nic(**archinstall.arguments.get('nic', {})) -- cgit v1.2.3-54-g00ecf From 9e3ded83119df6a5f2b470ee648754869d4eb824 Mon Sep 17 00:00:00 2001 From: advaithm Date: Sun, 4 Apr 2021 08:54:35 +0530 Subject: install networkmanager, if required --- examples/guided.py | 1 + 1 file changed, 1 insertion(+) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index ec66e892..5ca45008 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -318,6 +318,7 @@ def perform_installation(device, boot_partition, language, mirrors): if archinstall.arguments.get('nic', None) == 'Copy ISO network configuration to installation': installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. elif archinstall.arguments.get('NetworkManager',None) == True: + installation.add_additional_packages("networkmanager") installation.enable_service('NetworkManager.service') # Otherwise, if a interface was selected, configure that interface elif archinstall.arguments.get('nic', None): -- cgit v1.2.3-54-g00ecf From 9daa3f49242227e0cc6c2272b9322578edaab644 Mon Sep 17 00:00:00 2001 From: advaithm Date: Sun, 4 Apr 2021 09:26:28 +0530 Subject: fixed some typos and changed up how we detect if we have to enable/install network manager --- archinstall/lib/user_interaction.py | 4 ++-- examples/guided.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 83e59e90..f8b4d9c5 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -94,11 +94,11 @@ def ask_to_configure_network(): # Optionally configure one network interface. #while 1: # {MAC: Ifname} - interfaces = {'ISO-CONFIG' : 'Copy ISO network configuration to installation','NetworkManager':'Use NetworkManager to control and manage you internet conntetion', **list_interfaces()} + interfaces = {'ISO-CONFIG' : 'Copy ISO network configuration to installation','NetworkManager':'Use NetworkManager to control and manage your internet connection', **list_interfaces()} nic = generic_select(interfaces.values(), "Select one network interface to configure (leave blank to skip): ") if nic and nic != 'Copy ISO network configuration to installation': - if nic == 'Use NetworkManager to control and manage you internet conntetion': + if nic == 'Use NetworkManager to control and manage your internet connection': return {'nic': nic,'NetworkManager':True} mode = generic_select(['DHCP (auto detect)', 'IP (static)'], f"Select which mode to configure for {nic}: ") if mode == 'IP (static)': diff --git a/examples/guided.py b/examples/guided.py index 5ca45008..1e077169 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -317,7 +317,7 @@ def perform_installation(device, boot_partition, language, mirrors): # Perform a copy of the config if archinstall.arguments.get('nic', None) == 'Copy ISO network configuration to installation': installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. - elif archinstall.arguments.get('NetworkManager',None) == True: + elif archinstall.arguments.get('nic',None) == 'Use NetworkManager to control and manage your internet connection': installation.add_additional_packages("networkmanager") installation.enable_service('NetworkManager.service') # Otherwise, if a interface was selected, configure that interface -- cgit v1.2.3-54-g00ecf From 8ad4a7d1c42ec5aaf665d4f769cc4860780225d2 Mon Sep 17 00:00:00 2001 From: Advaith Madhukar Date: Sun, 4 Apr 2021 14:42:19 +0530 Subject: fixed network manager check --- examples/guided.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 1e077169..1a1cf84c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -317,7 +317,7 @@ def perform_installation(device, boot_partition, language, mirrors): # Perform a copy of the config if archinstall.arguments.get('nic', None) == 'Copy ISO network configuration to installation': installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. - elif archinstall.arguments.get('nic',None) == 'Use NetworkManager to control and manage your internet connection': + elif archinstall.arguments.get('nic',{}).get('NetworkManager',False): installation.add_additional_packages("networkmanager") installation.enable_service('NetworkManager.service') # Otherwise, if a interface was selected, configure that interface @@ -347,4 +347,4 @@ def perform_installation(device, boot_partition, language, mirrors): ask_user_questions() -perform_installation_steps() \ No newline at end of file +perform_installation_steps() -- cgit v1.2.3-54-g00ecf From dbe7f3fcb8fa71d14bb27a9963d841cc12007117 Mon Sep 17 00:00:00 2001 From: advaithm Date: Sun, 4 Apr 2021 19:20:08 +0530 Subject: Fixed issue with no network configueration --- examples/guided.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 1a1cf84c..ee8c5d57 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -317,6 +317,9 @@ def perform_installation(device, boot_partition, language, mirrors): # Perform a copy of the config if archinstall.arguments.get('nic', None) == 'Copy ISO network configuration to installation': installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. + elif archinstall.arguments.get('nic',None) == None: + #skip if we don't have a network + pass elif archinstall.arguments.get('nic',{}).get('NetworkManager',False): installation.add_additional_packages("networkmanager") installation.enable_service('NetworkManager.service') @@ -326,7 +329,6 @@ def perform_installation(device, boot_partition, language, mirrors): installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved') - if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '': installation.add_additional_packages(archinstall.arguments.get('packages', None)) -- cgit v1.2.3-54-g00ecf From e2a6a85d66ef0d43c5bb941d9ec945c854f45849 Mon Sep 17 00:00:00 2001 From: advaithm Date: Mon, 5 Apr 2021 20:47:42 +0530 Subject: Revert "Fixed issue with no network configueration" This reverts commit dbe7f3fcb8fa71d14bb27a9963d841cc12007117. --- examples/guided.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index ee8c5d57..1a1cf84c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -317,9 +317,6 @@ def perform_installation(device, boot_partition, language, mirrors): # Perform a copy of the config if archinstall.arguments.get('nic', None) == 'Copy ISO network configuration to installation': installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. - elif archinstall.arguments.get('nic',None) == None: - #skip if we don't have a network - pass elif archinstall.arguments.get('nic',{}).get('NetworkManager',False): installation.add_additional_packages("networkmanager") installation.enable_service('NetworkManager.service') @@ -329,6 +326,7 @@ def perform_installation(device, boot_partition, language, mirrors): installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved') + if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '': installation.add_additional_packages(archinstall.arguments.get('packages', None)) -- cgit v1.2.3-54-g00ecf From 463d1b5fd37db1435f15987929963ee2f2c2dc02 Mon Sep 17 00:00:00 2001 From: advaithm Date: Mon, 5 Apr 2021 20:58:38 +0530 Subject: add shell drop for i3 and i3-gaps --- examples/guided.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 1a1cf84c..74db0ce5 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -344,7 +344,11 @@ def perform_installation(device, boot_partition, language, mirrors): if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw): installation.user_set_pw('root', root_pw) - + if archinstall.arguments.get('profile', None) == "i3-wm" or archinstall.arguments.get('profile', None) == "i3-gaps": + print("the installation of i3/i3-gaps does not conatain any configuerations for the wm. in this shell you should add your configuerations") + installation.arch_chroot("bash") ask_user_questions() perform_installation_steps() + + \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 947700a605b5c9a066f29b9a51e36a079ccfd45a Mon Sep 17 00:00:00 2001 From: advaithm Date: Mon, 5 Apr 2021 21:03:56 +0530 Subject: use subprocess to launch the shell --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 74db0ce5..fd4ee906 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -346,7 +346,7 @@ def perform_installation(device, boot_partition, language, mirrors): installation.user_set_pw('root', root_pw) if archinstall.arguments.get('profile', None) == "i3-wm" or archinstall.arguments.get('profile', None) == "i3-gaps": print("the installation of i3/i3-gaps does not conatain any configuerations for the wm. in this shell you should add your configuerations") - installation.arch_chroot("bash") + subprocess.check_call("arch-chroot /mnt") ask_user_questions() perform_installation_steps() -- cgit v1.2.3-54-g00ecf From 9404dbe967beaa060101c4d53758ee308f754740 Mon Sep 17 00:00:00 2001 From: advaithm Date: Mon, 5 Apr 2021 21:05:15 +0530 Subject: Update guided.py --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index fd4ee906..b3c5ca04 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,4 +1,4 @@ -import getpass, time, json, sys, signal, os +import getpass, time, json, sys, signal, os, subprocess import archinstall from archinstall.lib.hardware import hasUEFI -- cgit v1.2.3-54-g00ecf From b56f7d0515d7dc3b31f2c255c20bc514df9155b1 Mon Sep 17 00:00:00 2001 From: advaithm Date: Mon, 5 Apr 2021 21:28:20 +0530 Subject: fixed subprocess call --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index b3c5ca04..032a1f39 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -346,7 +346,7 @@ def perform_installation(device, boot_partition, language, mirrors): installation.user_set_pw('root', root_pw) if archinstall.arguments.get('profile', None) == "i3-wm" or archinstall.arguments.get('profile', None) == "i3-gaps": print("the installation of i3/i3-gaps does not conatain any configuerations for the wm. in this shell you should add your configuerations") - subprocess.check_call("arch-chroot /mnt") + subprocess.check_call("arch-chroot /mnt",shell=True) ask_user_questions() perform_installation_steps() -- cgit v1.2.3-54-g00ecf From f0e40f56765156aff22cb270b28aa15c5547534f Mon Sep 17 00:00:00 2001 From: advaithm Date: Tue, 6 Apr 2021 07:21:11 +0530 Subject: added _post_install hook. --- archinstall/lib/profiles.py | 15 +++++++++++++++ examples/guided.py | 14 ++++++++++---- profiles/i3-gaps.py | 10 +++++++++- profiles/i3-wm.py | 9 ++++++++- 4 files changed, 42 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 08b1d618..77c9c6b2 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -177,6 +177,21 @@ class Profile(Script): if hasattr(imported, '_prep_function'): return True return False + def has_post_install(self): + with open(self.path, 'r') as source: + source_data = source.read() + + # Some crude safety checks, make sure the imported profile has + # a __name__ check and if so, check if it's got a _prep_function() + # we can call to ask for more user input. + # + # If the requirements are met, import with .py in the namespace to not + # trigger a traditional: + # if __name__ == 'moduleName' + if '__name__' in source_data and '_post_install' in source_data: + with self.load_instructions(namespace=f"{self.namespace}.py") as imported: + if hasattr(imported, '_post_install'): + return True class Application(Profile): def __repr__(self, *args, **kwargs): diff --git a/examples/guided.py b/examples/guided.py index 032a1f39..3f11b7a8 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,4 +1,4 @@ -import getpass, time, json, sys, signal, os, subprocess +import getpass, time, json, sys, signal, os import archinstall from archinstall.lib.hardware import hasUEFI @@ -344,9 +344,15 @@ def perform_installation(device, boot_partition, language, mirrors): if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw): installation.user_set_pw('root', root_pw) - if archinstall.arguments.get('profile', None) == "i3-wm" or archinstall.arguments.get('profile', None) == "i3-gaps": - print("the installation of i3/i3-gaps does not conatain any configuerations for the wm. in this shell you should add your configuerations") - subprocess.check_call("arch-chroot /mnt",shell=True) + if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_post_install(): + with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported: + if not imported._post_install(): + archinstall.log( + ' * Profile\'s preparation requirements was not fulfilled.', + bg='black', + fg='red' + ) + exit(1) ask_user_questions() perform_installation_steps() diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index bf8227ba..d9469dcd 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -1,4 +1,4 @@ -import archinstall +import archinstall, subprocess def _prep_function(*args, **kwargs): """ @@ -16,6 +16,14 @@ def _prep_function(*args, **kwargs): else: print('Deprecated (??): xorg profile has no _prep_function() anymore') +def _post_install(*args, **kwargs): + """ + Another magic function called after the system + has been installed. + """ + print("the installation of i3 does not conatain any configuerations for the wm. in this shell you take your time should add your configuerations") + subprocess.check_call("arch-chroot /mnt",shell=True) + if __name__ == 'i3-wm': # Install dependency profiles installation.install_profile('xorg') diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index 168abb72..8b541bbf 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -1,4 +1,4 @@ -import archinstall +import archinstall, subprocess def _prep_function(*args, **kwargs): """ @@ -15,6 +15,13 @@ def _prep_function(*args, **kwargs): return imported._prep_function() else: print('Deprecated (??): xorg profile has no _prep_function() anymore') +def _post_install(*args, **kwargs): + """ + Another magic function called after the system + has been installed. + """ + print("the installation of i3-gaps does not conatain any configuerations for the wm. in this shell you should take your time to add your configuerations") + subprocess.check_call("arch-chroot /mnt",shell=True) if __name__ == 'i3-wm': # Install dependency profiles -- cgit v1.2.3-54-g00ecf From 4af3bbac2306146ce038666f2911690c655bcb63 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 6 Apr 2021 09:55:12 +0200 Subject: Phrasing and removed background coloring --- examples/guided.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 3f11b7a8..85492a81 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -348,8 +348,7 @@ def perform_installation(device, boot_partition, language, mirrors): with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported: if not imported._post_install(): archinstall.log( - ' * Profile\'s preparation requirements was not fulfilled.', - bg='black', + ' * Profile\'s post configuration requirements was not fulfilled.', fg='red' ) exit(1) @@ -357,4 +356,4 @@ def perform_installation(device, boot_partition, language, mirrors): ask_user_questions() perform_installation_steps() - \ No newline at end of file + -- cgit v1.2.3-54-g00ecf From d9984550b6ad4f4e7d659adb32cef541e85d69d9 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 6 Apr 2021 18:04:03 -0400 Subject: Move choice into guided installation instead of DEs Arch wiki says packages should enable the user services automatically --- archinstall/lib/user_interaction.py | 8 ++++++++ examples/guided.py | 10 +++++++++- profiles/applications/pipewire.py | 4 ++-- profiles/awesome.py | 6 ------ profiles/cinnamon.py | 6 ------ profiles/gnome.py | 6 ------ profiles/i3-gaps.py | 8 +------- profiles/i3-wm.py | 6 ------ profiles/kde.py | 6 ------ profiles/xfce4.py | 6 ------ 10 files changed, 20 insertions(+), 46 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 58f88bd2..3c5115ea 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -89,6 +89,14 @@ def ask_for_a_timezone(): level=LOG_LEVELS.Warning, fg='red' ) + +def ask_for_audio_selection(): + audio = "pulseaudio" # Default for most desktop environments + pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() + if pipewire_choice == "y": + audio = "pipewire" + + return audio def ask_to_configure_network(): # Optionally configure one network interface. diff --git a/examples/guided.py b/examples/guided.py index 81cc2991..cd45bef5 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -182,6 +182,10 @@ def ask_user_questions(): ) exit(1) + # Ask about audio server selection (this right now just asks for pipewire and defaults to pulseaudio otherwise) + if not archinstall.arguments.get('audio', None): + archinstall.arguments['audio'] = archinstall.ask_for_audio_selection() + # Additional packages (with some light weight error handling for invalid package names) if not archinstall.arguments.get('packages', None): archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)] @@ -329,7 +333,11 @@ def perform_installation(device, boot_partition, language, mirrors): installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved') - + print('This audio server will be used: ' + archinstall.arguments.get('audio', None)) + if archinstall.arguments.get('audio', None) == 'pipewire': + print('Installing pipewire ...') + installation.install_profile('pipewire') + if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '': installation.add_additional_packages(archinstall.arguments.get('packages', None)) diff --git a/profiles/applications/pipewire.py b/profiles/applications/pipewire.py index 2d9f6a6c..aea5b50d 100644 --- a/profiles/applications/pipewire.py +++ b/profiles/applications/pipewire.py @@ -1,5 +1,5 @@ import archinstall -__packages__ = ["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"] +packages = ["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"] -installation.add_additional_packages(__packages__) +installation.add_additional_packages(packages) diff --git a/profiles/awesome.py b/profiles/awesome.py index fcad1839..8004fc62 100644 --- a/profiles/awesome.py +++ b/profiles/awesome.py @@ -25,12 +25,6 @@ def _prep_function(*args, **kwargs): # through importlib.util.spec_from_file_location("awesome", "/somewhere/awesome.py") # or through conventional import awesome if __name__ == 'awesome': - # Install the pipewire audio server if the user wants to use it - pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() - if choice == "y": - pipewire = archinstall.Application(installation, 'pipewire') - pipewire.install() - # Install the application awesome from the template under /applications/ awesome = archinstall.Application(installation, 'awesome') awesome.install() diff --git a/profiles/cinnamon.py b/profiles/cinnamon.py index a3225c30..dac38bd3 100644 --- a/profiles/cinnamon.py +++ b/profiles/cinnamon.py @@ -22,12 +22,6 @@ def _prep_function(*args, **kwargs): # through importlib.util.spec_from_file_location("cinnamon", "/somewhere/cinnamon.py") # or through conventional import cinnamon if __name__ == 'cinnamon': - # Install the pipewire audio server if the user wants to use it - pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() - if choice == "y": - pipewire = archinstall.Application(installation, 'pipewire') - pipewire.install() - # Install dependency profiles installation.install_profile('xorg') diff --git a/profiles/gnome.py b/profiles/gnome.py index d13e6eee..63fcd57d 100644 --- a/profiles/gnome.py +++ b/profiles/gnome.py @@ -23,12 +23,6 @@ def _prep_function(*args, **kwargs): # through importlib.util.spec_from_file_location("gnome", "/somewhere/gnome.py") # or through conventional import gnome if __name__ == 'gnome': - # Install the pipewire audio server if the user wants to use it - pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() - if choice == "y": - pipewire = archinstall.Application(installation, 'pipewire') - pipewire.install() - # Install dependency profiles installation.install_profile('xorg') diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py index f75dfb11..50511dce 100644 --- a/profiles/i3-gaps.py +++ b/profiles/i3-gaps.py @@ -29,13 +29,7 @@ def _post_install(*args, **kwargs): return True -if __name__ == 'i3-wm': - # Install the pipewire audio server if the user wants to use it - pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() - if choice == "y": - pipewire = archinstall.Application(installation, 'pipewire') - pipewire.install() - +if __name__ == 'i3-wm': # Install dependency profiles installation.install_profile('xorg') # gaps is installed by deafult so we are overriding it here diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py index 6d40065c..cd6cbc81 100644 --- a/profiles/i3-wm.py +++ b/profiles/i3-wm.py @@ -29,12 +29,6 @@ def _post_install(*args, **kwargs): return True if __name__ == 'i3-wm': - # Install the pipewire audio server if the user wants to use it - pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() - if choice == "y": - pipewire = archinstall.Application(installation, 'pipewire') - pipewire.install() - # Install dependency profiles installation.install_profile('xorg') # we are installing lightdm to auto start i3 diff --git a/profiles/kde.py b/profiles/kde.py index dabba57b..0207ed22 100644 --- a/profiles/kde.py +++ b/profiles/kde.py @@ -32,12 +32,6 @@ def _post_install(*args, **kwargs): # through importlib.util.spec_from_file_location("kde", "/somewhere/kde.py") # or through conventional import kde if __name__ == 'kde': - # Install the pipewire audio server if the user wants to use it - pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() - if choice == "y": - pipewire = archinstall.Application(installation, 'pipewire') - pipewire.install() - # Install dependency profiles installation.install_profile('xorg') diff --git a/profiles/xfce4.py b/profiles/xfce4.py index 8e418578..36c9958a 100644 --- a/profiles/xfce4.py +++ b/profiles/xfce4.py @@ -23,12 +23,6 @@ def _prep_function(*args, **kwargs): # through importlib.util.spec_from_file_location("xfce4", "/somewhere/xfce4.py") # or through conventional import xfce4 if __name__ == 'xfce4': - # Install the pipewire audio server if the user wants to use it - pipewire_choice = input("Would you like to install the pipewire audio server? [Y/n] ").lower() - if choice == "y": - pipewire = archinstall.Application(installation, 'pipewire') - pipewire.install() - # Install dependency profiles installation.install_profile('xorg') -- cgit v1.2.3-54-g00ecf From 93750dbd223269804c2a9a3a7dbdf30d4f17ac82 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Tue, 6 Apr 2021 20:44:44 -0400 Subject: Try removing pipewire.py and calling add additional packages Unfortunately, calling the profile was not working. --- examples/guided.py | 2 +- profiles/applications/pipewire.py | 5 ----- profiles/gnome.py | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 profiles/applications/pipewire.py (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index cd45bef5..90828d87 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -336,7 +336,7 @@ def perform_installation(device, boot_partition, language, mirrors): print('This audio server will be used: ' + archinstall.arguments.get('audio', None)) if archinstall.arguments.get('audio', None) == 'pipewire': print('Installing pipewire ...') - installation.install_profile('pipewire') + installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"]) if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '': installation.add_additional_packages(archinstall.arguments.get('packages', None)) diff --git a/profiles/applications/pipewire.py b/profiles/applications/pipewire.py deleted file mode 100644 index aea5b50d..00000000 --- a/profiles/applications/pipewire.py +++ /dev/null @@ -1,5 +0,0 @@ -import archinstall - -packages = ["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"] - -installation.add_additional_packages(packages) diff --git a/profiles/gnome.py b/profiles/gnome.py index 63fcd57d..b37679de 100644 --- a/profiles/gnome.py +++ b/profiles/gnome.py @@ -29,7 +29,7 @@ if __name__ == 'gnome': # Install the application gnome from the template under /applications/ gnome = archinstall.Application(installation, 'gnome') gnome.install() - + installation.enable_service('gdm') # Gnome Display Manager # We could also start it via xinitrc since we do have Xorg, # but for gnome that's deprecated and wayland is preferred. -- cgit v1.2.3-54-g00ecf From fb2c9aca397f6fc0ffba097b4c4dcb5e96257362 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Tue, 6 Apr 2021 20:47:30 -0400 Subject: Have pulseaudio installed just in case DEs don't depend on it if pipewire is not requested. --- examples/guided.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 90828d87..74df899f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -337,6 +337,9 @@ def perform_installation(device, boot_partition, language, mirrors): if archinstall.arguments.get('audio', None) == 'pipewire': print('Installing pipewire ...') installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"]) + elif archinstall.arguments.get('audio', None) == 'pulseaudio': + print('Installing pulseaudio ...') + installation.add_additional_packages("pulseaudio") if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '': installation.add_additional_packages(archinstall.arguments.get('packages', None)) -- cgit v1.2.3-54-g00ecf From 86699ae23ebb3eabb3817ccb456eb1ddd9dcebbf Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 7 Apr 2021 09:28:16 +0200 Subject: Switched from print to installation.log --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 74df899f..a5442d77 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -333,7 +333,7 @@ def perform_installation(device, boot_partition, language, mirrors): installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved') - print('This audio server will be used: ' + archinstall.arguments.get('audio', None)) + installation.log(f"The {archinstall.arguments.get('audio', None)} audio server will be used.", level=archinstall.LOG_LEVELS.Info) if archinstall.arguments.get('audio', None) == 'pipewire': print('Installing pipewire ...') installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"]) -- cgit v1.2.3-54-g00ecf From f85fb66bc61ee9b90537da59be00b37f49e5ffb8 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 7 Apr 2021 09:12:33 -0400 Subject: Add filtration on top level profile --- archinstall/lib/profiles.py | 8 ++++++++ examples/guided.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 39411553..1948a819 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -177,6 +177,7 @@ class Profile(Script): if hasattr(imported, '_prep_function'): return True return False + def has_post_install(self): with open(self.path, 'r') as source: source_data = source.read() @@ -193,6 +194,13 @@ class Profile(Script): if hasattr(imported, '_post_install'): return True + def is_top_level_profile(self): + with open(self.path, 'r') as source: + source_data = source.read() + + # TODO: I imagine that there is probably a better way to write this. + return 'top_level_profile = True' in source_data + @property def packages(self) -> list: """ diff --git a/examples/guided.py b/examples/guided.py index 0a655e8a..a7cc7edc 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,6 +1,7 @@ import getpass, time, json, sys, signal, os import archinstall from archinstall.lib.hardware import hasUEFI +from archinstall.lib.profiles import Profile """ This signal-handler chain (and global variable) @@ -167,7 +168,7 @@ def ask_user_questions(): # Ask for archinstall-specific profiles (such as desktop environments etc) if not archinstall.arguments.get('profile', None): - archinstall.arguments['profile'] = archinstall.select_profile(archinstall.list_profiles()) + archinstall.arguments['profile'] = archinstall.select_profile(filter(lambda profile: (Profile(None, profile).is_top_level_profile()), archinstall.list_profiles())) else: archinstall.arguments['profile'] = archinstall.list_profiles()[archinstall.arguments['profile']] -- cgit v1.2.3-54-g00ecf From fd7510a88ccd68c600e6f1c10b30152126d0351a Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Wed, 7 Apr 2021 19:51:16 -0400 Subject: Make audio server selection only prompt for desktop profiles --- examples/guided.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 55855d1b..4c3cb58c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -182,9 +182,16 @@ def ask_user_questions(): ) exit(1) - # Ask about audio server selection (this right now just asks for pipewire and defaults to pulseaudio otherwise) + # Ask about audio server selection if one is not already set if not archinstall.arguments.get('audio', None): - archinstall.arguments['audio'] = archinstall.ask_for_audio_selection() + + # only ask for audio server selection on a desktop profile + if str(archinstall.arguments['profile']) == 'Profile(desktop)': + archinstall.arguments['audio'] = archinstall.ask_for_audio_selection() + else: + # packages installed by a profile may depend on audio and something may get installed anyways, not much we can do about that. + # we will not try to remove packages post-installation to not have audio, as that may cause multiple issues + archinstall.arguments['audio'] = 'none' # Additional packages (with some light weight error handling for invalid package names) if not archinstall.arguments.get('packages', None): @@ -334,13 +341,14 @@ def perform_installation(device, boot_partition, language, mirrors): installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved') - installation.log(f"The {archinstall.arguments.get('audio', None)} audio server will be used.", level=archinstall.LOG_LEVELS.Info) - if archinstall.arguments.get('audio', None) == 'pipewire': - print('Installing pipewire ...') - installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"]) - elif archinstall.arguments.get('audio', None) == 'pulseaudio': - print('Installing pulseaudio ...') - installation.add_additional_packages("pulseaudio") + if archinstall.arguments['audio'] != 'none': + installation.log(f"The {archinstall.arguments.get('audio', None)} audio server will be used.", level=archinstall.LOG_LEVELS.Info) + if archinstall.arguments.get('audio', None) == 'pipewire': + print('Installing pipewire ...') + installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"]) + elif archinstall.arguments.get('audio', None) == 'pulseaudio': + print('Installing pulseaudio ...') + installation.add_additional_packages("pulseaudio") if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '': installation.add_additional_packages(archinstall.arguments.get('packages', None)) -- cgit v1.2.3-54-g00ecf From cdf6fc796fc7d00b29c62c09e0788a74e05461a1 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 8 Apr 2021 08:17:40 +0200 Subject: Safety precaution by using .get instead of ["..."] --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 4c3cb58c..fa74fbba 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -341,7 +341,7 @@ def perform_installation(device, boot_partition, language, mirrors): installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved') - if archinstall.arguments['audio'] != 'none': + if archinstall.arguments.get('audio', None) != None: installation.log(f"The {archinstall.arguments.get('audio', None)} audio server will be used.", level=archinstall.LOG_LEVELS.Info) if archinstall.arguments.get('audio', None) == 'pipewire': print('Installing pipewire ...') -- cgit v1.2.3-54-g00ecf From dffb611d18a9de5695297dee7c97e7cc4e97c0c6 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 13 Apr 2021 20:19:46 -0400 Subject: Fix warning on BIOS/MBR systems --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index d47a949c..fa644480 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -4,7 +4,7 @@ from archinstall.lib.hardware import hasUEFI from archinstall.lib.profiles import Profile if hasUEFI() is False: - log("ArchInstall currently only supports machines booted with UEFI. MBR & GRUB support is coming in version 2.2.0!", fg="red", level=archinstall.LOG_LEVELS.Error) + archinstall.log("ArchInstall currently only supports machines booted with UEFI.\nMBR & GRUB support is coming in version 2.2.0!", fg="red", level=archinstall.LOG_LEVELS.Error) exit(1) def ask_user_questions(): -- cgit v1.2.3-54-g00ecf From 3347d04bfa8daef042cc51af24e996b111374a66 Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 14 Apr 2021 13:46:47 +0530 Subject: fixed issues raised in a review --- archinstall/lib/user_interaction.py | 27 +++++++++++++-------------- examples/guided.py | 23 ++++++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 16627794..6756fb50 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -345,6 +345,7 @@ def select_language(options, show_only_country_codes=True): elif selected_language.isdigit() and (pos := int(selected_language)) <= len(languages)-1: selected_language = languages[pos] + return select_language # I'm leaving "options" on purpose here. # Since languages possibly contains a filtered version of # all possible language layouts, and we might want to write @@ -352,9 +353,9 @@ def select_language(options, show_only_country_codes=True): # go through the search step. elif selected_language in options: selected_language = options[options.index(selected_language)] + return selected_language else: - RequirementError("Selected language does not exist.") - return selected_language + print("Invalid Langue please select a valid option.") raise RequirementError("Selecting languages require a least one language to be given as an option.") @@ -383,21 +384,19 @@ def select_mirror_regions(mirrors, show_top_mirrors=True): print(' -- You can skip this step by leaving the option blank --') selected_mirror = input('Select one of the above regions to download packages from (by number or full name): ') if len(selected_mirror.strip()) == 0: - return {} - - elif selected_mirror.isdigit() and (pos := int(selected_mirror)) <= len(regions)-1: + return {"mirror": None} + + elif selected_mirror.isdigit() and int(selected_mirror) <= len(regions)-1: + # I'm leaving "mirrors" on purpose here. + # Since region possibly contains a known region of + # all possible regions, and we might want to write + # for instance Sweden (if we know that exists) without having to + # go through the search step. region = regions[int(selected_mirror)] selected_mirrors[region] = mirrors[region] - # I'm leaving "mirrors" on purpose here. - # Since region possibly contains a known region of - # all possible regions, and we might want to write - # for instance Sweden (if we know that exists) without having to - # go through the search step. elif selected_mirror in mirrors: selected_mirrors[selected_mirror] = mirrors[selected_mirror] else: - RequirementError("Selected region does not exist.") - - return selected_mirrors + print("Selected region does not exist.") - raise RequirementError("Selecting mirror region require a least one region to be given as an option.") + return selected_mirrors \ No newline at end of file diff --git a/examples/guided.py b/examples/guided.py index 8797b87e..6d81a680 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -23,7 +23,8 @@ def ask_user_questions(): # Set which region to download packages from during the installation if not archinstall.arguments.get('mirror-region', None): - archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) + while archinstall.arguments.get("mirror-region",{}) == {}: + archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) else: selected_region = archinstall.arguments['mirror-region'] archinstall.arguments['mirror-region'] = {selected_region : archinstall.list_mirrors()[selected_region]} @@ -184,13 +185,16 @@ def ask_user_questions(): archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)] if len(archinstall.arguments['packages']): - # Verify packages that were given - try: - archinstall.log(f"Verifying that additional packages exist (this might take a few seconds)") - archinstall.validate_package_list(archinstall.arguments['packages']) - except archinstall.RequirementError as e: - archinstall.log(e, fg='red') - exit(1) + invalid_packages = True + while invalid_packages == True: + # Verify packages that were given + try: + archinstall.log(f"Verifying that additional packages exist (this might take a few seconds)") + archinstall.validate_package_list(archinstall.arguments['packages']) + invalid_packages = False + except archinstall.RequirementError as e: + archinstall.log(e, fg='red') + invalid_packages = True # Ask or Call the helper function that asks the user to optionally configure a network. if not archinstall.arguments.get('nic', None): @@ -284,7 +288,8 @@ def perform_installation(mountpoint): archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium if installation.minimal_installation(): installation.set_hostname(archinstall.arguments['hostname']) - installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium + if archinstall.arguments['mirror-region'] != None: + installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium installation.set_keyboard_language(archinstall.arguments['keyboard-language']) installation.add_bootloader() -- cgit v1.2.3-54-g00ecf From 85bcc589510db63412f11afdf7cae54e9bedd772 Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 14 Apr 2021 14:16:11 +0530 Subject: missed a merge --- examples/guided.py | 8 -------- 1 file changed, 8 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index e45868ef..1af57fd6 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -291,16 +291,8 @@ def perform_installation(mountpoint): if installation.minimal_installation(): installation.set_hostname(archinstall.arguments['hostname']) -<<<<<<< HEAD if archinstall.arguments['mirror-region'] != None: installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium -======= - - # Configure the selected mirrors in the installation - if archinstall.arguments.get('mirror-region', None): - installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium - ->>>>>>> af2671c1ec1ac2ecbdbd35c90c3e5016dcf516ed installation.set_keyboard_language(archinstall.arguments['keyboard-language']) installation.add_bootloader() -- cgit v1.2.3-54-g00ecf From 78a9f0077e570e2f6ca4afed7f7153510522b10e Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 14 Apr 2021 14:21:53 +0530 Subject: fixed line 249 --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 1af57fd6..6b8a36df 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -291,7 +291,7 @@ def perform_installation(mountpoint): if installation.minimal_installation(): installation.set_hostname(archinstall.arguments['hostname']) - if archinstall.arguments['mirror-region'] != None: + if archinstall.arguments['mirror-region'].get("mirror",None)!= None: installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium installation.set_keyboard_language(archinstall.arguments['keyboard-language']) installation.add_bootloader() -- cgit v1.2.3-54-g00ecf From b08b2f3062eae00e8ac4eab613d4edec07b324ad Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 14 Apr 2021 14:29:46 +0530 Subject: another patch for line 249 --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 6b8a36df..53dc1f09 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -291,7 +291,7 @@ def perform_installation(mountpoint): if installation.minimal_installation(): installation.set_hostname(archinstall.arguments['hostname']) - if archinstall.arguments['mirror-region'].get("mirror",None)!= None: + if archinstall.arguments['mirror-region'].get("mirrors",{})!= None: installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium installation.set_keyboard_language(archinstall.arguments['keyboard-language']) installation.add_bootloader() -- cgit v1.2.3-54-g00ecf From c13c109bfff31d2035cad103c16fc74ebdbd4abf Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 14 Apr 2021 11:16:31 +0200 Subject: Removed a \t --- examples/guided.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 53dc1f09..e0644540 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -309,7 +309,7 @@ def perform_installation(mountpoint): installation.enable_service('systemd-networkd') installation.enable_service('systemd-resolved') - if archinstall.arguments.get('audio', None) != None: + if archinstall.arguments.get('audio', None) != None: installation.log(f"This audio server will be used: {archinstall.arguments.get('audio', None)}", level=archinstall.LOG_LEVELS.Info) if archinstall.arguments.get('audio', None) == 'pipewire': print('Installing pipewire ...') -- cgit v1.2.3-54-g00ecf From df3f7af91b28c3df75e9be8f2a961a408f3e5dbb Mon Sep 17 00:00:00 2001 From: advaithm Date: Wed, 14 Apr 2021 14:47:57 +0530 Subject: reworked mirror selection --- examples/guided.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 53dc1f09..8be47b82 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,3 +1,4 @@ +from archinstall.lib.exceptions import RequirementError import getpass, time, json, os import archinstall from archinstall.lib.hardware import hasUEFI @@ -23,8 +24,12 @@ def ask_user_questions(): # Set which region to download packages from during the installation if not archinstall.arguments.get('mirror-region', None): - while archinstall.arguments.get("mirror-region",{}) == {}: - archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) + valid_mirror = False + while valid_mirror == False: + try: + archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) + except RequirementError as e: + archinstall.log(e, fg="yellow") else: selected_region = archinstall.arguments['mirror-region'] archinstall.arguments['mirror-region'] = {selected_region : archinstall.list_mirrors()[selected_region]} -- cgit v1.2.3-54-g00ecf From 7ae4b170b38b98d71dc9825c11cff2afb8644d21 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 14 Apr 2021 11:53:31 +0200 Subject: Removed excessive import The exceptions are already exposed in `archinstall.`. This might change in the future tho. --- examples/guided.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 37d15b25..7ba787f4 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -1,4 +1,3 @@ -from archinstall.lib.exceptions import RequirementError import getpass, time, json, os import archinstall from archinstall.lib.hardware import hasUEFI @@ -28,7 +27,7 @@ def ask_user_questions(): while valid_mirror == False: try: archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) - except RequirementError as e: + except archinstall.RequirementError as e: archinstall.log(e, fg="yellow") else: selected_region = archinstall.arguments['mirror-region'] -- cgit v1.2.3-54-g00ecf From 99fb1304ea4bcf2744b06abdd4b747b686aaeef4 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 14 Apr 2021 12:06:15 +0200 Subject: Updated the loop logic for packages It wouldn't loop over the question again, so correct for that. --- examples/guided.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 7ba787f4..fc7ddeb6 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -183,22 +183,24 @@ def ask_user_questions(): archinstall.arguments['audio'] = None # Additional packages (with some light weight error handling for invalid package names) - if not archinstall.arguments.get('packages', None): - print("Packages not part of the desktop environment are not installed by default.") - print("If you desire a web browser, such as firefox or chromium, you may specify it in the following prompt.") - archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)] - - if len(archinstall.arguments['packages']): - invalid_packages = True - while invalid_packages == True: + while True: + if not archinstall.arguments.get('packages', None): + print("Only packages such as base, base-devel, linux, linux-firmware, efibootmgr and optional profile packages are installed.") + print("If you desire a web browser, such as firefox or chromium, you may specify it in the following prompt.") + archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)] + + if len(archinstall.arguments['packages']): # Verify packages that were given try: archinstall.log(f"Verifying that additional packages exist (this might take a few seconds)") archinstall.validate_package_list(archinstall.arguments['packages']) - invalid_packages = False + break except archinstall.RequirementError as e: archinstall.log(e, fg='red') - invalid_packages = True + archinstall.arguments['packages'] = None # Clear the packages to trigger a new input question + else: + # no additional packages were selected, which we'll allow + break # Ask or Call the helper function that asks the user to optionally configure a network. if not archinstall.arguments.get('nic', None): -- cgit v1.2.3-54-g00ecf From 5b3a1221414a60676eb8622d033a6fadc1661411 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 14 Apr 2021 12:08:37 +0200 Subject: Updated the loop logic for mirrors It wouldn't break out of the loop since the `valid_mirror` variable was never changed. --- examples/guided.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index fc7ddeb6..8a16f561 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -23,12 +23,12 @@ def ask_user_questions(): # Set which region to download packages from during the installation if not archinstall.arguments.get('mirror-region', None): - valid_mirror = False - while valid_mirror == False: + while True: try: archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) + break except archinstall.RequirementError as e: - archinstall.log(e, fg="yellow") + archinstall.log(e, fg="red") else: selected_region = archinstall.arguments['mirror-region'] archinstall.arguments['mirror-region'] = {selected_region : archinstall.list_mirrors()[selected_region]} -- cgit v1.2.3-54-g00ecf From 1aadfa98c4b4073dc4ad204297739c995213afae Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 14 Apr 2021 12:46:18 +0200 Subject: Added a safety net to language selection --- examples/guided.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 8a16f561..c0d22023 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -14,7 +14,12 @@ def ask_user_questions(): will we continue with the actual installation steps. """ if not archinstall.arguments.get('keyboard-language', None): - archinstall.arguments['keyboard-language'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip() + while True: + try: + archinstall.arguments['keyboard-language'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip() + break + except archinstall.RequirementError as err: + archinstall.log(err, fg="red") # Before continuing, set the preferred keyboard layout/language in the current terminal. # This will just help the user with the next following questions. -- cgit v1.2.3-54-g00ecf From 80a3ca3826d15a8742c60e2a13d6def09768057a Mon Sep 17 00:00:00 2001 From: Malccolm Haak Date: Sat, 17 Apr 2021 14:23:39 +1000 Subject: In guided install Non-UEFI installs need to use grub-install as its the only supported bootloader that doesn't require UEFI --- examples/guided.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 81cc2991..dfc2da07 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -257,12 +257,12 @@ def perform_installation_steps(): # Wipe the entire drive if the disk flag `keep_partitions`is False. if archinstall.arguments['harddrive'].keep_partitions is False: fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get('filesystem', 'btrfs')) - + # Check if encryption is desired and mark the root partition as encrypted. if archinstall.arguments.get('!encryption-password', None): root_partition = fs.find_partition('/') root_partition.encrypted = True - + # After the disk is ready, iterate the partitions and check # which ones are safe to format, and format those. for partition in archinstall.arguments['harddrive']: @@ -314,7 +314,11 @@ def perform_installation(device, boot_partition, language, mirrors): if installation.minimal_installation(): installation.set_mirrors(mirrors) # Set the mirrors in the installation medium installation.set_keyboard_language(language) - installation.add_bootloader() + if hasUEFI(): + installation.add_bootloader() + else: + installation.add_bootloader(bootloder='grub-install') + # If user selected to copy the current ISO network configuration # Perform a copy of the config @@ -338,7 +342,7 @@ def perform_installation(device, boot_partition, language, mirrors): for user, user_info in archinstall.arguments.get('users', {}).items(): installation.user_create(user, user_info["!password"], sudo=False) - + for superuser, user_info in archinstall.arguments.get('superusers', {}).items(): installation.user_create(superuser, user_info["!password"], sudo=True) @@ -359,4 +363,4 @@ def perform_installation(device, boot_partition, language, mirrors): ask_user_questions() perform_installation_steps() - + -- cgit v1.2.3-54-g00ecf From 77894df51c581d26c958f07524e576d3bc118efd Mon Sep 17 00:00:00 2001 From: Malccolm Haak Date: Sat, 17 Apr 2021 14:37:14 +1000 Subject: Whitespace needs to be tabs. Added test for UEFI, if not found add grub-install to pacstrap install --- archinstall/lib/installer.py | 20 +++++++++++--------- examples/guided.py | 8 ++++---- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'examples') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index a99bc944..70ff86f2 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -22,7 +22,7 @@ class Installer(): :param partition: Requires a partition as the first argument, this is so that the installer can mount to `mountpoint` and strap packages there. :type partition: class:`archinstall.Partition` - + :param boot_partition: There's two reasons for needing a boot partition argument, The first being so that `mkinitcpio` can place the `vmlinuz` kernel at the right place during the `pacstrap` or `linux` and the base packages for a minimal installation. @@ -33,7 +33,7 @@ class Installer(): :param profile: A profile to install, this is optional and can be called later manually. This just simplifies the process by not having to call :py:func:`~archinstall.Installer.install_profile` later on. :type profile: str, optional - + :param hostname: The given /etc/hostname for the machine. :type hostname: str, optional @@ -118,7 +118,7 @@ class Installer(): if not os.path.isdir(f"{self.mountpoint}/{os.path.dirname(absolute_logfile)}"): os.makedirs(f"{self.mountpoint}/{os.path.dirname(absolute_logfile)}") - + shutil.copy2(absolute_logfile, f"{self.mountpoint}/{absolute_logfile}") return True @@ -126,7 +126,7 @@ class Installer(): 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}') - + partition.mount(f'{self.mountpoint}{mountpoint}') def post_install_check(self, *args, **kwargs): @@ -149,14 +149,14 @@ class Installer(): def genfstab(self, flags='-pU'): 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: 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}') - + return True def set_hostname(self, hostname=None, *args, **kwargs): @@ -219,7 +219,7 @@ class Installer(): network["DNS"] = dns conf = Networkd(Match={"Name": nic}, Network=network) - + with open(f"{self.mountpoint}/etc/systemd/network/10-{nic}.network", "a") as netconf: netconf.write(str(conf)) @@ -234,7 +234,7 @@ class Installer(): # If we haven't installed the base yet (function called pre-maturely) if self.helper_flags.get('base', False) is False: self.base_packages.append('iwd') - # This function will be called after minimal_installation() + # This function will be called after minimal_installation() # as a hook for post-installs. This hook is only needed if # base is not installed yet. def post_install_enable_iwd_service(*args, **kwargs): @@ -285,6 +285,8 @@ class Installer(): self.base_packages.append('xfsprogs') if self.partition.filesystem == 'f2fs': self.base_packages.append('f2fs-tools') + if not(hasUEFI()): + self.base_packages.append('grub-install') self.pacstrap(self.base_packages) self.helper_flags['base-strapped'] = True #self.genfstab() @@ -353,7 +355,7 @@ class Installer(): f"default {self.init_time}", f"timeout 5" ] - + with open(f'{self.mountpoint}/boot/loader/loader.conf', 'w') as loader: for line in loader_data: if line[:8] == 'default ': diff --git a/examples/guided.py b/examples/guided.py index dfc2da07..38d5d653 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -314,10 +314,10 @@ def perform_installation(device, boot_partition, language, mirrors): if installation.minimal_installation(): installation.set_mirrors(mirrors) # Set the mirrors in the installation medium installation.set_keyboard_language(language) - if hasUEFI(): - installation.add_bootloader() - else: - installation.add_bootloader(bootloder='grub-install') + if hasUEFI(): + installation.add_bootloader() + else: + installation.add_bootloader(bootloder='grub-install') # If user selected to copy the current ISO network configuration -- cgit v1.2.3-54-g00ecf