Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72487932 authored by Jackeagle's avatar Jackeagle
Browse files

Fix kernel .repo detection for persistent Docker volumes

The previous check only looked for .repo/ directory existence, but on
persistent Docker volumes .repo/ can survive from a previous broken run
where cp -R produced a corrupt .repo/repo (missing main.py). The repo
launcher then walks up and reuses the parent Android tree's .repo,
causing catastrophic re-sync of all repos with the wrong manifest.

Check for .repo/repo/main.py specifically and recreate via git clone
if missing, ensuring the repo launcher always finds the local checkout.
parent 857657e3
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -400,16 +400,21 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then

      # Build kernel from source for Pixel/Tensor devices via build_kernel()
      # (defined in vendor/lineage/build/envsetup.sh).
      # build_kernel() uses cp -R to copy .repo/repo which breaks on Docker's
      # overlay fs. We pre-create .repo/repo via git clone so build_kernel()
      # skips its cp -R (it checks if .repo already exists).
      # build_kernel() uses cp -R to copy .repo/repo which can produce a broken
      # git repo on Docker volumes. The repo launcher then can't find main.py
      # locally, walks up, and reuses the parent Android tree's .repo instead.
      # Fix: ensure .repo/repo/main.py exists via git clone before build_kernel()
      # runs. build_kernel() checks if .repo/ exists and skips its own cp -R.
      if [[ "${SKIP_KERNEL_BUILD}" != "true" && "${SKIP_KERNEL_BUILD}" != "1" ]]; then
        _kernel_platform_source=$(get_build_var TARGET_KERNEL_PLATFORM_SOURCE 2>/dev/null || true)
        if [ -n "$_kernel_platform_source" ]; then
          _kernel_build_top="${ANDROID_BUILD_TOP}/out-kernel/${_kernel_platform_source}"

          if [ ! -d "${_kernel_build_top}/.repo" ]; then
            echo ">> [$(date)] Pre-creating kernel .repo/repo via git clone for Docker compatibility"
          # Check for main.py specifically — .repo/ may persist from a previous
          # broken run where cp -R failed, so checking just .repo/ is not enough.
          if [ ! -f "${_kernel_build_top}/.repo/repo/main.py" ]; then
            echo ">> [$(date)] Setting up kernel .repo/repo via git clone for Docker compatibility"
            rm -rf "${_kernel_build_top}/.repo/repo"
            mkdir -p "${_kernel_build_top}/.repo"
            git clone "${ANDROID_BUILD_TOP}/.repo/repo" "${_kernel_build_top}/.repo/repo"
            touch "${_kernel_build_top}/.out-dir"