2023-03-14 08:57:39 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# This script is run from the user's Constellation workspace (BUILD_WORKING_DIRECTORY).
|
|
|
|
# It prepares the workspace by symlinking all required binaries into folder.
|
|
|
|
|
2023-03-29 08:13:26 -04:00
|
|
|
###### script header ######
|
|
|
|
|
2023-03-14 08:57:39 -04:00
|
|
|
lib=$(realpath @@BASE_LIB@@) || exit 1
|
2023-03-29 08:13:26 -04:00
|
|
|
stat "${lib}" >> /dev/null || exit 1
|
2023-03-14 08:57:39 -04:00
|
|
|
|
2023-03-16 09:24:53 -04:00
|
|
|
# shellcheck source=../sh/lib.bash
|
2023-03-14 08:57:39 -04:00
|
|
|
if ! source "${lib}"; then
|
|
|
|
echo "Error: could not find import"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-29 08:13:26 -04:00
|
|
|
bootstrapper=$(realpath @@BOOTSTRAPPER@@)
|
|
|
|
stat "${bootstrapper}" >> /dev/null
|
|
|
|
upgrade_agent=$(realpath @@UPGRADE_AGENT@@)
|
|
|
|
stat "${upgrade_agent}" >> /dev/null
|
|
|
|
cli=$(realpath @@CLI@@)
|
|
|
|
stat "${cli}" >> /dev/null
|
|
|
|
cdbg=$(realpath @@CDBG@@)
|
|
|
|
stat "${cdbg}" >> /dev/null
|
2023-04-03 12:13:17 -04:00
|
|
|
container_sums=$(realpath @@CONTAINER_SUMS@@)
|
|
|
|
stat "${container_sums}" >> /dev/null
|
2023-05-30 03:05:36 -04:00
|
|
|
edition=$(cat @@EDITION@@)
|
2023-03-29 08:13:26 -04:00
|
|
|
|
|
|
|
cd "${BUILD_WORKING_DIRECTORY}"
|
|
|
|
|
|
|
|
###### script body ######
|
2023-03-14 08:57:39 -04:00
|
|
|
|
2023-04-12 11:29:55 -04:00
|
|
|
replace_prefix() {
|
|
|
|
local host_cache=$1
|
|
|
|
local builder_cache=$2
|
|
|
|
local dir=$3
|
|
|
|
if [[ ${dir#"${builder_cache}"} == "${dir}" ]]; then
|
|
|
|
echo "${dir}"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
relpath=${dir#"${builder_cache}"}
|
|
|
|
realpath -m "${host_cache}/${relpath}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set HOST_CACHE when running in a container with mounted cache.
|
|
|
|
host_cache="${HOST_CACHE:-${HOME}/.cache}"
|
|
|
|
builder_cache="${HOME}/.cache"
|
|
|
|
|
2023-03-14 09:37:58 -04:00
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
workdir="."
|
2023-03-14 08:57:39 -04:00
|
|
|
else
|
2023-03-14 09:37:58 -04:00
|
|
|
workdir="$1"
|
2023-03-14 08:57:39 -04:00
|
|
|
fi
|
|
|
|
|
2023-05-30 03:05:36 -04:00
|
|
|
echo "Using ${edition} cli edition"
|
|
|
|
|
2023-04-12 11:29:55 -04:00
|
|
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${bootstrapper}")" "${workdir}/bootstrapper"
|
|
|
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${upgrade_agent}")" "${workdir}/upgrade-agent"
|
|
|
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cdbg}")" "${workdir}/cdbg"
|
2023-04-03 12:13:17 -04:00
|
|
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${container_sums}")" "${workdir}/container_sums.sha256"
|
2023-05-30 03:05:36 -04:00
|
|
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cli}")" "${workdir}/constellation"
|