updated the installer so that it should actually work
Some checks failed
Build / build (push) Failing after 5m23s

This commit is contained in:
tumillanino
2025-11-11 18:57:02 +11:00
parent a7bd4d9457
commit 33dd952ad4
583 changed files with 161651 additions and 67 deletions

View File

@@ -0,0 +1,23 @@
# Ensure user is in sudo group
for group in $(groups); do
if [[ $group == 'wheel' || $group == 'sudo' ]]; then
declare -ri sudo_ok=1
fi
done
# If user is not in sudo group notify and exit with error
if [[ ! -n $sudo_ok ]]; then
quit_on_err 'The current user is not a member of either the sudo or wheel group, this os-installer configuration requires sudo permissions'
fi
# Ensure all expected osi variables are set
[[ -z ${OSI_LOCALE+x} ]] && quit_on_err 'OSI_LOCALE not set'
[[ -z ${OSI_DEVICE_PATH+x} ]] && quit_on_err 'OSI_DEVICE_PATH not set'
[[ -z ${OSI_DEVICE_IS_PARTITION+x} ]] && quit_on_err 'OSI_DEVICE_IS_PARTITION not set'
[[ -z ${OSI_DEVICE_EFI_PARTITION+x} ]] && quit_on_err 'OSI_DEVICE_EFI_PARTITION not set'
[[ -z ${OSI_USE_ENCRYPTION+x} ]] && quit_on_err 'OSI_USE_ENCRYPTION not set'
[[ -z ${OSI_ENCRYPTION_PIN+x} ]] && quit_on_err 'OSI_ENCRYPTION_PIN not set'
# Check if something is already mounted to $workdir
mountpoint -q $workdir &&
quit_on_err "$workdir is already a mountpoint, unmount this directory and try again"

View File

@@ -0,0 +1,99 @@
# Write partition table to the disk unless manual partitioning is used
if [[ $OSI_DEVICE_IS_PARTITION -eq 0 ]]; then
sudo sfdisk $OSI_DEVICE_PATH < $osidir/bits/part.sfdisk ||
quit_on_err 'Failed to write partition table to disk'
fi
# NVMe drives follow a slightly different naming scheme to other block devices
# this will change `/dev/nvme0n1` to `/dev/nvme0n1p` for easier parsing later
if [[ $OSI_DEVICE_IS_PARTITION -ne 0 ]]; then
declare -r partition_path="${OSI_DEVICE_PATH}"
elif [[ $OSI_DEVICE_PATH == *"nvme"*"n"* ]]; then
declare -r partition_path="${OSI_DEVICE_PATH}p"
elif [[ $OSI_DEVICE_PATH == *"mmcblk"* ]]; then
declare -r partition_path="${OSI_DEVICE_PATH}p"
else
declare -r partition_path="${OSI_DEVICE_PATH}"
fi
# Check if encryption is requested, write filesystems accordingly
if [[ $OSI_USE_ENCRYPTION -eq 1 ]]; then
# If user requested disk encryption
if [[ $OSI_DEVICE_IS_PARTITION -eq 0 ]]; then
# If target is a drive
sudo mkfs.fat -F32 ${partition_path}1 -n $bootlabel || quit_on_err "Failed to create FAT filesystem on ${partition_path}1"
echo $OSI_ENCRYPTION_PIN | sudo cryptsetup -q luksFormat ${partition_path}2 ||
quit_on_err "Failed to create LUKS partition on ${partition_path}2"
echo $OSI_ENCRYPTION_PIN | sudo cryptsetup open ${partition_path}2 $rootlabel - ||
quit_on_err 'Failed to unlock LUKS partition'
sudo mkfs.btrfs -f -L $rootlabel /dev/mapper/$rootlabel ||
quit_on_err 'Failed to create Btrfs partition on LUKS'
sudo mount -o compress=zstd /dev/mapper/$rootlabel $workdir ||
quit_on_err "Failed to mount LUKS/Btrfs root partition to $workdir"
sudo mount --mkdir ${partition_path}1 $workdir/boot ||
quit_on_err 'Failed to mount boot'
else
# If target is a partition
sudo mkfs.fat -F32 $OSI_DEVICE_EFI_PARTITION -n $bootlabel ||
quit_on_err "Failed to create FAT filesystem on $OSI_DEVICE_EFI_PARTITION"
echo $OSI_ENCRYPTION_PIN | sudo cryptsetup -q luksFormat $OSI_DEVICE_PATH ||
quit_on_err "Failed to create LUKS partition on $OSI_DEVICE_PATH"
echo $OSI_ENCRYPTION_PIN | sudo cryptsetup open $OSI_DEVICE_PATH $rootlabel - ||
quit_on_err 'Failed to unlock LUKS partition'
sudo mkfs.btrfs -f -L $rootlabel /dev/mapper/$rootlabel ||
quit_on_err 'Failed to create Btrfs partition on LUKS'
sudo mount -o compress=zstd /dev/mapper/$rootlabel $workdir ||
quit_on_err "Failed to mount LUKS/Btrfs root partition to $workdir"
sudo mount --mkdir $OSI_DEVICE_EFI_PARTITION $workdir/boot ||
quit_on_err 'Failed to mount boot'
fi
else
# If no disk encryption requested
if [[ $OSI_DEVICE_IS_PARTITION -eq 0 ]]; then
# If target is a drive
sudo mkfs.fat -F32 ${partition_path}1 -n $bootlabel ||
quit_on_err "Failed to create FAT filesystem on ${partition_path}1"
sudo mkfs.btrfs -f -L $rootlabel ${partition_path}2 ||
quit_on_err "Failed to create root on ${partition_path}2"
sudo mount -o compress=zstd ${partition_path}2 $workdir ||
quit_on_err "Failed to mount root to $workdir"
sudo mount --mkdir ${partition_path}1 $workdir/boot ||
quit_on_err 'Failed to mount boot'
else
# If target is a partition
sudo mkfs.fat -F32 $OSI_DEVICE_EFI_PARTITION -n $bootlabel ||
quit_on_err "Failed to create FAT filesystem on $OSI_EFI_PARTITION"
sudo mkfs.btrfs -f -L $rootlabel $OSI_DEVICE_PATH ||
quit_on_err "Failed to create root on $OSI_DEVICE_PATH"
sudo mount -o compress=zstd $OSI_DEVICE_PATH $workdir ||
quit_on_err "Failed to mount root to $workdir"
sudo mount --mkdir $OSI_DEVICE_EFI_PARTITION $workdir/boot ||
quit_on_err 'Failed to mount boot'
fi
fi
# Ensure partitions are mounted, quit and error if not
for mountpoint in $workdir $workdir/boot; do
mountpoint -q $mountpoint ||
quit_on_err "No volume mounted to $mountpoint"
done

View File

@@ -0,0 +1,14 @@
# Manually install the systemd-boot bootloader
sudo mkdir -p $workdir/boot/EFI/{BOOT,systemd} $workdir/boot/loader/entries ||
quit_on_err 'Failed to create bootloader directories'
# TODO: Grab this from the image instead?
sudo cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi $workdir/boot/EFI/systemd/ ||
quit_on_err 'Failed to copy systemd-boot bootloader to systemd-bootx64.efi'
sudo cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi $workdir/boot/EFI/BOOT/BOOTx64.EFI ||
quit_on_err 'Failed to copy systemd-boot bootloader to BOOTx64.EFI'
printf 'timeout 5\nconsole-mode max\neditor yes\nauto-entries yes\nauto-firmware yes' |
sudo tee $workdir/boot/loader/loader.conf ||
quit_on_err 'Failed to create loader.conf'

View File

@@ -0,0 +1,3 @@
# Initialize arkdep
sudo ARKDEP_NO_BOOTCTL=1 ARKDEP_ROOT="$workdir" arkdep init ||
quit_on_err 'Failed to init arkep'