2025-12-09 05:31:55 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
2026-09-18 15:51:25 +02:00
|
|
|
# The distribution bases this repository builds on. They are published by
|
|
|
|
|
# https://github.com/kevinveenbirkenbach/base-images, one multi-platform image
|
|
|
|
|
# per distribution, and carry the build dependencies the package build needs.
|
|
|
|
|
#
|
|
|
|
|
# Env overrides exist for testing an unpublished base; the registry namespace
|
|
|
|
|
# follows the images repository, not this one.
|
|
|
|
|
|
|
|
|
|
: "${BASE_IMAGES_REGISTRY:=ghcr.io}"
|
|
|
|
|
: "${BASE_IMAGES_OWNER:=kevinveenbirkenbach}"
|
|
|
|
|
: "${BASE_IMAGES_TAG:=latest}"
|
2025-12-12 22:04:39 +01:00
|
|
|
|
2025-12-09 05:31:55 +01:00
|
|
|
resolve_base_image() {
|
2025-12-13 14:34:15 +01:00
|
|
|
local PKGMGR_DISTRO="$1"
|
|
|
|
|
case "$PKGMGR_DISTRO" in
|
2026-09-18 15:51:25 +02:00
|
|
|
arch|manjaro|debian|ubuntu|fedora|centos)
|
|
|
|
|
echo "${BASE_IMAGES_REGISTRY}/${BASE_IMAGES_OWNER}/base-${PKGMGR_DISTRO}:${BASE_IMAGES_TAG}"
|
|
|
|
|
;;
|
|
|
|
|
*) echo "ERROR: Unknown distro '$PKGMGR_DISTRO'" >&2; exit 1 ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Platforms each distribution's base offers; see base-images/scripts/build/distros.sh.
|
|
|
|
|
resolve_platforms() {
|
|
|
|
|
local PKGMGR_DISTRO="$1"
|
|
|
|
|
case "$PKGMGR_DISTRO" in
|
|
|
|
|
arch|manjaro|debian|ubuntu|fedora|centos) echo "linux/amd64,linux/arm64" ;;
|
2025-12-13 14:34:15 +01:00
|
|
|
*) echo "ERROR: Unknown distro '$PKGMGR_DISTRO'" >&2; exit 1 ;;
|
2025-12-09 05:31:55 +01:00
|
|
|
esac
|
|
|
|
|
}
|
2026-11-04 18:38:42 +01:00
|
|
|
|
|
|
|
|
package_set_cmd() {
|
|
|
|
|
local PKGMGR_DISTRO="$1"
|
|
|
|
|
case "$PKGMGR_DISTRO" in
|
|
|
|
|
arch|manjaro) echo 'pacman -Q' ;;
|
|
|
|
|
debian|ubuntu) echo 'dpkg-query -W' ;;
|
|
|
|
|
fedora|centos) echo 'rpm -qa | sort' ;;
|
|
|
|
|
*) echo "ERROR: Unknown distro '$PKGMGR_DISTRO'" >&2; exit 1 ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
version_prefixes() {
|
|
|
|
|
local -a parts
|
|
|
|
|
IFS=. read -ra parts <<< "$1"
|
|
|
|
|
local acc="${parts[0]}" i
|
|
|
|
|
echo "${acc}"
|
|
|
|
|
for ((i = 1; i < ${#parts[@]}; i++)); do
|
|
|
|
|
acc+=".${parts[i]}"
|
|
|
|
|
echo "${acc}"
|
|
|
|
|
done
|
|
|
|
|
}
|