#!/usr/bin/env bash # Remove the container-owned generated artefacts under the working tree. # # `build/` (install-stamp) is produced inside the compose container by # the in-container UID (typically `nobody`). The host # user cannot rm them directly. This helper starts the infinito # compose container if a stopped one exists, then deletes the # nobody-owned artefacts from inside it. Safe no-op when the targets # do not exist. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)" cd "${REPO_ROOT}" # shellcheck source=scripts/meta/env/load.sh source scripts/meta/env/load.sh : "${INFINITO_CONTAINER:?INFINITO_CONTAINER not set after sourcing load.sh}" : "${INFINITO_SRC_DIR:?INFINITO_SRC_DIR not set after sourcing load.sh}" if ! docker ps --filter "name=${INFINITO_CONTAINER}" --format '{{.Names}}' | grep -q .; then if docker ps -a --filter "name=${INFINITO_CONTAINER}" --format '{{.Names}}' | grep -q .; then echo "[clean-container-owned] starting stopped container ${INFINITO_CONTAINER}" docker start "${INFINITO_CONTAINER}" >/dev/null else echo "[clean-container-owned] no ${INFINITO_CONTAINER} container exists — nothing to clean" >&2 exit 0 fi fi echo "[clean-container-owned] removing container-owned generated artefacts inside ${INFINITO_CONTAINER}" docker exec -i "${INFINITO_CONTAINER}" sh -lc " set -eu cd '${INFINITO_SRC_DIR}' rm -rf build " echo "[clean-container-owned] done"