Symlink example files to actual scripts (#3495)
This commit is contained in:
parent
1308897d79
commit
4c065c3698
|
|
@ -1,195 +0,0 @@
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from archinstall import SysInfo, debug, error, info
|
|
||||||
from archinstall.lib.args import arch_config_handler
|
|
||||||
from archinstall.lib.configuration import ConfigurationOutput
|
|
||||||
from archinstall.lib.disk.filesystem import FilesystemHandler
|
|
||||||
from archinstall.lib.disk.utils import disk_layouts
|
|
||||||
from archinstall.lib.global_menu import GlobalMenu
|
|
||||||
from archinstall.lib.installer import Installer, accessibility_tools_in_use, run_custom_user_commands
|
|
||||||
from archinstall.lib.interactions.general_conf import PostInstallationAction, ask_post_installation
|
|
||||||
from archinstall.lib.models import Bootloader
|
|
||||||
from archinstall.lib.models.device_model import (
|
|
||||||
DiskLayoutType,
|
|
||||||
EncryptionType,
|
|
||||||
)
|
|
||||||
from archinstall.lib.models.users import User
|
|
||||||
from archinstall.lib.profile.profiles_handler import profile_handler
|
|
||||||
from archinstall.tui import Tui
|
|
||||||
|
|
||||||
|
|
||||||
def ask_user_questions() -> None:
|
|
||||||
"""
|
|
||||||
First, we'll ask the user for a bunch of user input.
|
|
||||||
Not until we're satisfied with what we want to install
|
|
||||||
will we continue with the actual installation steps.
|
|
||||||
"""
|
|
||||||
|
|
||||||
with Tui():
|
|
||||||
global_menu = GlobalMenu(arch_config_handler.config)
|
|
||||||
|
|
||||||
if not arch_config_handler.args.advanced:
|
|
||||||
global_menu.set_enabled("parallel_downloads", False)
|
|
||||||
|
|
||||||
global_menu.run()
|
|
||||||
|
|
||||||
|
|
||||||
def perform_installation(mountpoint: Path) -> None:
|
|
||||||
"""
|
|
||||||
Performs the installation steps on a block device.
|
|
||||||
Only requirement is that the block devices are
|
|
||||||
formatted and setup prior to entering this function.
|
|
||||||
"""
|
|
||||||
info("Starting installation...")
|
|
||||||
|
|
||||||
config = arch_config_handler.config
|
|
||||||
|
|
||||||
if not config.disk_config:
|
|
||||||
error("No disk configuration provided")
|
|
||||||
return
|
|
||||||
|
|
||||||
disk_config = config.disk_config
|
|
||||||
run_mkinitcpio = not config.uki
|
|
||||||
locale_config = config.locale_config
|
|
||||||
disk_encryption = config.disk_encryption
|
|
||||||
optional_repositories = config.mirror_config.optional_repositories if config.mirror_config else []
|
|
||||||
mountpoint = disk_config.mountpoint if disk_config.mountpoint else mountpoint
|
|
||||||
|
|
||||||
with Installer(
|
|
||||||
mountpoint,
|
|
||||||
disk_config,
|
|
||||||
disk_encryption=disk_encryption,
|
|
||||||
kernels=config.kernels,
|
|
||||||
) as installation:
|
|
||||||
# Mount all the drives to the desired mountpoint
|
|
||||||
if disk_config.config_type != DiskLayoutType.Pre_mount:
|
|
||||||
installation.mount_ordered_layout()
|
|
||||||
|
|
||||||
installation.sanity_check()
|
|
||||||
|
|
||||||
if disk_config.config_type != DiskLayoutType.Pre_mount:
|
|
||||||
if disk_encryption and disk_encryption.encryption_type != EncryptionType.NoEncryption:
|
|
||||||
# generate encryption key files for the mounted luks devices
|
|
||||||
installation.generate_key_files()
|
|
||||||
|
|
||||||
if mirror_config := config.mirror_config:
|
|
||||||
installation.set_mirrors(mirror_config, on_target=False)
|
|
||||||
|
|
||||||
installation.minimal_installation(
|
|
||||||
optional_repositories=optional_repositories,
|
|
||||||
mkinitcpio=run_mkinitcpio,
|
|
||||||
hostname=arch_config_handler.config.hostname,
|
|
||||||
locale_config=locale_config,
|
|
||||||
)
|
|
||||||
|
|
||||||
if mirror_config := config.mirror_config:
|
|
||||||
installation.set_mirrors(mirror_config, on_target=True)
|
|
||||||
|
|
||||||
if config.swap:
|
|
||||||
installation.setup_swap("zram")
|
|
||||||
|
|
||||||
if config.bootloader == Bootloader.Grub and SysInfo.has_uefi():
|
|
||||||
installation.add_additional_packages("grub")
|
|
||||||
|
|
||||||
installation.add_bootloader(config.bootloader, config.uki)
|
|
||||||
|
|
||||||
# If user selected to copy the current ISO network configuration
|
|
||||||
# Perform a copy of the config
|
|
||||||
network_config = config.network_config
|
|
||||||
|
|
||||||
if network_config:
|
|
||||||
network_config.install_network_config(
|
|
||||||
installation,
|
|
||||||
config.profile_config,
|
|
||||||
)
|
|
||||||
|
|
||||||
if users := config.users:
|
|
||||||
installation.create_users(users)
|
|
||||||
|
|
||||||
audio_config = config.audio_config
|
|
||||||
if audio_config:
|
|
||||||
audio_config.install_audio_config(installation)
|
|
||||||
else:
|
|
||||||
info("No audio server will be installed")
|
|
||||||
|
|
||||||
if config.packages and config.packages[0] != "":
|
|
||||||
installation.add_additional_packages(config.packages)
|
|
||||||
|
|
||||||
if profile_config := config.profile_config:
|
|
||||||
profile_handler.install_profile_config(installation, profile_config)
|
|
||||||
|
|
||||||
if timezone := config.timezone:
|
|
||||||
installation.set_timezone(timezone)
|
|
||||||
|
|
||||||
if config.ntp:
|
|
||||||
installation.activate_time_synchronization()
|
|
||||||
|
|
||||||
if accessibility_tools_in_use():
|
|
||||||
installation.enable_espeakup()
|
|
||||||
|
|
||||||
if root_pw := config.root_enc_password:
|
|
||||||
root_user = User("root", root_pw, False)
|
|
||||||
installation.set_user_password(root_user)
|
|
||||||
|
|
||||||
if (profile_config := config.profile_config) and profile_config.profile:
|
|
||||||
profile_config.profile.post_install(installation)
|
|
||||||
|
|
||||||
# If the user provided a list of services to be enabled, pass the list to the enable_service function.
|
|
||||||
# Note that while it's called enable_service, it can actually take a list of services and iterate it.
|
|
||||||
if servies := config.services:
|
|
||||||
installation.enable_service(servies)
|
|
||||||
|
|
||||||
# If the user provided custom commands to be run post-installation, execute them now.
|
|
||||||
if cc := config.custom_commands:
|
|
||||||
run_custom_user_commands(cc, installation)
|
|
||||||
|
|
||||||
installation.genfstab()
|
|
||||||
|
|
||||||
debug(f"Disk states after installing:\n{disk_layouts()}")
|
|
||||||
|
|
||||||
if not arch_config_handler.args.silent:
|
|
||||||
with Tui():
|
|
||||||
action = ask_post_installation()
|
|
||||||
|
|
||||||
match action:
|
|
||||||
case PostInstallationAction.EXIT:
|
|
||||||
pass
|
|
||||||
case PostInstallationAction.REBOOT:
|
|
||||||
os.system("reboot")
|
|
||||||
case PostInstallationAction.CHROOT:
|
|
||||||
try:
|
|
||||||
installation.drop_to_shell()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def guided() -> None:
|
|
||||||
if not arch_config_handler.args.silent:
|
|
||||||
ask_user_questions()
|
|
||||||
|
|
||||||
config = ConfigurationOutput(arch_config_handler.config)
|
|
||||||
config.write_debug()
|
|
||||||
config.save()
|
|
||||||
|
|
||||||
if arch_config_handler.args.dry_run:
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
if not arch_config_handler.args.silent:
|
|
||||||
with Tui():
|
|
||||||
if not config.confirm_config():
|
|
||||||
debug("Installation aborted")
|
|
||||||
guided()
|
|
||||||
|
|
||||||
if arch_config_handler.config.disk_config:
|
|
||||||
fs_handler = FilesystemHandler(
|
|
||||||
arch_config_handler.config.disk_config,
|
|
||||||
arch_config_handler.config.disk_encryption,
|
|
||||||
)
|
|
||||||
|
|
||||||
fs_handler.perform_filesystem_operations()
|
|
||||||
|
|
||||||
perform_installation(arch_config_handler.args.mountpoint)
|
|
||||||
|
|
||||||
|
|
||||||
guided()
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../archinstall/scripts/guided.py
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from archinstall.default_profiles.minimal import MinimalProfile
|
|
||||||
from archinstall.lib.args import arch_config_handler
|
|
||||||
from archinstall.lib.configuration import ConfigurationOutput
|
|
||||||
from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu
|
|
||||||
from archinstall.lib.disk.encryption_menu import DiskEncryptionMenu
|
|
||||||
from archinstall.lib.disk.filesystem import FilesystemHandler
|
|
||||||
from archinstall.lib.installer import Installer
|
|
||||||
from archinstall.lib.models import Bootloader
|
|
||||||
from archinstall.lib.models.profile_model import ProfileConfiguration
|
|
||||||
from archinstall.lib.models.users import Password, User
|
|
||||||
from archinstall.lib.output import debug, error, info
|
|
||||||
from archinstall.lib.profile.profiles_handler import profile_handler
|
|
||||||
from archinstall.tui import Tui
|
|
||||||
|
|
||||||
|
|
||||||
def perform_installation(mountpoint: Path) -> None:
|
|
||||||
config = arch_config_handler.config
|
|
||||||
|
|
||||||
disk_config = config.disk_config
|
|
||||||
|
|
||||||
if disk_config is None:
|
|
||||||
error("No disk configuration provided")
|
|
||||||
return
|
|
||||||
|
|
||||||
disk_encryption = config.disk_encryption
|
|
||||||
mountpoint = disk_config.mountpoint if disk_config.mountpoint else mountpoint
|
|
||||||
|
|
||||||
with Installer(
|
|
||||||
mountpoint,
|
|
||||||
disk_config,
|
|
||||||
disk_encryption=disk_encryption,
|
|
||||||
kernels=config.kernels,
|
|
||||||
) as installation:
|
|
||||||
# Strap in the base system, add a boot loader and configure
|
|
||||||
# some other minor details as specified by this profile and user.
|
|
||||||
if installation.minimal_installation():
|
|
||||||
installation.set_hostname("minimal-arch")
|
|
||||||
installation.add_bootloader(Bootloader.Systemd)
|
|
||||||
|
|
||||||
network_config = config.network_config
|
|
||||||
|
|
||||||
if network_config:
|
|
||||||
network_config.install_network_config(
|
|
||||||
installation,
|
|
||||||
config.profile_config,
|
|
||||||
)
|
|
||||||
|
|
||||||
installation.add_additional_packages(["nano", "wget", "git"])
|
|
||||||
|
|
||||||
profile_config = ProfileConfiguration(MinimalProfile())
|
|
||||||
profile_handler.install_profile_config(installation, profile_config)
|
|
||||||
|
|
||||||
user = User("devel", Password(plaintext="devel"), False)
|
|
||||||
installation.create_users(user)
|
|
||||||
|
|
||||||
# Once this is done, we output some useful information to the user
|
|
||||||
# And the installation is complete.
|
|
||||||
info("There are two new accounts in your installation after reboot:")
|
|
||||||
info(" * root (password: airoot)")
|
|
||||||
info(" * devel (password: devel)")
|
|
||||||
|
|
||||||
|
|
||||||
def _minimal() -> None:
|
|
||||||
with Tui():
|
|
||||||
disk_config = DiskLayoutConfigurationMenu(disk_layout_config=None).run()
|
|
||||||
|
|
||||||
disk_encryption = None
|
|
||||||
if disk_config:
|
|
||||||
disk_encryption = DiskEncryptionMenu(disk_config).run()
|
|
||||||
|
|
||||||
arch_config_handler.config.disk_config = disk_config
|
|
||||||
arch_config_handler.config.disk_encryption = disk_encryption
|
|
||||||
|
|
||||||
config = ConfigurationOutput(arch_config_handler.config)
|
|
||||||
config.write_debug()
|
|
||||||
config.save()
|
|
||||||
|
|
||||||
if arch_config_handler.args.dry_run:
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
if not arch_config_handler.args.silent:
|
|
||||||
with Tui():
|
|
||||||
if not config.confirm_config():
|
|
||||||
debug("Installation aborted")
|
|
||||||
_minimal()
|
|
||||||
|
|
||||||
if arch_config_handler.config.disk_config:
|
|
||||||
fs_handler = FilesystemHandler(
|
|
||||||
arch_config_handler.config.disk_config,
|
|
||||||
arch_config_handler.config.disk_encryption,
|
|
||||||
)
|
|
||||||
|
|
||||||
fs_handler.perform_filesystem_operations()
|
|
||||||
|
|
||||||
perform_installation(arch_config_handler.args.mountpoint)
|
|
||||||
|
|
||||||
|
|
||||||
_minimal()
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../archinstall/scripts/minimal.py
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from archinstall.lib.args import arch_config_handler
|
|
||||||
from archinstall.lib.configuration import ConfigurationOutput
|
|
||||||
from archinstall.lib.disk.filesystem import FilesystemHandler
|
|
||||||
from archinstall.lib.disk.utils import disk_layouts
|
|
||||||
from archinstall.lib.global_menu import GlobalMenu
|
|
||||||
from archinstall.lib.installer import Installer
|
|
||||||
from archinstall.lib.output import debug, error
|
|
||||||
from archinstall.tui import Tui
|
|
||||||
|
|
||||||
|
|
||||||
def ask_user_questions() -> None:
|
|
||||||
with Tui():
|
|
||||||
global_menu = GlobalMenu(arch_config_handler.config)
|
|
||||||
global_menu.disable_all()
|
|
||||||
|
|
||||||
global_menu.set_enabled("archinstall_language", True)
|
|
||||||
global_menu.set_enabled("disk_config", True)
|
|
||||||
global_menu.set_enabled("disk_encryption", True)
|
|
||||||
global_menu.set_enabled("swap", True)
|
|
||||||
global_menu.set_enabled("__config__", True)
|
|
||||||
|
|
||||||
global_menu.run()
|
|
||||||
|
|
||||||
|
|
||||||
def perform_installation(mountpoint: Path) -> None:
|
|
||||||
"""
|
|
||||||
Performs the installation steps on a block device.
|
|
||||||
Only requirement is that the block devices are
|
|
||||||
formatted and setup prior to entering this function.
|
|
||||||
"""
|
|
||||||
config = arch_config_handler.config
|
|
||||||
|
|
||||||
if not config.disk_config:
|
|
||||||
error("No disk configuration provided")
|
|
||||||
return
|
|
||||||
|
|
||||||
disk_config = config.disk_config
|
|
||||||
disk_encryption = config.disk_encryption
|
|
||||||
mountpoint = disk_config.mountpoint if disk_config.mountpoint else mountpoint
|
|
||||||
|
|
||||||
with Installer(
|
|
||||||
mountpoint,
|
|
||||||
disk_config,
|
|
||||||
disk_encryption=disk_encryption,
|
|
||||||
kernels=config.kernels,
|
|
||||||
) as installation:
|
|
||||||
# Mount all the drives to the desired mountpoint
|
|
||||||
# This *can* be done outside of the installation, but the installer can deal with it.
|
|
||||||
if disk_config:
|
|
||||||
installation.mount_ordered_layout()
|
|
||||||
|
|
||||||
# to generate a fstab directory holder. Avoids an error on exit and at the same time checks the procedure
|
|
||||||
target = Path(f"{mountpoint}/etc/fstab")
|
|
||||||
if not target.parent.exists():
|
|
||||||
target.parent.mkdir(parents=True)
|
|
||||||
|
|
||||||
# For support reasons, we'll log the disk layout post installation (crash or no crash)
|
|
||||||
debug(f"Disk states after installing:\n{disk_layouts()}")
|
|
||||||
|
|
||||||
|
|
||||||
def _only_hd() -> None:
|
|
||||||
if not arch_config_handler.args.silent:
|
|
||||||
ask_user_questions()
|
|
||||||
|
|
||||||
config = ConfigurationOutput(arch_config_handler.config)
|
|
||||||
config.write_debug()
|
|
||||||
config.save()
|
|
||||||
|
|
||||||
if arch_config_handler.args.dry_run:
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
if not arch_config_handler.args.silent:
|
|
||||||
with Tui():
|
|
||||||
if not config.confirm_config():
|
|
||||||
debug("Installation aborted")
|
|
||||||
_only_hd()
|
|
||||||
|
|
||||||
if arch_config_handler.config.disk_config:
|
|
||||||
fs_handler = FilesystemHandler(
|
|
||||||
arch_config_handler.config.disk_config,
|
|
||||||
arch_config_handler.config.disk_encryption,
|
|
||||||
)
|
|
||||||
|
|
||||||
fs_handler.perform_filesystem_operations()
|
|
||||||
|
|
||||||
perform_installation(arch_config_handler.args.mountpoint)
|
|
||||||
|
|
||||||
|
|
||||||
_only_hd()
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../archinstall/scripts/only_hd.py
|
||||||
Loading…
Reference in New Issue