Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--archinstall/__init__.py2
-rw-r--r--archinstall/lib/disk.py61
-rw-r--r--archinstall/lib/general.py54
-rw-r--r--archinstall/lib/hardware.py40
-rw-r--r--archinstall/lib/installer.py54
-rw-r--r--archinstall/lib/profiles.py43
-rw-r--r--archinstall/lib/user_interaction.py12
-rw-r--r--docs/archinstall/general.rst2
-rw-r--r--docs/installing/guided.rst2
-rw-r--r--examples/guided.py45
-rw-r--r--examples/minimal.py2
-rw-r--r--profiles/52-54-00-12-34-56.py2
-rw-r--r--profiles/applications/awesome.py6
-rw-r--r--profiles/applications/cinnamon.py4
-rw-r--r--profiles/applications/i3-gaps.py2
-rw-r--r--profiles/applications/i3-wm.py2
-rw-r--r--profiles/applications/kde-wayland.py7
-rw-r--r--profiles/applications/kde.py5
-rw-r--r--profiles/applications/xfce4.py4
-rw-r--r--profiles/awesome.py13
-rw-r--r--profiles/cinnamon.py (renamed from profiles/kde-wayland.py)25
-rw-r--r--profiles/desktop.py4
-rw-r--r--profiles/gnome.py2
-rw-r--r--profiles/i3-gaps.py43
-rw-r--r--profiles/i3-wm.py42
-rw-r--r--profiles/kde.py8
-rw-r--r--profiles/minimal.py20
-rw-r--r--profiles/xfce4.py35
-rw-r--r--profiles/xorg.py2
30 files changed, 454 insertions, 93 deletions
diff --git a/README.md b/README.md
index 2f3881e1..31ffc964 100644
--- a/README.md
+++ b/README.md
@@ -57,10 +57,10 @@ with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
This installer will perform the following:
* Prompt the user to select a disk and disk-password
- * Proceed to wipe the selected disk with a `GPT` partition table.
+ * Proceed to wipe the selected disk with a `GPT` partition table on a UEFI system and MBR on a bios system.
* Sets up a default 100% used disk with encryption.
* Installs a basic instance of Arch Linux *(base base-devel linux linux-firmware btrfs-progs efibootmgr)*
- * Installs and configures a bootloader to partition 0.
+ * Installs and configures a bootloader to partition 0 on uefi. on bios it sets the root to partition 0.
* Install additional packages *(nano, wget, git)*
* Installs a profile with a window manager called [awesome](https://github.com/archlinux/archinstall/blob/master/profiles/awesome.py) *(more on profile installations in the [documentation](https://python-archinstall.readthedocs.io/en/latest/archinstall/Profile.html))*.
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
index d98b6daa..8a49bef6 100644
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -2,7 +2,7 @@ from .lib.general import *
from .lib.disk import *
from .lib.user_interaction import *
from .lib.exceptions import *
-from .lib.installer import *
+from .lib.installer import __packages__, __base_packages__, Installer
from .lib.profiles import *
from .lib.luks import *
from .lib.mirrors import *
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index dbb69662..e2f4d76e 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -5,6 +5,7 @@ from .exceptions import DiskError
from .general import *
from .output import log, LOG_LEVELS
from .storage import storage
+from .hardware import hasUEFI
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
GPT = 0b00000001
@@ -73,7 +74,7 @@ class BlockDevice():
raise DiskError(f'Could not locate backplane info for "{self.path}"')
if self.info['type'] == 'loop':
- for drive in json.loads(b''.join(sys_command(f'losetup --json', hide_from_log=True)).decode('UTF_8'))['loopdevices']:
+ for drive in json.loads(b''.join(sys_command(['losetup', '--json'], hide_from_log=True)).decode('UTF_8'))['loopdevices']:
if not drive['name'] == self.path: continue
return drive['back-file']
@@ -94,10 +95,10 @@ class BlockDevice():
@property
def partitions(self):
- o = b''.join(sys_command(f'partprobe {self.path}'))
+ o = b''.join(sys_command(['partprobe', self.path]))
#o = b''.join(sys_command('/usr/bin/lsblk -o name -J -b {dev}'.format(dev=dev)))
- o = b''.join(sys_command(f'/usr/bin/lsblk -J {self.path}'))
+ o = b''.join(sys_command(['/usr/bin/lsblk', '-J', self.path]))
if b'not a block device' in o:
raise DiskError(f'Can not read partitions off something that isn\'t a block device: {self.path}')
@@ -219,7 +220,7 @@ class Partition():
if not self._encrypted:
return self.path
else:
- for blockdevice in json.loads(b''.join(sys_command('lsblk -J')).decode('UTF-8'))['blockdevices']:
+ for blockdevice in json.loads(b''.join(sys_command(['lsblk', '-J'])).decode('UTF-8'))['blockdevices']:
if (parent := self.find_parent_of(blockdevice, os.path.basename(self.path))):
return f"/dev/{parent}"
# raise DiskError(f'Could not find appropriate parent for encrypted partition {self}')
@@ -412,7 +413,7 @@ class Filesystem():
# TODO:
# When instance of a HDD is selected, check all usages and gracefully unmount them
# as well as close any crypto handles.
- def __init__(self, blockdevice, mode=GPT):
+ def __init__(self, blockdevice,mode):
self.blockdevice = blockdevice
self.mode = mode
@@ -425,6 +426,11 @@ class Filesystem():
return self
else:
raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt')
+ elif self.mode == MBR:
+ if sys_command(f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos').exit_code == 0:
+ return self
+ else:
+ raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos')
else:
raise DiskError(f'Unknown mode selected to format in: {self.mode}')
@@ -467,28 +473,39 @@ class Filesystem():
def use_entire_disk(self, root_filesystem_type='ext4'):
log(f"Using and formatting the entire {self.blockdevice}.", level=LOG_LEVELS.Debug)
- self.add_partition('primary', start='1MiB', end='513MiB', format='fat32')
- self.set_name(0, 'EFI')
- self.set(0, 'boot on')
- # TODO: Probably redundant because in GPT mode 'esp on' is an alias for "boot on"?
- # https://www.gnu.org/software/parted/manual/html_node/set.html
- self.set(0, 'esp on')
- self.add_partition('primary', start='513MiB', end='100%')
-
- self.blockdevice.partition[0].filesystem = 'vfat'
- self.blockdevice.partition[1].filesystem = root_filesystem_type
- log(f"Set the root partition {self.blockdevice.partition[1]} to use filesystem {root_filesystem_type}.", level=LOG_LEVELS.Debug)
-
- self.blockdevice.partition[0].target_mountpoint = '/boot'
- self.blockdevice.partition[1].target_mountpoint = '/'
-
- self.blockdevice.partition[0].allow_formatting = True
- self.blockdevice.partition[1].allow_formatting = True
+ if hasUEFI():
+ self.add_partition('primary', start='1MiB', end='513MiB', format='fat32')
+ self.set_name(0, 'EFI')
+ self.set(0, 'boot on')
+ # TODO: Probably redundant because in GPT mode 'esp on' is an alias for "boot on"?
+ # https://www.gnu.org/software/parted/manual/html_node/set.html
+ self.set(0, 'esp on')
+ self.add_partition('primary', start='513MiB', end='100%')
+
+ self.blockdevice.partition[0].filesystem = 'vfat'
+ self.blockdevice.partition[1].filesystem = root_filesystem_type
+ log(f"Set the root partition {self.blockdevice.partition[1]} to use filesystem {root_filesystem_type}.", level=LOG_LEVELS.Debug)
+
+ self.blockdevice.partition[0].target_mountpoint = '/boot'
+ self.blockdevice.partition[1].target_mountpoint = '/'
+
+ self.blockdevice.partition[0].allow_formatting = True
+ self.blockdevice.partition[1].allow_formatting = True
+ else:
+ #we don't need a seprate boot partition it would be a waste of space
+ self.add_partition('primary', start='1MB', end='100%')
+ self.blockdevice.partition[0].filesystem=root_filesystem_type
+ log(f"Set the root partition {self.blockdevice.partition[0]} to use filesystem {root_filesystem_type}.", level=LOG_LEVELS.Debug)
+ self.blockdevice.partition[0].target_mountpoint = '/'
+ self.blockdevice.partition[0].allow_formatting = True
def add_partition(self, type, start, end, format=None):
log(f'Adding partition to {self.blockdevice}', level=LOG_LEVELS.Info)
previous_partitions = self.blockdevice.partitions
+ if self.mode == MBR:
+ if len(self.blockdevice.partitions)>3:
+ DiskError("Too many partitions on disk, MBR disks can only have 3 parimary partitions")
if format:
partitioning = self.parted(f'{self.blockdevice.device} mkpart {type} {format} {start} {end}') == 0
else:
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index f2a714e7..5b1b3c2a 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -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, peak_output=False, *args, **kwargs):
kwargs.setdefault("worker_id", gen_uid())
kwargs.setdefault("emulate", False)
kwargs.setdefault("suppress_errors", False)
@@ -86,13 +86,22 @@ class sys_command():#Thread):
if kwargs['emulate']:
self.log(f"Starting command '{cmd}' in emulation mode.", level=LOG_LEVELS.Debug)
- self.raw_cmd = cmd
- try:
- self.cmd = shlex.split(cmd)
- except Exception as e:
- raise ValueError(f'Incorrect string to split: {cmd}\n{e}')
+ if type(cmd) is list:
+ # if we get a list of arguments
+ self.raw_cmd = shlex.join(cmd)
+ self.cmd = cmd
+ else:
+ # else consider it a single shell string
+ # this should only be used if really necessary
+ self.raw_cmd = cmd
+ try:
+ self.cmd = shlex.split(cmd)
+ except Exception as e:
+ raise ValueError(f'Incorrect string to split: {cmd}\n{e}')
+
self.args = args
self.kwargs = kwargs
+ self.peak_output = peak_output
self.kwargs.setdefault("worker", None)
self.callback = callback
@@ -150,6 +159,38 @@ class sys_command():#Thread):
'exit_code': self.exit_code
}
+ def peak(self, output :str):
+ if type(output) == bytes:
+ try:
+ output = output.decode('UTF-8')
+ except UnicodeDecodeError:
+ return None
+
+ output = output.strip('\r\n ')
+ if len(output) <= 0:
+ return None
+
+ if self.peak_output:
+ from .user_interaction import get_terminal_width
+
+ # Move back to the beginning of the terminal
+ sys.stdout.flush()
+ sys.stdout.write("\033[%dG" % 0)
+ sys.stdout.flush()
+
+ # Clear the line
+ sys.stdout.write(" " * get_terminal_width())
+ sys.stdout.flush()
+
+ # Move back to the beginning again
+ sys.stdout.flush()
+ sys.stdout.write("\033[%dG" % 0)
+ sys.stdout.flush()
+
+ # And print the new output we're peaking on:
+ sys.stdout.write(output)
+ sys.stdout.flush()
+
def run(self):
self.status = 'running'
old_dir = os.getcwd()
@@ -181,6 +222,7 @@ class sys_command():#Thread):
for fileno, event in poller.poll(0.1):
try:
output = os.read(child_fd, 8192)
+ self.peak(output)
self.trace_log += output
except OSError:
alive = False
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index 5828fd09..3da333de 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -1,14 +1,23 @@
-import os
+import os, subprocess, json
from .general import sys_command
from .networking import list_interfaces, enrichIfaceTypes
-
-def hasWifi():
+from typing import Optional
+def hasWifi()->bool:
return 'WIRELESS' in enrichIfaceTypes(list_interfaces().values()).values()
-def hasUEFI():
+def hasAMDCPU()->bool:
+ if subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode():
+ return True
+ return False
+def hasIntelCPU()->bool:
+ if subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode():
+ return True
+ return False
+
+def hasUEFI()->bool:
return os.path.isdir('/sys/firmware/efi')
-def graphicsDevices():
+def graphicsDevices()->dict:
cards = {}
for line in sys_command(f"lspci"):
if b' VGA ' in line:
@@ -16,13 +25,28 @@ def graphicsDevices():
cards[identifier.strip().lower().decode('UTF-8')] = line
return cards
-def hasNvidiaGraphics():
+def hasNvidiaGraphics()->bool:
return any('nvidia' in x for x in graphicsDevices())
-def hasAmdGraphics():
+def hasAmdGraphics()->bool:
return any('amd' in x for x in graphicsDevices())
-def hasIntelGraphics():
+def hasIntelGraphics()->bool:
return any('intel' in x for x in graphicsDevices())
+
+def cpuVendor()-> Optional[str]:
+ cpu_info = json.loads(subprocess.check_output("lscpu -J", shell=True).decode('utf-8'))['lscpu']
+ for info in cpu_info:
+ if info.get('field',None):
+ if info.get('field',None) == "Vendor ID:":
+ return info.get('data',None)
+
+def isVM() -> bool:
+ try:
+ subprocess.check_call(["systemd-detect-virt"]) # systemd-detect-virt issues a none 0 exit code if it is not on a virtual machine
+ return True
+ except:
+ return False
+
# TODO: Add more identifiers
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 1d277bc6..e9343cd1 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -1,4 +1,4 @@
-import os, stat, time, shutil, pathlib
+import os, stat, time, shutil, pathlib, subprocess
from .exceptions import *
from .disk import *
@@ -9,6 +9,10 @@ from .mirrors import *
from .systemd import Networkd
from .output import log, LOG_LEVELS
from .storage import storage
+from .hardware import *
+# Any package that the Installer() is responsible for (optional and the default ones)
+__packages__ = ["base", "base-devel", "linux", "linux-firmware", "efibootmgr", "nano", "ntp", "iwd"]
+__base_packages__ = __packages__[:6]
class Installer():
"""
@@ -34,7 +38,7 @@ class Installer():
:type hostname: str, optional
"""
- def __init__(self, partition, boot_partition, *, base_packages='base base-devel linux linux-firmware efibootmgr nano', profile=None, mountpoint='/mnt', hostname='ArchInstalled', logdir=None, logfile=None):
+ def __init__(self, partition, boot_partition, *, base_packages=__base_packages__, profile=None, mountpoint='/mnt', hostname='ArchInstalled', logdir=None, logfile=None):
self.profile = profile
self.hostname = hostname
self.mountpoint = mountpoint
@@ -52,7 +56,7 @@ class Installer():
'user' : False # Root counts as a user, if additional users are skipped.
}
- self.base_packages = base_packages.split(' ')
+ self.base_packages = base_packages.split(' ') if type(base_packages) is str else base_packages
self.post_base_install = []
storage['session'] = self
@@ -67,9 +71,11 @@ class Installer():
log(*args, level=level, **kwargs)
def __enter__(self, *args, **kwargs):
- self.partition.mount(self.mountpoint)
- os.makedirs(f'{self.mountpoint}/boot', exist_ok=True)
- self.boot_partition.mount(f'{self.mountpoint}/boot')
+ if hasUEFI():
+ # on bios we don't have a boot partition
+ self.partition.mount(self.mountpoint)
+ os.makedirs(f'{self.mountpoint}/boot', exist_ok=True)
+ self.boot_partition.mount(f'{self.mountpoint}/boot')
return self
def __exit__(self, *args, **kwargs):
@@ -133,7 +139,7 @@ class Installer():
self.log(f'Installing packages: {packages}', level=LOG_LEVELS.Info)
if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0:
- if (pacstrap := sys_command(f'/usr/bin/pacstrap {self.mountpoint} {" ".join(packages)}', **kwargs)).exit_code == 0:
+ if (pacstrap := sys_command(f'/usr/bin/pacstrap {self.mountpoint} {" ".join(packages)}', peak_output=True, **kwargs)).exit_code == 0:
return True
else:
self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=LOG_LEVELS.Info)
@@ -147,11 +153,11 @@ class Installer():
self.log(f"Updating {self.mountpoint}/etc/fstab", level=LOG_LEVELS.Info)
fstab = sys_command(f'/usr/bin/genfstab {flags} {self.mountpoint}').trace_log
- with open(f"{self.mountpoint}/etc/fstab", 'ab',newline='\n') as fstab_fh:
+ with open(f"{self.mountpoint}/etc/fstab", 'ab') as fstab_fh:
fstab_fh.write(fstab)
if not os.path.isfile(f'{self.mountpoint}/etc/fstab'):
- raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{b"".join(fstab)}')
+ raise RequirementError(f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n{fstab}')
return True
@@ -284,7 +290,14 @@ class Installer():
self.pacstrap(self.base_packages)
self.helper_flags['base-strapped'] = True
#self.genfstab()
-
+ if not isVM():
+ vendor = cpuVendor()
+ if vendor == "AuthenticAMD":
+ self.base_packages.append("amd-ucode")
+ elif vendor == "GenuineIntel":
+ self.base_packages.append("intel-ucode")
+ else:
+ self.log("unknown cpu vendor not installing ucode")
with open(f"{self.mountpoint}/etc/fstab", "a") as fstab:
fstab.write(
"\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n"
@@ -331,6 +344,8 @@ class Installer():
self.log(f'Adding bootloader {bootloader} to {self.boot_partition}', level=LOG_LEVELS.Info)
if bootloader == 'systemd-bootctl':
+ if not hasUEFI():
+ raise HardwareIncompatibilityError
# TODO: Ideally we would want to check if another config
# points towards the same disk and/or partition.
# And in which case we should do some clean up.
@@ -358,13 +373,20 @@ class Installer():
## For some reason, blkid and /dev/disk/by-uuid are not getting along well.
## And blkid is wrong in terms of LUKS.
#UUID = sys_command('blkid -s PARTUUID -o value {drive}{partition_2}'.format(**args)).decode('UTF-8').strip()
-
# Setup the loader entry
with open(f'{self.mountpoint}/boot/loader/entries/{self.init_time}.conf', 'w') as entry:
entry.write(f'# Created by: archinstall\n')
entry.write(f'# Created on: {self.init_time}\n')
entry.write(f'title Arch Linux\n')
entry.write(f'linux /vmlinuz-linux\n')
+ if not isVM():
+ vendor = cpuVendor()
+ if vendor == "AuthenticAMD":
+ entry.write("initrd /amd-ucode.img\n")
+ elif vendor == "GenuineIntel":
+ entry.write("initrd /intel-ucode.img\n")
+ else:
+ self.log("unknow cpu vendor, not adding ucode to systemd-boot config")
entry.write(f'initrd /initramfs-linux.img\n')
## blkid doesn't trigger on loopback devices really well,
## so we'll use the old manual method until we get that sorted out.
@@ -392,6 +414,16 @@ class Installer():
return True
raise RequirementError(f"Could not identify the UUID of {self.partition}, there for {self.mountpoint}/boot/loader/entries/arch.conf will be broken until fixed.")
+ elif bootloader == "grub-install":
+ if hasUEFI():
+ o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB'))
+ sys_command('/usr/bin/arch-chroot grub-mkconfig -o /boot/grub/grub.cfg')
+ else:
+ root_device = subprocess.check_output(f'basename "$(readlink -f "/sys/class/block/{self.partition.path.strip("/dev/")}/..")',shell=True).decode().strip()
+ if root_device == "block":
+ root_device = f"{self.partition.path}"
+ o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} grub-install --target=--target=i386-pc /dev/{root_device}'))
+ sys_command('/usr/bin/arch-chroot grub-mkconfig -o /boot/grub/grub.cfg')
else:
raise RequirementError(f"Unknown (or not yet implemented) bootloader added to add_bootloader(): {bootloader}")
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index 4ef6c533..7e76c891 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -178,6 +178,49 @@ class Profile(Script):
return True
return False
+ def has_post_install(self):
+ with open(self.path, 'r') as source:
+ source_data = source.read()
+
+ # Some crude safety checks, make sure the imported profile has
+ # a __name__ check and if so, check if it's got a _prep_function()
+ # we can call to ask for more user input.
+ #
+ # If the requirements are met, import with .py in the namespace to not
+ # trigger a traditional:
+ # if __name__ == 'moduleName'
+ if '__name__' in source_data and '_post_install' in source_data:
+ with self.load_instructions(namespace=f"{self.namespace}.py") as imported:
+ if hasattr(imported, '_post_install'):
+ return True
+
+ def is_top_level_profile(self):
+ with open(self.path, 'r') as source:
+ source_data = source.read()
+ return 'top_level_profile = True' in source_data
+
+ @property
+ def packages(self) -> list:
+ """
+ Returns a list of packages baked into the profile definition.
+ If no package definition has been done, .packages() will return None.
+ """
+ with open(self.path, 'r') as source:
+ source_data = source.read()
+
+ # Some crude safety checks, make sure the imported profile has
+ # a __name__ check before importing.
+ #
+ # If the requirements are met, import with .py in the namespace to not
+ # trigger a traditional:
+ # if __name__ == 'moduleName'
+ if '__name__' in source_data and '__packages__' in source_data:
+ with self.load_instructions(namespace=f"{self.namespace}.py") as imported:
+ if hasattr(imported, '__packages__'):
+ return imported.__packages__
+ return None
+
+
class Application(Profile):
def __repr__(self, *args, **kwargs):
return f'Application({os.path.basename(self.profile)})'
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 3830962c..b94bf3f5 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -103,15 +103,25 @@ def ask_for_a_timezone():
level=LOG_LEVELS.Warning,
fg='red'
)
+
+def ask_for_audio_selection():
+ 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"
+
+ return audio
def ask_to_configure_network():
# Optionally configure one network interface.
#while 1:
# {MAC: Ifname}
- interfaces = {'ISO-CONFIG' : 'Copy ISO network configuration to installation', **list_interfaces()}
+ interfaces = {'ISO-CONFIG' : 'Copy ISO network configuration to installation','NetworkManager':'Use NetworkManager to control and manage your internet connection', **list_interfaces()}
nic = generic_select(interfaces.values(), "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}
mode = generic_select(['DHCP (auto detect)', 'IP (static)'], f"Select which mode to configure for {nic}: ")
if mode == 'IP (static)':
while 1:
diff --git a/docs/archinstall/general.rst b/docs/archinstall/general.rst
index 0403ae30..776a38b1 100644
--- a/docs/archinstall/general.rst
+++ b/docs/archinstall/general.rst
@@ -12,7 +12,7 @@ Packages
========
.. autofunction:: archinstall.find_package
-
+Be
.. autofunction:: archinstall.find_packages
Locale related
diff --git a/docs/installing/guided.rst b/docs/installing/guided.rst
index 2e1cda09..8699ae62 100644
--- a/docs/installing/guided.rst
+++ b/docs/installing/guided.rst
@@ -1,5 +1,3 @@
-.. _installing.guided:
-
Guided installation
===================
diff --git a/examples/guided.py b/examples/guided.py
index ed838a29..66cc2405 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,5 +1,7 @@
import getpass, time, json, sys, signal, os
import archinstall
+from archinstall.lib.hardware import hasUEFI
+from archinstall.lib.profiles import Profile
"""
This signal-handler chain (and global variable)
@@ -166,7 +168,7 @@ def ask_user_questions():
# Ask for archinstall-specific profiles (such as desktop environments etc)
if not archinstall.arguments.get('profile', None):
- archinstall.arguments['profile'] = archinstall.select_profile(archinstall.list_profiles())
+ archinstall.arguments['profile'] = archinstall.select_profile(filter(lambda profile: (Profile(None, profile).is_top_level_profile()), archinstall.list_profiles()))
else:
archinstall.arguments['profile'] = archinstall.list_profiles()[archinstall.arguments['profile']]
@@ -180,6 +182,17 @@ def ask_user_questions():
)
exit(1)
+ # Ask about audio server selection if one is not already set
+ if not archinstall.arguments.get('audio', None):
+
+ # only ask for audio server selection on a desktop profile
+ if str(archinstall.arguments['profile']) == 'Profile(desktop)':
+ archinstall.arguments['audio'] = archinstall.ask_for_audio_selection()
+ else:
+ # packages installed by a profile may depend on audio and something may get installed anyways, not much we can do about that.
+ # we will not try to remove packages post-installation to not have audio, as that may cause multiple issues
+ archinstall.arguments['audio'] = 'none'
+
# Additional packages (with some light weight error handling for invalid package names)
if not archinstall.arguments.get('packages', None):
print("Packages not part of the desktop environment are not installed by default.")
@@ -248,7 +261,12 @@ def perform_installation_steps():
Setup the blockdevice, filesystem (and optionally encryption).
Once that's done, we'll hand over to perform_installation()
"""
- with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs:
+ # maybe we can ask the user what they would prefer on uefi systems?
+ if hasUEFI():
+ mode = archinstall.GPT
+ else:
+ 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:
fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get('filesystem', 'btrfs'))
@@ -315,14 +333,24 @@ def perform_installation(device, boot_partition, language, mirrors):
# Perform a copy of the config
if archinstall.arguments.get('nic', None) == '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):
+ 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):
installation.configure_nic(**archinstall.arguments.get('nic', {}))
installation.enable_service('systemd-networkd')
installation.enable_service('systemd-resolved')
-
+ if archinstall.arguments.get('audio', None) != None:
+ installation.log(f"The {archinstall.arguments.get('audio', None)} audio server will be used.", level=archinstall.LOG_LEVELS.Info)
+ if archinstall.arguments.get('audio', None) == 'pipewire':
+ print('Installing pipewire ...')
+ installation.add_additional_packages(["pipewire", "pipewire-alsa", "pipewire-docs", "pipewire-jack", "pipewire-media-session", "pipewire-pulse", "gst-plugin-pipewire", "libpulse"])
+ elif archinstall.arguments.get('audio', None) == 'pulseaudio':
+ print('Installing pulseaudio ...')
+ installation.add_additional_packages("pulseaudio")
+
if archinstall.arguments.get('packages', None) and archinstall.arguments.get('packages', None)[0] != '':
installation.add_additional_packages(archinstall.arguments.get('packages', None))
@@ -340,7 +368,14 @@ def perform_installation(device, boot_partition, language, mirrors):
if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw):
installation.user_set_pw('root', root_pw)
-
+ 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():
+ archinstall.log(
+ ' * Profile\'s post configuration requirements was not fulfilled.',
+ fg='red'
+ )
+ exit(1)
ask_user_questions()
perform_installation_steps()
diff --git a/examples/minimal.py b/examples/minimal.py
index 9124f5bd..6016bbbf 100644
--- a/examples/minimal.py
+++ b/examples/minimal.py
@@ -8,7 +8,7 @@ archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', suppress_error
harddrive = archinstall.select_disk(archinstall.all_disks())
disk_password = getpass.getpass(prompt='Disk password (won\'t echo): ')
-with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
+with archinstall.Filesystem(harddrive) as fs:
# Use the entire disk instead of setting up partitions on your own
fs.use_entire_disk('luks2')
diff --git a/profiles/52-54-00-12-34-56.py b/profiles/52-54-00-12-34-56.py
index 679c6721..ed2c9d78 100644
--- a/profiles/52-54-00-12-34-56.py
+++ b/profiles/52-54-00-12-34-56.py
@@ -11,7 +11,7 @@ archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', suppress_error
harddrive = archinstall.all_disks()['/dev/sda']
disk_password = '1234'
-with archinstall.Filesystem(harddrive, archinstall.GPT) as fs:
+with archinstall.Filesystem(harddrive) as fs:
# Use the entire disk instead of setting up partitions on your own
fs.use_entire_disk('luks2')
diff --git a/profiles/applications/awesome.py b/profiles/applications/awesome.py
index 578f246e..b8d779c0 100644
--- a/profiles/applications/awesome.py
+++ b/profiles/applications/awesome.py
@@ -1,10 +1,10 @@
import archinstall
+__packages__ = ["awesome", "xorg-xrandr", "xterm", "feh", "slock", "terminus-font", "gnu-free-fonts", "ttf-liberation", "xsel"]
+
installation.install_profile('xorg')
-installation.add_additional_packages(
- "awesome xorg-xrandr xterm feh slock terminus-font gnu-free-fonts ttf-liberation xsel"
-)
+installation.add_additional_packages(__packages__)
with open(f'{installation.mountpoint}/etc/X11/xinit/xinitrc', 'r') as xinitrc:
xinitrc_data = xinitrc.read()
diff --git a/profiles/applications/cinnamon.py b/profiles/applications/cinnamon.py
new file mode 100644
index 00000000..af1cbee2
--- /dev/null
+++ b/profiles/applications/cinnamon.py
@@ -0,0 +1,4 @@
+import archinstall
+
+installation.add_additional_packages("cinnamon system-config-printer gnome-keyring gnome-terminal blueberry metacity lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings")
+# We'll create a cinnamon-minimal later, but for now, we'll avoid issues by giving more than we need.
diff --git a/profiles/applications/i3-gaps.py b/profiles/applications/i3-gaps.py
new file mode 100644
index 00000000..4dd95989
--- /dev/null
+++ b/profiles/applications/i3-gaps.py
@@ -0,0 +1,2 @@
+import archinstall
+installation.add_additional_packages("i3lock i3status i3blocks 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..8662497d
--- /dev/null
+++ b/profiles/applications/i3-wm.py
@@ -0,0 +1,2 @@
+import archinstall
+installation.add_additional_packages("i3lock i3status i3blocks i3-wm") \ No newline at end of file
diff --git a/profiles/applications/kde-wayland.py b/profiles/applications/kde-wayland.py
deleted file mode 100644
index 6a9be294..00000000
--- a/profiles/applications/kde-wayland.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import archinstall
-packages = "plasma-meta kde-applications-meta plasma-wayland-session sddm"
-# if the package selection can be reduced go for it
-if "nvidia" in _gfx_driver_packages:
- packages = packages + " egl-wayland"
-installation.add_additional_packages(packages)
-# We'll support plasma-desktop-wayland (minimal) later
diff --git a/profiles/applications/kde.py b/profiles/applications/kde.py
index 87a266b0..af1e6597 100644
--- a/profiles/applications/kde.py
+++ b/profiles/applications/kde.py
@@ -1,2 +1,5 @@
import archinstall
-installation.add_additional_packages("plasma-meta kde-applications-meta sddm") # We'll support plasma-desktop (minimal) later iirc sddm should be part of plasma-meta
+packages = "plasma-meta konsole kate dolphin sddm plasma-wayland-session"
+if "nvidia" in _gfx_driver_packages:
+ packages = packages + " egl-wayland"
+installation.add_additional_packages(packages)
diff --git a/profiles/applications/xfce4.py b/profiles/applications/xfce4.py
new file mode 100644
index 00000000..6d6f8f7c
--- /dev/null
+++ b/profiles/applications/xfce4.py
@@ -0,0 +1,4 @@
+import archinstall
+
+installation.add_additional_packages("xfce4 xfce4-goodies lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings")
+# We'll create a xfce4-minimal later, but for now, we'll avoid issues by giving more than we need.
diff --git a/profiles/awesome.py b/profiles/awesome.py
index a565ccb3..0d133962 100644
--- a/profiles/awesome.py
+++ b/profiles/awesome.py
@@ -2,6 +2,11 @@
import archinstall
+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__ = ['nano', 'nemo', 'gpicview-gtk3', 'openssh', 'sshfs', 'htop', 'scrot', 'wget']
def _prep_function(*args, **kwargs):
"""
@@ -28,13 +33,7 @@ if __name__ == 'awesome':
awesome = archinstall.Application(installation, 'awesome')
awesome.install()
- # Then setup and configure the desktop environment: awesome
- editor = "nano"
- filebrowser = "nemo gpicview-gtk3"
- utils = "openssh sshfs htop scrot wget"
-
-
- installation.add_additional_packages(f"{utils} {filebrowser} {editor}")
+ installation.add_additional_packages(__packages__)
alacritty = archinstall.Application(installation, 'alacritty')
alacritty.install()
diff --git a/profiles/kde-wayland.py b/profiles/cinnamon.py
index e21f62c8..1a796bc7 100644
--- a/profiles/kde-wayland.py
+++ b/profiles/cinnamon.py
@@ -1,7 +1,7 @@
-# A desktop environment using "KDE".
-import archinstall, os
+# A desktop environment using "Cinnamon"
+import archinstall
-# TODO: Remove hard dependency of bash (due to .bash_profile)
+is_top_level_profile = False
def _prep_function(*args, **kwargs):
"""
@@ -11,7 +11,7 @@ def _prep_function(*args, **kwargs):
for more input before any other installer steps start.
"""
- # KDE requires a functioning Xorg installation.
+ # Cinnamon requires a functioning Xorg installation.
profile = archinstall.Profile(None, 'xorg')
with profile.load_instructions(namespace='xorg.py') as imported:
if hasattr(imported, '_prep_function'):
@@ -20,15 +20,14 @@ def _prep_function(*args, **kwargs):
print('Deprecated (??): xorg profile has no _prep_function() anymore')
# Ensures that this code only gets executed if executed
-# through importlib.util.spec_from_file_location("kde", "/somewhere/kde.py")
-# or through conventional import kde
-if __name__ == 'kde-wayland':
+# through importlib.util.spec_from_file_location("cinnamon", "/somewhere/cinnamon.py")
+# or through conventional import cinnamon
+if __name__ == 'cinnamon':
# Install dependency profiles
installation.install_profile('xorg')
- # Install the application kde from the template under /applications/
- kde = archinstall.Application(installation, 'kde-wayland')
- kde.install()
- print("when you login, select Plasma (Wayland) for the wayland session")
- # Enable autostart of KDE for all users
- installation.enable_service('sddm')
+ # Install the application cinnamon from the template under /applications/
+ cinnamon = archinstall.Application(installation, 'cinnamon')
+ cinnamon.install()
+
+ installation.enable_service('lightdm') # Light Display Manager
diff --git a/profiles/desktop.py b/profiles/desktop.py
index 41a2ad8b..389198d6 100644
--- a/profiles/desktop.py
+++ b/profiles/desktop.py
@@ -2,6 +2,8 @@
import archinstall, os
+is_top_level_profile = True
+
def _prep_function(*args, **kwargs):
"""
Magic function called by the importing installer
@@ -10,7 +12,7 @@ def _prep_function(*args, **kwargs):
for more input before any other installer steps start.
"""
- supported_desktops = ['gnome', 'kde', 'awesome']
+ supported_desktops = ['gnome', 'kde', 'awesome', 'xfce4', 'cinnamon', 'i3-gaps', 'i3-wm']
desktop = archinstall.generic_select(supported_desktops, 'Select your desired desktop environment: ')
# Temporarily store the selected desktop profile
diff --git a/profiles/gnome.py b/profiles/gnome.py
index b37679de..c75cafee 100644
--- a/profiles/gnome.py
+++ b/profiles/gnome.py
@@ -2,6 +2,8 @@
import archinstall
+is_top_level_profile = False
+
def _prep_function(*args, **kwargs):
"""
Magic function called by the importing installer
diff --git a/profiles/i3-gaps.py b/profiles/i3-gaps.py
new file mode 100644
index 00000000..e900117a
--- /dev/null
+++ b/profiles/i3-gaps.py
@@ -0,0 +1,43 @@
+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.
+ """
+
+ # 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')
+
+def _post_install(*args, **kwargs):
+ """
+ Another magic function called after the system
+ has been installed.
+ """
+ installation.log("the installation of i3 does not conatain any configuerations for the wm. In this shell you should take your time to add your desiired configueration. Exit the shell once you are done to continue the installation.", fg="yellow")
+ try:
+ subprocess.check_call("arch-chroot /mnt",shell=True)
+ except subprocess.CallProcessError:
+ return False
+
+ return True
+
+if __name__ == 'i3-wm':
+ # 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")
+ # install the i3 group now
+ i3 = archinstall.Application(installation, 'i3-gaps')
+ i3.install()
+ # Auto start lightdm for all users
+ installation.enable_service('lightdm')
diff --git a/profiles/i3-wm.py b/profiles/i3-wm.py
new file mode 100644
index 00000000..a2449e39
--- /dev/null
+++ b/profiles/i3-wm.py
@@ -0,0 +1,42 @@
+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.
+ """
+
+ # 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')
+def _post_install(*args, **kwargs):
+ """
+ Another magic function called after the system
+ has been installed.
+ """
+ installation.log("the installation of i3 does not conatain any configuerations for the wm. In this shell you should take your time to add your desiired configueration. Exit the shell once you are done to continue the installation.", fg="yellow")
+ try:
+ subprocess.check_call("arch-chroot /mnt",shell=True)
+ except subprocess.CallProcessError:
+ return False
+
+ return True
+
+if __name__ == 'i3-wm':
+ # Install dependency profiles
+ installation.install_profile('xorg')
+ # we are installing lightdm to auto start i3
+ installation.add_additional_packages("lightdm-gtk-greeter lightdm")
+ # install the i3 group now
+ i3 = archinstall.Application(installation, 'i3-wm')
+ i3.install()
+ # Auto start lightdm for all users
+ installation.enable_service('lightdm')
diff --git a/profiles/kde.py b/profiles/kde.py
index 32819bd5..d6abe029 100644
--- a/profiles/kde.py
+++ b/profiles/kde.py
@@ -2,6 +2,8 @@
import archinstall, os
+is_top_level_profile = False
+
# TODO: Remove hard dependency of bash (due to .bash_profile)
def _prep_function(*args, **kwargs):
@@ -20,6 +22,12 @@ def _prep_function(*args, **kwargs):
else:
print('Deprecated (??): xorg profile has no _prep_function() anymore')
+def _post_install(*args, **kwargs):
+ if "nvidia" in _gfx_driver_packages:
+ print("Plasma Wayland has known compatibility issues with the proprietary Nvidia driver")
+ print("After booting, you can choose between Wayland and Xorg using the drop-down menu")
+ return True
+
# Ensures that this code only gets executed if executed
# through importlib.util.spec_from_file_location("kde", "/somewhere/kde.py")
# or through conventional import kde
diff --git a/profiles/minimal.py b/profiles/minimal.py
new file mode 100644
index 00000000..79821a89
--- /dev/null
+++ b/profiles/minimal.py
@@ -0,0 +1,20 @@
+# Used to do a minimal install
+
+import archinstall, os
+
+is_top_level_profile = True
+
+def _prep_function(*args, **kwargs):
+ """
+ Magic function called by the importing installer
+ before continuing any further. For minimal install,
+ we don't need to do anything special here, but it
+ needs to exist and return True.
+ """
+ return True # Do nothing and just return True
+
+if __name__ == 'minimal':
+ """
+ This "profile" is a meta-profile.
+ It is used for a custom minimal installation, without any desktop-specific packages.
+ """
diff --git a/profiles/xfce4.py b/profiles/xfce4.py
new file mode 100644
index 00000000..c8637eda
--- /dev/null
+++ b/profiles/xfce4.py
@@ -0,0 +1,35 @@
+
+# A desktop environment using "Xfce4"
+
+is_top_level_profile = False
+
+import archinstall
+
+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.
+ """
+
+ # XFCE requires a functional 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')
+
+# Ensures that this code only gets executed if executed
+# through importlib.util.spec_from_file_location("xfce4", "/somewhere/xfce4.py")
+# or through conventional import xfce4
+if __name__ == 'xfce4':
+ # Install dependency profiles
+ installation.install_profile('xorg')
+
+ # Install the application xfce4 from the template under /applications/
+ xfce = archinstall.Application(installation, 'xfce4')
+ xfce.install()
+
+ installation.enable_service('lightdm') # Light Display Manager
diff --git a/profiles/xorg.py b/profiles/xorg.py
index 1282b8a5..e905d533 100644
--- a/profiles/xorg.py
+++ b/profiles/xorg.py
@@ -2,6 +2,8 @@
import archinstall, os
+is_top_level_profile = True
+
AVAILABLE_DRIVERS = {
# Sub-dicts are layer-2 options to be selected
# and lists are a list of packages to be installed