diff --git a/pipeline/build-discover-adapter.sh b/pipeline/build-discover-adapter.sh index c5197db..376aa4f 100644 --- a/pipeline/build-discover-adapter.sh +++ b/pipeline/build-discover-adapter.sh @@ -1,15 +1,36 @@ #!/bin/bash # Compile only our plugin and its matching Discover common library, in isolation. +# The build root is persistent and pinned to the cycle's repository snapshot, and +# artifacts produced from identical inputs are reused instead of rebuilt. set -euo pipefail source_root=$1 tools=$2 cache=$3 output=$4 +mirror=${ARCHIPELAGO_MIRROR_URL:-'https://mirror.nw-sys.ru/archlinux/$repo/os/$arch'} mkdir -p "$output" sources="$(dirname "$cache")/desktop-sources" mkdir -p "$sources" -systemd-nspawn --quiet --ephemeral --settings=no --register=no \ - --machine="archipelago-discover-build-$$" -D "$tools" \ + +key=$( { sha256sum "$0"; printf '%s\n' "$mirror"; + ( cd "$source_root" && find system/integrations/discover contracts/dbus builder/packages/plasma-setup \ + -type f -print0 | LC_ALL=C sort -z | xargs -0 sha256sum ); } | sha256sum | cut -d' ' -f1 ) +cached=$(dirname "$cache")/adapters/discover-$key +if [[ -f $cached/SHA256SUMS ]]; then + cp -a "$cached"/. "$output"/ + printf 'discover adapter cache hit %s\n' "$key" + exit 0 +fi + +root=$(dirname "$cache")/adapter-tools/root.x86_64 +if [[ ! -d $root ]]; then + mkdir -p "$(dirname "$root")" + cp -a --reflink=auto "$tools" "$root" +fi +printf 'Server = %s\n' "$mirror" > "$root/etc/pacman.d/mirrorlist" + +systemd-nspawn --quiet --settings=no --register=no \ + --machine="archipelago-discover-build-$$" -D "$root" \ --bind-ro="$source_root/system/integrations/discover:/adapter" \ --bind-ro="$source_root/contracts/dbus:/contract" \ --bind-ro="$source_root/builder/packages/plasma-setup:/setup-recipe" \ @@ -18,7 +39,7 @@ systemd-nspawn --quiet --ephemeral --settings=no --register=no \ /bin/bash -euo pipefail -c ' pacman-key --init pacman-key --populate archlinux -pacman -Syu --needed --noconfirm base-devel cmake ninja extra-cmake-modules discover qt6-tools kitemmodels curl +pacman -Syu --needed --noconfirm base-devel cmake ninja extra-cmake-modules discover qt6-tools kitemodels curl test "$(pacman -Q discover)" = "discover 6.8.2-1" exec 9>/sources/download.lock flock 9 @@ -64,7 +85,7 @@ sha256sum /contract/qt-types.py >> /output/SHA256SUMS # repository universe. Purpose installs it normally from that signed repository. source /setup-recipe/PKGBUILD pacman -S --needed --noconfirm "${depends[@]}" "${makedepends[@]}" -useradd -m package-builder +useradd -m package-builder 2>/dev/null || true install -d -o package-builder -g package-builder /tmp/plasma-setup-build cp /setup-recipe/PKGBUILD /tmp/plasma-setup-build/ cp /output/plasma-setup-6.8.2.tar.xz /tmp/plasma-setup-build/ @@ -76,3 +97,9 @@ cp /tmp/plasma-setup-build/plasma-setup-6.8.2.tar.xz /output/ sha256sum /output/plasma-setup* >> /output/SHA256SUMS pacman -Q > /output/packages.txt ' + +mkdir -p "$(dirname "$cached")" +rm -rf "$cached.tmp" +cp -a "$output" "$cached.tmp" +mv "$cached.tmp" "$cached" +printf 'discover adapter cached as %s\n' "$key" diff --git a/pipeline/build-software-adapter.sh b/pipeline/build-software-adapter.sh index aedad0b..c9a39bd 100644 --- a/pipeline/build-software-adapter.sh +++ b/pipeline/build-software-adapter.sh @@ -1,13 +1,34 @@ #!/bin/bash # Compile the frozen adapter source against the worker's Arch GNOME headers. +# The build root is persistent and pinned to the cycle's repository snapshot, and +# a plugin produced from identical inputs is reused instead of rebuilt. set -euo pipefail source_root=$1 tools=$2 cache=$3 output=$4 +mirror=${ARCHIPELAGO_MIRROR_URL:-'https://mirror.nw-sys.ru/archlinux/$repo/os/$arch'} mkdir -p "$output" -systemd-nspawn --quiet --ephemeral --settings=no --register=no \ - --machine="archipelago-software-build-$$" -D "$tools" \ + +key=$( { sha256sum "$0"; printf '%s\n' "$mirror"; + ( cd "$source_root" && find system/integrations/gnome-software contracts/dbus -type f -print0 | + LC_ALL=C sort -z | xargs -0 sha256sum ); } | sha256sum | cut -d' ' -f1 ) +cached=$(dirname "$cache")/adapters/software-$key +if [[ -f $cached/SHA256SUMS ]]; then + cp -a "$cached"/. "$output"/ + printf 'software adapter cache hit %s\n' "$key" + exit 0 +fi + +root=$(dirname "$cache")/adapter-tools/root.x86_64 +if [[ ! -d $root ]]; then + mkdir -p "$(dirname "$root")" + cp -a --reflink=auto "$tools" "$root" +fi +printf 'Server = %s\n' "$mirror" > "$root/etc/pacman.d/mirrorlist" + +systemd-nspawn --quiet --settings=no --register=no \ + --machine="archipelago-software-build-$$" -D "$root" \ --bind-ro="$source_root/system/integrations/gnome-software:/source" \ --bind-ro="$source_root/contracts/dbus:/contract" \ --bind="$cache:/var/cache/pacman/pkg" --bind="$output:/output" \ @@ -37,3 +58,9 @@ done LD_LIBRARY_PATH="$library_path${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" /output/test-plugin > /output/plugin-contract.log 2>&1 pacman -Q > /output/packages.txt ' + +mkdir -p "$(dirname "$cached")" +rm -rf "$cached.tmp" +cp -a "$output" "$cached.tmp" +mv "$cached.tmp" "$cached" +printf 'software adapter cached as %s\n' "$key" diff --git a/pipeline/release-cycle.py b/pipeline/release-cycle.py index 126f7ee..89d9898 100644 --- a/pipeline/release-cycle.py +++ b/pipeline/release-cycle.py @@ -240,14 +240,16 @@ find {remote_root}/probes -type f -name '*.py' -exec sha256sum {{}} + >> {remote remote(shlex.join(['bash', remote_root + '/source/src/infrastructure/pipeline/prepare-flatpak-tools.sh', config['flatpak_cache'], config['bootstrap']]) + ' > ' + shlex.quote(remote_root + '/flatpak-tools.log') + ' 2>&1', 14400) - remote(shlex.join(['bash', remote_root + '/source/src/infrastructure/pipeline/build-software-adapter.sh', + remote(shlex.join(['env', 'ARCHIPELAGO_MIRROR_URL=' + snapshot_url, + 'bash', remote_root + '/source/src/infrastructure/pipeline/build-software-adapter.sh', remote_root + '/source/src', config['flatpak_cache'] + '/tools/root.x86_64', config['build_environment']['ARCHIPELAGO_PACKAGE_CACHE'], remote_root + '/software-adapter']) + ' > ' + shlex.quote(remote_root + '/software-adapter.log') + ' 2>&1', 14400) call(['rsync', '-a', f'{worker}:{remote_root}/software-adapter/', str(run / 'software-adapter') + '/']) if 'kde' in desktops: phase('building-discover-adapter') - remote(shlex.join(['bash', remote_root + '/source/src/infrastructure/pipeline/build-discover-adapter.sh', + remote(shlex.join(['env', 'ARCHIPELAGO_MIRROR_URL=' + snapshot_url, + 'bash', remote_root + '/source/src/infrastructure/pipeline/build-discover-adapter.sh', remote_root + '/source/src', config['flatpak_cache'] + '/tools/root.x86_64', config['build_environment']['ARCHIPELAGO_PACKAGE_CACHE'], remote_root + '/discover-adapter']) + ' > ' + shlex.quote(remote_root + '/discover-adapter.log') + ' 2>&1', 14400)