The smoketest VMs start with -vga virtio, but Arch packages that display apart from qemu-base, so the base image build failed with "Virtio VGA not available". update.sh now installs qemu-hw-display-virtio-vga, and doctor and smoketest run check QEMU has the display before anything downloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
2.1 KiB
Bash
75 lines
2.1 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Purpose : Paths, settings and helpers shared by coredesktop-dev's scripts
|
|
|
|
# The deployed copy: the machine's running CoreDesktop, which update pulls
|
|
COREDESKTOP="$HOME/.local/share/coredesktop"
|
|
|
|
CONFIG_DIR="$HOME/.config/coredesktop-dev"
|
|
CONFIG="$CONFIG_DIR/config"
|
|
|
|
# First line after the shebang of the pre-push hook this project installs, so it
|
|
# never overwrites or removes a hook someone else wrote. Used by hooks.sh.
|
|
# shellcheck disable=SC2034
|
|
HOOK_MARKER="# Installed by coredesktop-dev; remove with: coredesktop-dev hooks remove"
|
|
|
|
die() {
|
|
echo "$*" >&2
|
|
exit 1
|
|
}
|
|
|
|
confirm() {
|
|
local answer
|
|
read -rp "$1 [y/N] " answer
|
|
[[ "$answer" == [yY]* ]]
|
|
}
|
|
|
|
# Sets WORKING_COPY from the settings file (empty if there is none)
|
|
load_config() {
|
|
WORKING_COPY=""
|
|
# shellcheck source=/dev/null
|
|
[ -f "$CONFIG" ] && source "$CONFIG"
|
|
return 0
|
|
}
|
|
|
|
save_config() {
|
|
mkdir -p "$CONFIG_DIR"
|
|
printf 'WORKING_COPY=%q\n' "$1" > "$CONFIG"
|
|
}
|
|
|
|
# True if DIR is the deployed copy, however it's spelled
|
|
is_deployed_copy() {
|
|
[ -e "$1" ] && [ "$(realpath "$1")" = "$(realpath "$COREDESKTOP" 2> /dev/null)" ]
|
|
}
|
|
|
|
# True if DIR is the top of a git clone of CoreDesktop
|
|
is_coredesktop_clone() {
|
|
[ -d "$1" ] \
|
|
&& [ "$(git -C "$1" rev-parse --show-toplevel 2> /dev/null)" = "$(realpath "$1")" ] \
|
|
&& [ -f "$1/update" ] && [ -d "$1/updates.d" ]
|
|
}
|
|
|
|
# Load the settings and stop unless they point at a CoreDesktop clone
|
|
require_working_copy() {
|
|
load_config
|
|
[ -n "$WORKING_COPY" ] \
|
|
|| die "No working copy is set. Run $(sibling_dir)/install.sh, or: sibling add <coredesktop-dev url>"
|
|
is_coredesktop_clone "$WORKING_COPY" \
|
|
|| die "The working copy, $WORKING_COPY, isn't a clone of CoreDesktop (set in $CONFIG)."
|
|
}
|
|
|
|
in_flatpak() {
|
|
[ -f /.flatpak-info ] || [ -n "${FLATPAK_ID:-}" ]
|
|
}
|
|
|
|
# Whether QEMU has the display the smoketest's VMs start with (-vga virtio).
|
|
# Arch packages it apart from qemu-base, as qemu-hw-display-virtio-vga.
|
|
qemu_has_virtio_vga() {
|
|
[[ "$(qemu-system-x86_64 -device help 2> /dev/null)" == *'name "virtio-vga"'* ]]
|
|
}
|
|
|
|
# This project's folder
|
|
sibling_dir() {
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd
|
|
}
|