35 lines
641 B
Bash
35 lines
641 B
Bash
#!/bin/bash
|
|
|
|
fail() {
|
|
echo "ERROR: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
require_file() {
|
|
[ -f "$1" ] || fail "Missing file: $1"
|
|
}
|
|
|
|
require_dir() {
|
|
[ -d "$1" ] || fail "Missing directory: $1"
|
|
}
|
|
|
|
load_env_file() {
|
|
ENV_FILE="$1"
|
|
require_file "$ENV_FILE"
|
|
set -a
|
|
. "$ENV_FILE"
|
|
set +a
|
|
}
|
|
|
|
maybe_fake_legacy() {
|
|
TOOL_NAME="$1"
|
|
if command -v "$TOOL_NAME" >/dev/null 2>&1; then
|
|
return 1
|
|
fi
|
|
if [ "${RETRODEBIAN_FAKE_LEGACY_TOOLS:-1}" = "1" ]; then
|
|
echo "[fake-legacy] $TOOL_NAME not found, emulating." >&2
|
|
return 0
|
|
fi
|
|
fail "$TOOL_NAME not found and RETRODEBIAN_FAKE_LEGACY_TOOLS != 1"
|
|
}
|