diff --git a/hack/boot-assets/build.sh b/hack/boot-assets/build.sh index d837fa8..b856686 100755 --- a/hack/boot-assets/build.sh +++ b/hack/boot-assets/build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -PROJECT_DIR=$(pwd) +RUN_DIR=$(pwd) TEMP_USERNAME=siderolabs @@ -18,6 +18,13 @@ make image-talos-metal-agent PUSH=true REGISTRY="$TEMP_REGISTRY" USERNAME="$TEMP TEMP_DIR=$(mktemp -d -t agent-boot-assets-XXXXX) +function cleanup() { + cd "${RUN_DIR}" + rm -rf "$TEMP_DIR" +} + +trap cleanup EXIT SIGINT + echo "Building in $TEMP_DIR" cd "$TEMP_DIR" @@ -68,7 +75,7 @@ ASSETS_DIR="$TEMP_DIR/assets" mkdir -p "$ASSETS_DIR" -SCRIPT_DIR="$PROJECT_DIR/hack/boot-assets" +SCRIPT_DIR="$RUN_DIR/hack/boot-assets" function build_artifacts() { local arch=$1 @@ -91,6 +98,4 @@ cp "$SCRIPT_DIR/Dockerfile" . docker build -t "$FINAL_IMAGE" . -rm -rf "$TEMP_DIR" - echo "Built image: $FINAL_IMAGE"