From c0a111cdaf57ea039df740c8255dae0544bb256c Mon Sep 17 00:00:00 2001 From: Ihor Solodrai Date: Tue, 5 Nov 2024 17:27:13 -0800 Subject: [PATCH] kernel-build: handle downloaded .kernel correctly for cached build Signed-off-by: Ihor Solodrai --- .github/workflows/kernel-build.yml | 18 ++++++++++++++---- get-linux-source/checkout_latest_kernel.sh | 4 +++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/kernel-build.yml b/.github/workflows/kernel-build.yml index 9f49e2c..e4a18cd 100644 --- a/.github/workflows/kernel-build.yml +++ b/.github/workflows/kernel-build.yml @@ -66,6 +66,8 @@ jobs: fetch-depth: 50 - if: ${{ inputs.download_sources }} name: Download bpf-next tree + env: + FORCE_GIT_FETCH: ${{ env.CACHED_KERNEL_BUILD }} uses: ./get-linux-source with: dest: '.kernel' @@ -73,10 +75,12 @@ jobs: name: Move linux source in place shell: bash run: | - rm -rf .kernel/.git - cp -rf .kernel/. . - rm -rf .kernel - - if: $${{ env.CACHED_KERNEL_BUILD }} + mv .git /tmp/.git.not-kernel + cd .kernel + mv -t .. $(ls -A) + cd .. + rmdir .kernel + - if: ${{ env.CACHED_KERNEL_BUILD }} uses: ./prepare-incremental-build with: repo-root: ${{ env.REPO_ROOT }} @@ -84,6 +88,12 @@ jobs: arch: ${{ inputs.arch }} toolchain_full: ${{ inputs.toolchain_full }} kbuild-output: ${{ env.KBUILD_OUTPUT }} + - if: ${{ inputs.download_sources }} + name: Restore .git # is this really necessary? + shell: bash + run: | + rm -rf .git + mv /tmp/.git.not-kernel .git - uses: ./patch-kernel with: patches-root: '${{ github.workspace }}/ci/diffs' diff --git a/get-linux-source/checkout_latest_kernel.sh b/get-linux-source/checkout_latest_kernel.sh index 8e36e47..f07f54e 100755 --- a/get-linux-source/checkout_latest_kernel.sh +++ b/get-linux-source/checkout_latest_kernel.sh @@ -6,6 +6,8 @@ source $(cd $(dirname $0) && pwd)/../helpers.sh CWD=$(pwd) +FORCE_GIT_FETCH=${FORCE_GIT_FETCH:-} + echo KERNEL_ORIGIN = ${KERNEL_ORIGIN} echo KERNEL_BRANCH = ${KERNEL_BRANCH} echo REPO_PATH = ${REPO_PATH} @@ -29,7 +31,7 @@ if [ ! -d "${REPO_PATH}" ]; then mkdir -p $(dirname "${REPO_PATH}") cd $(dirname "${REPO_PATH}") # attempt to fetch desired bpf-next repo snapshot - if [ -n "${SNAPSHOT_URL}" ] && \ + if [ -n "${SNAPSHOT_URL}" ] && [ -z "${FORCE_GIT_FETCH}" ] && \ wget -U 'BPFCIBot/1.0 (bpf@vger.kernel.org)' -nv ${SNAPSHOT_URL} && \ tar xf bpf-next-${LINUX_SHA}.tar.gz --totals ; then mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH})