#!/bin/bash # shellcheck disable=SC2034 DESCRIPTION="a machine a month behind on a stale mirror: update picks fresh mirrors, upgrades the kernel, asks for a reboot" IMAGE=installed TIER="nightly" scenario() { local date kernel_before date="$(date -d '30 days ago' +%Y/%m/%d)" # Go back to Arch as it was a month ago, from the Arch Linux Archive, which # is also a mirror that stopped syncing a month ago. Packages from Arch's # repos that the archive doesn't have yet, often split off since (e.g. # clang-libs from clang), go first: their files conflict with the old # packages'. update installs them again run_in_vm downgrade "set -e pacman -Qqn | sort > ~/native-now echo 'Server = https://archive.archlinux.org/repos/$date/\$repo/os/\$arch' \ | sudo tee /etc/pacman.d/mirrorlist sudo pacman -Syy newer=\"\$(pacman -Qqm | sort | comm -12 ~/native-now -)\" rm ~/native-now if [ -n \"\$newer\" ]; then echo \"Not in the archive yet, removing: \"\$newer sudo pacman -Rdd --noconfirm \$newer fi sudo pacman -Suu --noconfirm" [ "$STATUS" -eq 0 ] || skip "couldn't downgrade to Arch as of $date (see $LAST_LOG)" vm_reboot kernel_before="$(vm_value 'uname -r')" run_in_vm version '"$HOME/.local/bin/version"' assert_output "last synced with Arch" local snapshots_before snapshots_before="$(vm_value 'sudo snapper -c root list 2> /dev/null | wc -l')" cd_update assert_status 0 assert_output "Please reboot when convenient" refute_vm "the first mirror isn't the archive any more" \ 'grep -m1 "^Server" /etc/pacman.d/mirrorlist | grep -q archive.archlinux.org' assert_vm "update took a snapshot first (if / is btrfs)" " [ \"\$(findmnt -no FSTYPE /)\" != btrfs ] \ || [ \"\$(sudo snapper -c root list | wc -l)\" -gt $snapshots_before ]" vm_reboot refute_vm "a newer kernel is running" "[ \"\$(uname -r)\" = $(q "$kernel_before") ]" health }