ci: dispatch-only arm64 attach workflow for cnoc (additive, amd64 digest unchanged)
Builds ONLY the arm64 leg of an existing cnoc:nodeNN tag (QEMU, push by digest) and merges it with the tag's current amd64 manifest into a new index. Independent of build-push.yaml (its push-to-main trigger is untouched). Guards: plan pre-check, ELF machine check of both platforms, node version parity, tag-moved check, amd64 digest verified unchanged afterwards. Scripts copied from cloud-apache-container (.gitea/scripts, so the image's COPY ./scripts is unaffected). Actions pinned to commit SHAs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
9bdd394d59
commit
6547822321
5 files changed
+818
No files matched your search
+230
@@ -0,0 +1,230 @@
|
||||
#!/usr/bin/env bash
|
||||
## attach-arm64-index.test.sh - .gitea/scripts/attach-arm64-index.sh against a stateful stub IMAGETOOLS
|
||||
## that models the registry (tags, digests, index flattening on `create`).
|
||||
set -euo pipefail
|
||||
HERE=$(cd "$(dirname "$0")/.." && pwd)
|
||||
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
|
||||
fail=0
|
||||
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
|
||||
d() { local c=$1; printf 'sha256:'; printf "$c%.0s" {1..64}; } # d a -> sha256:aaaa...
|
||||
A=$(d a); AT=$(d e); B=$(d b); BT=$(d f); C=$(d c); OLD=$(d 1)
|
||||
R=reg/cac
|
||||
|
||||
cat >"$T/stub.py" <<'PY'
|
||||
import hashlib, json, os, sys
|
||||
S = os.environ['STATE']
|
||||
def load(n):
|
||||
p = os.path.join(S, n)
|
||||
return json.load(open(p)) if os.path.exists(p) else {}
|
||||
def save(n, d):
|
||||
json.dump(d, open(os.path.join(S, n), 'w'))
|
||||
def dig(c):
|
||||
return 'sha256:' + hashlib.sha256(json.dumps(c, sort_keys=True).encode()).hexdigest()
|
||||
tags, blobs, arch = load('tags.json'), load('blobs.json'), load('arch.json')
|
||||
args = sys.argv[1:]
|
||||
with open(os.path.join(S, 'log'), 'a') as f:
|
||||
f.write(' '.join(args) + '\n')
|
||||
cmd = args[0]
|
||||
rest = [a for i, a in enumerate(args[1:]) if a != '--builder' and (i == 0 or args[i] != '--builder')]
|
||||
def resolve(ref):
|
||||
if '@' in ref:
|
||||
d = ref.split('@', 1)[1]
|
||||
if d not in blobs: sys.exit(1)
|
||||
return d, blobs[d]
|
||||
if ref not in tags: sys.stderr.write('ERROR: %s: not found\n' % ref); sys.exit(1)
|
||||
c = tags[ref]; return dig(c), c
|
||||
if cmd == 'inspect':
|
||||
raw = '--raw' in rest
|
||||
ref = [a for a in rest if not a.startswith('--') and not a.startswith('{{')][0] if not raw else rest[rest.index('--raw') + 1]
|
||||
if raw:
|
||||
sys.stdout.write(json.dumps(resolve(ref)[1], sort_keys=True))
|
||||
elif '{{.Manifest.Digest}}' in rest:
|
||||
print(resolve(ref)[0])
|
||||
elif '{{json .Image}}' in rest:
|
||||
d, c = resolve(ref)
|
||||
if d not in arch: sys.exit(1)
|
||||
print(json.dumps({'architecture': arch[d]}))
|
||||
elif cmd == 'create':
|
||||
ts = []; srcs = []; i = 0
|
||||
while i < len(rest):
|
||||
if rest[i] == '-t': ts.append(rest[i + 1]); i += 2
|
||||
else: srcs.append(rest[i]); i += 1
|
||||
ms = []
|
||||
for s in srcs:
|
||||
d, c = resolve(s)
|
||||
if 'manifests' in c: ms.extend(c['manifests'])
|
||||
else: ms.append({'digest': d, 'platform': {'os': 'linux', 'architecture': arch[d]}})
|
||||
if os.environ.get('MANGLE') == 'drop-amd64' and len(srcs) == 2:
|
||||
ms = [m for m in ms if m['platform'].get('architecture') != 'amd64']
|
||||
if os.environ.get('MANGLE') == 'fail' and len(srcs) == 2:
|
||||
sys.exit(1)
|
||||
idx = {'mediaType': 'application/vnd.oci.image.index.v1+json', 'manifests': ms}
|
||||
for t in ts:
|
||||
tags[t] = idx
|
||||
blobs[dig(idx)] = idx
|
||||
save('tags.json', tags); save('blobs.json', blobs)
|
||||
PY
|
||||
export IMAGETOOLS="python3 $T/stub.py" STATE=$T/st
|
||||
|
||||
# mk_state <tag-content-kind>: writes the registry fixture. Digests: A amd64 image, AT its attestation,
|
||||
# B arm64 image (new build, pushed by digest, not in any tag), C a second amd64 child.
|
||||
mk() {
|
||||
rm -rf "$T/st"; mkdir -p "$T/st"; : >"$T/st/log"
|
||||
python3 -I - "$1" "$A" "$AT" "$B" "$BT" "$C" "$OLD" "$R" "$T/st" <<'PY'
|
||||
import json, sys, os
|
||||
kind, A, AT, B, BT, C, OLD, R, S = sys.argv[1:]
|
||||
att = lambda d, of: {'digest': d, 'platform': {'os': 'unknown', 'architecture': 'unknown'}, 'annotations': {'vnd.docker.reference.type': 'attestation-manifest', 'vnd.docker.reference.digest': of}}
|
||||
pl = lambda d, a: {'digest': d, 'platform': {'os': 'linux', 'architecture': a}}
|
||||
idx = lambda ms: {'mediaType': 'application/vnd.oci.image.index.v1+json', 'manifests': ms}
|
||||
tags, blobs = {}, {}
|
||||
arch = {A: 'amd64', B: 'arm64', C: 'amd64'}
|
||||
newb = idx([pl(B, 'arm64'), att(BT, B)]) # the arm64 build output (index with attestation)
|
||||
blobs[B] = newb; arch[B] = 'arm64'
|
||||
blobs[A] = {'config': {'digest': 'sha256:' + '9' * 64}, 'layers': []}
|
||||
if kind == 'amd64only': tags[R + ':php82'] = idx([pl(A, 'amd64'), att(AT, A)])
|
||||
elif kind == 'both': tags[R + ':php82'] = idx([pl(A, 'amd64'), att(AT, A), pl(OLD, 'arm64')]); arch[OLD] = 'arm64'
|
||||
elif kind == 'noamd': tags[R + ':php82'] = idx([pl(OLD, 'arm64')]); arch[OLD] = 'arm64'
|
||||
elif kind == 'twoamd': tags[R + ':php82'] = idx([pl(A, 'amd64'), pl(C, 'amd64')])
|
||||
elif kind == 'single': tags[R + ':php82'] = blobs[A]
|
||||
elif kind == 'missing': pass
|
||||
for t, c in list(tags.items()):
|
||||
import hashlib
|
||||
d = 'sha256:' + hashlib.sha256(json.dumps(c, sort_keys=True).encode()).hexdigest()
|
||||
blobs[d] = c
|
||||
if kind == 'single': arch[d] = 'amd64'
|
||||
json.dump(tags, open(S + '/tags.json', 'w')); json.dump(blobs, open(S + '/blobs.json', 'w')); json.dump(arch, open(S + '/arch.json', 'w'))
|
||||
PY
|
||||
}
|
||||
EXP=sha256:$(printf '0%.0s' {1..64})
|
||||
tagdig() { python3 -I -c '
|
||||
import json,hashlib,sys
|
||||
t=json.load(open(sys.argv[1]))[sys.argv[2]]
|
||||
print("sha256:"+hashlib.sha256(json.dumps(t,sort_keys=True).encode()).hexdigest())' "$T/st/tags.json" "$R:php82"; }
|
||||
plats() { python3 -I -c '
|
||||
import json,sys
|
||||
t=json.load(open(sys.argv[1]))[sys.argv[2]]
|
||||
print(" ".join("%s=%s" % (m["platform"]["architecture"], m["digest"]) for m in t["manifests"] if "annotations" not in m))' "$T/st/tags.json" "$R:php82"; }
|
||||
run() { "$HERE/attach-arm64-index.sh" "$@" >"$T/out" 2>"$T/err"; echo $?; }
|
||||
creates() { grep -c '^create' "$T/st/log" || true; }
|
||||
|
||||
# ---- happy path: amd64-only tag + new arm64 -> index with amd64 UNCHANGED + arm64
|
||||
mk amd64only; before=$(tagdig)
|
||||
chk "attach to amd64-only tag -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$before")" 0
|
||||
|
||||
chk " amd64 manifest digest unchanged, arm64 added" "$(plats)" "amd64=$A arm64=$B"
|
||||
chk " amd64 attestation carried over" "$(python3 -I -c 'import json,sys;print(sum(1 for m in json.load(open(sys.argv[1]))[sys.argv[2]]["manifests"] if m["digest"]==sys.argv[3]))' "$T/st/tags.json" "$R:php82" "$AT")" 1
|
||||
chk " exactly one create, from the old index + the arm64 digest" "$(grep -c "^create -t $R:php82 $R@$before $R@$B\$" "$T/st/log")" 1
|
||||
chk " prints before/after/amd64" "$(grep -c "^before_index=$before\$\|^amd64=$A\$\|^after_index=sha256:" "$T/out")" 3
|
||||
[ "$(tagdig)" != "$before" ] && chk " new index digest differs" ok ok || chk " new index digest differs" same differs
|
||||
|
||||
# ---- already multi-arch: refuse (3), nothing written
|
||||
mk both; before=$(tagdig)
|
||||
chk "tag already has arm64 -> rc 3" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$before")" 3
|
||||
chk " no create" "$(creates)" 0
|
||||
chk " tag untouched" "$(tagdig)" "$before"
|
||||
# ---- --force replaces the arm64 entry, amd64 manifest untouched
|
||||
chk "--force on multi-arch -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --force --expect-index "$(tagdig)")" 0
|
||||
chk " arm64 replaced, amd64 same" "$(plats)" "amd64=$A arm64=$B"
|
||||
chk " create used the amd64 child only (old arm64 not a source)" "$(grep -c "^create -t $R:php82 $R@$A $R@$B\$" "$T/st/log")" 1
|
||||
|
||||
# ---- tag moved since the plan
|
||||
mk amd64only
|
||||
chk "--expect-index mismatch -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$C")" 1
|
||||
chk " no create" "$(creates)" 0
|
||||
# ---- --plan-only
|
||||
chk "--plan-only -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --plan-only)" 0
|
||||
chk " no create" "$(creates)" 0
|
||||
mk both
|
||||
chk "--plan-only on multi-arch tag still refuses (3)" "$(run --repo $R --tag php82 --arm64 "$B" --plan-only)" 3
|
||||
|
||||
# ---- bad inputs / bad tags
|
||||
mk amd64only
|
||||
chk "arm64 digest that is not arm64 -> rc 1" "$(run --repo $R --tag php82 --arm64 "$C" --expect-index "$EXP")" 1
|
||||
chk "arm64 digest == amd64 digest -> rc 1" "$(run --repo $R --tag php82 --arm64 "$A" --expect-index "$EXP")" 1
|
||||
chk "arm64 digest unknown to registry -> rc 1" "$(run --repo $R --tag php82 --arm64 "$(d 7)" --expect-index "$EXP")" 1
|
||||
chk "malformed --arm64 -> rc 2" "$(run --repo $R --tag php82 --arm64 nope)" 2
|
||||
chk "--arm64 missing without --plan-only -> rc 2" "$(run --repo $R --tag php82)" 2
|
||||
chk "malformed --expect-index -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index x)" 2
|
||||
chk "bad tag (injection) -> rc 2" "$(run --repo $R --tag 'a b;c' --arm64 "$B")" 2
|
||||
chk "unknown argument -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --bogus)" 2
|
||||
chk " none of those created anything" "$(creates)" 0
|
||||
mk missing
|
||||
chk "missing tag -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$EXP")" 1
|
||||
mk noamd
|
||||
chk "tag without amd64 -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$EXP")" 1
|
||||
mk twoamd
|
||||
chk "tag with two amd64 entries -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$EXP")" 1
|
||||
chk " no create" "$(creates)" 0
|
||||
|
||||
# ---- plain single amd64 manifest tag
|
||||
mk single; before=$(tagdig)
|
||||
chk "single amd64 manifest tag -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$before")" 0
|
||||
chk " create from the manifest digest + arm64" "$(grep -c "^create -t $R:php82 $R@$before $R@$B\$" "$T/st/log")" 1
|
||||
|
||||
# ---- post-create verification: a create that loses amd64 is detected and rolled back
|
||||
mk amd64only; before=$(tagdig)
|
||||
rc=$(MANGLE=drop-amd64 run --repo $R --tag php82 --arm64 "$B" --expect-index "$before"); chk "create dropped amd64 -> rc 1" "$rc" 1
|
||||
chk " restored: tag is the previous index again" "$(plats)" "amd64=$A"
|
||||
chk " second create was the restore from the old index" "$(grep -c "^create -t $R:php82 $R@$before\$" "$T/st/log")" 1
|
||||
mk amd64only
|
||||
rc=$(MANGLE=fail run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)"); chk "create failing -> rc != 0" "$([ "$rc" != 0 ] && echo yes)" yes
|
||||
chk " tag untouched" "$(plats)" "amd64=$A"
|
||||
|
||||
chk "missing --expect-index -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B")" 2
|
||||
# concurrent publish during attach: tag ends with a different amd64 -> never rolled back
|
||||
mk amd64only; before=$(tagdig)
|
||||
cat >"$T/race.sh" <<'RS'
|
||||
#!/usr/bin/env bash
|
||||
python3 "$STUBPY" "$@"; rc=$?
|
||||
if [ "$1" = create ] && [ ! -f "$STATE/raced" ]; then touch "$STATE/raced"; python3 - <<'PY'
|
||||
import json, os
|
||||
S = os.environ['STATE']; t = json.load(open(S + '/tags.json'))
|
||||
k = [x for x in t if x.endswith(':php82')][0]
|
||||
t[k] = {'manifests': [{'digest': 'sha256:' + 'd' * 64, 'platform': {'os': 'linux', 'architecture': 'amd64'}}]}
|
||||
json.dump(t, open(S + '/tags.json', 'w'))
|
||||
PY
|
||||
fi
|
||||
exit $rc
|
||||
RS
|
||||
chmod +x "$T/race.sh"
|
||||
rc=$(STUBPY=$T/stub.py IMAGETOOLS="$T/race.sh" run --repo $R --tag php82 --arm64 "$B" --expect-index "$before"); chk "publish raced in during attach -> rc 1" "$rc" 1
|
||||
chk " newer amd64 NOT rolled back" "$(plats)" "amd64=sha256:$(printf 'd%.0s' {1..64})"
|
||||
chk " no restore create" "$(grep -c "^create -t $R:php82 $R@$before\$" "$T/st/log" || true)" 0
|
||||
|
||||
# ---- --follow-tag: an alias (latest == php85) follows; a different latest is left alone
|
||||
mk amd64only
|
||||
python3 -I - "$T/st/tags.json" "$R" <<'PY'
|
||||
import json, sys
|
||||
t = json.load(open(sys.argv[1])); t[sys.argv[2] + ':latest'] = t[sys.argv[2] + ':php82']; json.dump(t, open(sys.argv[1], 'w'))
|
||||
PY
|
||||
chk "--follow-tag latest (alias) -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag latest)" 0
|
||||
chk " latest now equals the new php82 index" "$(python3 -I -c '
|
||||
import json,sys
|
||||
t=json.load(open(sys.argv[1])); print(t[sys.argv[2]+":latest"]==t[sys.argv[2]+":php82"])' "$T/st/tags.json" "$R")" True
|
||||
chk " latest has amd64 unchanged + arm64" "$(python3 -I -c '
|
||||
import json,sys
|
||||
t=json.load(open(sys.argv[1])); print(" ".join(m["platform"]["architecture"]+"="+m["digest"] for m in t[sys.argv[2]+":latest"]["manifests"] if "annotations" not in m))' "$T/st/tags.json" "$R")" "amd64=$A arm64=$B"
|
||||
mk amd64only
|
||||
python3 -I - "$T/st/tags.json" "$R" "$A" <<'PY'
|
||||
import json, sys
|
||||
t = json.load(open(sys.argv[1])); t[sys.argv[2] + ':latest'] = {'manifests': [{'digest': sys.argv[3], 'platform': {'os': 'linux', 'architecture': 'amd64'}}]}; json.dump(t, open(sys.argv[1], 'w'))
|
||||
PY
|
||||
lbefore=$(python3 -I -c '
|
||||
import json,hashlib,sys
|
||||
t=json.load(open(sys.argv[1]))[sys.argv[2]+":latest"]
|
||||
print("sha256:"+hashlib.sha256(json.dumps(t,sort_keys=True).encode()).hexdigest())' "$T/st/tags.json" "$R")
|
||||
chk "--follow-tag latest (not an alias) -> rc 0, tag attached" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag latest)" 0
|
||||
chk " latest untouched" "$(python3 -I -c '
|
||||
import json,hashlib,sys
|
||||
t=json.load(open(sys.argv[1]))[sys.argv[2]+":latest"]
|
||||
print("sha256:"+hashlib.sha256(json.dumps(t,sort_keys=True).encode()).hexdigest())' "$T/st/tags.json" "$R")" "$lbefore"
|
||||
mk amd64only
|
||||
chk "--follow-tag with missing latest -> rc 0, left alone" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag latest)" 0
|
||||
chk "bad --follow-tag -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag 'x y')" 2
|
||||
chk "--follow-tag == --tag -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag php82)" 2
|
||||
|
||||
# ---- GITHUB_OUTPUT
|
||||
mk amd64only; GITHUB_OUTPUT=$T/gho "$HERE/attach-arm64-index.sh" --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" >/dev/null 2>&1
|
||||
chk "GITHUB_OUTPUT has after_index and platforms" "$(grep -c '^after_index=\|^platforms=linux/amd64,linux/arm64$' "$T/gho")" 2
|
||||
|
||||
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo FAILURES; exit 1; }
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
## verify-image-arch.test.sh - .gitea/scripts/verify-image-arch.py against a stub `docker` that serves
|
||||
## fabricated ELF headers through `docker cp -L ctr:path -` (a tar stream), like the real one.
|
||||
set -euo pipefail
|
||||
HERE=$(cd "$(dirname "$0")/.." && pwd)
|
||||
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
|
||||
fail=0
|
||||
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
|
||||
|
||||
cat >"$T/mktar.py" <<'PY'
|
||||
import io, os, struct, sys, tarfile
|
||||
path = sys.argv[1]
|
||||
spec = dict(l.rstrip('\n').split('=', 1) for l in open(os.environ['FIX']) if '=' in l).get(path)
|
||||
if spec is None or spec == 'missing':
|
||||
sys.stderr.write('Error response from daemon: Could not find the file %s in container\n' % path); sys.exit(1)
|
||||
if spec == 'notelf': head = b'#!/bin/sh\necho hi\n' + b'\0' * 64
|
||||
elif spec == 'elf32': head = b'\x7fELF\x01\x01\x01' + b'\0' * 11 + struct.pack('<H', 0x3E) + b'\0' * 60
|
||||
elif spec == 'be': head = b'\x7fELF\x02\x02\x01' + b'\0' * 11 + struct.pack('>H', 0xB7) + b'\0' * 60
|
||||
elif spec == 'dir':
|
||||
t = tarfile.open(fileobj=sys.stdout.buffer, mode='w|'); ti = tarfile.TarInfo('d'); ti.type = tarfile.DIRTYPE; t.addfile(ti); t.close(); sys.exit(0)
|
||||
else: head = b'\x7fELF\x02\x01\x01' + b'\0' * 11 + struct.pack('<H', int(spec, 16)) + b'\0' * 60
|
||||
body = head + b'\0' * 200000 # bigger than the pipe buffer: reader must stop early
|
||||
t = tarfile.open(fileobj=sys.stdout.buffer, mode='w|')
|
||||
ti = tarfile.TarInfo(os.path.basename(path)); ti.size = len(body); t.addfile(ti, io.BytesIO(body)); t.close()
|
||||
PY
|
||||
cat >"$T/dk" <<'STUB'
|
||||
#!/usr/bin/env bash
|
||||
echo "$*" >>"$LOG"
|
||||
case "$1" in
|
||||
pull) exit "${PULL_RC:-0}" ;;
|
||||
create) [ "${CREATE_RC:-0}" = 0 ] || { echo "no such image" >&2; exit 1; }; echo cid1 ;;
|
||||
rm|image) ;;
|
||||
cp) python3 -I "$MKTAR" "${3#*:}" ;;
|
||||
esac
|
||||
STUB
|
||||
chmod +x "$T/dk"
|
||||
export DOCKER="$T/dk" FIX=$T/fix LOG=$T/log MKTAR=$T/mktar.py
|
||||
V="python3 -I $HERE/verify-image-arch.py"
|
||||
run() { : >"$LOG"; $V "$@" >"$T/out" 2>"$T/err"; echo $?; }
|
||||
|
||||
printf '%s\n' /usr/bin/php=b7 /usr/sbin/httpd=b7 >"$T/fix"
|
||||
chk "arm64 image with aarch64 binaries -> 0" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/sbin/httpd --bin /usr/bin/php)" 0
|
||||
chk " pulled with the platform flag, container removed" "$(grep -c '^pull --quiet --platform linux/arm64 r/x@sha256:1$\|^rm -f cid1$' "$LOG")" 2
|
||||
chk " prints AArch64" "$(grep -c 'e_machine=0xB7 (AArch64)' "$T/out")" 2
|
||||
printf '%s\n' /usr/bin/php=3e >"$T/fix"
|
||||
chk "arm64 image carrying an x86-64 binary -> 1" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php)" 1
|
||||
chk " says x86-64 was found" "$(grep -c 'FAIL.*e_machine=0x3E (x86-64), want 0xB7 (AArch64)' "$T/out")" 1
|
||||
chk "amd64 image with x86-64 binary -> 0" "$(run --image r/x@sha256:1 --platform linux/amd64 --bin /usr/bin/php)" 0
|
||||
printf '%s\n' /usr/bin/php=b7 >"$T/fix"
|
||||
chk "amd64 image carrying an aarch64 binary -> 1" "$(run --image r/x@sha256:1 --platform linux/amd64 --bin /usr/bin/php)" 1
|
||||
printf '%s\n' /usr/bin/php=b7 /usr/sbin/httpd=3e >"$T/fix"
|
||||
chk "one good + one wrong binary -> 1 (all are checked)" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php --bin /usr/sbin/httpd)" 1
|
||||
chk " the good one is still reported OK" "$(grep -c '^OK ' "$T/out")" 1
|
||||
printf '%s\n' /bin/a=notelf /bin/b=elf32 /bin/c=be /bin/d=dir /bin/e=missing >"$T/fix"
|
||||
for b in a b c d e; do chk "bad binary /bin/$b -> 1" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /bin/$b)" 1; done
|
||||
chk "binary absent from the fixture -> 1" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/nothere)" 1
|
||||
printf '%s\n' /usr/bin/php=b7 >"$T/fix"
|
||||
chk "docker pull fails (3 attempts) -> 4, not an arch verdict" "$(VERIFY_PULL_SLEEP=0 PULL_RC=1 run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php)" 4
|
||||
chk " pull was tried 3 times" "$(grep -c '^pull' "$LOG")" 3
|
||||
chk "docker create fails -> 1" "$(CREATE_RC=1 run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php)" 1
|
||||
chk "pulled image is removed afterwards" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php >/dev/null; grep -c '^image rm r/x@sha256:1$' "$LOG")" 1
|
||||
chk "--no-pull skips the pull" "$(run --image r/x@sha256:1 --platform linux/arm64 --no-pull --bin /usr/bin/php; grep -c '^pull' "$LOG" || true)" "0
|
||||
0"
|
||||
chk "usage: no --bin -> 2" "$(run --image r/x --platform linux/arm64)" 2
|
||||
chk "usage: bad platform -> 2" "$(run --image r/x --platform linux/s390x --bin /usr/bin/php)" 2
|
||||
|
||||
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo FAILURES; exit 1; }
|
||||
Reference in new issue
Block a user