summaryrefslogtreecommitdiff
path: root/iso/root
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-01-21 14:40:55 +0000
committerdavidovski <david@davidovski.xyz>2023-01-21 14:40:55 +0000
commitbc5cdd7f0a7bf1d0f1478ade5085b2089a21515f (patch)
treef890ccadd41c60f17f5181cafb4adfe84a92d9c8 /iso/root
parentcaa260edd5b9b49f1f4c3d78022805ceee38a0e3 (diff)
Add full chroot for mkiso
Diffstat (limited to 'iso/root')
-rwxr-xr-xiso/root/installer.sh48
1 files changed, 32 insertions, 16 deletions
diff --git a/iso/root/installer.sh b/iso/root/installer.sh
index de06852..d2654ac 100755
--- a/iso/root/installer.sh
+++ b/iso/root/installer.sh
@@ -9,6 +9,7 @@ DEBUG_MODE=false
logfile="installer.log"
default_packages="base xipkg dracut grub doas neofetch vim tzdata mksh"
additional_services="networkmanager xorg iwd"
+cmdline=""
OPT_KERNEL="linux-libre"
OPT_BOOTSYSTEM="efi"
@@ -45,7 +46,7 @@ list_disks () {
}
list_partitions () {
- ls $1*
+ lsblk $1 -nlp -o NAME
echo "none"
}
@@ -97,6 +98,8 @@ encrypt_disk () {
#dd if=/dev/zero of=/dev/mapper/to_be_wiped >> $logfile
#cryptsetup close to_be_wiped >> $logfile
+ default_packages="$default_packages crypsetup lvm2"
+
partition_disk $ROOT_DISK
enter_password "disk encryption password"
t_msg "Encrypting $ROOT_DISK.."
@@ -109,6 +112,11 @@ encrypt_disk () {
lvcreate -l 100%FREE xilinux -n root >> $logfile
+ uuid="$(blkid --probe --output value --match-tag UUID $SYS_PART)"
+
+ cmdline="rd.luks.uuid=luks-$uuid rd.lvm.lv=xilinux/root root=/dev/xilinux/root rootflags=rw,relatime"
+ default_packages="$default_packages lvm2 cryptsetup"
+
export SYS_PART=/dev/xilinux/root
return 0
}
@@ -119,12 +127,14 @@ partition_disks () {
local selected=$(echo $T_RESULT | cut -d' ' -f1)
export ROOT_DISK=$selected
- t_yesno "${BLUE}Use full disk encryption?" && {
- export OPT_ENCRYPTION="lvm-luks"
- encrypt_disk $ROOT_DISK
- return 0
- } || t_yesno "${BLUE}Auto-partition $selected disk?\n${RED}(Warning: existing data will be overwritten)" && {
- partition_disk $selected || return 1
+ t_yesno "${BLUE}Auto-partition $selected disk?\n${RED}(Warning: existing data will be overwritten)" && {
+ t_yesno "${BLUE}Use full disk encryption?" && {
+ export OPT_ENCRYPTION="lvm-luks"
+ encrypt_disk $ROOT_DISK
+ return 0
+ } || {
+ partition_disk $selected || return 1
+ }
} || {
cfdisk $selected && {
t_radio 'Select primary system partition' $(list_partitions $selected)
@@ -173,15 +183,17 @@ mount_disks () {
[ -b "$SYS_PART" ] && {
mount $SYS_PART $sysroot
+ true
} || {
t_prompt "${RED}No system partition is available!"
return 1
}
- echo "[efi] mounting $EFI_PART to $efi_mntpoint" >> $logfile
+ echo "[efi] mounting $EFI_PART to ${efi_mntpoint}" >> $logfile
[ -b "$EFI_PART" ] && {
mkdir -p $efi_mntpoint
mount $EFI_PART $efi_mntpoint
+ true
}
[ -b "$SWAP_PART" ] && swapon $SWAP_PART
@@ -217,6 +229,7 @@ copy_resolvconf () {
sync_system () {
t_msg "Syncing system..."
xichroot $sysroot xi sync >> $logfile
+ return 0
}
generate_fstab () {
@@ -229,7 +242,7 @@ build_initramfs () {
mkdir -p $sysroot/var/tmp
for kernel_version in $(ls $sysroot/usr/lib/modules); do
t_msg "Building initramfs for $kernel_version..."
- xichroot $sysroot dracut --kver $kernel_version 2>&1 >> $logfile
+ xichroot $sysroot dracut --kver $kernel_version 2>> $logfile >> $logfile
done
}
@@ -237,7 +250,7 @@ install_grub () {
t_yesno "Install grub?" && {
[ "$OPT_BOOTSYSTEM" = "efi" ] && {
target="x86_64-efi"
- opts="--target=$target --efi-directory=$efi_mntpoint"
+ opts="--target=$target --efi-directory=${efi_mntpoint#$sysroot}"
t_yesno "Install as removable system?" && opts="--removable $opts " || true
} || {
target="i386-pc"
@@ -245,9 +258,11 @@ install_grub () {
}
t_msg "Installing grub for target $target..."
+ echo "[grub] installing with $opts" >> $logfile
xichroot $sysroot grub-install $opts >> $logfile
t_msg "Creating grub configuration..."
+ sed -i "s@GRUB_CMDLINE_LINUX_DEFAULT=\".*\"@GRUB_CMDLINE_LINUX_DEFAULT=\"$cmdline\"@g" $sysroot/etc/default/grub
xichroot $sysroot grub-mkconfig -o /boot/grub/grub.cfg
t_prompt "Installed grub for $target"
@@ -374,6 +389,7 @@ service_xorg () {
t_msg "Installing xorg..."
xi -qvly -r $sysroot install base-xorg base-fonts >> $logfile
t_check "Select video drivers:" $(xi search xf86-video- | cut -f2 -d/)
+ t_msg "Installing $T_RESULT..."
[ "${#T_RESULT}" != "0" ] && xi -r $sysroot install $T_RESULT >> $logfile
t_prompt "Installed basic xorg functionality
TODO: preconfigured window managers, for now you need to configure them yourself"
@@ -394,7 +410,7 @@ umount_disks () {
t_msg "Unmounting disks..."
umount -R $sysroot
[ -b "$SWAP_PART" ] && swapoff $SWAP_PART
- [ "$OPT_ENCRYPTION" = "lvm-luks"] && cryptsetup close cryptlvm
+ [ "$OPT_ENCRYPTION" = "lvm-luks" ] && cryptsetup close cryptlvm
return 0
}
@@ -417,13 +433,12 @@ mount_disks
prompt_kernel
bootstrap_system
install_base
-copy_resolvconf
+build_initramfs
+install_grub
configure_hostname
select_timezone
-sync_system
+copy_resolvconf
generate_fstab
-build_initramfs
-install_grub
configure_users
fix_permissions
install_additional
@@ -444,8 +459,9 @@ $DEBUG_MODE && {
for step in $steps; do
t_cls_ptrn
+ echo "[installer] doing step $step" >> $logfile
$step 2>> $logfile || {
- t_prompt "${RED}An error occured!"
+ t_prompt "${RED}An error occurred!"
t_clean
exit 1
}