From 772eba1e20647605be07c1e8fdb58051b0153280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Schl=C3=B6ffel?= Date: Sun, 7 Jun 2026 22:29:58 +0200 Subject: [PATCH] Add Alpine package test shell --- README.md | 6 ++++ mise.toml | 4 +++ scripts/apk/test-shell.sh | 60 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100755 scripts/apk/test-shell.sh diff --git a/README.md b/README.md index b7c3b5b..81f6786 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ mise run apk:checksum mise run apk:lint mise run apk:packages mise run apk:smoke +mise run apk:test-shell mise run apk:publish-check mise run apk:shell mise run apk:clean @@ -53,11 +54,16 @@ cached in `.cache/abuild/` and `.cache/apk-distfiles/`. ```sh mise run apk:smoke +mise run apk:test-shell mise run apk:publish-check ``` `apk:publish-check` runs APKBUILD linting, rebuilds configured architectures, lists package metadata, and installs the built packages in an Alpine container. +`apk:test-shell` builds the selected architecture, installs the local package +set in an Alpine container, and opens a shell. Use `SKIP_BUILD=1` to reuse an +existing local repository. Set `TEST_SHELL_TIMEOUT` to adjust the timeout for +`apk update` and `apk add` inside the test container. Install from the local repo with the base package plus the role-specific OpenRC subpackage you need: diff --git a/mise.toml b/mise.toml index 44ba9ad..66ed676 100644 --- a/mise.toml +++ b/mise.toml @@ -35,6 +35,10 @@ run = "scripts/apk/build.sh lint" description = "Install-test built packages from the local repository in Docker" run = "scripts/apk/smoke.sh" +[tasks."apk:test-shell"] +description = "Open an Alpine shell with the current local package build installed" +run = "scripts/apk/test-shell.sh" + [tasks."apk:packages"] description = "List built Alpine packages and dependencies" run = "scripts/apk/list-packages.sh" diff --git a/scripts/apk/test-shell.sh b/scripts/apk/test-shell.sh new file mode 100755 index 0000000..04f95fd --- /dev/null +++ b/scripts/apk/test-shell.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +alpine_version="${ALPINE_VERSION:-3.22}" +platform="${ALPINE_BUILD_PLATFORM:-linux/amd64}" +arch="${ALPINE_ARCH:-x86_64}" +packages="${TEST_SHELL_PACKAGES:-seaweedfs seaweedfs-doc bash-completion seaweedfs-master-openrc seaweedfs-filer-openrc seaweedfs-worker-openrc}" +shell="${TEST_SHELL:-/bin/bash}" +timeout_seconds="${TEST_SHELL_TIMEOUT:-120}" + +case "${arch}" in + x86_64|aarch64) ;; + *) printf 'unsupported Alpine architecture: %s\n' "${arch}" >&2; exit 2 ;; +esac + +if [[ "${SKIP_BUILD:-0}" != "1" ]]; then + "${repo_root}/scripts/apk/build.sh" build "${arch}" +fi + +if [[ ! -d "${repo_root}/packages/local/${arch}" ]]; then + printf 'missing local repository: packages/local/%s\n' "${arch}" >&2 + printf 'run: mise run apk:build\n' >&2 + exit 1 +fi + +docker_args=(--rm --platform "${platform}") +if [[ -t 0 && -t 1 ]]; then + docker_args+=(-it) +fi + +docker run "${docker_args[@]}" \ + -e "ALPINE_ARCH=${arch}" \ + -e "PACKAGE_LIST=${packages}" \ + -e "TEST_SHELL=${shell}" \ + -e "TEST_SHELL_TIMEOUT=${timeout_seconds}" \ + -v "${repo_root}:/work:ro" \ + -v "${repo_root}/packages/local:/repo:ro" \ + "alpine:${alpine_version}" \ + sh -lc ' + set -e + printf "Installing repository key for %s...\n" "${ALPINE_ARCH}" + cp "/repo/${ALPINE_ARCH}"/*.rsa.pub /etc/apk/keys/ + echo /repo >> /etc/apk/repositories + + printf "Refreshing apk indexes...\n" + timeout "${TEST_SHELL_TIMEOUT}" apk update + + printf "Installing test packages: %s\n" "${PACKAGE_LIST}" + timeout "${TEST_SHELL_TIMEOUT}" apk add ${PACKAGE_LIST} + + printf "\nInstalled SeaweedFS packages:\n" + apk info -e seaweedfs seaweedfs-doc seaweedfs-bash-completion \ + seaweedfs-master-openrc seaweedfs-filer-openrc seaweedfs-worker-openrc \ + | sort + printf "\nSeaweedFS version:\n" + weed version + printf "\nEntering %s. Repository mounted read-only at /work.\n\n" "${TEST_SHELL}" + exec "${TEST_SHELL}" + '