Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorВладислав <awayfromgalaxy@gmail.com>2021-04-27 15:18:02 +0300
committerGitHub <noreply@github.com>2021-04-27 15:18:02 +0300
commit0c6ebc7e809cabcd2aacf3e13daf5327142f3b31 (patch)
treee4ff0e9cdd04b70f83eed822fcdec067f5b2094f /examples
parent985b7fac3ff400de9954d441480ab795222f4b24 (diff)
parentae1c4ea7c2a1d56b23c843a2318c1400ebebb1af (diff)
Merge branch 'master' into misc-cleanup
Diffstat (limited to 'examples')
-rw-r--r--examples/guided.py55
1 files changed, 39 insertions, 16 deletions
diff --git a/examples/guided.py b/examples/guided.py
index cc9cf5fc..6b9cfd24 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -2,10 +2,11 @@ import getpass, time, json, os
import archinstall
from archinstall.lib.hardware import hasUEFI
from archinstall.lib.profiles import Profile
+from archinstall.lib.user_interaction import generic_select
-if hasUEFI() is False:
- 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)
+if archinstall.arguments.get('help'):
+ print("See `man archinstall` for help.")
+ exit(0)
def ask_user_questions():
"""
@@ -64,6 +65,7 @@ def ask_user_questions():
partition_mountpoints[partition] = None
except archinstall.UnknownFilesystemFormat as err:
archinstall.log(f" {partition} (Filesystem not supported)", fg='red')
+
# We then ask what to do with the partitions.
if (option := archinstall.ask_for_disk_layout()) == 'abort':
@@ -148,7 +150,7 @@ def ask_user_questions():
if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')):
archinstall.arguments['!encryption-password'] = passwd
archinstall.arguments['harddrive'].encryption_password = archinstall.arguments['!encryption-password']
-
+ archinstall.arguments["bootloader"] = archinstall.ask_for_bootloader()
# Get the hostname for the machine
if not archinstall.arguments.get('hostname', None):
archinstall.arguments['hostname'] = input('Desired hostname for the installation: ').strip(' ')
@@ -185,7 +187,6 @@ def ask_user_questions():
# Ask about audio server selection if one is not already set
if not archinstall.arguments.get('audio', None):
-
# 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()
@@ -194,6 +195,15 @@ def ask_user_questions():
# we will not try to remove packages post-installation to not have audio, as that may cause multiple issues
archinstall.arguments['audio'] = None
+ # Ask what kernel user wants:
+ if not archinstall.arguments.get("kernels", None):
+ archinstall.log(f"Here you can choose which kernel to use, leave blank for default which is 'linux'.")
+
+ if (kernel := generic_select(["linux", "linux-lts", "linux-zen", "continue"], "choose a kernel:")):
+ archinstall.arguments['kernels'] = kernel
+ else:
+ archinstall.arguments['kernels'] = 'linux'
+
# Additional packages (with some light weight error handling for invalid package names)
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.")
@@ -246,7 +256,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'))
@@ -269,8 +283,8 @@ def perform_installation_steps():
partition.format()
else:
archinstall.log(f"Did not format {partition} because .safe_to_format() returned False or .allow_formatting was False.", level=archinstall.LOG_LEVELS.Debug)
-
- fs.find_partition('/boot').format('vfat')
+ if hasUEFI():
+ fs.find_partition('/boot').format('vfat')# we don't have a boot partition in bios mode
if archinstall.arguments.get('!encryption-password', None):
# First encrypt and unlock, then format the desired partition inside the encrypted part.
@@ -282,8 +296,8 @@ def perform_installation_steps():
else:
fs.find_partition('/').format(fs.find_partition('/').filesystem)
fs.find_partition('/').mount('/mnt')
-
- fs.find_partition('/boot').mount('/mnt/boot')
+ if hasUEFI():
+ fs.find_partition('/boot').mount('/mnt/boot')
perform_installation('/mnt')
@@ -294,7 +308,7 @@ def perform_installation(mountpoint):
Only requirement is that the block devices are
formatted and setup prior to entering this function.
"""
- with archinstall.Installer(mountpoint) as installation:
+ with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', 'linux')) as installation:
## if len(mirrors):
# Certain services might be running that affects the system during installation.
# Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist
@@ -302,17 +316,17 @@ def perform_installation(mountpoint):
installation.log(f'Waiting for automatic mirror selection (reflector) to complete.', level=archinstall.LOG_LEVELS.Info)
while archinstall.service_state('reflector') not in ('dead', 'failed'):
time.sleep(1)
-
# Set mirrors used by pacstrap (outside of installation)
if archinstall.arguments.get('mirror-region', None):
archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium
-
if installation.minimal_installation():
installation.set_hostname(archinstall.arguments['hostname'])
if archinstall.arguments['mirror-region'].get("mirrors",{})!= None:
installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
+ if archinstall.arguments["bootloader"]=="grub-install" and hasUEFI()==True:
+ installation.add_additional_packages("grub")
installation.set_keyboard_language(archinstall.arguments['keyboard-language'])
- installation.add_bootloader()
+ installation.add_bootloader(archinstall.arguments["bootloader"])
# If user selected to copy the current ISO network configuration
# Perform a copy of the config
@@ -331,6 +345,7 @@ def perform_installation(mountpoint):
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 ...')
@@ -346,7 +361,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)
@@ -356,6 +371,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", ""):
@@ -366,4 +390,3 @@ def perform_installation(mountpoint):
ask_user_questions()
perform_installation_steps()
-