diff --git a/RebuildBdd/run-rebuild-bdd.sh b/RebuildBdd/run-rebuild-bdd.sh index d06a0bd..e050fb1 100755 --- a/RebuildBdd/run-rebuild-bdd.sh +++ b/RebuildBdd/run-rebuild-bdd.sh @@ -185,9 +185,14 @@ TARGET_ENABLE_BOOTSTRAP="${TARGET_ENABLE_BOOTSTRAP:-${GLOBAL_ENABLE_BOOTSTRAP:-y TARGET_REPO_SUBDIR="${TARGET_REPO_SUBDIR#/}" TARGET_REPO_SUBDIR="${TARGET_REPO_SUBDIR%/}" +TARGET_CLONE_DIR="$TARGET_REPO_DIR" TARGET_SCRIPT_DIR="$TARGET_REPO_DIR" -if [[ -n "$TARGET_REPO_SUBDIR" && "$TARGET_REPO_DIR" != */"$TARGET_REPO_SUBDIR" ]]; then - TARGET_SCRIPT_DIR="${TARGET_REPO_DIR}/${TARGET_REPO_SUBDIR}" +if [[ -n "$TARGET_REPO_SUBDIR" ]]; then + if [[ "$TARGET_REPO_DIR" == */"$TARGET_REPO_SUBDIR" ]]; then + TARGET_CLONE_DIR="$(dirname "$TARGET_REPO_DIR")" + else + TARGET_SCRIPT_DIR="${TARGET_REPO_DIR}/${TARGET_REPO_SUBDIR}" + fi fi TARGET_ENABLE_BOOTSTRAP="$(to_bool_yes_no "$TARGET_ENABLE_BOOTSTRAP")" || fail "TARGET_ENABLE_BOOTSTRAP invalide" @@ -268,6 +273,7 @@ TARGET_CORE_SCRIPT="${TARGET_SCRIPT_DIR}/rebuild-bdd-core.sh" REMOTE_BOOTSTRAP_CMD=" set -euo pipefail +CLONE_DIR=$(shell_quote "$TARGET_CLONE_DIR") REPO_DIR=$(shell_quote "$TARGET_SCRIPT_DIR") REPO_URL=$(shell_quote "$TARGET_REPO_URL") REPO_BRANCH=$(shell_quote "$TARGET_REPO_BRANCH") @@ -283,15 +289,16 @@ command -v git >/dev/null 2>&1 || { echo '{\"status\":\"error\",\"message\":\"gi command -v bash >/dev/null 2>&1 || { echo '{\"status\":\"error\",\"message\":\"bash absent sur la cible\"}'; exit 1; } command -v python3 >/dev/null 2>&1 || { echo '{\"status\":\"error\",\"message\":\"python3 absent sur la cible\"}'; exit 1; } +mkdir -p \"\$(dirname \"\$CLONE_DIR\")\" mkdir -p \"\$(dirname \"\$REPO_DIR\")\" -if [[ ! -d \"\$REPO_DIR/.git\" ]]; then - rm -rf \"\$REPO_DIR\" - git clone --branch \"\$REPO_BRANCH\" --single-branch \"\$REPO_URL\" \"\$REPO_DIR\" +if [[ ! -d \"\$CLONE_DIR/.git\" ]]; then + rm -rf \"\$CLONE_DIR\" + git clone --branch \"\$REPO_BRANCH\" --single-branch \"\$REPO_URL\" \"\$CLONE_DIR\" else - git -C \"\$REPO_DIR\" fetch --prune origin - git -C \"\$REPO_DIR\" checkout -f \"\$REPO_BRANCH\" - git -C \"\$REPO_DIR\" reset --hard \"origin/\$REPO_BRANCH\" + git -C \"\$CLONE_DIR\" fetch --prune origin + git -C \"\$CLONE_DIR\" checkout -f \"\$REPO_BRANCH\" + git -C \"\$CLONE_DIR\" reset --hard \"origin/\$REPO_BRANCH\" fi [[ -f \"\$CORE_SCRIPT\" ]] || { echo '{\"status\":\"error\",\"message\":\"script core introuvable sur la cible\"}'; exit 1; }