Files
hercules-hyperion/scripts/lib/common.sh
Yvan Janssens 93e90a1839
Some checks failed
ci/woodpecker/manual/woodpecker Pipeline failed
Add Woodpecker Debian package pipeline
2026-05-04 14:51:57 +02:00

45 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
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")" "$*"
}
die() {
printf '[%s] %s\n' "$(basename "$0")" "$*" >&2
exit 1
}
require_cmd() {
command -v "$1" >/dev/null 2>&1 || die "Required command not found: $1"
}
require_env() {
local name="$1"
[[ -n "${!name:-}" ]] || die "Required environment variable is missing: $name"
}
load_build_config() {
[[ -f "$BUILD_CONFIG_FILE" ]] || die "Build config not found: $BUILD_CONFIG_FILE"
set -a
# shellcheck disable=SC1090
. "$BUILD_CONFIG_FILE"
set +a
[[ -n "${REPO:-}" ]] || die "REPO is missing in $BUILD_CONFIG_FILE"
[[ -n "${BRANCH:-}" ]] || die "BRANCH is missing in $BUILD_CONFIG_FILE"
}
ci_work_root() {
printf '%s\n' "${CI_WORK_ROOT:-$DEFAULT_CI_WORK_ROOT}"
}