Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/luks.py7
-rw-r--r--archinstall/lib/user_interaction.py46
-rw-r--r--examples/guided.py50
-rw-r--r--examples/minimal.py78
-rw-r--r--profiles/applications/i3-gaps.py2
-rw-r--r--profiles/applications/i3-wm.py2
-rw-r--r--profiles/applications/lxqt.py2
-rw-r--r--profiles/applications/sway.py4
-rw-r--r--profiles/desktop.py4
-rw-r--r--profiles/i3-gaps.py17
-rw-r--r--profiles/i3-wm.py17
-rw-r--r--profiles/i3.py72
-rw-r--r--profiles/sway.py2
13 files changed, 221 insertions, 82 deletions
diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py
index a1d42196..561d4d6e 100644
--- a/archinstall/lib/luks.py
+++ b/archinstall/lib/luks.py
@@ -1,5 +1,7 @@
import os
import shlex
+import time
+import pathlib
from .exceptions import *
from .general import *
from .disk import Partition
@@ -123,6 +125,11 @@ class luks2():
from .disk import get_filesystem_type
if '/' in mountpoint:
os.path.basename(mountpoint) # TODO: Raise exception instead?
+
+ wait_timer = time.time()
+ while pathlib.Path(partition.path).exists() is False and time.time() - wait_timer < 10:
+ time.sleep(0.025)
+
sys_command(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --key-file {os.path.abspath(key_file)} --type luks2')
if os.path.islink(f'/dev/mapper/{mountpoint}'):
self.mapdev = f'/dev/mapper/{mountpoint}'
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 3830962c..1f5924e4 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -1,4 +1,5 @@
import getpass, pathlib, os, shutil, re
+import sys, time, signal
from .exceptions import *
from .profiles import Profile
from .locale_helpers import search_keyboard_layout
@@ -19,14 +20,49 @@ def get_longest_option(options):
return max([len(x) for x in options])
def check_for_correct_username(username):
- if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32:
- return True
- log(
+ if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32:
+ return True
+ log(
"The username you entered is invalid. Try again",
level=LOG_LEVELS.Warning,
fg='red'
)
- return False
+ return False
+
+def do_countdown():
+ SIG_TRIGGER = False
+ def kill_handler(sig, frame):
+ print()
+ exit(0)
+
+ def sig_handler(sig, frame):
+ global SIG_TRIGGER
+ SIG_TRIGGER = True
+ signal.signal(signal.SIGINT, kill_handler)
+
+ original_sigint_handler = signal.getsignal(signal.SIGINT)
+ signal.signal(signal.SIGINT, sig_handler)
+
+ for i in range(5, 0, -1):
+ print(f"{i}", end='')
+
+ for x in range(4):
+ sys.stdout.flush()
+ time.sleep(0.25)
+ print(".", end='')
+
+ if SIG_TRIGGER:
+ abort = input('\nDo you really want to abort (y/n)? ')
+ if abort.strip() != 'n':
+ exit(0)
+
+ if SIG_TRIGGER is False:
+ sys.stdin.read()
+ SIG_TRIGGER = False
+ signal.signal(signal.SIGINT, sig_handler)
+ print()
+ signal.signal(signal.SIGINT, original_sigint_handler)
+ return True
def get_password(prompt="Enter a password: "):
while (passwd := getpass.getpass(prompt)):
@@ -184,7 +220,7 @@ def generic_select(options, input_text="Select one of the above by index or abso
return None
elif selected_option.isdigit():
selected_option = int(selected_option)
- if selected_option >= len(options):
+ if selected_option > len(options):
raise RequirementError(f'Selected option "{selected_option}" is out of range')
selected_option = options[selected_option]
elif selected_option in options:
diff --git a/examples/guided.py b/examples/guided.py
index a28aa50e..6feebd00 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,30 +1,8 @@
-import getpass, time, json, sys, signal, os
+import getpass, time, json, os
import archinstall
from archinstall.lib.hardware import hasUEFI
from archinstall.lib.profiles import Profile
-"""
-This signal-handler chain (and global variable)
-is used to trigger the "Are you sure you want to abort?" question further down.
-It might look a bit odd, but have a look at the line: "if SIG_TRIGGER:"
-"""
-SIG_TRIGGER = False
-def kill_handler(sig, frame):
- print()
- exit(0)
-
-def sig_handler(sig, frame):
- global SIG_TRIGGER
- SIG_TRIGGER = True
- signal.signal(signal.SIGINT, kill_handler)
-
-original_sigint_handler = signal.getsignal(signal.SIGINT)
-signal.signal(signal.SIGINT, sig_handler)
-
-if archinstall.arguments.get('help'):
- print("See `man archinstall` for help.")
- exit(0)
-
def ask_user_questions():
"""
First, we'll ask the user for a bunch of user input.
@@ -206,8 +184,6 @@ def ask_user_questions():
def perform_installation_steps():
- global SIG_TRIGGER
-
print()
print('This is your chosen configuration:')
archinstall.log("-- Guided template chosen (with below config) --", level=archinstall.LOG_LEVELS.Debug)
@@ -222,29 +198,7 @@ def perform_installation_steps():
"""
print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='')
-
- for i in range(5, 0, -1):
- print(f"{i}", end='')
-
- for x in range(4):
- sys.stdout.flush()
- time.sleep(0.25)
- print(".", end='')
-
- if SIG_TRIGGER:
- abort = input('\nDo you really want to abort (y/n)? ')
- if abort.strip() != 'n':
- exit(0)
-
- if SIG_TRIGGER is False:
- sys.stdin.read()
- SIG_TRIGGER = False
- signal.signal(signal.SIGINT, sig_handler)
-
- # Put back the default/original signal handler now that we're done catching
- # and interrupting SIGINT with "Do you really want to abort".
- print()
- signal.signal(signal.SIGINT, original_sigint_handler)
+ archinstall.do_countdown()
"""
Setup the blockdevice, filesystem (and optionally encryption).
diff --git a/examples/minimal.py b/examples/minimal.py
index 9124f5bd..367574b5 100644
--- a/examples/minimal.py
+++ b/examples/minimal.py
@@ -1,30 +1,64 @@
import archinstall, getpass
-# Unmount and close previous runs
-archinstall.sys_command(f'umount -R /mnt', suppress_errors=True)
-archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', suppress_errors=True)
-
# Select a harddrive and a disk password
-harddrive = archinstall.select_disk(archinstall.all_disks())
-disk_password = getpass.getpass(prompt='Disk password (won\'t echo): ')
+archinstall.log(f"Minimal only supports:")
+archinstall.log(f" * Being installed to a single disk")
+
+if archinstall.arguments.get('help', None):
+ archinstall.log(f" - Optional disk encryption via --!encryption-password=<password>")
+ archinstall.log(f" - Optional filesystem type via --filesystem=<fs type>")
+ archinstall.log(f" - Optional systemd network via --network")
+
+archinstall.arguments['harddrive'] = archinstall.select_disk(archinstall.all_disks())
+archinstall.arguments['harddrive'].keep_partitions = False
+
+def install_on(root, boot):
+ # We kick off the installer by telling it where the root and boot lives
+ with archinstall.Installer(root, boot_partition=boot, hostname='minimal-arch') 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.add_bootloader()
+
+ # Optionally enable networking:
+ if archinstall.arguments.get('network', None):
+ installation.copy_ISO_network_config(enable_services=True)
+
+ installation.add_additional_packages(['nano', 'wget', 'git'])
+ installation.install_profile('minimal')
+
+ installation.user_create('devel', 'devel')
+ installation.user_set_pw('root', 'airoot')
+
+ # Once this is done, we output some useful information to the user
+ # And the installation is complete.
+ archinstall.log(f"There are two new accounts in your installation after reboot:")
+ archinstall.log(f" * root (password: airoot)")
+ archinstall.log(f" * devel (password: devel)")
+
+print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='')
+archinstall.do_countdown()
+
+# First, we configure the basic filesystem layout
+with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs:
+ # We use the entire disk instead of setting up partitions on your own
+ if archinstall.arguments['harddrive'].keep_partitions is False:
+ fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get('filesystem', 'btrfs'))
-with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
- # Use the entire disk instead of setting up partitions on your own
- fs.use_entire_disk('luks2')
+ boot = fs.find_partition('/boot')
+ root = fs.find_partition('/')
- if harddrive.partition[1].size == '512M':
- raise OSError('Trying to encrypt the boot partition for petes sake..')
- harddrive.partition[0].format('fat32')
+ boot.format('vfat')
- with archinstall.luks2(harddrive.partition[1], 'luksloop', disk_password) as unlocked_device:
- unlocked_device.format('btrfs')
-
- with archinstall.Installer(unlocked_device, boot_partition=harddrive.partition[0], hostname='testmachine') as installation:
- if installation.minimal_installation():
- installation.add_bootloader()
+ # We encrypt the root partition if we got a password to do so with,
+ # Otherwise we just skip straight to formatting and installation
+ if archinstall.arguments.get('!encryption-password', None):
+ root.encrypt()
- installation.add_additional_packages(['nano', 'wget', 'git'])
- installation.install_profile('minimal')
+ with archinstall.luks2(root, 'luksloop', archinstall.arguments.get('!encryption-password', None)) as unlocked_root:
+ unlocked_root.format(root.filesystem)
- installation.user_create('devel', 'devel')
- installation.user_set_pw('root', 'toor')
+ install_on(unlocked_root)
+ else:
+ root.format(root.filesystem)
+ install_on(root, boot) \ No newline at end of file
diff --git a/profiles/applications/i3-gaps.py b/profiles/applications/i3-gaps.py
new file mode 100644
index 00000000..4daed7ad
--- /dev/null
+++ b/profiles/applications/i3-gaps.py
@@ -0,0 +1,2 @@
+import archinstall
+installation.add_additional_packages("i3-gaps") \ No newline at end of file
diff --git a/profiles/applications/i3-wm.py b/profiles/applications/i3-wm.py
new file mode 100644
index 00000000..e7838a64
--- /dev/null
+++ b/profiles/applications/i3-wm.py
@@ -0,0 +1,2 @@
+import archinstall
+installation.add_additional_packages("i3-wm") \ No newline at end of file
diff --git a/profiles/applications/lxqt.py b/profiles/applications/lxqt.py
index f2a75e0e..5ce875cc 100644
--- a/profiles/applications/lxqt.py
+++ b/profiles/applications/lxqt.py
@@ -1,3 +1,3 @@
import archinstall
-installation.add_additional_packages("lxqt breeze-icons sddm")
+installation.add_additional_packages("lxqt breeze-icons oxygen-icons xdg-utils ttf-freefont leafpad slock archlinux-wallpaper sddm")
diff --git a/profiles/applications/sway.py b/profiles/applications/sway.py
index 5f66233c..c99f378a 100644
--- a/profiles/applications/sway.py
+++ b/profiles/applications/sway.py
@@ -1,3 +1,3 @@
import archinstall
-
-installation.add_additional_packages("sway sddm")
+packages = "sway swaylock swayidle dmenu alacritty"
+installation.add_additional_packages(packages)
diff --git a/profiles/desktop.py b/profiles/desktop.py
index 4c6255e7..e2850da4 100644
--- a/profiles/desktop.py
+++ b/profiles/desktop.py
@@ -6,7 +6,7 @@ is_top_level_profile = True
# New way of defining packages for a profile, which is iterable and can be used out side
# of the profile to get a list of "what packages will be installed".
-__packages__ = ['nano', 'openssh', 'htop', 'wget', 'iwd', 'wireless_tools', 'wpa_supplicant', 'smartmontools']
+__packages__ = ['nano', 'vim', 'openssh', 'htop', 'wget', 'iwd', 'wireless_tools', 'wpa_supplicant', 'smartmontools']
def _prep_function(*args, **kwargs):
"""
@@ -16,7 +16,7 @@ def _prep_function(*args, **kwargs):
for more input before any other installer steps start.
"""
- supported_desktops = ['gnome', 'kde', 'awesome', 'sway', 'cinnamon', 'xfce4', 'lxqt']
+ supported_desktops = ['gnome', 'kde', 'awesome', 'sway', 'cinnamon', 'xfce4', 'lxqt', 'i3']
desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ')
# Temporarily store the selected desktop profile
diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py
new file mode 100644
index 00000000..ddca34b7
--- /dev/null
+++ b/profiles/i3-gaps.py
@@ -0,0 +1,17 @@
+import archinstall, subprocess
+
+is_top_level_profile = False
+
+def _prep_function(*args, **kwargs):
+ """
+ Magic function called by the importing installer
+ before continuing any further. It also avoids executing any
+ other code in this stage. So it's a safe way to ask the user
+ for more input before any other installer steps start.
+ """
+ return True
+
+if __name__ == 'i3-gaps':
+ # install the i3 group now
+ i3 = archinstall.Application(installation, 'i3-gaps')
+ i3.install()
diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py
new file mode 100644
index 00000000..4a0415fc
--- /dev/null
+++ b/profiles/i3-wm.py
@@ -0,0 +1,17 @@
+import archinstall, subprocess
+
+is_top_level_profile = False
+
+def _prep_function(*args, **kwargs):
+ """
+ Magic function called by the importing installer
+ before continuing any further. It also avoids executing any
+ other code in this stage. So it's a safe way to ask the user
+ for more input before any other installer steps start.
+ """
+ return True
+
+if __name__ == 'i3-wm':
+ # install the i3 group now
+ i3 = archinstall.Application(installation, 'i3-wm')
+ i3.install()
diff --git a/profiles/i3.py b/profiles/i3.py
new file mode 100644
index 00000000..9f58e7eb
--- /dev/null
+++ b/profiles/i3.py
@@ -0,0 +1,72 @@
+# Common package for i3, lets user select which i3 configuration they want.
+
+import archinstall, os
+
+is_top_level_profile = False
+
+# New way of defining packages for a profile, which is iterable and can be used out side
+# of the profile to get a list of "what packages will be installed".
+__packages__ = ['i3lock', 'i3status', 'i3blocks']
+
+def _prep_function(*args, **kwargs):
+ """
+ Magic function called by the importing installer
+ before continuing any further. It also avoids executing any
+ other code in this stage. So it's a safe way to ask the user
+ for more input before any other installer steps start.
+ """
+
+ supported_configurations = ['i3-wm', 'i3-gaps']
+ desktop = archinstall.generic_select(supported_configurations, 'Select your desired configuration: ')
+
+ # Temporarily store the selected desktop profile
+ # in a session-safe location, since this module will get reloaded
+ # the next time it gets executed.
+ archinstall.storage['_desktop_profile'] = desktop
+
+ # i3 requires a functioning Xorg installation.
+ profile = archinstall.Profile(None, 'xorg')
+ with profile.load_instructions(namespace='xorg.py') as imported:
+ if hasattr(imported, '_prep_function'):
+ return imported._prep_function()
+ else:
+ print('Deprecated (??): xorg profile has no _prep_function() anymore')
+
+ profile = archinstall.Profile(None, desktop)
+ # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered.
+ with profile.load_instructions(namespace=f"{desktop}.py") as imported:
+ if hasattr(imported, '_prep_function'):
+ return imported._prep_function()
+ else:
+ print(f"Deprecated (??): {desktop} profile has no _prep_function() anymore")
+
+if __name__ == 'i3':
+ """
+ This "profile" is a meta-profile.
+ There are no desktop-specific steps, it simply routes
+ the installer to whichever desktop environment/window manager was chosen.
+
+ Maybe in the future, a network manager or similar things *could* be added here.
+ We should honor that Arch Linux does not officially endorse a desktop-setup, nor is
+ it trying to be a turn-key desktop distribution.
+
+ There are plenty of desktop-turn-key-solutions based on Arch Linux,
+ this is therefore just a helper to get started
+ """
+
+ # Install common packages for all i3 configurations
+ installation.add_additional_packages(__packages__)
+
+ # Install dependency profiles
+ installation.install_profile('xorg')
+
+ # gaps is installed by deafult so we are overriding it here
+ installation.add_additional_packages("lightdm-gtk-greeter lightdm")
+
+ # Auto start lightdm for all users
+ installation.enable_service('lightdm')
+
+ # TODO: Remove magic variable 'installation' and place it
+ # in archinstall.storage or archinstall.session/archinstall.installation
+ installation.install_profile(archinstall.storage['_desktop_profile'])
+
diff --git a/profiles/sway.py b/profiles/sway.py
index fd8407df..5633cce2 100644
--- a/profiles/sway.py
+++ b/profiles/sway.py
@@ -20,5 +20,3 @@ if __name__ == 'sway':
# Install the application sway from the template under /applications/
sway = archinstall.Application(installation, 'sway')
sway.install()
-
- installation.enable_service('sddm') # SDDM, which supports Sway