diff options
Diffstat (limited to 'images/debian/functions')
| -rw-r--r-- | images/debian/functions | 72 | +72 −0 |
1 files changed, 72 insertions, 0 deletions
diff --git a/images/debian/functions b/images/debian/functions new file mode 100644 --- /dev/null +++ b/images/debian/functions @@ -0,0 +1,72 @@ +#!/bin/sh +# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-License-Identifier: AGPL-3.0-only + +poweroff_cmd="sudo systemctl poweroff" +default_arch=amd64 + +boot() { + case "$arch" in + amd64) + qemu=qemu-system-x86_64 + _boot $(cpu_opts x86_64) + ;; + arm64) + driveopts="id=root,if=none" + qemu=qemu-system-aarch64 + _boot \ + $(cpu_opts aarch64) \ + -device virtio-blk-pci,drive=root \ + -kernel "$wd/$arch/vmlinuz" \ + -initrd "$wd/$arch/initrd.img" \ + -append "root=/dev/vda3" + ;; + ppc64el) + driveopts="id=root,if=none" + qemu=qemu-system-ppc64 + _boot \ + $(cpu_opts ppc64le) \ + -device virtio-blk-pci,drive=root \ + -kernel "$wd/$arch/vmlinux" \ + -initrd "$wd/$arch/initrd.img" \ + -append "root=/dev/vda3" + ;; + *) + echo "Unsupported architecture $arch" >&2 + exit 1 + ;; + esac +} + +install() { + port=$1 + shift 1 + guest_ssh -p $port build@localhost sudo env DEBIAN_FRONTEND=noninteractive \ + apt-get update -y + guest_ssh -p $port build@localhost sudo env DEBIAN_FRONTEND=noninteractive \ + apt-get install -y "$@" +} + +sanity_check() { + arch=$1 + shift + + echo "Booting..." + cmd_boot "$arch" 8022 qemu & + trap 'cmd_cleanup 8022' EXIT + _wait_boot 8022 + echo "Testing sudo..." + guest_ssh -p 8022 build@localhost sudo ls -a + echo "Testing apt..." + guest_ssh -p 8022 build@localhost sudo apt-get update + install 8022 curl + echo "Testing networking..." + guest_ssh -p 8022 build@localhost curl https://builds.sr.ht + echo "Testing git..." + guest_ssh -p 8022 build@localhost git --version + echo "Testing mercurial..." + guest_ssh -p 8022 build@localhost hg --version + echo "Everything works!" + guest_ssh -p 8022 build@localhost sudo systemctl poweroff || true +} |
