From 8f8a22d9b926033e94e2d7d12bc9d92aa33947ea Mon Sep 17 00:00:00 2001 From: Nikolay Govorov Date: Sun, 5 Jul 2026 22:42:00 +0100 Subject: Cleans up SourceHut scripts by removing unused wrappers --- images/alpine/3.20/functions | 1 - images/alpine/3.21/functions | 1 - images/alpine/3.22/functions | 1 - images/alpine/3.23/functions | 1 - images/alpine/3.24/functions | 1 - images/alpine/edge/functions | 1 - images/alpine/edge/genimg | 1 - images/alpine/functions | 26 +----- images/alpine/genimg | 10 +-- images/control | 132 +++---------------------------- images/debian/bookworm/functions | 1 - images/debian/forky/functions | 1 - images/debian/functions | 40 +--------- images/debian/genimg | 10 +-- images/debian/sid/functions | 1 - images/debian/trixie/functions | 1 - images/fedora/42/functions | 1 - images/fedora/43/functions | 1 - images/fedora/44/functions | 1 - images/fedora/functions | 14 +--- images/fedora/genimg | 10 +-- images/freebsd/14.x/functions | 1 - images/freebsd/15.x/functions | 1 - images/freebsd/current/functions | 43 ---------- images/freebsd/genimg | 10 +-- images/freebsd/genpkgimg | 10 +-- images/ubuntu/functions | 40 +++------- images/ubuntu/genimg | 10 +-- images/ubuntu/jammy/functions | 1 - images/ubuntu/noble/functions | 1 - images/ubuntu/resolute/functions | 1 - 31 files changed, 41 insertions(+), 333 deletions(-) delete mode 120000 images/alpine/3.20/functions delete mode 120000 images/alpine/3.21/functions delete mode 120000 images/alpine/3.22/functions delete mode 120000 images/alpine/3.23/functions delete mode 120000 images/alpine/3.24/functions delete mode 120000 images/alpine/edge/functions delete mode 120000 images/debian/bookworm/functions delete mode 120000 images/debian/forky/functions delete mode 120000 images/debian/sid/functions delete mode 120000 images/debian/trixie/functions delete mode 120000 images/fedora/42/functions delete mode 120000 images/fedora/43/functions delete mode 120000 images/fedora/44/functions delete mode 120000 images/freebsd/14.x/functions delete mode 120000 images/freebsd/15.x/functions delete mode 100644 images/freebsd/current/functions delete mode 120000 images/ubuntu/jammy/functions delete mode 120000 images/ubuntu/noble/functions delete mode 120000 images/ubuntu/resolute/functions diff --git a/images/alpine/3.20/functions b/images/alpine/3.20/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/alpine/3.20/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/alpine/3.21/functions b/images/alpine/3.21/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/alpine/3.21/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/alpine/3.22/functions b/images/alpine/3.22/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/alpine/3.22/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/alpine/3.23/functions b/images/alpine/3.23/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/alpine/3.23/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/alpine/3.24/functions b/images/alpine/3.24/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/alpine/3.24/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/alpine/edge/functions b/images/alpine/edge/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/alpine/edge/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/alpine/edge/genimg b/images/alpine/edge/genimg index ebc1701..44cd6c3 100755 --- a/images/alpine/edge/genimg +++ b/images/alpine/edge/genimg @@ -3,5 +3,4 @@ # SPDX-License-Identifier: AGPL-3.0-only export release=edge -export linux=linux-lts exec ../genimg diff --git a/images/alpine/functions b/images/alpine/functions index 340f0fa..db6504c 100644 --- a/images/alpine/functions +++ b/images/alpine/functions @@ -1,5 +1,6 @@ #!/bin/sh -# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2026 Nikolay Govorov # SPDX-License-Identifier: AGPL-3.0-only poweroff_cmd="sudo poweroff" @@ -21,29 +22,6 @@ install() { guest_ssh -p $port build@localhost sudo apk add "$@" } -add_repository() { - port=$1 - name=$2 - src=$3 - repo=$(echo $src | cut -d' ' -f1) - key=$(echo $src | cut -d' ' -f2) - keyname=$(echo $src | cut -d' ' -f3) - guest_ssh -p $port build@localhost \ - "curl -s '$key' | sudo tee /etc/apk/keys/'$keyname'" - if [ "${name#@}" = "${name}" ] - then - printf '%s\n' "$repo" \ - | guest_ssh -p $port build@localhost \ - "cat - /etc/apk/repositories | sudo tee /etc/apk/repositories.new" - else - printf '%s %s\n' "$name" "$repo" \ - | guest_ssh -p $port build@localhost \ - "cat - /etc/apk/repositories | sudo tee /etc/apk/repositories.new" - fi - guest_ssh -p $port build@localhost \ - "sudo mv /etc/apk/repositories.new /etc/apk/repositories" -} - sanity_check() { echo "Booting..." cmd_boot x86_64 8022 qemu & diff --git a/images/alpine/genimg b/images/alpine/genimg index 689ce7e..2ac659b 100755 --- a/images/alpine/genimg +++ b/images/alpine/genimg @@ -1,5 +1,6 @@ #!/bin/sh -eux -# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2026 Nikolay Govorov # SPDX-License-Identifier: AGPL-3.0-only echo "$release" >/dev/null # fail on -u if release unset @@ -176,11 +177,4 @@ pkg_version() { run_root apk add $linux=$(pkg_version $linux) -cat >/mnt/home/build/.gitconfig <&2 exit 1 fi @@ -50,27 +45,7 @@ cpu_opts() { esac } -_docker_boot() { - docker run -d \ - -v "$self/$base":/base:ro \ - --mount type=tmpfs,destination=/var/tmp \ - --device /dev/kvm \ - --cpus=2 \ - -p 127.0.0.1:$port:$port \ - --rm \ - --name "builds_job_${BUILD_JOB_ID:-unknown_$(date +"%s")}" \ - qemu /bin/${qemu:-qemu-system-$arch} \ - -m ${MEMORY:-4096} \ - -smp cpus=2 \ - -net nic,model=virtio -net user,hostfwd=tcp::$port-:$guestport \ - -display none \ - -device virtio-rng-pci \ - -device virtio-balloon \ - -drive file="$wd/$arch/root.img.qcow2",media=disk,snapshot=on,${driveopts:-if=virtio} \ - "$@" > /tmp/docker-$port.id -} - -_qemu_boot() { +_boot() { ${qemu:-qemu-system-$arch} \ -pidfile /tmp/qemu-$port.id \ -m ${MEMORY:-4096} \ @@ -83,89 +58,21 @@ _qemu_boot() { "$@" & } -_qemu_chroot_boot() { - qemu-chroot \ - -p /tmp/qemu-$port.id \ - -b "$self/$base":/base \ - -b /var/tmp:/var/tmp \ - /bin/${qemu:-qemu-system-$arch} \ - -m ${MEMORY:-4096} \ - -smp cpus=2 \ - -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:$port-:$guestport \ - -display none \ - -device virtio-rng-pci \ - -device virtio-balloon \ - -drive file="$wd/$arch/root.img.qcow2",media=disk,snapshot=on,${driveopts:-if=virtio} \ - "$@" & -} - -_qemu_kvm_boot() { - qemu-kvm \ - -pidfile /tmp/qemu-$port.id \ - -m ${MEMORY:-4096} \ - -smp cpus=2 \ - -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:$port-:$guestport \ - -display none \ - -device virtio-rng-pci \ - -device virtio-balloon \ - -drive file="$wd/$arch/root.img.qcow2",media=disk,snapshot=on,${driveopts:-if=virtio} \ - "$@" & -} - -_boot() { - if [ "$means" = "docker" ] - then - _docker_boot "$@" - elif [ "$means" = "qemu" ] - then - _qemu_boot "$@" - elif [ "$means" = "qemu-chroot" ] - then - _qemu_chroot_boot "$@" - elif [ "$means" = "qemu-kvm" ] - then - _qemu_kvm_boot "$@" - fi -} - cmd_boot() { arch=$1 shift - if [ "$arch" = "default" ] - then + if [ "$arch" = "default" ]; then arch="$default_arch" fi - if [ ! -e "$self/$base/$arch/root.img.qcow2" ] - then + + if [ ! -e "$self/$base/$arch/root.img.qcow2" ]; then printf "Image '%s' is not available for arch '%s'\n" "$base" "$arch" >&2 exit 1 fi port=$1 - if [ "$#" -gt 1 ] - then - means=$2 - else - means="${default_means:-docker}" - fi - - if [ "$means" = "docker" ] - then - wd="/base" - elif [ "$means" = "qemu" ] - then - wd="$self/$base" - elif [ "$means" = "qemu-chroot" ] - then - wd="/base" - elif [ "$means" = "qemu-kvm" ] - then - wd="$self/$base" - else - printf "Unknown boot mode '%s'\n" "$means" >&2 - exit 1 - fi + wd="$self/$base" boot } @@ -193,14 +100,6 @@ cmd_cleanup() { # Power off if [ "$#" -eq 1 ] then - if [ -e /tmp/docker-$port.id ] - then - cid=$(cat /tmp/docker-$port.id) - guest_ssh -p $port build@localhost $poweroff_cmd || true - sleep 2 - docker kill $cid && sleep 2 || true - rm /tmp/docker-$port.id - fi if [ -e /tmp/qemu-$port.id ] then cid=$(cat /tmp/qemu-$port.id) @@ -212,14 +111,15 @@ cmd_cleanup() { fi } -if ! [ -e "$self/$base/functions" ] -then +if [ -f "$self/$base/functions" ]; then + . "$self/$base/functions" +elif [ -f "$self/$(dirname "$base")/functions" ]; then + . "$self/$(dirname "$base")/functions" +else printf "Missing base image functions '%s'\n" "$base" >&2 exit 1 fi -. $self/$base/functions - case "$cmd" in boot) cmd_boot "$@" @@ -230,12 +130,6 @@ case "$cmd" in sanity-check) sanity_check "$@" ;; - install) - install "$@" - ;; - add-repo) - add_repository "$@" - ;; ssh) port=$1 shift diff --git a/images/debian/bookworm/functions b/images/debian/bookworm/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/debian/bookworm/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/debian/forky/functions b/images/debian/forky/functions deleted file mode 120000 index c0b5bcc..0000000 --- a/images/debian/forky/functions +++ /dev/null @@ -1 +0,0 @@ -../functions \ No newline at end of file diff --git a/images/debian/functions b/images/debian/functions index e812b0a..64470ce 100644 --- a/images/debian/functions +++ b/images/debian/functions @@ -1,5 +1,6 @@ -#!/usr/bin/env bash -# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +#!/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" @@ -47,41 +48,6 @@ install() { apt-get install -y "$@" } -add_repository() { - port=$1 - name=$2 - src=$3 - repo=$(echo $src | cut -d' ' -f1) - distro=$(echo $src | cut -d' ' -f2) - cmpnt=$(echo $src | cut -d' ' -f3) - key=$(echo $src | cut -d' ' -f4) - signed_by="" - if [ "$key" != "" ] - then - # Import the GPG key into a user trustdb - guest_ssh -p $port build@localhost sudo \ - gpg \ - --keyserver hkp://keyserver.ubuntu.com:80 \ - --recv-keys $key - - guest_ssh -p $port build@localhost sudo \ - mkdir -pm 0755 /etc/apt/keyrings - - # Export the GPG key to Apt's key directory - guest_ssh -p $port build@localhost sudo \ - gpg \ - --output /etc/apt/keyrings/$name.gpg \ - --export $key - - signed_by="[signed-by=/etc/apt/keyrings/$name.gpg]" - fi - printf 'deb %s %s %s %s\n' "$signed_by" "$repo" "$distro" "$cmpnt" \ - | guest_ssh -p $port build@localhost sudo tee -a /etc/apt/sources.list.d/$name.list - printf 'deb-src %s %s %s %s\n' "$signed_by" "$repo" "$distro" "$cmpnt" \ - | guest_ssh -p $port build@localhost sudo tee -a /etc/apt/sources.list.d/$name.list - guest_ssh -p "$port" build@localhost sudo apt-get update -} - sanity_check() { arch=$1 shift diff --git a/images/debian/genimg b/images/debian/genimg index 9e1677b..297a26d 100755 --- a/images/debian/genimg +++ b/images/debian/genimg @@ -1,5 +1,6 @@ #!/bin/sh -eux -# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2026 Nikolay Govorov # SPDX-License-Identifier: AGPL-3.0-only echo "$release" >/dev/null # fail on -u if release unset @@ -147,13 +148,6 @@ cat >>/mnt/etc/fstab </mnt/home/build/.gitconfig </mnt/home/build/.gitconfig <&2 - exit 1 - fi - qemu=qemu-system-x86_64 - _boot $(cpu_opts x86_64) -} - -install() { - port=$1 - shift 1 - guest_ssh -p $port build@localhost \ - "sudo pkg update && sudo pkg upgrade -y && sudo pkg install -y $@" -} - -sanity_check() { - echo "Booting..." - cmd_boot amd64 8022 qemu & - trap 'cmd_cleanup 8022' EXIT - _wait_boot 8022 - sleep 20 - echo "Testing sudo..." - guest_ssh -p 8022 build@localhost sudo ls -a - echo "Testing networking..." - guest_ssh -p 8022 build@localhost curl http://builds.sr.ht - echo "Testing pkg..." - guest_ssh -p 8022 build@localhost sudo pkg update - guest_ssh -p 8022 build@localhost sudo pkg upgrade -y - guest_ssh -p 8022 build@localhost sudo pkg install -y htop - echo "Testing git..." - guest_ssh -p 8022 build@localhost git --version - echo "Everything works!" - guest_ssh -p 8022 build@localhost sudo poweroff || true -} diff --git a/images/freebsd/genimg b/images/freebsd/genimg index 6e86c53..c5219ea 100755 --- a/images/freebsd/genimg +++ b/images/freebsd/genimg @@ -1,5 +1,6 @@ #!/bin/sh -eux -# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2017-2026 Drew DeVault +# SPDX-FileCopyrightText: 2026 Nikolay Govorov # SPDX-License-Identifier: AGPL-3.0-only echo "$release" >/dev/null # fail on -u if unset @@ -96,13 +97,6 @@ pw -R /mnt groupadd sudo pw -R /mnt useradd -n build -u 1000 -s /usr/local/bin/bash -m -w none -G sudo echo "%sudo ALL=(ALL) NOPASSWD: ALL" >>/mnt/usr/local/etc/sudoers -cat >/mnt/home/build/.gitconfig </dev/null # fail on -u if unset @@ -81,13 +82,6 @@ pw -R disk groupadd sudo pw -R disk useradd -n build -u 1000 -s /usr/local/bin/bash -m -w none -G sudo echo "%sudo ALL=(ALL) NOPASSWD: ALL" >>disk/usr/local/etc/sudoers -cat >disk/home/build/.gitconfig </dev/null # fail on -u if release unset @@ -168,13 +169,6 @@ cat >>/mnt/etc/fstab </mnt/home/build/.gitconfig <