From 5a7b0c91d838938752fdd50bdee5f54aa80a6db5 Mon Sep 17 00:00:00 2001 From: Anton Afanasyeu Date: Sun, 9 Aug 2026 18:58:24 +0200 Subject: [PATCH] Fix isolated builder: standalone mobile clone for Docker git checkout. Submodule gitfile paths break when only ac-mobile-android is mounted as /workspace; clone the mobile repo directly instead of submodule init. Co-authored-by: Cursor --- ci-build-and-publish-ota.sh | 17 ++++++++++++++--- docker-build-runner.sh | 27 ++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/ci-build-and-publish-ota.sh b/ci-build-and-publish-ota.sh index 9d764e6..46457db 100755 --- a/ci-build-and-publish-ota.sh +++ b/ci-build-and-publish-ota.sh @@ -33,10 +33,21 @@ echo "==> Phase: init build_id=${BUILD_ID} channel=${OTA_CHANNEL}" if [[ -n "${GIT_REF:-}" ]]; then echo "==> Phase: git checkout ${GIT_REF}" - git fetch --all --tags 2>/dev/null || true - git checkout --force "$GIT_REF" + current_head="$(git rev-parse HEAD 2>/dev/null || echo "")" + target_head="" if [[ -n "${GIT_SHA:-}" ]]; then - git reset --hard "$GIT_SHA" + target_head="$(git rev-parse "${GIT_SHA}" 2>/dev/null || echo "")" + else + target_head="$(git rev-parse "${GIT_REF}" 2>/dev/null || echo "")" + fi + if [[ -n "$current_head" && -n "$target_head" && "$current_head" == "$target_head" ]]; then + echo "==> already at ${current_head:0:12}" + else + git fetch --all --tags 2>/dev/null || true + git checkout --force "$GIT_REF" + if [[ -n "${GIT_SHA:-}" ]]; then + git reset --hard "$GIT_SHA" + fi fi fi diff --git a/docker-build-runner.sh b/docker-build-runner.sh index 50dbe58..f6f1160 100755 --- a/docker-build-runner.sh +++ b/docker-build-runner.sh @@ -179,14 +179,31 @@ stage_ci_scripts() { done } -init_mobile_submodule_only() { +init_mobile_standalone() { local base="$1" + local ref="${GIT_REF:-next}" if [[ ! -d "${base}/.git" ]]; then return 0 fi - if git -C "$base" config -f .gitmodules --get "submodule.${MOBILE_SUBDIR}.path" >/dev/null 2>&1; then - log "[runner] isolate: init workspace submodule ${MOBILE_SUBDIR} (no third-party recurse)" - run_step git-submodule-mobile git -c safe.directory="${base}" -C "${base}" submodule update --init "${MOBILE_SUBDIR}" + local url path + url="$(git -C "$base" config -f .gitmodules --get "submodule.${MOBILE_SUBDIR}.url" 2>/dev/null || true)" + path="$(git -C "$base" config -f .gitmodules --get "submodule.${MOBILE_SUBDIR}.path" 2>/dev/null || true)" + if [[ -z "$url" || -z "$path" ]]; then + return 0 + fi + + log "[runner] isolate: standalone clone ${path} for docker mount (avoid gitfile ../.git/modules)" + rm -rf "${base}/${path}" + if [[ -n "${GIT_SHA:-}" ]]; then + run_step git-clone-mobile git clone --depth "${CLONE_DEPTH}" "$url" "${base}/${path}" + run_step git-fetch-mobile git -c safe.directory="${base}/${path}" -C "${base}/${path}" fetch --depth "${CLONE_DEPTH}" origin "${GIT_SHA}" + run_step git-checkout-mobile git -c safe.directory="${base}/${path}" -C "${base}/${path}" checkout "${GIT_SHA}" + elif git clone --depth "${CLONE_DEPTH}" --single-branch --branch "${ref}" "$url" "${base}/${path}" 2>/dev/null; then + : + else + run_step git-clone-mobile git clone --depth "${CLONE_DEPTH}" "$url" "${base}/${path}" + run_step git-fetch-mobile git -c safe.directory="${base}/${path}" -C "${base}/${path}" fetch --depth "${CLONE_DEPTH}" origin "${ref}" + run_step git-checkout-mobile git -c safe.directory="${base}/${path}" -C "${base}/${path}" checkout "${ref}" fi } @@ -218,7 +235,7 @@ prepare_isolated_source() { run_step git-pin git -c safe.directory="${SOURCE_DIR}" -C "${SOURCE_DIR}" checkout "${GIT_SHA}" fi - init_mobile_submodule_only "${SOURCE_DIR}" + init_mobile_standalone "${SOURCE_DIR}" local host_tree iso_tree host_tree="$(host_mobile_tree)"