Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/config-sample.json35
-rw-r--r--examples/guided.py53
2 files changed, 72 insertions, 16 deletions
diff --git a/examples/config-sample.json b/examples/config-sample.json
new file mode 100644
index 00000000..55bdf04b
--- /dev/null
+++ b/examples/config-sample.json
@@ -0,0 +1,35 @@
+{
+ "!root-password": "<root_password>",
+ "audio": null,
+ "bootloader": "systemd-bootctl",
+ "filesystem": "btrfs",
+ "harddrive": {
+ "path": "/dev/sda"
+ },
+ "hostname": "box",
+ "kernels": [
+ "linux"
+ ],
+ "keyboard-language": "us",
+ "mirror-region": {
+ "Worldwide": {
+ "https://mirror.rackspace.com/archlinux/$repo/os/$arch": true
+ }
+ },
+ "nic": {
+ "NetworkManager": true
+ },
+ "packages": [],
+ "profile": null,
+ "superusers": {
+ "<username>": {
+ "!password": "<password>"
+ }
+ },
+ "timezone": "UTC",
+ "users": {
+ "<username>": {
+ "!password": "<password>"
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/guided.py b/examples/guided.py
index cce06b29..f0d0db7a 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,10 +1,12 @@
import json
import logging
+import os
import time
import archinstall
from archinstall.lib.hardware import has_uefi
from archinstall.lib.networking import check_mirror_reachable
+from archinstall.lib.profiles import Profile
if archinstall.arguments.get('help'):
print("See `man archinstall` for help.")
@@ -51,7 +53,7 @@ def ask_user_questions():
else:
archinstall.arguments['harddrive'] = archinstall.select_disk(archinstall.all_disks())
if archinstall.arguments['harddrive'] is None:
- archinstall.arguments['target-mount'] = '/mnt'
+ archinstall.arguments['target-mount'] = archinstall.storage.get('MOUNT_POINT', '/mnt')
# Perform a quick sanity check on the selected harddrive.
# 1. Check if it has partitions
@@ -242,7 +244,8 @@ def perform_installation_steps():
archinstall.log(json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON), level=logging.INFO)
print()
- input('Press Enter to continue.')
+ if not archinstall.arguments.get('silent'):
+ input('Press Enter to continue.')
"""
Issue a final warning before we continue with something un-revertable.
@@ -260,7 +263,6 @@ def perform_installation_steps():
mode = archinstall.GPT
if has_uefi() is False:
mode = archinstall.MBR
-
with archinstall.Filesystem(archinstall.arguments['harddrive'], mode) as fs:
# Wipe the entire drive if the disk flag `keep_partitions`is False.
if archinstall.arguments['harddrive'].keep_partitions is False:
@@ -291,14 +293,14 @@ def perform_installation_steps():
# unlocks the drive so that it can be used as a normal block-device within archinstall.
with archinstall.luks2(fs.find_partition('/'), 'luksloop', archinstall.arguments.get('!encryption-password', None)) as unlocked_device:
unlocked_device.format(fs.find_partition('/').filesystem)
- unlocked_device.mount('/mnt')
+ unlocked_device.mount(archinstall.storage.get('MOUNT_POINT', '/mnt'))
else:
- fs.find_partition('/').mount('/mnt')
+ fs.find_partition('/').mount(archinstall.storage.get('MOUNT_POINT', '/mnt'))
if has_uefi():
- fs.find_partition('/boot').mount('/mnt/boot')
+ fs.find_partition('/boot').mount(archinstall.storage.get('MOUNT_POINT', '/mnt') + '/boot')
- perform_installation('/mnt')
+ perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt'))
def perform_installation(mountpoint):
@@ -324,7 +326,6 @@ def perform_installation(mountpoint):
installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium
if archinstall.arguments["bootloader"] == "grub-install" and has_uefi():
installation.add_additional_packages("grub")
- installation.set_keyboard_language(archinstall.arguments['keyboard-language'])
installation.add_bootloader(archinstall.arguments["bootloader"])
# If user selected to copy the current ISO network configuration
@@ -370,6 +371,10 @@ def perform_installation(mountpoint):
if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw):
installation.user_set_pw('root', root_pw)
+ # This step must be after profile installs to allow profiles to install language pre-requisits.
+ # After which, this step will set the language both for console and x11 if x11 was installed for instance.
+ installation.set_keyboard_language(archinstall.arguments['keyboard-language'])
+
if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_post_install():
with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported:
if not imported._post_install():
@@ -377,20 +382,36 @@ def perform_installation(mountpoint):
exit(1)
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
+ if not archinstall.arguments.get('silent'):
+ 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
# For support reasons, we'll log the disk layout post installation (crash or no crash)
archinstall.log(f"Disk states after installing: {archinstall.disk_layouts()}", level=logging.DEBUG)
if not check_mirror_reachable():
- archinstall.log("Arch Linux mirrors are not reachable. Please check your internet connection and try again.", level=logging.INFO, fg="red")
+ log_file = os.path.join(archinstall.storage.get('LOG_PATH', None), archinstall.storage.get('LOG_FILE', None))
+ 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)
-ask_user_questions()
+if archinstall.arguments.get('silent', None) is None:
+ ask_user_questions()
+else:
+ # Workarounds if config is loaded from a file
+ # The harddrive section should be moved to perform_installation_steps, where it's actually being performed
+ # Blockdevice object should be created in perform_installation_steps
+ # This needs to be done until then
+ archinstall.arguments['harddrive'] = archinstall.BlockDevice(path=archinstall.arguments['harddrive']['path'])
+ # Temporarily disabling keep_partitions if config file is loaded
+ archinstall.arguments['harddrive'].keep_partitions = False
+ # Temporary workaround to make Desktop Environments work
+ archinstall.storage['_desktop_profile'] = archinstall.arguments.get('desktop', None)
+ if archinstall.arguments.get('profile', None):
+ archinstall.arguments['profile'] = Profile(installer=None, path=archinstall.arguments['profile']['path'])
+
perform_installation_steps()