Add a repository-local host installer

This commit is contained in:
ms2k 2026-07-19 13:55:52 +09:00
commit b9c3bcfbbc

48
tools/install-to-host Executable file
View file

@ -0,0 +1,48 @@
#!/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
for command in cargo install; do
command -v "$command" >/dev/null 2>&1 || {
printf '%s\n' "install-to-host: $command is required" >&2
exit 1
}
done
cd "$root"
tools/materialize-fuser
cargo build \
--release \
--locked \
--package lazaret-client \
--package lazaret-host-coordinator \
--package lazaret-escalation-client \
--bins
target_dir="${CARGO_TARGET_DIR:-target}"
if [[ "$target_dir" != /* ]]; then
target_dir="$root/$target_dir"
fi
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
printf '%s\n' "Installed Lazaret in $install_dir"