index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Aggam Rahamim <agamclass@gmail.com> | 2021-04-25 14:56:03 +0300 |
---|---|---|
committer | Aggam Rahamim <agamclass@gmail.com> | 2021-04-25 14:56:03 +0300 |
commit | e25018131756757999bbe8ba8e54ec3ae8224c7d (patch) | |
tree | 828fb3ad3882d4dfac3e522c52a16369c6042990 /examples | |
parent | 5c9859d316b8064949370c03745cfd99e0d67670 (diff) | |
parent | 4db40c06eb37390eaa19b6d8b0afa7b21c5e65b3 (diff) |
-rw-r--r-- | examples/guided.py | 79 |
diff --git a/examples/guided.py b/examples/guided.py index ee7b63d9..ddc4d06f 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -4,9 +4,9 @@ from archinstall.lib.hardware import hasUEFI from archinstall.lib.profiles import Profile from archinstall.lib.user_interaction import generic_select -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) - exit(1) +if archinstall.arguments.get('help'): + print("See `man archinstall` for help.") + exit(0) def ask_user_questions(): """ @@ -15,7 +15,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. @@ -24,7 +29,12 @@ 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 True: + try: + archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) + break + except archinstall.RequirementError as e: + archinstall.log(e, fg="red") else: selected_region = archinstall.arguments['mirror-region'] archinstall.arguments['mirror-region'] = {selected_region : archinstall.list_mirrors()[selected_region]} @@ -190,19 +200,24 @@ def ask_user_questions(): # 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']): - # 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) + 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']) + break + except archinstall.RequirementError as e: + archinstall.log(e, fg='red') + 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): @@ -236,7 +251,11 @@ 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: + mode = archinstall.GPT + if hasUEFI() is False: + 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')) @@ -299,11 +318,8 @@ def perform_installation(mountpoint): if installation.minimal_installation(): installation.set_hostname(archinstall.arguments['hostname']) - - # Configure the selected mirrors in the installation - if archinstall.arguments.get('mirror-region', 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() @@ -320,10 +336,11 @@ 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 ...') + installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"]) elif archinstall.arguments.get('audio', None) == 'pulseaudio': print('Installing pulseaudio ...') @@ -339,7 +356,7 @@ def perform_installation(mountpoint): 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) @@ -349,6 +366,15 @@ def perform_installation(mountpoint): if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw): installation.user_set_pw('root', root_pw) + 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 post configuration requirements was not fulfilled.', + fg='red' + ) + exit(1) + 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", ""): @@ -358,5 +384,4 @@ def perform_installation(mountpoint): pass ask_user_questions() -perform_installation_steps() - +perform_installation_steps()
\ No newline at end of file |