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

Commit c8dcc32e authored by Jackeagle's avatar Jackeagle
Browse files

build_kernel: Fix repo init reusing parent Android tree checkout

Check for manifests.git instead of just .repo/ directory, as a failed
run leaves .repo/ with only a TRACE_FILE which caused the setup block
to be skipped entirely on subsequent runs.

Also create an empty manifests.git via git init --bare so the repo
launcher recognizes the local .repo as a valid checkout and does not
walk up to the parent Android tree's .repo. This matches the state on
dedicated servers where a completed repo init leaves manifests.git in
place.
parent 40a8231a
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -943,13 +943,22 @@ function build_kernel() {

    local KERNEL_BUILD_TOP="${ANDROID_BUILD_TOP}/out-kernel/${target_kernel_source}"

    # Make sure we have the kernel source folder structure in place
    if [ ! -d "${KERNEL_BUILD_TOP}/.repo" ]; then
    # Make sure we have the kernel source folder structure in place.
    # Check for manifests.git specifically — a previous failed run may have
    # left .repo/ with only a TRACE_FILE, causing the old .repo/ check to
    # skip setup entirely while repo still walks up to the parent Android tree.
    if [ ! -d "${KERNEL_BUILD_TOP}/.repo/manifests.git" ]; then
        echo "Kernel source ${KERNEL_BUILD_TOP} is missing, preparing folder structure"

        # Copy .repo/repo from Android tree to allow nested `repo init`
        # Copy .repo/repo from Android tree to allow nested `repo init`.
        # Also create an empty manifests.git so the repo launcher recognizes
        # this as a valid local checkout and does not walk up to the parent
        # Android tree's .repo (which would cause it to reinitialize the wrong
        # manifest). On a dedicated server, manifests.git already exists from
        # a previously completed repo init, which is why it works there.
        mkdir -p "${KERNEL_BUILD_TOP}/.repo"
        cp -R "${ANDROID_BUILD_TOP}/.repo/repo" "${KERNEL_BUILD_TOP}/.repo/repo"
        git init --bare "${KERNEL_BUILD_TOP}/.repo/manifests.git" --quiet

        # Allow custom .repo/project-objects dir
        if [ -n "${KERNEL_REPO_PROJECT_OBJECTS_DIR}" ]; then