Skip to content

Commit

Permalink
get-linux-source: fixup for prepare-incremental-build
Browse files Browse the repository at this point in the history
  • Loading branch information
theihor committed Nov 6, 2024
1 parent 170a993 commit 08a3466
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 35 deletions.
31 changes: 12 additions & 19 deletions .github/workflows/kernel-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ jobs:
timeout-minutes: 100
env:
ARTIFACTS_ARCHIVE: "vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst"
BASE_BRANCH: >-
${{ github.event_name == 'push' && github.ref_name
|| github.base_ref
|| 'bpf-next'
}}
BUILD_SCHED_EXT_SELFTESTS: ${{ inputs.arch == 'x86_64' || inputs.arch == 'aarch64' && 'true' || '' }}
CACHED_KERNEL_BUILD: ${{ github.event_name == 'push' || github.repository == 'libbpf/ci' && 'true' || '' }}
KBUILD_OUTPUT: ${{ github.workspace }}/kbuild-output
Expand All @@ -67,33 +62,31 @@ jobs:
- if: ${{ inputs.download_sources }}
name: Download bpf-next tree
env:
FETCH_GIT_REPO: ${{ env.CACHED_KERNEL_BUILD }}
FETCH_DEPTH: ${{ env.CACHED_KERNEL_BUILD && 16 || 0 }}
uses: ./get-linux-source
with:
dest: '.kernel'
- if: ${{ inputs.download_sources }}
name: Move linux source in place
shell: bash
run: |
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 }}
base-branch: ${{ env.BASE_BRANCH }}
repo-root: ${{ inputs.download_sources && '.kernel' || env.REPO_ROOT }}
base-branch: >-
${{ github.repository == 'kernel-patches/bpf' && github.event_name == 'push' && github.ref_name
|| github.repository == 'kernel-patches/bpf' && github.event_name != 'push' && github.base_ref
|| 'master'
}}
arch: ${{ inputs.arch }}
toolchain_full: ${{ inputs.toolchain_full }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
- if: ${{ inputs.download_sources }}
name: Restore .git # is this really necessary?
name: Move linux source in place
shell: bash
run: |
cd .kernel
rm -rf .git
mv /tmp/.git.not-kernel .git
mv -t .. $(ls -A)
cd ..
rmdir .kernel
- uses: ./patch-kernel
with:
patches-root: '${{ github.workspace }}/ci/diffs'
Expand Down
32 changes: 16 additions & 16 deletions get-linux-source/checkout_latest_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ source $(cd $(dirname $0) && pwd)/../helpers.sh

CWD=$(pwd)

FETCH_GIT_REPO=${FETCH_GIT_REPO:-}
# 0 means just download a snapshot
FETCH_DEPTH=${FETCH_DEPTH:-0}

echo KERNEL_ORIGIN = ${KERNEL_ORIGIN}
echo KERNEL_BRANCH = ${KERNEL_BRANCH}
Expand All @@ -31,28 +32,27 @@ 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}" ] && [ -z "${FETCH_GIT_REPO}" ] && \
if [ -n "${SNAPSHOT_URL}" ] && [ "${FETCH_DEPTH}" -eq 0 ] && \
wget -U 'BPFCIBot/1.0 ([email protected])' -nv ${SNAPSHOT_URL} && \
tar xf bpf-next-${LINUX_SHA}.tar.gz --totals ; then
mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH})
else
# but fallback to git fetch approach if that fails
mkdir -p $(basename ${REPO_PATH})
cd $(basename ${REPO_PATH})
git init
git remote add bpf-next ${KERNEL_ORIGIN}
# try shallow clone first
git fetch --depth 32 bpf-next
# check if desired SHA exists
if ! git cat-file -e ${LINUX_SHA}^{commit} ; then
# if not, fetch all of bpf-next; slow and painful
git fetch bpf-next
fi
git reset --hard ${LINUX_SHA}
# but fallback to git fetch approach if that fails
git clone --depth ${FETCH_DEPTH} ${KERNEL_ORIGIN} ${REPO_PATH}
cd "${REPO_PATH}"
# check if desired SHA exists
if ! git cat-file -e ${LINUX_SHA}^{commit} ; then
# if not, fetch all of bpf-next; slow and painful
git fetch origin
fi
git reset --hard ${LINUX_SHA}
cd -
fi
if [ -z "${FETCH_GIT_REPO}" ]; then
if [ "${FETCH_DEPTH}" -eq 0 ]; then
rm -rf ${REPO_PATH}/.git || true
fi

foldable end pull_kernel_srcs
else
echo "${REPO_PATH} directory already exists, will not download kernel sources"
fi

0 comments on commit 08a3466

Please sign in to comment.