rebased to latest commits
This commit is contained in:
commit
b292981de6
|
|
@ -76,7 +76,7 @@ class sys_command():#Thread):
|
|||
"""
|
||||
Stolen from archinstall_gui
|
||||
"""
|
||||
def __init__(self, cmd, callback=None, start_callback=None, *args, **kwargs):
|
||||
def __init__(self, cmd, callback=None, start_callback=None, environment_vars={}, *args, **kwargs):
|
||||
kwargs.setdefault("worker_id", gen_uid())
|
||||
kwargs.setdefault("emulate", False)
|
||||
kwargs.setdefault("suppress_errors", False)
|
||||
|
|
@ -93,6 +93,7 @@ class sys_command():#Thread):
|
|||
raise ValueError(f'Incorrect string to split: {cmd}\n{e}')
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.environment_vars = environment_vars
|
||||
|
||||
self.kwargs.setdefault("worker", None)
|
||||
self.callback = callback
|
||||
|
|
@ -159,7 +160,7 @@ class sys_command():#Thread):
|
|||
# Replace child process with our main process
|
||||
if not self.kwargs['emulate']:
|
||||
try:
|
||||
os.execv(self.cmd[0], self.cmd)
|
||||
os.execve(self.cmd[0], self.cmd, {**os.environ, **self.environment_vars})
|
||||
except FileNotFoundError:
|
||||
self.status = 'done'
|
||||
self.log(f"{self.cmd[0]} does not exist.", level=LOG_LEVELS.Debug)
|
||||
|
|
@ -262,6 +263,11 @@ class sys_command():#Thread):
|
|||
with open(f'{self.cwd}/trace.log', 'wb') as fh:
|
||||
fh.write(self.trace_log)
|
||||
|
||||
try:
|
||||
os.close(child_fd)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def prerequisite_check():
|
||||
if not os.path.isdir("/sys/firmware/efi"):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import os, stat, time, shutil, pathlib
|
||||
import os, stat, time, shutil, pathlib, subprocess
|
||||
|
||||
from .exceptions import *
|
||||
from .disk import *
|
||||
|
|
@ -81,6 +81,7 @@ class Installer():
|
|||
if not (missing_steps := self.post_install_check()):
|
||||
self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=LOG_LEVELS.Info)
|
||||
self.sync_log_to_install_medium()
|
||||
|
||||
return True
|
||||
else:
|
||||
self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning)
|
||||
|
|
@ -190,6 +191,9 @@ class Installer():
|
|||
def arch_chroot(self, cmd, *args, **kwargs):
|
||||
return self.run_command(cmd)
|
||||
|
||||
def drop_to_shell(self):
|
||||
subprocess.check_call(f"/usr/bin/arch-chroot {self.target}", shell=True)
|
||||
|
||||
def configure_nic(self, nic, dhcp=True, ip=None, gateway=None, dns=None, *args, **kwargs):
|
||||
if dhcp:
|
||||
conf = Networkd(Match={"Name": nic}, Network={"DHCP": "yes"})
|
||||
|
|
@ -443,6 +447,12 @@ class Installer():
|
|||
|
||||
o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.target} sh -c \"echo '{user}:{password}' | chpasswd\""))
|
||||
pass
|
||||
|
||||
def user_set_shell(self, user, shell):
|
||||
self.log(f'Setting shell for {user} to {shell}', level=LOG_LEVELS.Info)
|
||||
|
||||
o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\""))
|
||||
pass
|
||||
|
||||
def set_keyboard_language(self, language):
|
||||
if len(language.strip()):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import subprocess
|
||||
import os
|
||||
|
||||
from .exceptions import *
|
||||
|
|
@ -26,4 +27,4 @@ def search_keyboard_layout(filter, layout='qwerty'):
|
|||
yield language
|
||||
|
||||
def set_keyboard_language(locale):
|
||||
return os.system(f'loadkeys {locale}') == 0
|
||||
return subprocess.call(['loadkeys',locale]) == 0
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ def service_state(service_name: str):
|
|||
if os.path.splitext(service_name)[1] != '.service':
|
||||
service_name += '.service' # Just to be safe
|
||||
|
||||
state = b''.join(sys_command(f'systemctl show -p SubState --value {service_name}'))
|
||||
state = b''.join(sys_command(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS' : '0'}))
|
||||
|
||||
return state.strip().decode('UTF-8')
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from archinstall.lib.hardware import hasUEFI
|
|||
from archinstall.lib.profiles import Profile
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
def ask_user_questions():
|
||||
|
|
@ -281,27 +281,38 @@ def perform_installation(mountpoint):
|
|||
# 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
|
||||
# We need to wait for it before we continue since we opted in to use a custom mirror/region.
|
||||
installation.log(f'Waiting for automatic mirror selection has completed before using custom mirrors.')
|
||||
while 'dead' not in (status := archinstall.service_state('reflector')):
|
||||
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)
|
||||
|
||||
archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium
|
||||
# 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'])
|
||||
<<<<<<< HEAD
|
||||
if archinstall.arguments['mirror-region'] != None:
|
||||
installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
|
||||
=======
|
||||
|
||||
# Configure the selected mirrors in the installation
|
||||
if archinstall.arguments.get('mirror-region', None):
|
||||
installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
|
||||
|
||||
>>>>>>> af2671c1ec1ac2ecbdbd35c90c3e5016dcf516ed
|
||||
installation.set_keyboard_language(archinstall.arguments['keyboard-language'])
|
||||
installation.add_bootloader()
|
||||
|
||||
# If user selected to copy the current ISO network configuration
|
||||
# Perform a copy of the config
|
||||
if archinstall.arguments.get('nic', None) == 'Copy ISO network configuration to installation':
|
||||
if archinstall.arguments.get('nic', {}) == 'Copy ISO network configuration to installation':
|
||||
installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium.
|
||||
elif archinstall.arguments.get('nic',{}).get('NetworkManager',False):
|
||||
elif archinstall.arguments.get('nic', {}).get('NetworkManager',False):
|
||||
installation.add_additional_packages("networkmanager")
|
||||
installation.enable_service('NetworkManager.service')
|
||||
# Otherwise, if a interface was selected, configure that interface
|
||||
elif archinstall.arguments.get('nic', None):
|
||||
elif archinstall.arguments.get('nic', {}):
|
||||
installation.configure_nic(**archinstall.arguments.get('nic', {}))
|
||||
installation.enable_service('systemd-networkd')
|
||||
installation.enable_service('systemd-resolved')
|
||||
|
|
@ -335,6 +346,14 @@ def perform_installation(mountpoint):
|
|||
if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw):
|
||||
installation.user_set_pw('root', root_pw)
|
||||
|
||||
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", ""):
|
||||
try:
|
||||
installation.drop_to_shell()
|
||||
except:
|
||||
pass
|
||||
|
||||
ask_user_questions()
|
||||
perform_installation_steps()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue