: nply/foundationpkgs-binaries

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
#!/bin/sh
# Network smoke test, isolated APT state; never installs or changes live sources.
set -eu
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
if ! command -v apt-get >/dev/null 2>&1; then
 echo 'SKIP: apt-get required'; exit 0
fi
work=$(mktemp -d)
trap 'rm -rf "$work"' 0
mkdir -p "$work/lists/partial" "$work/cache/archives/partial" "$work/bad-lists/partial"
cp "$root/keys/foundationpkgs-archive-keyring.gpg" "$work/trusted.gpg"
printf 'not an archive key\n' > "$work/wrong.gpg"
url=https://nply.org/dl/foundationpkgs-binaries/apt
printf 'deb [signed-by=%s] %s trixie main\n' "$work/trusted.gpg" "$url" > "$work/good.list"
printf 'deb [signed-by=%s] %s trixie main\n' "$work/wrong.gpg" "$url" > "$work/bad.list"
apt_update() {
 apt-get -o "Dir::Etc::sourcelist=$1" -o Dir::Etc::sourceparts=- \
  -o "Dir::State::lists=$2" -o Dir::State::status=/dev/null \
  -o "Dir::Cache=$work/cache" -o "APT::Sandbox::User=$(id -un)" \
  -o APT::Update::Error-Mode=any update
}
apt_update "$work/good.list" "$work/lists"
# Resolve and download via real APT (including index checksum verification), no install.
(cd "$work" && apt-get -o "Dir::Etc::sourcelist=$work/good.list" \
 -o Dir::Etc::sourceparts=- -o "Dir::State::lists=$work/lists" \
 -o "APT::Sandbox::User=$(id -un)" download saait)
set -- "$work"/saait_*.deb
[ "$#" -eq 1 ] && [ -f "$1" ]
[ "$(dpkg-deb -f "$1" Package)" = saait ]
[ "$(dpkg-deb -f "$1" Architecture)" = amd64 ]
if apt_update "$work/bad.list" "$work/bad-lists" > "$work/rejected.log" 2>&1; then
 echo 'FAIL: repository accepted with an invalid signing key' >&2; exit 1
fi
grep -Ei 'NO_PUBKEY|Missing key|not signed|signature' "$work/rejected.log" >/dev/null
printf 'PASS: real APT accepts scoped archive key, downloads saait and rejects invalid key; live APT state untouched\n'