sha256sum prints the file path next to the digest, and the build path carries the run id, so every run produced a new cache key and rebuilt both adapters. Read the script through stdin so only its content enters the key.
66 lines
3.1 KiB
Bash
66 lines
3.1 KiB
Bash
#!/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"
|
|
|
|
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" \
|
|
/bin/bash -euo pipefail -c '
|
|
pacman-key --init
|
|
pacman-key --populate archlinux
|
|
pacman -Syu --needed --noconfirm gcc pkgconf glib2-devel gnome-software json-glib sysprof
|
|
pkg-config --exact-version=51.1 gnome-software
|
|
gdbus-codegen --interface-prefix org.archipelago.System1. --c-namespace ArchipelagoSystem \
|
|
--generate-c-code /output/archipelago-system-bus /contract/org.archipelago.System1.xml
|
|
gcc -shared -fPIC -O2 -Wall -Werror=implicit-function-declaration \
|
|
-DG_LOG_DOMAIN=\"GsPluginArchipelago\" /source/gs-plugin-archipelago.c \
|
|
/output/archipelago-system-bus.c \
|
|
-o /output/libgs_plugin_archipelago.so $(pkg-config --cflags --libs gnome-software json-glib-1.0)
|
|
sha256sum /source/gs-plugin-archipelago.c /output/libgs_plugin_archipelago.so > /output/SHA256SUMS
|
|
sha256sum /source/system-bus.h >> /output/SHA256SUMS
|
|
sha256sum /contract/org.archipelago.System1.xml /output/archipelago-system-bus.[ch] >> /output/SHA256SUMS
|
|
gcc -O2 -Wall -Werror=implicit-function-declaration \
|
|
-DG_LOG_DOMAIN=\"GsPluginArchipelago\" /source/test-plugin.c \
|
|
-o /output/test-plugin $(pkg-config --cflags --libs gnome-software json-glib-1.0)
|
|
# GNOME Software keeps its private ABI outside the default loader search path.
|
|
# Use the same library directories that pkg-config supplied to the linker.
|
|
library_path=
|
|
for flag in $(pkg-config --libs-only-L gnome-software); do
|
|
case "$flag" in -L*) library_path="${library_path:+$library_path:}${flag#-L}" ;; esac
|
|
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"
|