Script zur Installation einer Arch-VM zum bauen der Images von ArchOS.

This commit is contained in:
eichehome 2023-09-26 16:37:14 +02:00
parent 386d3bb61e
commit 9cff4b5947

172
build/archos-build.uefi Normal file
View file

@ -0,0 +1,172 @@
#!/usr/bin/bash
DEVICE="ArchOS.raw"
declare -A GUID=""
GUID=([ESP]="c12a7328-f81f-11d2-ba4b-00a0c93ec93b" [ROOT]="4f68bce3-e8cd-4db1-96e7-fbcaf984b709")
mkdir repart
cd repart || exit
cat > 10-esp.conf << EOF
[Partition]
Type=esp
Label=EFI System Partition
SizeMinBytes=512M
SizeMaxBytes=512M
Format=vfat
EOF
cat > 20-root.conf << EOF
[Partition]
Type=root
Label=ArchOS Build Root
Format=ext4
GrowFileSystem=yes
EOF
cat > 30-swap.conf << EOF
[Partition]
Type=swap
Label=ArchOS Build Swap
SizeMinBytes=512M
SizeMaxBytes=3G
Format=swap
EOF
cd ..
# Temporär
touch "${DEVICE}"
systemd-repart --definitions=repart --dry-run=no --size=auto --empty=allow "${DEVICE}"
#systemd-repart --definitions=repart --dry-run=no --size=10G --empty=create "${DEVICE}"
mount /dev/disk/by-partuuid/"${GUID[ROOT]}" /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-partuuid/"${GUID[ESP]}" /mnt/boot
# Pacman im Live-System konfigurieren
sed -i 's/#\(Color\)/\1/' /etc/pacman.conf
# Umbruch notwendug
sed -i 's/#\(ParallelDownloads\s=\s5\)/\1\
ILoveCandy/' /etc/pacman.conf
TIMEZONE="Europe/Berlin"
LANG="de_DE.UTF-8"
KEYMAP="de-latin1"
HOSTNAME_NEW="arch-build"
KERNEL="linux"
BASE=(base)
INITRD=(mkinitcpio)
MICROCODE="amd-ucode"
WIFI_BACKEND=(wpa_supplicant)
NETWORK=(iptables-nft firewalld inetutils avahi networkmanager networkmanager-openconnect networkmanager-openvpn networkmanager-pptp networkmanager-vpnc "${WIFI_BACKEND[@]}" modemmanager)
OTHER=(vim mkosi git lynx openssh htop bash-completion man-db man-pages reflector "${BASE[@]}" "${INITRD[@]}" plymouth linux-firmware xdg-utils)
pacstrap /mnt "${KERNEL}" "${MICROCODE}" "${NETWORK[@]}" "${OTHER[@]}"
arch-chroot /mnt hwclock --systohc
arch-chroot /mnt rm -rf /etc/localtime
arch-chroot /mnt ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
sed -i 's/#\(Color\)/\1/' /mnt/etc/pacman.conf
# Umbruch notwendug
sed -i 's/#\(ParallelDownloads\s=\s5\)/\1\
ILoveCandy/' /mnt/etc/pacman.conf
sed -i "s/#\(${LANG}\)/\1/" /mnt/etc/locale.gen
arch-chroot /mnt locale-gen
echo "LANG=${LANG}" > /mnt/etc/locale.conf
echo "KEYMAP=${KEYMAP}" > /mnt/etc/vconsole.conf
echo "${HOSTNAME_NEW}" > /mnt/etc/hostname
cat > /mnt/etc/hosts << EOF
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
arch-chroot /mnt chpasswd <<< "root:testen"
arch-chroot /mnt chpasswd <<< "build:build"
sed -i 's/#\(CHARACTER_SET:\).*/\1utf-8/' /mnt/etc/lynx.cfg
cat > /mnt/etc/xdg/reflector/reflector.conf << EOF
--save /etc/pacman.d/mirrorlist
--country Germany
--protocol https
--latest 5
EOF
mkdir -p /mnt/etc/systemd/resolved.conf.d
cat > /mnt/etc/systemd/resolved.conf.d/disable-multicastDNS.conf << EOF
[Resolve]
MulticastDNS=no
EOF
arch-chroot /mnt systemctl enable systemd-resolved
arch-chroot /mnt systemctl enable systemd-timesyncd
arch-chroot /mnt systemctl enable NetworkManager
arch-chroot /mnt systemctl enable reflector.timer
arch-chroot /mnt systemctl enable firewalld
arch-chroot /mnt systemctl enable fstrim.timer
arch-chroot /mnt systemctl enable gdm
arch-chroot /mnt systemctl enable avahi-daemon
arch-chroot /mnt systemctl enable bluetooth
sed -i 's/^HOOKS=(.*)/HOOKS=(base systemd keyboard plymouth autodetect sd-vconsole modconf kms block filesystems fsck)/' /mnt/etc/mkinitcpio.conf
arch-chroot /mnt mkinitcpio -p "${KERNEL}"
arch-chroot /mnt bootctl install
cat > /mnt/boot/loader/loader.conf << EOF
timeout 5
console-mode max
editor yes
default *
EOF
cat > /mnt/boot/loader/entries/arch.conf << EOF
title Arch Linux Build
version 0.1
linux /vmlinuz-${KERNEL}
initrd /${MICROCODE}.img
initrd /initramfs-${KERNEL}.img
options quiet splash rw
EOF
mkdir -p /mnt/usr/lib/repart.d
#cd repart || exit
cat > /mnt/usr/lib/repart.d/10-esp.conf << EOF
[Partition]
Type=esp
Label=EFI System Partition
SizeMinBytes=512M
SizeMaxBytes=512M
Format=vfat
EOF
cat > /mnt/usr/lib/repart.d/20-root.conf << EOF
[Partition]
Type=root
Label=ArchOS Build Root
Format=ext4
GrowFileSystem=yes
EOF
cat > /mnt/usr/lib/repart.d/30-swap.conf << EOF
[Partition]
Type=swap
Label=ArchOS Build Swap
SizeMinBytes=512M
SizeMaxBytes=3G
Format=swap
EOF
exit 0