build: add image builder and image variants

This commit is contained in:
ahp
2026-10-18 16:42:25 +03:30
parent ee597ebeaa
commit 3202d12c50
6 changed files with 455 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
#!/bin/bash
function pre() {
rm "${MOUNT}/etc/machine-id"
arch-chroot "${MOUNT}" /usr/bin/btrfs subvolume create /swap
chattr +C "${MOUNT}/swap"
chmod 0700 "${MOUNT}/swap"
arch-chroot "${MOUNT}" /usr/bin/btrfs filesystem mkswapfile --size 512m --uuid clear /swap/swapfile
echo -e "/swap/swapfile none swap defaults 0 0" >>"${MOUNT}/etc/fstab"
arch-chroot "${MOUNT}" /usr/bin/systemd-firstboot --locale=C.UTF-8 --timezone=UTC --hostname=parch --keymap=us
ln -sf /run/systemd/resolve/stub-resolv.conf "${MOUNT}/etc/resolv.conf"
install -m 644 "${MOUNT}/usr/local/share/parch-branding/os-release" "${MOUNT}/usr/lib/os-release"
install -m 644 "${MOUNT}/usr/local/share/parch-branding/issue" "${MOUNT}/etc/issue"
install -m 644 "${MOUNT}/usr/local/share/parch-branding/lsb-release" "${MOUNT}/etc/lsb-release"
install -m 644 "${MOUNT}/usr/local/share/parch-branding/pixmaps/parch-logo.svg" "${MOUNT}/usr/share/pixmaps/parch-logo.svg"
install -m 644 "${MOUNT}/usr/local/share/parch-branding/pixmaps/parch-logo-dark.svg" "${MOUNT}/usr/share/pixmaps/parch-logo-dark.svg"
cat <<EOF >"${MOUNT}/etc/systemd/system/pacman-init.service"
[Unit]
Description=Initializes Pacman keyring
Before=sshd.service cloud-final.service archlinux-keyring-wkd-sync.service
After=time-sync.target
ConditionFirstBoot=yes
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/pacman-key --init
ExecStart=/usr/bin/pacman-key --populate archlinux
ExecStart=-/usr/bin/pacman-key --populate parchlinux
ExecStart=/usr/bin/gpg --homedir /etc/pacman.d/gnupg --batch --import-ownertrust /usr/share/pacman/keyrings/parchlinux-trusted
[Install]
WantedBy=multi-user.target
EOF
cat <<'EOF' >"${MOUNT}/etc/pacman.d/mirrorlist"
Server = https://fastly.mirror.pkgbuild.com/$repo/os/$arch
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
EOF
arch-chroot "${MOUNT}" /bin/bash -e <<EOF
source /etc/profile
systemctl enable sshd
systemctl enable systemd-networkd
systemctl enable systemd-resolved
systemctl enable systemd-timesyncd
systemctl enable systemd-time-wait-sync
systemctl enable pacman-init.service
EOF
arch-chroot "${MOUNT}" /usr/bin/grub-install --target=i386-pc "${LOOPDEV}"
arch-chroot "${MOUNT}" /usr/bin/grub-install --target=x86_64-efi --efi-directory=/efi --removable
sed -i 's/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=1/' "${MOUNT}/etc/default/grub"
sed -i 's/^GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="net.ifnames=0"/' "${MOUNT}/etc/default/grub"
sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"rootflags=compress=zstd:1\"/' "${MOUNT}/etc/default/grub"
arch-chroot "${MOUNT}" /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
}
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
IMAGE_NAME="Parch-Linux-x86_64-basic-${build_version}.qcow2"
DISK_SIZE="40G"
PACKAGES=()
SERVICES=()
function pre() {
local NEWUSER="arch"
arch-chroot "${MOUNT}" /usr/bin/useradd -m -U "${NEWUSER}"
echo -e "${NEWUSER}\n${NEWUSER}" | arch-chroot "${MOUNT}" /usr/bin/passwd "${NEWUSER}"
echo "${NEWUSER} ALL=(ALL) NOPASSWD: ALL" >"${MOUNT}/etc/sudoers.d/${NEWUSER}"
cat <<EOF >"${MOUNT}/etc/systemd/network/80-dhcp.network"
[Match]
Name=en*
Name=eth*
[Link]
RequiredForOnline=routable
[Network]
DHCP=yes
EOF
}
function post() {
qemu-img convert -c -f raw -O qcow2 "${1}" "${2}"
rm "${1}"
}
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
IMAGE_NAME="Parch-Linux-x86_64-cloudimg-${build_version}.qcow2"
DISK_SIZE=""
PACKAGES=(cloud-init cloud-guest-utils gptfdisk)
SERVICES=(cloud-init-main.service cloud-init-local.service cloud-init-network.service cloud-config.service cloud-final.service qemu-guest-agent.service)
function pre() {
cat <<'EOF' >"${MOUNT}/etc/systemd/network/80-dhcp.network"
[Match]
Name=en* eth*
[Network]
DHCP=yes
EOF
sed -Ei 's/^(GRUB_CMDLINE_LINUX_DEFAULT=.*)"$/\1 console=tty0 console=ttyS0,115200"/' "${MOUNT}/etc/default/grub"
echo 'GRUB_TERMINAL="serial console"' >>"${MOUNT}/etc/default/grub"
echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' >>"${MOUNT}/etc/default/grub"
arch-chroot "${MOUNT}" /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
}
function post() {
qemu-img convert -c -f raw -O qcow2 "${1}" "${2}"
rm "${1}"
}
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
IMAGE_NAME="Parch-Linux-x86_64-libvirt-executor-${build_version}.qcow2"
DISK_SIZE="40G"
PACKAGES=(git git-lfs gitlab-runner)
SERVICES=()
function pre() {
arch-chroot "${MOUNT}" /usr/bin/systemctl disable systemd-time-wait-sync
sed -E 's/^#(IgnorePkg *=)/\1 linux/' -i "${MOUNT}/etc/pacman.conf"
sed 's/^\(GRUB_CMDLINE_LINUX=".*\)"$/\1 lockdown=confidentiality"/' -i "${MOUNT}/etc/default/grub"
arch-chroot "${MOUNT}" /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
rm -f "${MOUNT}/etc/hostname"
cat <<EOF >"${MOUNT}/etc/systemd/network/80-dhcp.network"
[Match]
Name=en*
Name=eth*
[Network]
DHCP=yes
EOF
}
function post() {
qemu-img convert -c -f raw -O qcow2 "${1}" "${2}"
rm "${1}"
}