Merge branch 'master' of https://github.com/archlinux/archinstall into torxed-fix-93

This commit is contained in:
Anton Hvornum 2021-10-30 20:36:21 +02:00
commit 2a2239dd03
12 changed files with 47 additions and 38 deletions

View File

@ -1,8 +1,7 @@
# Contributing to archinstall # Contributing to archinstall
Any contributions through pull requests are welcome as this project aims to be a community based project to ease some Arch Linux installation steps. Any contributions through pull requests are welcome as this project aims to be a community based project to ease some Arch Linux installation steps.
Bear in mind that in the future this repo might be transferred to the official [GitLab repo under Arch Linux](http://gitlab.archlinux.org/archlinux/) Bear in mind that in the future this repo might be transferred to the official [GitLab repo under Arch Linux](http://gitlab.archlinux.org/archlinux/) *(if GitLab becomes open to the general public)*.
*(if GitLab becomes open to the general public)*.
Therefore, guidelines and style changes to the code might come into effect as well as guidelines surrounding bug reporting and discussions. Therefore, guidelines and style changes to the code might come into effect as well as guidelines surrounding bug reporting and discussions.

View File

@ -106,7 +106,6 @@ with archinstall.Installer('/mnt') as installation:
installation.user_create('devel', 'devel') installation.user_create('devel', 'devel')
installation.user_set_pw('root', 'airoot') installation.user_set_pw('root', 'airoot')
``` ```
This installer will perform the following: This installer will perform the following:

View File

@ -1,4 +1,5 @@
import os import os
from functools import partial
from pathlib import Path from pathlib import Path
from typing import Iterator, Optional, Union from typing import Iterator, Optional, Union
@ -75,12 +76,10 @@ def cpuinfo() -> Iterator[dict[str, str]]:
cpu[key.strip()] = value.strip() cpu[key.strip()] = value.strip()
def meminfo(key: Optional[str] = None) -> Union[dict[str, int], int]: def meminfo(key: Optional[str] = None) -> Union[dict[str, int], Optional[int]]:
"""Returns a dict with memory info if called with no args """Returns a dict with memory info if called with no args
or the value of the given key of said dict. or the value of the given key of said dict.
""" """
mem_info = {}
with MEMINFO.open() as file: with MEMINFO.open() as file:
mem_info = { mem_info = {
(columns := line.strip().split())[0].rstrip(':'): int(columns[1]) (columns := line.strip().split())[0].rstrip(':'): int(columns[1])
@ -97,11 +96,11 @@ def has_wifi() -> bool:
return 'WIRELESS' in enrich_iface_types(list_interfaces().values()).values() return 'WIRELESS' in enrich_iface_types(list_interfaces().values()).values()
def has_amd_cpu() -> bool: def has_cpu_vendor(vendor_id: str) -> bool:
return any(cpu.get("vendor_id") == "AuthenticAMD" for cpu in cpuinfo()) return any(cpu.get("vendor_id") == vendor_id for cpu in cpuinfo())
def has_intel_cpu() -> bool: has_amd_cpu = partial(has_cpu_vendor, "AuthenticAMD")
return any(cpu.get("vendor_id") == "GenuineIntel" for cpu in cpuinfo()) has_intel_cpu = partial(has_cpu_vendor, "GenuineIntel")
def has_uefi() -> bool: def has_uefi() -> bool:
return os.path.isdir('/sys/firmware/efi') return os.path.isdir('/sys/firmware/efi')
@ -152,15 +151,15 @@ def product_name() -> Optional[str]:
return product.read().strip() return product.read().strip()
def mem_available() -> Optional[str]: def mem_available() -> Optional[int]:
return meminfo('MemAvailable') return meminfo('MemAvailable')
def mem_free() -> Optional[str]: def mem_free() -> Optional[int]:
return meminfo('MemFree') return meminfo('MemFree')
def mem_total() -> Optional[str]: def mem_total() -> Optional[int]:
return meminfo('MemTotal') return meminfo('MemTotal')

View File

@ -1,6 +1,6 @@
import urllib.error import urllib.error
import urllib.request import urllib.request
from typing import Union from typing import Union, Mapping, Iterable
from .general import * from .general import *
from .output import log from .output import log
@ -113,22 +113,31 @@ def insert_mirrors(mirrors, *args, **kwargs):
return True return True
def use_mirrors(regions: dict, destination='/etc/pacman.d/mirrorlist'): def use_mirrors(
regions: Mapping[str, Iterable[str]],
destination: str ='/etc/pacman.d/mirrorlist'
) -> None:
log(f'A new package mirror-list has been created: {destination}', level=logging.INFO) log(f'A new package mirror-list has been created: {destination}', level=logging.INFO)
for region, mirrors in regions.items(): with open(destination, 'w') as mirrorlist:
with open(destination, 'w') as mirrorlist: for region, mirrors in regions.items():
for mirror in mirrors: for mirror in mirrors:
mirrorlist.write(f'## {region}\n') mirrorlist.write(f'## {region}\n')
mirrorlist.write(f'Server = {mirror}\n') mirrorlist.write(f'Server = {mirror}\n')
def re_rank_mirrors(
top: int = 10,
src: str = '/etc/pacman.d/mirrorlist',
dst: str = '/etc/pacman.d/mirrorlist',
) -> bool:
cmd = SysCommand(f"/usr/bin/rankmirrors -n {top} {src}")
if cmd.exit_code != 0:
return False
with open(dst, 'w') as f:
f.write(str(cmd))
return True return True
def re_rank_mirrors(top=10, *positionals, **kwargs):
if SysCommand(f'/usr/bin/rankmirrors -n {top} /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist').exit_code == 0:
return True
return False
def list_mirrors(sort_order=["https", "http"]): def list_mirrors(sort_order=["https", "http"]):
url = "https://archlinux.org/mirrorlist/?protocol=https&protocol=http&ip_version=4&ip_version=6&use_mirror_status=on" url = "https://archlinux.org/mirrorlist/?protocol=https&protocol=http&ip_version=4&ip_version=6&use_mirror_status=on"
regions = {} regions = {}

View File

@ -98,4 +98,4 @@ def load_plugin(path :str): # -> module (not sure how to write that in type defi
log(err, level=logging.ERROR) log(err, level=logging.ERROR)
log(f"The above error was detected when initiating the plugin: {path}", fg="red", level=logging.ERROR) log(f"The above error was detected when initiating the plugin: {path}", fg="red", level=logging.ERROR)
else: else:
log(f"Plugin '{path}' is missing a valid entry-point or is corrupt.", fg="yellow", level=logging.WARNING) log(f"Plugin '{path}' is missing a valid entry-point or is corrupt.", fg="yellow", level=logging.WARNING)

View File

@ -64,6 +64,7 @@ class Boot:
self.session = SysCommandWorker([ self.session = SysCommandWorker([
'/usr/bin/systemd-nspawn', '/usr/bin/systemd-nspawn',
'-D', self.instance.target, '-D', self.instance.target,
'--timezone=off',
'-b', '-b',
'--machine', self.container_name '--machine', self.container_name
]) ])

View File

@ -575,14 +575,14 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
# log(f"Selecting which partitions to re-use on {block_device}...", fg="yellow", level=logging.INFO) # log(f"Selecting which partitions to re-use on {block_device}...", fg="yellow", level=logging.INFO)
# partitions = generic_multi_select(block_device.partitions.values(), "Select which partitions to re-use (the rest will be left alone): ", sort=True) # partitions = generic_multi_select(block_device.partitions.values(), "Select which partitions to re-use (the rest will be left alone): ", sort=True)
# partitions_to_wipe = generic_multi_select(partitions, "Which partitions do you wish to wipe (multiple can be selected): ", sort=True) # partitions_to_wipe = generic_multi_select(partitions, "Which partitions do you wish to wipe (multiple can be selected): ", sort=True)
# mountpoints = {} # mountpoints = {}
# struct = { # struct = {
# "partitions" : [] # "partitions" : []
# } # }
# for partition in partitions: # for partition in partitions:
# mountpoint = input(f"Select a mountpoint (or skip) for {partition}: ").strip() # mountpoint = input(f"Select a mountpoint (or skip) for {partition}: ").strip()
# part_struct = {} # part_struct = {}
# if mountpoint: # if mountpoint:
# part_struct['mountpoint'] = mountpoint # part_struct['mountpoint'] = mountpoint
@ -590,7 +590,7 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
# part_struct['boot'] = True # part_struct['boot'] = True
# if has_uefi(): # if has_uefi():
# part_struct['ESP'] = True # part_struct['ESP'] = True
# elif mountpoint == '/' and # elif mountpoint == '/' and
# if partition.uuid: # if partition.uuid:
# part_struct['PARTUUID'] = partition.uuid # part_struct['PARTUUID'] = partition.uuid
# if partition in partitions_to_wipe: # if partition in partitions_to_wipe:
@ -632,15 +632,15 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
if not task: if not task:
break break
if task == 'Create a new partition': if task == 'Create a new partition':
if partition_type == 'gpt': if partition_type == 'gpt':
# https://www.gnu.org/software/parted/manual/html_node/mkpart.html # https://www.gnu.org/software/parted/manual/html_node/mkpart.html
# https://www.gnu.org/software/parted/manual/html_node/mklabel.html # https://www.gnu.org/software/parted/manual/html_node/mklabel.html
name = input("Enter a desired name for the partition: ").strip() name = input("Enter a desired name for the partition: ").strip()
fstype = input("Enter a desired filesystem type for the partition: ").strip() fstype = input("Enter a desired filesystem type for the partition: ").strip()
start = input(f"Enter the start sector (percentage or block number, default: {block_device.largest_free_space[0]}): ").strip() start = input(f"Enter the start sector (percentage or block number, default: {block_device.largest_free_space[0]}): ").strip()
if not start.strip(): if not start.strip():
start = block_device.largest_free_space[0] start = block_device.largest_free_space[0]
@ -674,7 +674,7 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
if input(f"{block_device} contains queued partitions, this will remove those, are you sure? y/N: ").strip().lower() in ('', 'n'): if input(f"{block_device} contains queued partitions, this will remove those, are you sure? y/N: ").strip().lower() in ('', 'n'):
continue continue
block_device_struct["partitions"] = suggest_single_disk_layout(block_device)[block_device] block_device_struct.update( suggest_single_disk_layout(block_device)[block_device.path] )
elif task is None: elif task is None:
return block_device_struct return block_device_struct
else: else:
@ -730,7 +730,10 @@ def manage_new_and_existing_partitions(block_device :BlockDevice) -> dict:
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['boot'] = not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('boot', False) block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['boot'] = not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('boot', False)
elif task == "Set desired filesystem for a partition": elif task == "Set desired filesystem for a partition":
if (partition := generic_select(block_device_struct["partitions"], 'Select which partition to set a filesystem on: ', options_output=False)): if not block_device_struct["partitions"]:
log("No partitions found. Create some partitions first", level=logging.WARNING, fg='yellow')
continue
elif (partition := generic_select(block_device_struct["partitions"], 'Select which partition to set a filesystem on: ', options_output=False)):
if not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('filesystem', None): if not block_device_struct["partitions"][block_device_struct["partitions"].index(partition)].get('filesystem', None):
block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['filesystem'] = {} block_device_struct["partitions"][block_device_struct["partitions"].index(partition)]['filesystem'] = {}
@ -750,7 +753,7 @@ def select_individual_blockdevice_usage(block_devices :list):
for device in block_devices: for device in block_devices:
layout = manage_new_and_existing_partitions(device) layout = manage_new_and_existing_partitions(device)
result[device.path] = layout result[device.path] = layout
return result return result

View File

@ -66,7 +66,7 @@ def load_config():
archinstall.storage['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts']) archinstall.storage['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts'])
except: except:
raise ValueError("--disk_layouts=<json> needs either a JSON file or a JSON string given with a valid disk layout.") raise ValueError("--disk_layouts=<json> needs either a JSON file or a JSON string given with a valid disk layout.")
def ask_user_questions(): def ask_user_questions():
""" """
First, we'll ask the user for a bunch of user input. First, we'll ask the user for a bunch of user input.
@ -371,4 +371,4 @@ if not archinstall.arguments.get('silent'):
ask_user_questions() ask_user_questions()
perform_filesystem_operations() perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt')) perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt'))

View File

@ -7,7 +7,6 @@ is_top_level_profile = False
__packages__ = [ __packages__ = [
"cutefish", "cutefish",
"noto-fonts", "noto-fonts",
"konsole",
"sddm" "sddm"
] ]

View File

@ -11,6 +11,7 @@ __packages__ = [
"lightdm", "lightdm",
"lightdm-gtk-greeter", "lightdm-gtk-greeter",
"gvfs", "gvfs",
"network-manager-applet",
] ]

View File

@ -11,7 +11,6 @@ __packages__ = [
'xorg-server', 'xorg-server',
'xorg-xinit', 'xorg-xinit',
'nvidia-dkms', 'nvidia-dkms',
'xorg-server',
*archinstall.lib.hardware.__packages__, *archinstall.lib.hardware.__packages__,
] ]

View File

@ -29,7 +29,7 @@ include =
archinstall.* archinstall.*
[options.package_data] [options.package_data]
archinstall = archinstall =
examples/*.py examples/*.py
profiles/*.py profiles/*.py
profiles/applications/*.py profiles/applications/*.py