Skip to content

Commit c422391

Browse files
committed
get-linux-source: always do git fetch
Recently proof-of-work proxy was rolled out for git.kernel.org, which prevents wget of the bpf-next snapshots. This lead to failures of get-linux-source action: * https://github.com/kernel-patches/vmtest/actions/runs/14313967784/job/40115985369 * https://github.com/libbpf/libbpf/actions/runs/14316467048/job/40123652831 Simplify the download script to always run git init + git fetch sequence. [1] https://social.kernel.org/notice/AsgziNL6zgmdbta3lY Signed-off-by: Ihor Solodrai <[email protected]>
1 parent c450b5d commit c422391

File tree

2 files changed

+10
-57
lines changed

2 files changed

+10
-57
lines changed

.github/workflows/gcc-bpf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
- if: ${{ inputs.download_sources }}
4747
name: Download bpf-next tree
48-
uses: libbpf/ci/get-linux-source@v3
48+
uses: ./get-linux-source
4949
with:
5050
dest: ${{ env.REPO_ROOT }}
5151
rev: ${{ env.BPF_NEXT_BASE_BRANCH }}
Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,22 @@
11
#!/bin/bash
22

3-
set -euo pipefail
3+
set -xeuo pipefail
44

5-
source $(cd $(dirname $0) && pwd)/../helpers.sh
6-
7-
CWD=$(pwd)
8-
9-
# 0 means just download a snapshot
10-
FETCH_DEPTH=${FETCH_DEPTH:-0}
5+
FETCH_DEPTH=${FETCH_DEPTH:-1}
116

127
echo KERNEL_ORIGIN = ${KERNEL_ORIGIN}
138
echo KERNEL_BRANCH = ${KERNEL_BRANCH}
149
echo REPO_PATH = ${REPO_PATH}
1510

16-
SNAPSHOT_URL=''
17-
if [[ "${KERNEL_BRANCH}" = 'master' ]]; then
18-
echo "using ${KERNEL_BRANCH} sha1"
19-
LINUX_SHA=$(git ls-remote ${KERNEL_ORIGIN} ${KERNEL_BRANCH} | awk '{print $1}')
20-
else
21-
LINUX_SHA=${KERNEL_BRANCH}
22-
fi
23-
SNAPSHOT_URL=${KERNEL_ORIGIN}/snapshot/bpf-next-${LINUX_SHA}.tar.gz
24-
25-
echo LINUX_SHA = ${LINUX_SHA}
26-
echo SNAPSHOT_URL = ${SNAPSHOT_URL}
27-
2811
if [ -d "${REPO_PATH}" ]; then
2912
echo "${REPO_PATH} directory already exists, will not download kernel sources"
30-
exit 0
13+
exit 1
3114
fi
3215

33-
mkdir -p $(dirname "${REPO_PATH}")
34-
cd $(dirname "${REPO_PATH}")
35-
36-
# attempt to fetch desired bpf-next repo snapshot
37-
if [[ -n "${SNAPSHOT_URL}" && "${FETCH_DEPTH}" -le 0 ]]; then
38-
wget -U 'BPFCIBot/1.0 ([email protected])' -nv ${SNAPSHOT_URL} || true
39-
PRESERVE_DOT_GIT=
40-
else
41-
PRESERVE_DOT_GIT=true
42-
fi
43-
44-
tarball=bpf-next-${LINUX_SHA}.tar.gz
45-
if [[ -f "$tarball" ]]; then
46-
tar xf "$tarball" --totals
47-
mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH})
48-
else
49-
# FETCH_DEPTH can be 0 here in case snapshot download has failed
50-
if [ "${FETCH_DEPTH}" -le 0 ]; then
51-
FETCH_DEPTH=1
52-
fi
53-
54-
git clone --depth ${FETCH_DEPTH} ${KERNEL_ORIGIN} ${REPO_PATH}
55-
56-
cd "${REPO_PATH}"
57-
# check if desired SHA exists
58-
if ! git cat-file -e ${LINUX_SHA}^{commit} ; then
59-
# if not, fetch all of bpf-next; slow and painful
60-
git fetch origin
61-
fi
62-
git reset --hard ${LINUX_SHA}
63-
cd -
64-
fi
65-
66-
if [ -z "${PRESERVE_DOT_GIT}" ]; then
67-
rm -rf ${REPO_PATH}/.git || true
68-
fi
16+
mkdir -p "${REPO_PATH}"
17+
cd "${REPO_PATH}"
6918

19+
git init
20+
git remote add origin ${KERNEL_ORIGIN}
21+
git fetch --depth=${FETCH_DEPTH} origin ${KERNEL_BRANCH}
22+
git checkout FETCH_HEAD

0 commit comments

Comments
 (0)