Accept and discard Linux-inert send-only flags on hostinet receive calls, add native and runsc syscall coverage, and bind the resulting immutable runtime build.
75 lines
2.3 KiB
Shell
Executable file
75 lines
2.3 KiB
Shell
Executable file
#!/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 cmp install readelf; 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
|
|
tools/materialize-runsc --build
|
|
cargo build \
|
|
--release \
|
|
--locked \
|
|
--package lazaret-client \
|
|
--package lazaret-host-coordinator \
|
|
--package lazaret-escalation-client \
|
|
--bins
|
|
env RUSTFLAGS="-C relocation-model=static -C link-arg=-no-pie" cargo build \
|
|
--release \
|
|
--locked \
|
|
--target x86_64-unknown-linux-musl \
|
|
--package lazaret-sandbox-init \
|
|
--bin lazaret-sandbox-init
|
|
|
|
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
|
|
sandbox_init="$target_dir/x86_64-unknown-linux-musl/release/lazaret-sandbox-init"
|
|
if readelf -l "$sandbox_init" | grep -q 'Requesting program interpreter' ||
|
|
! readelf -d "$sandbox_init" 2>&1 | grep -q 'There is no dynamic section'; then
|
|
printf '%s\n' "install-to-host: sandbox init is dynamically linked" >&2
|
|
exit 1
|
|
fi
|
|
install -m 755 "$sandbox_init" "$install_dir/lazaret-sandbox-init"
|
|
|
|
runsc_build_id=34ed2f67fc55ef97a0b1755b4a94ed682f6aae57a41ce27eceb66ea366185ca7
|
|
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
|
|
|
|
printf '%s\n' "Installed Lazaret in $install_dir"
|