Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/mirrors.py3
-rw-r--r--archinstall/lib/networking.py7
-rw-r--r--archinstall/lib/output.py13
-rw-r--r--archinstall/lib/packages.py2
-rw-r--r--archinstall/lib/profiles.py11
-rw-r--r--archinstall/lib/storage.py12
-rw-r--r--archinstall/lib/user_interaction.py80
7 files changed, 66 insertions, 62 deletions
diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py
index dd8fadc4..e53b356a 100644
--- a/archinstall/lib/mirrors.py
+++ b/archinstall/lib/mirrors.py
@@ -60,7 +60,7 @@ def insert_mirrors(mirrors, *args, **kwargs):
return True
-def use_mirrors(regions :dict, destination='/etc/pacman.d/mirrorlist'):
+def use_mirrors(regions: dict, destination='/etc/pacman.d/mirrorlist'):
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:
@@ -86,7 +86,6 @@ def list_mirrors():
log(f'Could not fetch an active mirror-list: {err}', level=logging.WARNING, fg="yellow")
return regions
-
region = 'Unknown region'
for line in response.readlines():
if len(line.strip()) == 0:
diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py
index 768cc1cc..3e5ed4e7 100644
--- a/archinstall/lib/networking.py
+++ b/archinstall/lib/networking.py
@@ -1,8 +1,9 @@
-import os
import fcntl
+import os
import socket
import struct
from collections import OrderedDict
+
from .exceptions import *
from .general import sys_command
from .storage import storage
@@ -10,7 +11,7 @@ from .storage import storage
def get_hw_addr(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(ifname, 'utf-8')[:15]))
+ info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(ifname, 'utf-8')[:15]))
return ':'.join('%02x' % b for b in info[18:24])
@@ -25,7 +26,7 @@ def list_interfaces(skip_loopback=True):
return interfaces
-def enrich_iface_types(interfaces :dict):
+def enrich_iface_types(interfaces: dict):
result = {}
for iface in interfaces:
if os.path.isdir(f"/sys/class/net/{iface}/bridge/"):
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index 0818aed0..cce9e88c 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -1,8 +1,9 @@
import abc
+import logging
import os
import sys
-import logging
from pathlib import Path
+
from .storage import storage
@@ -21,7 +22,7 @@ class journald(dict):
@abc.abstractmethod
def log(message, level=logging.DEBUG):
try:
- import systemd.journal # type: ignore
+ import systemd.journal # type: ignore
except ModuleNotFoundError:
return False
@@ -77,8 +78,8 @@ def supports_color():
# Heavily influenced by: https://github.com/django/django/blob/ae8338daf34fd746771e0678081999b656177bae/django/utils/termcolors.py#L13
# Color options here: https://askubuntu.com/questions/528928/how-to-do-underline-bold-italic-strikethrough-color-background-and-size-i
-def stylize_output(text :str, *opts, **kwargs):
- opt_dict = {'bold': '1', 'italic' : '3', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
+def stylize_output(text: str, *opts, **kwargs):
+ opt_dict = {'bold': '1', 'italic': '3', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white')
foreground = {color_names[x]: '3%s' % x for x in range(8)}
background = {color_names[x]: '4%s' % x for x in range(8)}
@@ -120,8 +121,8 @@ def log(*args, **kwargs):
log_file.write("")
except PermissionError:
# Fallback to creating the log file in the current folder
- err_string = f"Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead."
- absolute_logfile = Path('./').absolute()/filename
+ err_string = f"Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute() / filename} instead."
+ absolute_logfile = Path('./').absolute() / filename
absolute_logfile.parents[0].mkdir(exist_ok=True)
absolute_logfile = str(absolute_logfile)
storage['LOG_PATH'] = './'
diff --git a/archinstall/lib/packages.py b/archinstall/lib/packages.py
index 87c60abb..e16ed99e 100644
--- a/archinstall/lib/packages.py
+++ b/archinstall/lib/packages.py
@@ -51,7 +51,7 @@ def find_packages(*names):
return result
-def validate_package_list(packages :list):
+def validate_package_list(packages: list):
"""
Validates a list of given packages.
Raises `RequirementError` if one or more packages are not found.
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index ebcd3aff..8b5525b4 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -7,6 +7,7 @@ import sys
import urllib.parse
import urllib.request
from typing import Optional
+
from .general import multisplit
from .networking import *
from .storage import storage
@@ -16,7 +17,7 @@ def grab_url_data(path):
safe_path = path[:path.find(':')+1]+''.join([item if item in ('/', '?', '=', '&') else urllib.parse.quote(item) for item in multisplit(path[path.find(':')+1:], ('/', '?', '=', '&'))])
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
- ssl_context.verify_mode=ssl.CERT_NONE
+ ssl_context.verify_mode = ssl.CERT_NONE
response = urllib.request.urlopen(safe_path, context=ssl_context)
return response.read()
@@ -29,7 +30,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof
cache = {}
# Grab all local profiles found in PROFILE_PATH
for PATH_ITEM in storage['PROFILE_PATH']:
- for root, folders, files in os.walk(os.path.abspath(os.path.expanduser(PATH_ITEM+subpath))):
+ for root, folders, files in os.walk(os.path.abspath(os.path.expanduser(PATH_ITEM + subpath))):
for file in files:
if file == '__init__.py':
continue
@@ -51,7 +52,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof
# Grab profiles from upstream URL
if storage['PROFILE_DB']:
- profiles_url = os.path.join(storage["UPSTREAM_URL"]+subpath, storage['PROFILE_DB'])
+ profiles_url = os.path.join(storage["UPSTREAM_URL"] + subpath, storage['PROFILE_DB'])
try:
profile_list = json.loads(grab_url_data(profiles_url))
except urllib.error.HTTPError as err:
@@ -74,7 +75,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof
if filter_top_level_profiles:
for profile in list(cache.keys()):
if Profile(None, profile).is_top_level_profile() is False:
- del(cache[profile])
+ del (cache[profile])
return cache
@@ -166,7 +167,7 @@ class Profile(Script):
super(Profile, self).__init__(path, installer)
def __dump__(self, *args, **kwargs):
- return {'path' : self.path}
+ return {'path': self.path}
def __repr__(self, *args, **kwargs):
return f'Profile({os.path.basename(self.profile)})'
diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py
index d985ca17..53d5e938 100644
--- a/archinstall/lib/storage.py
+++ b/archinstall/lib/storage.py
@@ -8,15 +8,15 @@ import os
#
# And Keeping this in dict ensures that variables are shared across imports.
storage = {
- 'PROFILE_PATH' : [
+ 'PROFILE_PATH': [
'./profiles',
'~/.config/archinstall/profiles',
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'profiles'),
# os.path.abspath(f'{os.path.dirname(__file__)}/../examples')
],
- 'UPSTREAM_URL' : 'https://raw.githubusercontent.com/archlinux/archinstall/master/profiles',
- 'PROFILE_DB' : None, # Used in cases when listing profiles is desired, not mandatory for direct profile grabing.
- 'LOG_PATH' : '/var/log/archinstall',
- 'LOG_FILE' : 'install.log',
- 'MOUNT_POINT' : '/mnt'
+ 'UPSTREAM_URL': 'https://raw.githubusercontent.com/archlinux/archinstall/master/profiles',
+ 'PROFILE_DB': None, # Used in cases when listing profiles is desired, not mandatory for direct profile grabing.
+ 'LOG_PATH': '/var/log/archinstall',
+ 'LOG_FILE': 'install.log',
+ 'MOUNT_POINT': '/mnt'
}
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 0aeba3b9..4ca0fed8 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -48,6 +48,7 @@ def check_for_correct_username(username):
def do_countdown():
SIG_TRIGGER = False
+
def kill_handler(sig, frame):
print()
exit(0)
@@ -101,17 +102,17 @@ def print_large_list(options, padding=5, margin_bottom=0, separator=': '):
longest_line = highest_index_number_length + len(separator) + get_longest_option(options) + padding
spaces_without_option = longest_line - (len(separator) + highest_index_number_length)
max_num_of_columns = get_terminal_width() // longest_line
- max_options_in_cells = max_num_of_columns * (get_terminal_height()-margin_bottom)
+ max_options_in_cells = max_num_of_columns * (get_terminal_height() - margin_bottom)
if (len(options) > max_options_in_cells):
for index, option in enumerate(options):
print(f"{index}: {option}")
return 1, index
else:
- for row in range(0, (get_terminal_height()-margin_bottom)):
- for column in range(row, len(options), (get_terminal_height()-margin_bottom)):
- spaces = " "*(spaces_without_option - len(options[column]))
- print(f"{str(column): >{highest_index_number_length}}{separator}{options[column]}", end = spaces)
+ for row in range(0, (get_terminal_height() - margin_bottom)):
+ for column in range(row, len(options), (get_terminal_height() - margin_bottom)):
+ spaces = " " * (spaces_without_option - len(options[column]))
+ print(f"{str(column): >{highest_index_number_length}}{separator}{options[column]}", end=spaces)
print()
return column, row
@@ -148,7 +149,7 @@ def generic_multi_select(options, text="Select one or more of the options above
else:
printed_options.append(f'{option}')
- section.clear(0, get_terminal_height()-section._cursor_y-1)
+ section.clear(0, get_terminal_height() - section._cursor_y - 1)
print_large_list(printed_options, margin_bottom=2)
section._cursor_y = len(printed_options)
section._cursor_x = 0
@@ -204,7 +205,7 @@ class MiniCurses:
sys.stdout.flush()
sys.stdout.write("\033[%dG" % 0)
sys.stdout.flush()
- sys.stdout.write(" " * (get_terminal_width()-1))
+ sys.stdout.write(" " * (get_terminal_width() - 1))
sys.stdout.flush()
sys.stdout.write("\033[%dG" % 0)
sys.stdout.flush()
@@ -223,17 +224,17 @@ class MiniCurses:
sys.stdout.flush()
sys.stdout.write('\033[%d;%df' % (y, x))
- for line in range(get_terminal_height()-y-1, y):
- sys.stdout.write(" " * (get_terminal_width()-1))
+ for line in range(get_terminal_height() - y - 1, y):
+ sys.stdout.write(" " * (get_terminal_width() - 1))
sys.stdout.flush()
sys.stdout.write('\033[%d;%df' % (y, x))
sys.stdout.flush()
def deal_with_control_characters(self, char):
mapper = {
- '\x7f' : 'BACKSPACE',
- '\r' : 'CR',
- '\n' : 'NL'
+ '\x7f': 'BACKSPACE',
+ '\r': 'CR',
+ '\n': 'NL'
}
if (mapped_char := mapper.get(char, None)) == 'BACKSPACE':
@@ -319,7 +320,7 @@ def ask_for_superuser_account(prompt='Username for required superuser with sudo
continue
password = get_password(prompt=f'Password for user {new_user}: ')
- return {new_user: {"!password" : password}}
+ return {new_user: {"!password": password}}
def ask_for_additional_users(prompt='Any additional users to install (leave blank for no users): '):
@@ -335,9 +336,9 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan
password = get_password(prompt=f'Password for user {new_user}: ')
if input("Should this user be a superuser (sudoer) [y/N]: ").strip(' ').lower() in ('y', 'yes'):
- superusers[new_user] = {"!password" : password}
+ superusers[new_user] = {"!password": password}
else:
- users[new_user] = {"!password" : password}
+ users[new_user] = {"!password": password}
return users, superusers
@@ -347,7 +348,7 @@ def ask_for_a_timezone():
timezone = input('Enter a valid timezone (examples: Europe/Stockholm, US/Eastern) or press enter to use UTC: ').strip().strip('*.')
if timezone == '':
timezone = 'UTC'
- if (pathlib.Path("/usr")/"share"/"zoneinfo"/timezone).exists():
+ if (pathlib.Path("/usr") / "share" / "zoneinfo" / timezone).exists():
return timezone
else:
log(
@@ -359,17 +360,17 @@ def ask_for_a_timezone():
def ask_for_bootloader() -> str:
bootloader = "systemd-bootctl"
- if hasUEFI()==False:
- bootloader="grub-install"
+ if hasUEFI() == False:
+ bootloader = "grub-install"
else:
bootloader_choice = input("Would you like to use GRUB as a bootloader instead of systemd-boot? [y/N] ").lower()
if bootloader_choice == "y":
- bootloader="grub-install"
+ bootloader = "grub-install"
return bootloader
def ask_for_audio_selection():
- audio = "pulseaudio" # Default for most desktop environments
+ audio = "pulseaudio" # Default for most desktop environments
pipewire_choice = input("Would you like to install pipewire instead of pulseaudio as the default audio server? [Y/n] ").lower()
if pipewire_choice in ("y", ""):
audio = "pipewire"
@@ -379,18 +380,18 @@ def ask_for_audio_selection():
def ask_to_configure_network():
# Optionally configure one network interface.
- #while 1:
+ # while 1:
# {MAC: Ifname}
interfaces = {
- 'ISO-CONFIG' : 'Copy ISO network configuration to installation',
- 'NetworkManager':'Use NetworkManager to control and manage your internet connection',
+ 'ISO-CONFIG': 'Copy ISO network configuration to installation',
+ 'NetworkManager': 'Use NetworkManager to control and manage your internet connection',
**list_interfaces()
}
nic = generic_select(interfaces, "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 your internet connection':
- return {'nic': nic,'NetworkManager':True}
+ return {'nic': nic, 'NetworkManager': True}
# Current workaround:
# For selecting modes without entering text within brackets,
@@ -401,7 +402,7 @@ def ask_to_configure_network():
print(f"{index}: {mode}")
mode = generic_select(['DHCP', 'IP'], f"Select which mode to configure for {nic} or leave blank for DHCP: ",
- options_output=False)
+ options_output=False)
if mode == 'IP':
while 1:
ip = input(f"Enter the IP and subnet for {nic} (example: 192.168.0.5/24): ").strip()
@@ -436,7 +437,7 @@ def ask_to_configure_network():
if len(dns_input := input('Enter your DNS servers (space separated, blank for none): ').strip()):
dns = dns_input.split(' ')
- return {'nic': nic, 'dhcp': False, 'ip': ip, 'gateway' : gateway, 'dns' : dns}
+ return {'nic': nic, 'dhcp': False, 'ip': ip, 'gateway': gateway, 'dns': dns}
else:
return {'nic': nic}
elif nic:
@@ -447,26 +448,26 @@ def ask_to_configure_network():
def ask_for_disk_layout():
options = {
- 'keep-existing' : 'Keep existing partition layout and select which ones to use where',
- 'format-all' : 'Format entire drive and setup a basic partition scheme',
- 'abort' : 'Abort the installation'
+ 'keep-existing': 'Keep existing partition layout and select which ones to use where',
+ 'format-all': 'Format entire drive and setup a basic partition scheme',
+ 'abort': 'Abort the installation'
}
value = generic_select(options, "Found partitions on the selected drive, (select by number) what you want to do: ",
- allow_empty_input=False, sort=True)
+ allow_empty_input=False, sort=True)
return next((key for key, val in options.items() if val == value), None)
def ask_for_main_filesystem_format():
options = {
- 'btrfs' : 'btrfs',
- 'ext4' : 'ext4',
- 'xfs' : 'xfs',
- 'f2fs' : 'f2fs'
+ 'btrfs': 'btrfs',
+ 'ext4': 'ext4',
+ 'xfs': 'xfs',
+ 'f2fs': 'f2fs'
}
value = generic_select(options, "Select which filesystem your main partition should use (by number or name): ",
- allow_empty_input=False)
+ allow_empty_input=False)
return next((key for key, val in options.items() if val == value), None)
@@ -526,7 +527,7 @@ def generic_select(options, input_text="Select one of the above by index or abso
selected_option = options[selected_option]
break
elif selected_option in options:
- break # We gave a correct absolute value
+ break # We gave a correct absolute value
else:
raise RequirementError(f'Selected option "{selected_option}" does not exist in available options')
except RequirementError as err:
@@ -584,7 +585,7 @@ def select_profile(options):
print(' -- (Leave blank and hit enter to skip this step and continue) --')
selected_profile = generic_select(profiles, 'Enter a pre-programmed profile name if you want to install one: ',
- options_output=False)
+ options_output=False)
if selected_profile:
return Profile(None, selected_profile)
else:
@@ -674,8 +675,9 @@ def select_mirror_regions(mirrors, show_top_mirrors=True):
print_large_list(regions, margin_bottom=4)
print(' -- You can skip this step by leaving the option blank --')
- selected_mirror = generic_select(regions, 'Select one of the above regions to download packages from (by number or full name): ',
- options_output=False)
+ selected_mirror = generic_select(regions,
+ 'Select one of the above regions to download packages from (by number or full name): ',
+ options_output=False)
if not selected_mirror:
# Returning back empty options which can be both used to
# do "if x:" logic as well as do `x.get('mirror', {}).get('sub', None)` chaining