Installer Stage 1: implement up to where packages are first installed
parent
9eab022029
commit
52fa691909
|
@ -0,0 +1,150 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function press_any_key {
|
||||||
|
echo "Press any key to continue or Ctrl+c to abort."
|
||||||
|
read -n1 DISCARD_ME
|
||||||
|
}
|
||||||
|
|
||||||
|
function are_you_really_really_sure {
|
||||||
|
echo "Enter the following to continue: $1"
|
||||||
|
read DISCARD_ME
|
||||||
|
if [ "$1" = "$DISCARD_ME" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clear
|
||||||
|
echo "
|
||||||
|
This script will now install Void Linux on your USB stick.
|
||||||
|
It will be formatted and will not be usable from Windows or MacOS.
|
||||||
|
|
||||||
|
Before we begin, let’s make sure some dependencies are installed on the host/live system:
|
||||||
|
- up-to-date xbps
|
||||||
|
- xmirror
|
||||||
|
- squashfs-tools"
|
||||||
|
press_any_key
|
||||||
|
|
||||||
|
xbps-install --sync
|
||||||
|
xbps-install --yes --update xbps
|
||||||
|
xbps-install --yes xmirror squashfs-tools
|
||||||
|
|
||||||
|
#TODO: If going down the path of extracting routines from void-installer and
|
||||||
|
# xmirror, that should be done here.
|
||||||
|
|
||||||
|
#TODO: Select keyboard layout
|
||||||
|
|
||||||
|
clear
|
||||||
|
echo "Select the USB stick to install to (NAME column below)...
|
||||||
|
"
|
||||||
|
lsblk --nodeps --output NAME,SIZE,MODEL
|
||||||
|
echo ""
|
||||||
|
read -p "> " TARGET_DISK
|
||||||
|
|
||||||
|
while [ ! -b "/dev/$TARGET_DISK" ]; do
|
||||||
|
lsblk --nodeps --output NAME,SIZE,MODEL
|
||||||
|
echo "$TARGET_DISK is not a valid device!"
|
||||||
|
read -p "> " TARGET_DISK
|
||||||
|
done
|
||||||
|
|
||||||
|
clear
|
||||||
|
echo "Selected device:"
|
||||||
|
lsblk --output NAME,SIZE,MODEL,LABEL,FSTYPE "/dev/$TARGET_DISK"
|
||||||
|
echo "
|
||||||
|
WARNING: The selected device will be wiped, partitioned, and formatted.
|
||||||
|
ALL DATA ON IT WILL BE LOST PERMANENTLY.
|
||||||
|
It will not be usable with Windows or MacOS while holding Void.
|
||||||
|
"
|
||||||
|
if are_you_really_really_sure "Yes, erase it."; then
|
||||||
|
true
|
||||||
|
else
|
||||||
|
echo "Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# new GPT
|
||||||
|
# 2M BIOS GRUB
|
||||||
|
# 268M ESP
|
||||||
|
# 1G boot
|
||||||
|
# everything else one big partition
|
||||||
|
echo "g
|
||||||
|
n
|
||||||
|
|
||||||
|
|
||||||
|
+2M
|
||||||
|
n
|
||||||
|
|
||||||
|
|
||||||
|
+268M
|
||||||
|
n
|
||||||
|
|
||||||
|
|
||||||
|
+1G
|
||||||
|
n
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
t
|
||||||
|
1
|
||||||
|
4
|
||||||
|
t
|
||||||
|
2
|
||||||
|
1
|
||||||
|
t
|
||||||
|
3
|
||||||
|
136
|
||||||
|
t
|
||||||
|
4
|
||||||
|
20
|
||||||
|
w" | fdisk --wipe always --wipe-partitions always "/dev/$TARGET_DISK"
|
||||||
|
TARGET_PART_BIOS="$(lsblk --raw --noheadings --output PATH "/dev/$TARGET_DISK" | sed -n '2p')"
|
||||||
|
TARGET_PART_EFI="$(lsblk --raw --noheadings --output PATH "/dev/$TARGET_DISK" | sed -n '3p')"
|
||||||
|
TARGET_PART_BOOT="$(lsblk --raw --noheadings --output PATH "/dev/$TARGET_DISK" | sed -n '4p')"
|
||||||
|
TARGET_PART_BIG="$(lsblk --raw --noheadings --output PATH "/dev/$TARGET_DISK" | sed -n '5p')"
|
||||||
|
|
||||||
|
mkfs.vfat -F32 "$TARGET_PART_EFI"
|
||||||
|
mkfs.f2fs -f "$TARGET_PART_BOOT"
|
||||||
|
mkfs.f2fs -f "$TARGET_PART_BIG"
|
||||||
|
|
||||||
|
mkdir -p /mnt/target
|
||||||
|
mount -t tmpfs -o size=3g tmpfs /mnt/target
|
||||||
|
#TODO don't use default permissions for tmpfs
|
||||||
|
mkdir /mnt/target/boot
|
||||||
|
mount "$TARGET_PART_BOOT" /mnt/target/boot
|
||||||
|
mkdir /mnt/target/boot/efi
|
||||||
|
mount "$TARGET_PART_EFI" /mnt/target/boot/efi
|
||||||
|
mkdir -p /mnt/target/mnt/container
|
||||||
|
mount "$TARGET_PART_BIG" /mnt/target/mnt/container
|
||||||
|
mkdir /mnt/target/home
|
||||||
|
mkdir /mnt/target/mnt/container/home
|
||||||
|
mount --bind /mnt/target/mnt/container/home /mnt/target/home
|
||||||
|
|
||||||
|
clear
|
||||||
|
echo "Storage is now prepared and ready for installation.
|
||||||
|
|
||||||
|
You need to select a download mirror for Void next.
|
||||||
|
The script will launch xmirror on the host system and read the mirror
|
||||||
|
from the config file it generates."
|
||||||
|
press_any_key
|
||||||
|
|
||||||
|
xmirror
|
||||||
|
TARGET_MIRROR="$(sed 's/repository=//;s|/musl$||' /etc/xbps.d/00-repository-main.conf)"
|
||||||
|
|
||||||
|
#TODO: select installation type
|
||||||
|
TARGET_TYPE="x86_64-musl"
|
||||||
|
|
||||||
|
if grep "musl" <<< "$TARGET_TYPE"; then
|
||||||
|
TARGET_MIRROR="$TARGET_MIRROR/musl"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /mnt/target/var/db/xbps/keys
|
||||||
|
cp /var/db/xbps/keys/* /mnt/target/var/db/xbps/keys/
|
||||||
|
|
||||||
|
XBPS_ARCH="$TARGET_TYPE" xbps-install -S -r /mnt -R "$TARGET_MIRROR" \
|
||||||
|
linux bash shadow f2fs-tools dosfstools dbus NetworkManager iana-etc \
|
||||||
|
iw wpa_supplicant util-linux which tar man-pages iproute2 iputils \
|
||||||
|
wifi-firmware traceroute grep gzip file sed gawk less coreutils findutils \
|
||||||
|
diffutils pciutils usbutils tzdata base-files ncurses mdocml procps-ng \
|
||||||
|
kbd xbps sudo ethtool kmod eudev runit-void removed-packages nano acpid \
|
||||||
|
squashfs-tools
|
Loading…
Reference in New Issue