Merged in master

This commit is contained in:
Anton Hvornum 2021-06-14 16:05:19 +02:00
commit 00b1dfde6d
6 changed files with 65 additions and 58 deletions

View File

@ -149,7 +149,7 @@ After this, running archinstall with `python -m archinstall` will run against wh
To test this without a live ISO, the simplest approach is to use a local image and create a loop device.<br> To test this without a live ISO, the simplest approach is to use a local image and create a loop device.<br>
This can be done by installing `pacman -S arch-install-scripts util-linux` locally and doing the following: This can be done by installing `pacman -S arch-install-scripts util-linux` locally and doing the following:
# dd if=/dev/zero of=./testimage.img bs=1G count=5 # truncate -s 20G testimage.img
# losetup -fP ./testimage.img # losetup -fP ./testimage.img
# losetup -a | grep "testimage.img" | awk -F ":" '{print $1}' # losetup -a | grep "testimage.img" | awk -F ":" '{print $1}'
# pip install --upgrade archinstall # pip install --upgrade archinstall

View File

@ -29,6 +29,7 @@ def list_interfaces(skip_loopback=True):
def check_mirror_reachable(): def check_mirror_reachable():
log("Testing connectivity to the Arch Linux mirrors ...", level=logging.INFO)
if (exit_code := SysCommand("pacman -Sy").exit_code) == 0: if (exit_code := SysCommand("pacman -Sy").exit_code) == 0:
return True return True
elif os.geteuid() != 0: elif os.geteuid() != 0:

View File

@ -23,6 +23,23 @@ def grab_url_data(path):
return response.read() return response.read()
def is_desktop_profile(profile) -> bool:
if str(profile) == 'Profile(desktop)':
return True
desktop_profile = Profile(None, "desktop")
with open(desktop_profile.path, 'r') as source:
source_data = source.read()
if '__name__' in source_data and '__supported__' in source_data:
with desktop_profile.load_instructions(namespace=f"{desktop_profile.namespace}.py") as imported:
if hasattr(imported, '__supported__'):
desktop_profiles = imported.__supported__
return str(profile) in [f"Profile({s})" for s in desktop_profiles]
return False
def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_profiles=False): def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_profiles=False):
# TODO: Grab from github page as well, not just local static files # TODO: Grab from github page as well, not just local static files
if filter_irrelevant_macs: if filter_irrelevant_macs:

View File

@ -12,11 +12,12 @@ import time
from .disk import BlockDevice, valid_fs_type, find_partition_by_mountpoint, suggest_single_disk_layout, suggest_multi_disk_layout from .disk import BlockDevice, valid_fs_type, find_partition_by_mountpoint, suggest_single_disk_layout, suggest_multi_disk_layout
from .exceptions import * from .exceptions import *
from .general import SysCommand from .general import SysCommand
from .hardware import AVAILABLE_GFX_DRIVERS, has_uefi from .hardware import AVAILABLE_GFX_DRIVERS, has_uefi, has_amd_graphics, has_intel_graphics, has_nvidia_graphics
from .locale_helpers import list_keyboard_languages, verify_keyboard_layout, search_keyboard_layout from .locale_helpers import list_keyboard_languages, verify_keyboard_layout, search_keyboard_layout
from .networking import list_interfaces from .networking import list_interfaces
from .output import log from .output import log
from .profiles import Profile, list_profiles from .profiles import Profile, list_profiles
from .storage import *
# TODO: Some inconsistencies between the selection processes. # TODO: Some inconsistencies between the selection processes.
# Some return the keys from the options, some the values? # Some return the keys from the options, some the values?
@ -389,11 +390,12 @@ def ask_for_bootloader() -> str:
return bootloader return bootloader
def ask_for_audio_selection(): def ask_for_audio_selection(desktop=True):
audio = "pulseaudio" # Default for most desktop environments audio = 'pipewire' if desktop else 'none'
pipewire_choice = input("Would you like to install pipewire instead of pulseaudio as the default audio server? [Y/n] ").lower() choices = ['pipewire', 'pulseaudio'] if desktop else ['pipewire', 'pulseaudio', 'none']
if pipewire_choice in ("y", ""): selection = generic_select(choices, f'Choose an audio server or leave blank to use {audio}: ', options_output=True)
audio = "pipewire" if selection != "":
audio = selection
return audio return audio
@ -893,32 +895,22 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS):
""" """
drivers = sorted(list(options)) drivers = sorted(list(options))
default_option = options["All open-source (default)"]
if drivers: if drivers:
for line in SysCommand('/usr/bin/lspci'): arguments = storage.get('arguments', {})
if b' vga ' in line.lower(): if has_amd_graphics():
if b'nvidia' in line.lower(): print('For the best compatibility with your AMD hardware, you may want to use either the all open-source or AMD / ATI options.')
print(' ** nvidia card detected, suggested driver: nvidia **') if has_intel_graphics():
elif b'amd' in line.lower(): print('For the best compatibility with your Intel hardware, you may want to use either the all open-source or Intel options.')
print(' ** AMD card detected, suggested driver: AMD / ATI **') if has_nvidia_graphics():
print('For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.')
initial_option = generic_select(drivers, input_text="Select your graphics card driver: ") arguments['gfx_driver'] = generic_select(drivers, input_text="Select your graphics card driver: ")
if not initial_option: if arguments.get('gfx_driver', None) is None:
return default_option arguments['gfx_driver'] = "All open-source (default)"
selected_driver = options[initial_option] return options.get(arguments.get('gfx_driver'))
if type(selected_driver) == dict:
driver_options = sorted(list(selected_driver))
driver_package_group = generic_select(driver_options, f'Which driver-type do you want for {initial_option}: ', allow_empty_input=False)
driver_package_group = selected_driver[driver_package_group]
return driver_package_group
return selected_driver
raise RequirementError("Selecting drivers require a least one profile to be given as an option.") raise RequirementError("Selecting drivers require a least one profile to be given as an option.")

View File

@ -7,7 +7,7 @@ import archinstall
from archinstall.lib.general import run_custom_user_commands from archinstall.lib.general import run_custom_user_commands
from archinstall.lib.hardware import * from archinstall.lib.hardware import *
from archinstall.lib.networking import check_mirror_reachable from archinstall.lib.networking import check_mirror_reachable
from archinstall.lib.profiles import Profile from archinstall.lib.profiles import Profile, is_desktop_profile
if archinstall.arguments.get('help'): if archinstall.arguments.get('help'):
print("See `man archinstall` for help.") print("See `man archinstall` for help.")
@ -136,13 +136,8 @@ def ask_user_questions():
# Ask about audio server selection if one is not already set # Ask about audio server selection if one is not already set
if not archinstall.arguments.get('audio', None): if not archinstall.arguments.get('audio', None):
# only ask for audio server selection on a desktop profile # The argument to ask_for_audio_selection lets the library know if it's a desktop profile
if str(archinstall.arguments['profile']) == 'Profile(desktop)': archinstall.arguments['audio'] = archinstall.ask_for_audio_selection(is_desktop_profile(archinstall.arguments['profile']))
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
# Ask for preferred kernel: # Ask for preferred kernel:
@ -196,10 +191,10 @@ def perform_filesystem_operations():
with open("/var/log/archinstall/user_configuration.json", "w") as config_file: with open("/var/log/archinstall/user_configuration.json", "w") as config_file:
config_file.write(user_configuration) config_file.write(user_configuration)
print() print()
if archinstall.arguments.get('dry_run'): if archinstall.arguments.get('dry_run'):
exit(0) exit(0)
if not archinstall.arguments.get('silent'): if not archinstall.arguments.get('silent'):
input('Press Enter to continue.') input('Press Enter to continue.')
@ -340,7 +335,7 @@ if not check_mirror_reachable():
archinstall.log(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.", level=logging.INFO, fg="red") archinstall.log(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.", level=logging.INFO, fg="red")
exit(1) exit(1)
if archinstall.arguments.get('silent', None) is None: if not archinstall.arguments.get('silent'):
ask_user_questions() ask_user_questions()
else: else:
# Workarounds if config is loaded from a file # Workarounds if config is loaded from a file

View File

@ -21,6 +21,21 @@ __packages__ = [
'xdg-utils', 'xdg-utils',
] ]
__supported__ = [
'gnome',
'kde',
'awesome',
'sway',
'cinnamon',
'xfce4',
'lxqt',
'i3',
'budgie',
'mate',
'deepin',
'enlightenment',
]
def _prep_function(*args, **kwargs): def _prep_function(*args, **kwargs):
""" """
@ -30,22 +45,7 @@ def _prep_function(*args, **kwargs):
for more input before any other installer steps start. for more input before any other installer steps start.
""" """
supported_desktops = [ desktop = archinstall.generic_select(__supported__, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True)
'gnome',
'kde',
'awesome',
'sway',
'cinnamon',
'xfce4',
'lxqt',
'i3',
'budgie',
'mate',
'deepin',
'enlightenment',
]
desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ', allow_empty_input=False, sort=True)
# Temporarily store the selected desktop profile # Temporarily store the selected desktop profile
# in a session-safe location, since this module will get reloaded # in a session-safe location, since this module will get reloaded
@ -54,6 +54,8 @@ def _prep_function(*args, **kwargs):
archinstall.storage['_desktop_profile'] = desktop archinstall.storage['_desktop_profile'] = desktop
profile = archinstall.Profile(None, desktop) profile = archinstall.Profile(None, desktop)
# Set the resolved profile path to the actual desktop environment
archinstall.arguments['profile'] = profile
# Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered.
with profile.load_instructions(namespace=f"{desktop}.py") as imported: with profile.load_instructions(namespace=f"{desktop}.py") as imported:
if hasattr(imported, '_prep_function'): if hasattr(imported, '_prep_function'):