constellation/bazel/mkosi/mkosi_wrapper.sh.in

43 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2023-09-06 09:32:01 -04:00
#!/usr/bin/env bash
set -euo pipefail
shopt -s inherit_errexit
export PATH=/run/wrappers/bin:/run/current-system/sw/bin:/bin:/usr/bin:/usr/local/bin
VERSION_ARG=""
args=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--*-tree | --initrd | --package-directory | --output-dir)
# absolutize any file paths
shift # past the key and to the value
value="$1"
args+=("${key}" "$(realpath "${value}")")
shift # past the value
;;
*)
args+=("$1")
shift
;;
esac
done
2023-09-06 09:32:01 -04:00
if [[ -n ${VERSION_FILE+x} ]]; then
VERSION_ARG="--environment=IMAGE_VERSION=$(cat "${VERSION_FILE}")"
args+=("$VERSION_ARG")
fi
2023-10-16 10:45:36 -04:00
if [[ -n ${LOCAL_MIRROR+x} ]]; then
LOCAL_MIRROR=$(realpath "${LOCAL_MIRROR}")
reposdir=$(mktemp -d)
# putting an empty repo file under /etc/yum.repos.d/mkosi.repo
# will make mkosi use only package directories
# and not try to fetch packages from the network
touch "${reposdir}/mkosi.repo"
2023-10-16 10:45:36 -04:00
args+=("--package-manager-tree=${reposdir}:/etc/yum.repos.d")
args+=("--package-directory" "${LOCAL_MIRROR}")
2023-10-16 10:45:36 -04:00
fi
2023-09-06 09:32:01 -04:00
exec @@MKOSI@@ "${args[@]}" build