Generalize Debian distro CI packaging
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2026-05-05 11:54:48 +02:00
parent 6adf479d39
commit 95186bbb94
4 changed files with 178 additions and 12 deletions

View File

@@ -2,13 +2,6 @@
set -euo pipefail
readonly REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
readonly BUILD_CONFIG_FILE="${BUILD_CONFIG_FILE:-$REPO_ROOT/build.config}"
readonly DEFAULT_GITEA_BASE_URL="https://git.cyber.gent"
readonly DEFAULT_DEBIAN_DISTRIBUTION="noble"
readonly DEFAULT_DEBIAN_COMPONENT="main"
readonly DEFAULT_CI_WORK_ROOT="$REPO_ROOT/.ci-work"
log() {
printf '[%s] %s\n' "$(basename "$0")" "$*"
}
@@ -18,6 +11,88 @@ die() {
exit 1
}
detect_debian_distribution_id() {
local os_release="/etc/os-release"
local distro_id=""
local lsb_id=""
if [[ -r "$os_release" ]]; then
# shellcheck disable=SC1090
. "$os_release"
distro_id="${ID:-}"
fi
if [[ -n "$distro_id" ]]; then
case "$distro_id" in
ubuntu|debian)
printf '%s\n' "$distro_id"
return 0
;;
esac
fi
if command -v lsb_release >/dev/null 2>&1; then
lsb_id="$(lsb_release -is | tr '[:upper:]' '[:lower:]')"
case "$lsb_id" in
ubuntu|debian)
printf '%s\n' "$lsb_id"
return 0
;;
esac
fi
die "Unable to determine Debian/Ubuntu distribution ID from $os_release"
}
detect_debian_distribution() {
local os_release="/etc/os-release"
local distro_id=""
local version_codename=""
local ubuntu_codename=""
if [[ -r "$os_release" ]]; then
# shellcheck disable=SC1090
. "$os_release"
distro_id="${ID:-}"
version_codename="${VERSION_CODENAME:-}"
ubuntu_codename="${UBUNTU_CODENAME:-}"
fi
case "$distro_id" in
ubuntu)
if [[ -n "$ubuntu_codename" ]]; then
printf '%s\n' "$ubuntu_codename"
return 0
fi
;;
debian)
if [[ -n "$version_codename" ]]; then
printf '%s\n' "$version_codename"
return 0
fi
;;
esac
if [[ -n "$version_codename" ]]; then
printf '%s\n' "$version_codename"
return 0
fi
if command -v lsb_release >/dev/null 2>&1; then
lsb_release -cs
return 0
fi
die "Unable to determine Debian/Ubuntu distribution codename from $os_release"
}
readonly REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
readonly BUILD_CONFIG_FILE="${BUILD_CONFIG_FILE:-$REPO_ROOT/build.config}"
readonly DEFAULT_GITEA_BASE_URL="https://git.cyber.gent"
readonly DEFAULT_DEBIAN_DISTRIBUTION="$(detect_debian_distribution)"
readonly DEFAULT_DEBIAN_COMPONENT="main"
readonly DEFAULT_CI_WORK_ROOT="$REPO_ROOT/.ci-work"
require_cmd() {
command -v "$1" >/dev/null 2>&1 || die "Required command not found: $1"
}