Arch's cloud image enables systemd-time-wait-sync, and sshd is ordered after pacman-init, which waits for time-sync.target. Once provision.sh turns off systemd-networkd, systemd-timesyncd thinks it's offline and never syncs, so every boot after the base build waited forever and the installed image's build failed with "The VM didn't answer on SSH". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.4 KiB
Bash
67 lines
2.4 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Purpose : Turn Arch's cloud image into the machine CoreDesktop's README starts
|
|
# from: Arch with archinstall's desktop profile and GNOME. Run as root
|
|
# in the VM while building the smoketest's base image.
|
|
#
|
|
# Differences from a real archinstall machine, on purpose: the user (tester)
|
|
# logs in to GNOME automatically and has passwordless sudo, so the smoketest
|
|
# runs without anyone at the keyboard.
|
|
|
|
set -euo pipefail
|
|
|
|
USER_NAME=tester
|
|
|
|
echo "== Growing / to fill the disk"
|
|
btrfs filesystem resize max / || echo "Couldn't grow /; continuing."
|
|
df -h /
|
|
|
|
echo "== Sharing the host's package cache"
|
|
if ! grep -q '^pkgcache ' /etc/fstab; then
|
|
echo 'pkgcache /var/cache/pacman/pkg 9p trans=virtio,version=9p2000.L,msize=524288,nofail 0 0' >> /etc/fstab
|
|
fi
|
|
systemctl daemon-reload
|
|
mountpoint -q /var/cache/pacman/pkg || mount /var/cache/pacman/pkg \
|
|
|| echo "No shared package cache; packages download into the VM."
|
|
|
|
echo "== Installing GNOME"
|
|
pacman -Sy --needed --noconfirm archlinux-keyring
|
|
# archinstall's desktop profile with GNOME, NetworkManager and PipeWire
|
|
pacman -Su --needed --noconfirm \
|
|
gnome gnome-tweaks gdm \
|
|
networkmanager \
|
|
pipewire pipewire-alsa pipewire-pulse pipewire-jack wireplumber \
|
|
base-devel git sudo openssh nano vim htop wget smartmontools xdg-utils
|
|
|
|
echo "== Locale"
|
|
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
|
locale-gen
|
|
echo LANG=en_US.UTF-8 > /etc/locale.conf
|
|
|
|
echo "== NetworkManager instead of systemd-networkd"
|
|
systemctl disable systemd-networkd.service systemd-networkd.socket systemd-resolved.service || true
|
|
# NetworkManager writes its own resolv.conf; the cloud image's points at
|
|
# systemd-resolved
|
|
rm -f /etc/resolv.conf
|
|
systemctl enable NetworkManager.service gdm.service sshd.service
|
|
# Arch's cloud image makes boot wait until the clock has synced, and sshd
|
|
# waits for that. Without systemd-networkd, systemd-timesyncd thinks it's
|
|
# offline and never syncs, so sshd would never start. archinstall doesn't
|
|
# turn this on, and QEMU sets the VM's clock from the host's.
|
|
systemctl disable systemd-time-wait-sync.service
|
|
|
|
echo "== Automatic login to GNOME as $USER_NAME"
|
|
cat > /etc/gdm/custom.conf << EOF
|
|
[daemon]
|
|
AutomaticLoginEnable=True
|
|
AutomaticLogin=$USER_NAME
|
|
EOF
|
|
|
|
echo "== Smoketest folder"
|
|
install -d -o "$USER_NAME" -g "$USER_NAME" /srv/smoketest
|
|
|
|
# cloud-init has done its job (the user, their SSH key and sudo rights)
|
|
touch /etc/cloud/cloud-init.disabled
|
|
|
|
echo "== Done"
|