Build Alpine Packages / build-and-publish (v3.24, 3.24) (push) Has been cancelled
85 lines
2.3 KiB
Bash
Executable File
85 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
alpine_version="${ALPINE_VERSION:-3.24}"
|
|
platform="${ALPINE_BUILD_PLATFORM:-linux/amd64}"
|
|
arch="${ALPINE_ARCH:-x86_64}"
|
|
packages="${TEST_SHELL_PACKAGES:-}"
|
|
shell="${TEST_SHELL:-/bin/sh}"
|
|
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
|
|
|
|
shopt -s nullglob
|
|
repo_keys=("${repo_root}/packages/local/${arch}"/*.rsa.pub)
|
|
repo_indexes=("${repo_root}/packages/local/${arch}"/APKINDEX.tar.gz)
|
|
shopt -u nullglob
|
|
|
|
if [[ "${#repo_keys[@]}" -eq 0 ]]; then
|
|
printf 'missing repository key: packages/local/%s/*.rsa.pub\n' "${arch}" >&2
|
|
exit 1
|
|
fi
|
|
if [[ "${#repo_indexes[@]}" -eq 0 ]]; then
|
|
printf 'missing repository index: packages/local/%s/APKINDEX.tar.gz\n' "${arch}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
docker_args=(--rm -i --platform "${platform}")
|
|
if [[ -t 0 && -t 1 ]]; then
|
|
docker_args+=(-t)
|
|
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
|
|
|
|
if [ -n "${PACKAGE_LIST}" ]; then
|
|
printf "Installing requested test packages: %s\n" "${PACKAGE_LIST}"
|
|
timeout "${TEST_SHELL_TIMEOUT}" apk add ${PACKAGE_LIST}
|
|
fi
|
|
|
|
cat <<EOF
|
|
|
|
Local APK repository is ready.
|
|
Repository: /repo
|
|
Workspace: /work
|
|
|
|
Examples:
|
|
apk add seaweedfs seaweedfs-master-openrc
|
|
apk add greptimedb greptimedb-docs greptimedb-standalone-openrc
|
|
apk add lavinmq lavinmq-openrc
|
|
apk add gitea gitea-openrc
|
|
|
|
Entering ${TEST_SHELL}.
|
|
|
|
EOF
|
|
exec "${TEST_SHELL}"
|
|
'
|