scripts: namespace dev_cli tmp dir per user and drop dead BUILD_DIR

The shared /tmp/cloud-hypervisor/ path is created by the first user to
run dev_cli.sh and owned by them, so other users on the same host fail
the +x+w check and cannot chmod it back. Move both tmp paths under
/tmp/cloud-hypervisor-${USER}/ so each user gets their own tree.

While here, fold the local BUILD_DIR in build_container() into the
existing (previously unused) CLH_CTR_BUILD_DIR, which ensure_build_dir()
already creates.

Assisted-by: Claude:Opus-4.7
Signed-off-by: Bo Chen <bchen@crusoe.ai>
This commit is contained in:
Bo Chen
2026-05-13 18:56:37 +00:00
committed by Rob Bradford
parent 0638b38d60
commit 9ca5f63fe0

View File

@@ -20,7 +20,7 @@ CLH_ROOT_DIR=$(cd "${CLH_SCRIPTS_DIR}/.." && pwd)
CLH_BUILD_DIR="${CLH_ROOT_DIR}/build"
CLH_CARGO_TARGET="${CLH_BUILD_DIR}/cargo_target"
CLH_DOCKERFILE="${CLH_SCRIPTS_DIR}/../resources/Dockerfile"
CLH_CTR_BUILD_DIR="/tmp/cloud-hypervisor/ctr-build"
CLH_CTR_BUILD_DIR="/tmp/cloud-hypervisor-${USER}/ctr-build"
CLH_INTEGRATION_WORKLOADS="${HOME}/workloads"
# Container paths
@@ -649,10 +649,7 @@ cmd_tests() {
build_container() {
ensure_build_dir
BUILD_DIR=/tmp/cloud-hypervisor/container/
mkdir -p $BUILD_DIR
cp "$CLH_DOCKERFILE" $BUILD_DIR
cp "$CLH_DOCKERFILE" "$CLH_CTR_BUILD_DIR"
[ "$(uname -m)" = "aarch64" ] && TARGETARCH="arm64"
[ "$(uname -m)" = "x86_64" ] && TARGETARCH="amd64"
@@ -660,9 +657,9 @@ build_container() {
$DOCKER_RUNTIME build \
--target dev \
-t "$CTR_IMAGE" \
-f $BUILD_DIR/Dockerfile \
-f "$CLH_CTR_BUILD_DIR/Dockerfile" \
--build-arg TARGETARCH="$TARGETARCH" \
$BUILD_DIR
"$CLH_CTR_BUILD_DIR"
}
cmd_build-container() {