diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 133c4e9..5533261 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -53,13 +53,9 @@ jobs: $libs $(for l in $libs; do printf '%s:arm64 ' "$l"; done) libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-0:arm64 libgstreamer-plugins-base1.0-0:arm64" - if ! apt-get install -y --no-install-recommends $pkgs >/tmp/apt.log 2>&1; then - # Show why (usually a Multi-Arch package whose amd64 and arm64 - # versions differ while ports.ubuntu.com lags behind). - sed -n '/following packages have unmet/,$p' /tmp/apt.log | head -60 - tail -20 /tmp/apt.log - exit 1 - fi + # tools/ci-apt.sh: when ports.ubuntu.com lags behind, it aligns the + # Multi-Arch libraries on both architectures to the arm64 version. + sh "$W/src/tools/ci-apt.sh" $pkgs rm -rf /var/lib/apt/lists/* curl -sSf https://sh.rustup.rs | sh -s -- -y -q --profile minimal --no-modify-path --target aarch64-unknown-linux-gnu "$CARGO_HOME/bin/cargo" install -q --locked --git "$SDK_GIT" --tag "$SDK_TAG" sf-pack diff --git a/tools/ci-apt.sh b/tools/ci-apt.sh new file mode 100755 index 0000000..e629cac --- /dev/null +++ b/tools/ci-apt.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# apt-get install for the CI's two architectures (amd64 + arm64 multiarch). +# +# ports.ubuntu.com (arm64) often lags behind the main mirror (amd64). A +# "Multi-Arch: same" library must have one version on both architectures, so +# when the image already has a newer amd64 build (libpcre2, glib...) apt +# gives up ("held broken packages"). Then this script takes the arm64 +# packages apt complains about, and pins every installed package of the same +# source package on both architectures to the arm64 candidate version +# (a downgrade on amd64), and tries again. +# +# Usage: tools/ci-apt.sh +set -u +export DEBIAN_FRONTEND=noninteractive +pins="" +for try in 1 2 3 4; do + if apt-get install -y --no-install-recommends --allow-downgrades "$@" $pins >/tmp/apt.log 2>&1; then + [ -n "$pins" ] && echo "installed with aligned versions:$pins" + exit 0 + fi + names=$(sed -n 's/.*Depends: \([a-z0-9.+-]*\):arm64.*/\1/p' /tmp/apt.log | sort -u) + if [ -z "$names" ] || [ "$try" = 4 ]; then + sed -n '/following packages have unmet/,$p' /tmp/apt.log | head -60 + tail -20 /tmp/apt.log + exit 1 + fi + for n in $names; do + src=$(apt-cache show "$n:arm64" 2>/dev/null | sed -n 's/^Source: \([^ ]*\).*/\1/p' | head -1) + [ -n "$src" ] || src=$n + ver=$(apt-cache policy "$n:arm64" | sed -n 's/^ *Candidate: //p') + [ -n "$ver" ] && [ "$ver" != "(none)" ] || continue + # The package itself and its installed siblings from the same source. + sibs=$(dpkg-query -W -f '${Package} ${source:Package}\n' 2>/dev/null | awk -v s="$src" '$2 == s { print $1 }' | sed 's/:.*//' | sort -u) + for p in $n $sibs; do + v=$(apt-cache policy "$p:arm64" | sed -n 's/^ *Candidate: //p') + [ -n "$v" ] && [ "$v" != "(none)" ] || v=$ver + case " $pins " in *" $p=$v "*) ;; *) pins="$pins $p=$v $p:arm64=$v" ;; esac + done + done + echo "apt: aligning to the arm64 versions:$pins" +done