2026-07-19 13:55:52 +09:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
root="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
|
install_dir="${LAZARET_INSTALL_DIR:-$HOME/.local/bin}"
|
|
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
|
printf '%s\n' "usage: tools/install-to-host [--install-dir DIRECTORY]"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ "${1:-}" = "--help" ] && [ "$#" -eq 1 ]; then
|
|
|
|
|
usage
|
|
|
|
|
exit 0
|
|
|
|
|
elif [ "${1:-}" = "--install-dir" ] && [ "$#" -eq 2 ]; then
|
|
|
|
|
install_dir="$2"
|
|
|
|
|
elif [ "$#" -ne 0 ]; then
|
|
|
|
|
usage >&2
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
2026-08-18 01:36:48 +09:00
|
|
|
for command in cmp install; do
|
2026-07-19 13:55:52 +09:00
|
|
|
command -v "$command" >/dev/null 2>&1 || {
|
|
|
|
|
printf '%s\n' "install-to-host: $command is required" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
cd "$root"
|
2026-08-18 01:36:48 +09:00
|
|
|
tools/build
|
2026-07-19 13:55:52 +09:00
|
|
|
|
2026-08-18 01:36:48 +09:00
|
|
|
target_dir="$root/.lazaret/target"
|
2026-07-19 13:55:52 +09:00
|
|
|
|
|
|
|
|
install -d -m 755 "$install_dir"
|
|
|
|
|
for executable in lazaret lazaret-host-coordinator lazaret-escalation-client; do
|
|
|
|
|
install -m 755 "$target_dir/release/$executable" "$install_dir/$executable"
|
|
|
|
|
done
|
2026-07-19 22:38:37 +09:00
|
|
|
sandbox_init="$target_dir/x86_64-unknown-linux-musl/release/lazaret-sandbox-init"
|
|
|
|
|
install -m 755 "$sandbox_init" "$install_dir/lazaret-sandbox-init"
|
2026-07-19 13:55:52 +09:00
|
|
|
|
2026-08-02 19:57:36 +09:00
|
|
|
runsc_build_id=9e711e005f13402e728a0c3ada3fdc67a38918da31f720e5be1006edc4272a51
|
2026-07-26 18:01:03 +09:00
|
|
|
runsc_name="lazaret-runsc-$runsc_build_id"
|
|
|
|
|
runsc_source="$root/.lazaret/bin/$runsc_name"
|
|
|
|
|
runsc_destination="$install_dir/$runsc_name"
|
|
|
|
|
if [[ -e "$runsc_destination" ]]; then
|
|
|
|
|
cmp --silent "$runsc_source" "$runsc_destination" || {
|
|
|
|
|
printf '%s\n' "install-to-host: immutable runsc destination differs: $runsc_destination" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
install -m 755 "$runsc_source" "$runsc_destination"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-07-19 13:55:52 +09:00
|
|
|
printf '%s\n' "Installed Lazaret in $install_dir"
|