61 lines
2.0 KiB
Bash
Executable File
61 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
alpine_version="${ALPINE_VERSION:-3.23}"
|
|
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}"
|
|
'
|