Add multi-package Alpine packaging

This commit is contained in:
Joachim Schlöffel
2026-06-08 23:43:29 +02:00
parent d5a32abcd4
commit edc68c825b
22 changed files with 1013 additions and 146 deletions

View File

@@ -4,6 +4,8 @@ set -euo pipefail
command_name="${1:-build}"
requested_arch="${2:-${ALPINE_ARCH:-x86_64}}"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
. "${repo_root}/scripts/apk/package-lib.sh"
alpine_version="${ALPINE_VERSION:-3.23}"
repo_name="${ALPINE_REPO_NAME:-local}"
build_platform="${ALPINE_BUILD_PLATFORM:-linux/amd64}"
@@ -27,10 +29,14 @@ validate_arch() {
run_for_arch() {
local arch="$1"
local subcommand="$2"
local package_dir="$3"
local image_name
local container_package_dir
validate_arch "${arch}"
image_name="${ALPINE_APK_BUILDER_IMAGE:-seaweedfs-apk-builder:${arch}}"
apk_validate_package_dir "${package_dir}"
container_package_dir="$(apk_container_package_dir "${repo_root}" "${package_dir}")"
image_name="${ALPINE_APK_BUILDER_IMAGE:-alpine-apk-builder:${arch}}"
docker build \
--platform "${build_platform}" \
@@ -50,6 +56,7 @@ run_for_arch() {
-e "ALPINE_ARCH=${arch}" \
-e "CARCH=${arch}" \
-e "ALPINE_REPO_NAME=${repo_name}" \
-e "APKBUILD_DIR=${container_package_dir}" \
-e "PACKAGER=${PACKAGER:-Joachim Schlöffel <me@joachim-schloeffel.com>}" \
-v "${repo_root}:/work" \
-v "${repo_root}/.cache/abuild:/home/builder/.abuild" \
@@ -66,12 +73,38 @@ mkdir -p \
case "${command_name}" in
build-all)
for arch in ${ALPINE_ARCHES:-x86_64 aarch64}; do
run_for_arch "${arch}" build
done
while IFS= read -r package_dir; do
for arch in ${ALPINE_ARCHES:-x86_64 aarch64}; do
if ! apk_package_supports_arch "${package_dir}" "${arch}"; then
printf 'Skipping %s for unsupported arch %s\n' "$(apk_package_name "${package_dir}")" "${arch}"
continue
fi
run_for_arch "${arch}" build "${package_dir}"
done
done < <(apk_package_dirs "${repo_root}")
;;
build|checksum|lint|shell)
run_for_arch "${requested_arch}" "${command_name}"
build|checksum|lint)
while IFS= read -r package_dir; do
if [[ "${command_name}" == "build" ]] && ! apk_package_supports_arch "${package_dir}" "${requested_arch}"; then
printf 'Skipping %s for unsupported arch %s\n' "$(apk_package_name "${package_dir}")" "${requested_arch}"
continue
fi
run_for_arch "${requested_arch}" "${command_name}" "${package_dir}"
done < <(apk_package_dirs "${repo_root}")
;;
shell)
package_count=0
selected_package_dir=""
while IFS= read -r package_dir; do
package_count=$((package_count + 1))
selected_package_dir="${package_dir}"
done < <(apk_package_dirs "${repo_root}")
if [[ "${package_count}" -ne 1 ]]; then
printf 'apk:shell needs exactly one package; set ALPINE_PACKAGE=<name>\n' >&2
exit 2
fi
run_for_arch "${requested_arch}" "${command_name}" "${selected_package_dir}"
;;
*)
printf 'unknown command: %s\n' "${command_name}" >&2