diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83472d1..77b23b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,6 +80,12 @@ jobs: make build docker build --progress=plain --build-arg VERSION="$(git describe --tags --always)" -t runlike-local:dev . RUNLIKE_BIN="$PWD/build/runlike" RUNLIKE_IMAGE=runlike-local:dev go test -count=1 ./test/compat/ + # The .debs from make cross, and a repository signed with a + # throwaway key, installed in debian:stable and ubuntu:24.04. + - name: apt packages and repository + env: + DOCKER_HOST: unix:///var/run/docker.sock + run: test/apt/test.sh dist # Windows containers on Docker Engine 29.9.3: the Windows round trip, and # the PowerShell and cmd quoting in the real shells (fuzz and live). diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 920b702..18578e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,9 @@ # publishes the GitHub release (those notes, binaries, SHA256SUMS; the macOS # binary signed and notarized by Apple first, job build) and the # image assaflavie/runlike:X.Y.Z (+ :latest for the newest non-prerelease), -# and, for the newest non-prerelease, the formula in lavie/homebrew-tap. +# the .deb packages (also in the release), and, for the newest +# non-prerelease, the formula in lavie/homebrew-tap and the signed APT +# repository lavie/apt (https://lavie.github.io/apt). # A version whose release failed stays pending: the next push to master # releases it on that newer commit. # @@ -14,7 +16,8 @@ # version: without "republish" it releases that pending version on the # current master head (its tag must not exist); with "republish" it publishes # the existing tag again from the tagged commit. The secrets (DOCKERHUB_TOKEN, -# HOMEBREW_TAP_TOKEN, the Apple signing and notarization secrets) live only in the environment +# HOMEBREW_TAP_TOKEN, APT_REPO_TOKEN, APT_GPG_PRIVATE_KEY, APT_GPG_PASSPHRASE, +# the Apple signing and notarization secrets) live only in the environment # "release", which deploys from master only. # Never publishes to PyPI. name: release @@ -168,22 +171,25 @@ jobs: repository: lavie/homebrew-tap token: ${{ secrets.HOMEBREW_TAP_TOKEN }} path: .tap - # The formula script comes from the workflow's own commit, so a - # republish of a tag older than the script updates the tap too. + # The APT repository, for the same reason and the same versions. + - if: env.LATEST == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: lavie/apt + token: ${{ secrets.APT_REPO_TOKEN }} + path: .apt + # The formula and package scripts come from the workflow's own commit, + # so a republish of a tag older than the scripts updates them too. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: path: .tools - sparse-checkout: scripts/homebrew-formula.sh + sparse-checkout: | + scripts/homebrew-formula.sh + scripts/deb.sh + scripts/apt-repo.sh + LICENSE.txt sparse-checkout-cone-mode: false persist-credentials: false - - name: Tag the release commit - run: | - if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then - test "$(git rev-list -n1 "$TAG")" = "$COMMIT" || { echo "$TAG is not on $COMMIT"; exit 1; } - else - git tag "$TAG" "$COMMIT" - git push origin "refs/tags/$TAG" - fi - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: release-dist @@ -197,6 +203,40 @@ jobs: test -n "$DARWIN_SHA256" test "$(awk '$2 == "runlike-darwin-arm64" {print $1}' SHA256SUMS)" = "$DARWIN_SHA256" \ || { echo "runlike-darwin-arm64 is not the signed binary from build"; exit 1; } + # The .debs, from those same Linux binaries; dated by the release + # commit, so a republish builds the same bytes. deb.sh adds them to + # SHA256SUMS. + - name: .deb packages + run: | + SOURCE_DATE_EPOCH=$(git log -1 --format=%ct "$COMMIT") .tools/scripts/deb.sh "$VERSION" dist + # Sign the APT repository before the tag, so a bad key or passphrase + # stops the release here; it is pushed after the image. apt-repo.sh + # refuses a key other than the one the repository already publishes. + - name: APT repository + if: env.LATEST == 'true' + env: + APT_GPG_PRIVATE_KEY: ${{ secrets.APT_GPG_PRIVATE_KEY }} + APT_GPG_PASSPHRASE: ${{ secrets.APT_GPG_PASSPHRASE }} + run: | + command -v apt-ftparchive >/dev/null || { sudo apt-get update -q && sudo apt-get install -y -q apt-utils; } + export GNUPGHOME="$RUNNER_TEMP/gnupg" + install -d -m 700 "$GNUPGHOME" + gpg --batch --import <<<"$APT_GPG_PRIVATE_KEY" + .tools/scripts/apt-repo.sh .apt dist/runlike_*.deb + gpg --batch --verify .apt/dists/stable/InRelease + rm -rf "$GNUPGHOME" + cd .apt + git add -A + git diff --cached --quiet || git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ + commit -qm "runlike $VERSION" + - name: Tag the release commit + run: | + if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then + test "$(git rev-list -n1 "$TAG")" = "$COMMIT" || { echo "$TAG is not on $COMMIT"; exit 1; } + else + git tag "$TAG" "$COMMIT" + git push origin "refs/tags/$TAG" + fi - name: GitHub release env: GH_TOKEN: ${{ github.token }} @@ -231,3 +271,6 @@ jobs: git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ commit -qm "runlike $VERSION" git push origin HEAD + - name: APT repository push + if: env.LATEST == 'true' + run: git -C .apt push origin HEAD diff --git a/README.md b/README.md index 113f085..b4a2c07 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,22 @@ option of Docker CLI v29.9.3 (see [Supported options](#supported-options)). brew install lavie/tap/runlike ``` +- **apt** on Debian and Ubuntu (amd64, arm64), from the signed repository + [lavie/apt](https://github.com/lavie/apt). Once: + + ``` + sudo install -d -m 0755 /etc/apt/keyrings + sudo curl -fsSLo /etc/apt/keyrings/runlike.asc https://lavie.github.io/apt/runlike.asc + printf 'Types: deb\nURIs: https://lavie.github.io/apt\nSuites: stable\nComponents: main\nSigned-By: /etc/apt/keyrings/runlike.asc\n' \ + | sudo tee /etc/apt/sources.list.d/runlike.sources >/dev/null + ``` + + Then `sudo apt-get update && sudo apt-get install runlike`; `apt-get + upgrade` keeps it current. Without the repository: download + `runlike_X.Y.Z_amd64.deb` (or `_arm64.deb`) from the releases page and + run `sudo apt install ./runlike_*.deb`. The package suggests the Docker + CLI but does not install it: use `docker-ce-cli`, `docker.io` or a remote + context. - **With Go** (1.24 or later): ``` diff --git a/RELEASING.md b/RELEASING.md index ab90123..f716b3c 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -86,7 +86,16 @@ On every push to `master`: release waits for one. 4. **publish**, in the environment `release`: - It tags that commit `vX.Y.Z`. - - It takes the binaries and `SHA256SUMS` from build, unchanged. + - It takes the binaries and `SHA256SUMS` from build, unchanged, and + builds `runlike_X.Y.Z_amd64.deb` and `_arm64.deb` from the Linux + binaries ([scripts/deb.sh](scripts/deb.sh)), adding them to + `SHA256SUMS`. + - For the newest non-prerelease, it adds the .debs to the APT + repository [lavie/apt](https://github.com/lavie/apt) and signs it + ([scripts/apt-repo.sh](scripts/apt-repo.sh)), still before the tag, + so a bad key or token stops the release there. It pushes the + repository after the image; GitHub Pages serves it at + `https://lavie.github.io/apt`. - It creates the GitHub release with the notes file as its text and attaches the binaries. - It pushes the image `assaflavie/runlike:X.Y.Z` for linux/amd64 and @@ -97,6 +106,8 @@ On every push to `master`: ([scripts/homebrew-formula.sh](scripts/homebrew-formula.sh)): the release binaries for macOS arm64 and Linux, with their checksums. Users install with `brew install lavie/tap/runlike`. + - It pushes the APT repository. Users install with `apt-get install + runlike` after the one-time setup in the README. The release commit is the master commit the merge pushed, never a commit from the pull request's branch. With a merge commit, that is the merge @@ -160,6 +171,22 @@ Never publish to PyPI. The Python 1.x package is frozen. - [ ] **The tap repository `lavie/homebrew-tap`**: public. The release workflow writes its `Formula/runlike.rb`; do not edit that file by hand. +- [ ] **The APT repository `lavie/apt`**: public, created with a README + (the workflow cannot check out an empty repository). Settings > + Pages: "Deploy from a branch", branch `main`, folder `/ (root)`. The + release workflow writes everything else; do not edit it by hand. + - Environment secret `APT_REPO_TOKEN`: a fine-grained GitHub token + owned by `lavie`, with access to `lavie/apt` only and the permission + Contents: Read and write. Renew it before it expires, or releases fail + before the tag. + - Environment secrets `APT_GPG_PRIVATE_KEY` (the ASCII-armored secret + key, `gpg --armor --export-secret-keys FINGERPRINT`) and + `APT_GPG_PASSPHRASE`: a dedicated ed25519 signing key that signs + nothing else, with no expiry. Keep a copy in the password manager. + Users trust the published `runlike.asc`; `scripts/apt-repo.sh` + refuses to sign with any other key. To replace the key, delete + `runlike.asc` from `lavie/apt` first, and tell users to download it + again. - [ ] **Settings > Secrets and variables > Actions**: no repository-level secrets. Delete `DOCKERHUB_TOKEN` there if it exists. - [ ] **Settings > Rules > Rulesets > New branch ruleset** for `master` diff --git a/docs/assets/site.css b/docs/assets/site.css index a318cb9..74c1390 100644 --- a/docs/assets/site.css +++ b/docs/assets/site.css @@ -157,7 +157,7 @@ main > section { padding: clamp(3rem, 7vw, 5.5rem) max(var(--pad), calc((100% - .ways input.tab:checked + label.tab { color: var(--text); border-color: var(--border); border-bottom-color: var(--surface); background: var(--surface); } .ways input.tab:focus-visible + label.tab { outline: 3px solid var(--accent); outline-offset: -3px; } .ways .way { display: none; width: 100%; order: 1; padding: 1.4rem 0 .6rem; border-top: 1px solid var(--border); } -#way-sh:checked ~ #way-sh-panel, #way-brew:checked ~ #way-brew-panel, #way-go:checked ~ #way-go-panel, #way-docker:checked ~ #way-docker-panel { display: block; } +#way-sh:checked ~ #way-sh-panel, #way-brew:checked ~ #way-brew-panel, #way-apt:checked ~ #way-apt-panel, #way-go:checked ~ #way-go-panel, #way-docker:checked ~ #way-docker-panel { display: block; } .copy-block { display: flex; align-items: flex-start; background: var(--term-bg); color: var(--term-text); border-radius: 10px; margin: 0 0 .8rem; } .copy-block pre { flex: 1; min-width: 0; padding: .9rem 1rem; font: 13px/1.6 var(--mono); overflow-x: auto; } @media (max-width: 600px) { .copy-block pre { white-space: pre-wrap; overflow-wrap: anywhere; } } diff --git a/docs/index.html b/docs/index.html index feb3df5..7a679b8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -104,6 +104,7 @@

Download

+
@@ -116,6 +117,16 @@

Download

On macOS (Apple Silicon) and Linux, from the tap lavie/homebrew-tap. brew upgrade keeps it current.

brew install lavie/tap/runlike
+
+

On Debian and Ubuntu (amd64, arm64), from the signed repository lavie/apt. Add it once:

+
sudo install -d -m 0755 /etc/apt/keyrings
+sudo curl -fsSLo /etc/apt/keyrings/runlike.asc https://lavie.github.io/apt/runlike.asc
+printf 'Types: deb\nURIs: https://lavie.github.io/apt\nSuites: stable\nComponents: main\nSigned-By: /etc/apt/keyrings/runlike.asc\n' \
+  | sudo tee /etc/apt/sources.list.d/runlike.sources >/dev/null
+

Then install. apt-get upgrade keeps it current:

+
sudo apt-get update && sudo apt-get install runlike
+

Or download the .deb from the latest release and sudo apt install ./runlike_*.deb. The Docker CLI is suggested, not installed.

+

Go 1.24 or later. Lands in $(go env GOPATH)/bin.

go install github.com/lavie/runlike/v2/cmd/runlike@latest
diff --git a/scripts/apt-repo.sh b/scripts/apt-repo.sh new file mode 100755 index 0000000..111d4af --- /dev/null +++ b/scripts/apt-repo.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# apt-repo.sh REPO DEB...: add the .deb files to the static APT repository +# in REPO (the checkout of lavie/apt), rebuild its indexes and sign them. +# REPO/pool/main/r/runlike/*.deb every version ever added +# REPO/dists/stable/main/binary-{amd64,arm64}/Packages{,.gz} +# REPO/dists/stable/{Release,InRelease,Release.gpg} +# REPO/runlike.asc the public signing key +# Signs with the one secret key in $GNUPGHOME; its passphrase comes from +# $APT_GPG_PASSPHRASE (may be empty). Needs apt-ftparchive (apt-utils) and gpg. +set -euo pipefail +repo=${1:?usage: apt-repo.sh REPO DEB...} +shift +[ $# -gt 0 ] || { echo "usage: apt-repo.sh REPO DEB..." >&2; exit 1; } +fpr=$(gpg --batch --with-colons --list-secret-keys | awk -F: '$1 == "fpr" {print $10; exit}') +n=$(gpg --batch --with-colons --list-secret-keys | grep -c '^sec:' || true) +[ "$n" = 1 ] || { echo "need exactly one secret key in GNUPGHOME, found $n" >&2; exit 1; } +# Users trust the key in runlike.asc: a different key would break every +# apt-get update. To rotate the key on purpose, delete runlike.asc first. +if [ -f "$repo/runlike.asc" ]; then + old=$(gpg --batch --with-colons --show-keys "$repo/runlike.asc" | awk -F: '$1 == "fpr" {print $10; exit}') + [ "$old" = "$fpr" ] || { echo "$repo is signed by $old, not by this key $fpr" >&2; exit 1; } +fi + +pool=$repo/pool/main/r/runlike +mkdir -p "$pool" +cp "$@" "$pool/" +cd "$repo" +for arch in amd64 arm64; do + d=dists/stable/main/binary-$arch + mkdir -p "$d" + apt-ftparchive --arch "$arch" packages pool/main >"$d/Packages" + gzip -9nkf "$d/Packages" +done +s=dists/stable +rm -f "$s/Release" "$s/InRelease" "$s/Release.gpg" +apt-ftparchive \ + -o APT::FTPArchive::Release::Origin=runlike \ + -o APT::FTPArchive::Release::Label=runlike \ + -o APT::FTPArchive::Release::Suite=stable \ + -o APT::FTPArchive::Release::Codename=stable \ + -o APT::FTPArchive::Release::Architectures="amd64 arm64" \ + -o APT::FTPArchive::Release::Components=main \ + -o APT::FTPArchive::Release::Description="runlike, github.com/lavie/runlike" \ + release "$s" >Release.tmp +mv Release.tmp "$s/Release" +sign() { gpg --batch --yes --pinentry-mode loopback --passphrase-fd 3 --local-user "$fpr" "$@" 3<<<"${APT_GPG_PASSPHRASE:-}"; } +sign --clearsign -o "$s/InRelease" "$s/Release" +sign --armor --detach-sign -o "$s/Release.gpg" "$s/Release" +gpg --batch --armor --export "$fpr" >runlike.asc +touch .nojekyll # GitHub Pages: serve the files as they are diff --git a/scripts/deb.sh b/scripts/deb.sh new file mode 100755 index 0000000..387a8d9 --- /dev/null +++ b/scripts/deb.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# deb.sh VERSION DIST: build runlike_VERSION_amd64.deb and _arm64.deb in +# DIST from DIST/runlike-linux-amd64 and -arm64 (make cross output), and +# add them to DIST/SHA256SUMS. VERSION is the tag without v; a +# pre-release 2.1.0-rc.1 becomes the Debian version 2.1.0~rc.1, which +# sorts before 2.1.0. Needs dpkg-deb. Reproducible: file times and the +# archive come from SOURCE_DATE_EPOCH (default: 0). +set -euo pipefail +v=${1:?usage: deb.sh VERSION DIST} +dist=${2:?usage: deb.sh VERSION DIST} +[[ $v =~ ^[0-9][0-9A-Za-z.+-]*$ ]] || { echo "bad version: $v" >&2; exit 1; } +here=$(cd "$(dirname "$0")" && pwd) +export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-0} +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +for arch in amd64 arm64; do + r=$tmp/$arch + install -d "$r/DEBIAN" "$r/usr/bin" "$r/usr/share/doc/runlike" + install -m 0755 "$dist/runlike-linux-$arch" "$r/usr/bin/runlike" + install -m 0644 "$here/../LICENSE.txt" "$r/usr/share/doc/runlike/copyright" + # Suggests, not Recommends: apt installs Recommends by default, and + # docker.io would pull in a whole Docker Engine. People use + # docker-ce-cli, Debian's docker-cli, docker.io or a remote context. + cat >"$r/DEBIAN/control" <<-EOF + Package: runlike + Version: ${v//-/\~} + Architecture: $arch + Maintainer: Assaf Lavie + Installed-Size: $(du -sk "$r/usr" | cut -f1) + Suggests: docker-ce-cli | docker-cli | docker.io + Section: admin + Priority: optional + Homepage: https://github.com/lavie/runlike + Description: print the docker run command that recreates a container + runlike reads docker inspect output and prints the docker run command + line, with every option, that runs another container just like it. + EOF + find "$r" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} + + dpkg-deb --root-owner-group -Zxz --build "$r" "$dist/runlike_${v}_$arch.deb" >/dev/null + echo "$dist/runlike_${v}_$arch.deb" +done +cd "$dist" +# Keep SHA256SUMS one line per file: drop old .deb lines, then add. +{ grep -v '\.deb$' SHA256SUMS || true; sha256sum runlike_*.deb; } >"$tmp/sums" +mv "$tmp/sums" SHA256SUMS diff --git a/test/apt/test.sh b/test/apt/test.sh new file mode 100755 index 0000000..504571f --- /dev/null +++ b/test/apt/test.sh @@ -0,0 +1,119 @@ +#!/bin/bash +# test/apt/test.sh DIST: test the .deb packages and the signed APT +# repository end to end, all in containers on the current docker daemon +# (DOCKER_HOST or context), so it runs on a Lima VM and in CI alike. +# DIST holds make cross output (runlike-linux-amd64, -arm64, SHA256SUMS). +# 1. In debian:stable: scripts/deb.sh builds both .debs; dpkg-deb -I/-c +# checks them; a throwaway key (with a passphrase) signs a repository +# built by scripts/apt-repo.sh. The key dies with the container. +# 2. busybox httpd serves that repository on a private network. +# 3. In debian:stable and ubuntu:24.04 (the daemon's architecture): +# apt install ./runlike_*.deb; then apt-get update with a wrong key +# must fail; with the right key, apt-get install runlike must work and +# must not pull in docker. +set -euo pipefail +dist=$(cd "${1:?usage: test/apt/test.sh DIST}" && pwd) +root=$(cd "$(dirname "$0")/../.." && pwd) +v=0.0.0-test +id=rl-apt-$$ +tmp=$(mktemp -d) +cleanup() { + docker rm -f "$id-build" "$id-repo" "$id-client" >/dev/null 2>&1 || true + docker network rm "$id" >/dev/null 2>&1 || true + rm -rf "$tmp" +} +trap cleanup EXIT + +echo "== build the .debs and a signed repository (throwaway key)" +mkdir -p "$tmp/src/scripts" "$tmp/src/dist" +cp "$root/scripts/deb.sh" "$root/scripts/apt-repo.sh" "$tmp/src/scripts/" +cp "$root/LICENSE.txt" "$tmp/src/" +cp "$dist/runlike-linux-amd64" "$dist/runlike-linux-arm64" "$dist/SHA256SUMS" "$tmp/src/dist/" +docker create --name "$id-build" -w /src -e DEBIAN_FRONTEND=noninteractive debian:stable bash -euo pipefail -c ' + apt-get update -qq && apt-get install -y -qq --no-install-recommends dpkg-dev apt-utils gpg gpg-agent >/dev/null + scripts/deb.sh '"$v"' dist + for a in amd64 arm64; do + f=dist/runlike_'"$v"'_$a.deb + dpkg-deb -I "$f" >&2 + test "$(dpkg-deb -f "$f" Version)" = 0.0.0~test + test "$(dpkg-deb -f "$f" Architecture)" = "$a" + c=$(dpkg-deb -c "$f") && echo "$c" >&2 + test "$(grep -c "/usr/bin/runlike$" <<<"$c")" = 1 + grep -q -- "^-rwxr-xr-x root/root .* ./usr/bin/runlike$" <<<"$c" + cmp <(dpkg-deb --fsys-tarfile "$f" | tar -xO ./usr/bin/runlike) dist/runlike-linux-$a + done + (cd dist && sha256sum --quiet --ignore-missing -c SHA256SUMS) + test "$(grep -c "\.deb$" dist/SHA256SUMS)" = 2 + # Same input, same bytes: a republish does not change the .debs. + cp dist/runlike_'"$v"'_amd64.deb /tmp/first.deb && scripts/deb.sh '"$v"' dist >/dev/null + cmp /tmp/first.deb dist/runlike_'"$v"'_amd64.deb + test "$(grep -c "\.deb$" dist/SHA256SUMS)" = 2 + export GNUPGHOME=$(mktemp -d) APT_GPG_PASSPHRASE=throwaway-test + gpg --batch --passphrase "$APT_GPG_PASSPHRASE" --quick-gen-key "runlike test " ed25519 sign never + mkdir /out && scripts/apt-repo.sh /out/repo dist/*.deb + gpg --batch --verify /out/repo/dists/stable/InRelease + gpg --batch --verify /out/repo/dists/stable/Release.gpg /out/repo/dists/stable/Release + # As in release.yml: the armored secret key (the environment secret) + # imported into a fresh GNUPGHOME signs a second run, which keeps the + # repository valid. + key=$(gpg --batch --pinentry-mode loopback --passphrase "$APT_GPG_PASSPHRASE" --armor --export-secret-keys) + export GNUPGHOME=$(mktemp -d) + gpg --batch --import <<<"$key" + scripts/apt-repo.sh /out/repo dist/*.deb + gpg --batch --verify /out/repo/dists/stable/InRelease + cp dist/*.deb /out/ + export GNUPGHOME=$(mktemp -d) + gpg --batch --passphrase "" --quick-gen-key "wrong key " ed25519 sign never + gpg --batch --armor --export >/out/wrong.asc + # Another key must not re-sign the repository. + if APT_GPG_PASSPHRASE= scripts/apt-repo.sh /out/repo dist/*.deb 2>/tmp/e; then echo "re-signed with another key"; exit 1; fi + grep -q "is signed by" /tmp/e +' >/dev/null +docker cp "$tmp/src/." "$id-build:/src" +docker start -a "$id-build" +docker cp "$id-build:/out" "$tmp/out" +(cd "$tmp/out/repo" && find . -type f | sort) + +echo "== serve it" +docker network create "$id" >/dev/null +docker create --name "$id-repo" --network "$id" --network-alias repo busybox:stable httpd -f -p 80 -h /srv >/dev/null +docker cp "$tmp/out/repo/." "$id-repo:/srv" +docker start "$id-repo" >/dev/null + +for image in debian:stable ubuntu:24.04; do + echo "== $image" + docker create --name "$id-client" --network "$id" -w /t -e DEBIAN_FRONTEND=noninteractive "$image" bash -euo pipefail -c ' + a=$(dpkg --print-architecture) + no() { if "$@"; then echo "unexpected success: $*"; exit 1; fi; } # "! cmd" ignores set -e + check() { + runlike --version | tee /dev/stderr | grep "^runlike " >/dev/null + out=$(echo "[{\"Name\":\"/web\",\"Config\":{\"Image\":\"nginx:1.27\",\"Env\":[\"A=b c\"]},\"HostConfig\":{}}]" | runlike --stdin 2>/dev/null) + test "$out" = "docker run --name=web '"'"'--env=A=b c'"'"' --detach nginx:1.27" + test "$(dpkg-query -W -f "\${Version}" runlike)" = 0.0.0~test + no command -v docker + } + apt-get update -qq + apt-get install -y -qq ./runlike_'"$v"'_$a.deb >/dev/null + check + apt-get purge -y -qq runlike >/dev/null + no command -v runlike + + install -d /etc/apt/keyrings + src() { printf "Types: deb\nURIs: http://repo\nSuites: stable\nComponents: main\nSigned-By: /etc/apt/keyrings/runlike.asc\n" >/etc/apt/sources.list.d/runlike.sources; } + cp wrong.asc /etc/apt/keyrings/runlike.asc && src + if apt-get update >/tmp/u 2>&1; then cat /tmp/u; echo "wrong key accepted"; exit 1; fi + grep -q "is not signed" /tmp/u + echo "wrong key rejected" + cp runlike.asc /etc/apt/keyrings/runlike.asc + apt-get update 2>&1 | tee /tmp/u + no grep -q "^[WE]:" /tmp/u + apt-get install -y -qq runlike >/dev/null + check + echo "OK $(. /etc/os-release && echo "$PRETTY_NAME") $a" + ' >/dev/null + mkdir -p "$tmp/t"; cp "$tmp/out/wrong.asc" "$tmp/out/repo/runlike.asc" "$tmp/out/"*.deb "$tmp/t/" + docker cp "$tmp/t/." "$id-client:/t" + docker start -a "$id-client" + docker rm "$id-client" >/dev/null +done +echo "PASS"