Skip to content

Commit 3d86310

Browse files
committed
get-linux-source: add REFERENCE_REPO_PATH
Try for a REFERENCE_REPO_PATH if available, to reduce network traffic when cloning the Linux source. Signed-off-by: Ihor Solodrai <[email protected]>
1 parent dbc2639 commit 3d86310

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

get-linux-source/checkout_latest_kernel.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -xeuo pipefail
44

55
FETCH_DEPTH=${FETCH_DEPTH:-1}
6+
REFERENCE_REPO_PATH=${REFERENCE_REPO_PATH:-/libbpfci/mirrors/linux}
67

78
echo KERNEL_ORIGIN = ${KERNEL_ORIGIN}
89
echo KERNEL_BRANCH = ${KERNEL_BRANCH}
@@ -13,10 +14,12 @@ if [ -d "${REPO_PATH}" ]; then
1314
exit 1
1415
fi
1516

16-
mkdir -p "${REPO_PATH}"
17-
cd "${REPO_PATH}"
17+
clone_args=()
18+
clone_args+=(--branch ${KERNEL_BRANCH})
19+
clone_args+=(--reference-if-able ${REFERENCE_REPO_PATH})
20+
if [ ${FETCH_DEPTH} -ge 1 ]; then
21+
clone_args+=(--depth ${FETCH_DEPTH})
22+
fi
23+
24+
git clone "${clone_args[@]}" ${KERNEL_ORIGIN} ${REPO_PATH}
1825

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)