159 lines
3.6 KiB
Fish
159 lines
3.6 KiB
Fish
#!/usr/bin/env fish
|
|
|
|
# reads input, $argv[1] is default result
|
|
function ask
|
|
if test -z $argv[1]
|
|
read -p "echo '> '"
|
|
else
|
|
read -p "echo '[$argv[1]]> '" input
|
|
if test -z $input
|
|
echo $argv[1]
|
|
else
|
|
echo $input
|
|
end
|
|
end
|
|
end
|
|
|
|
# 2.. is valid responses
|
|
function asklist
|
|
while true
|
|
set -l answer (ask $argv[1])
|
|
switch $answer
|
|
case $argv[2..]
|
|
echo $answer
|
|
return 0
|
|
case "*"
|
|
echo "invalid response"
|
|
# this loops in the `while true`
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
function askyesno
|
|
while true
|
|
switch (ask $argv[1])
|
|
case y yes
|
|
return 0
|
|
case n no
|
|
return 1
|
|
case "*"
|
|
echo "should be yes or no!"
|
|
# this loops in the `while true`
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
if not pacman -Syi base
|
|
echo "pacman not working, are you connected to the internet?"
|
|
exit 1
|
|
end
|
|
|
|
echo "---"
|
|
echo "MOUNT"
|
|
echo "---"
|
|
mount | grep "on /mnt" | cat
|
|
echo "---"
|
|
echo "SWAP"
|
|
echo "---"
|
|
swapon
|
|
echo "make sure to create, format, and mount/swap partitions first!"
|
|
echo "all the relevant partitions are expected to be empty and mounted appropriately in /mnt"
|
|
echo "make sure to have a root partition, and a swap partition between 1x and 2x your system ram"
|
|
echo "the installer also assumes you use a swap PARTITION, and only one"
|
|
|
|
switch (cat /sys/firmware/efi/fw_platform_size)
|
|
case 64
|
|
echo "grub target will be 64 bit UEFI, check to make sure this is correct"
|
|
case 32
|
|
echo "grub target will be 32 bit UEFI, check to make sure this is correct"
|
|
case ""
|
|
echo "grub target will be BIOS (not uefi), check to make sure this is correct"
|
|
case "*"
|
|
echo "fw_platform_size is some weird unknown value!"
|
|
echo "normally it would be 64, 32, or nothing to indicate uefi/bios"
|
|
exit 1
|
|
end
|
|
echo "# say yes to continue ONLY if you have checked all of these things and they are correct"
|
|
if not askyesno no
|
|
exit 1
|
|
end
|
|
|
|
|
|
# extract overlay into system
|
|
tar xf overlay.tar --directory=/mnt
|
|
|
|
# make /mnt/etc/fstab
|
|
set -lx swapdevice
|
|
begin
|
|
function getdevice
|
|
set -l uuid (lsblk $argv[1] -rno uuid)
|
|
if test -n $uuid
|
|
echo UUID=$uuid
|
|
else
|
|
echo $words[1]
|
|
end
|
|
end
|
|
for mountline in (mount | grep "on /mnt")
|
|
set -l words (string split " " $mountline)
|
|
set -l device (getdevice $words[1])
|
|
set -l mountpoint $words[3]
|
|
set -l filesystem $words[5]
|
|
set -l options defaults
|
|
if test $filesystem = btrfs
|
|
# TODO subvol
|
|
if false
|
|
set -a options subvol=
|
|
end
|
|
end
|
|
set -l check (
|
|
switch $path
|
|
case "/"
|
|
echo 1
|
|
case "/*"
|
|
echo 2
|
|
case "*"
|
|
echo 0
|
|
end
|
|
)
|
|
echo "$device $mountpoint $filesystem $(string join , $options) 0 $check" >> /mnt/etc/fstab
|
|
end
|
|
set -l swaplines (swapon --raw --noheadings --show=NAME,PRIO)
|
|
if test (count $swaplines) -gt 1
|
|
echo "pick a swap device to use for hibernate (number on the left)"
|
|
echo "0 for no hibernate"
|
|
set -l fullswaplist swapon --show=NAME,LABEL,TYPE,SIZE,PRIO,UUID
|
|
set -l swaplist $fullswaplist[2..]
|
|
echo " $fullswaplist[1]"
|
|
for i in (seq (count $swaplist))
|
|
echo "$i $swaplist[i]"
|
|
end
|
|
set swapdevice (asklist 1 (seq (count $swaplist)))
|
|
end
|
|
for swapline in $swaplines
|
|
set -l words (string split " " $swapline)
|
|
set -l device (getdevice $words[1])
|
|
set -l options defaults
|
|
if test $words[2] -ge 0
|
|
set -a options pri=$words[2]
|
|
end
|
|
echo "$device none swap $(string join , $options) 0 0" >> /mnt/etc/fstab
|
|
end
|
|
end
|
|
|
|
echo "```"
|
|
cat /mnt/etc/fstab
|
|
echo "```"
|
|
echo "the default shell is now open so you can work on the fstab file if there are any errors"
|
|
echo "use the `exit` command to continue"
|
|
$SHELL
|
|
|
|
# pacstrap
|
|
pacstrap -K /mnt base linux-zen linux-zen-headers linux-firmware fish
|
|
|
|
arch-chroot /mnt /bin/fish in-chroot.fish
|
|
|
|
echo "finished! you can reboot and start using your system now"
|