2020-02-12 20:20:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-08-22 02:06:43 +00:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
source $(cd $(dirname $0) && pwd)/helpers.sh
|
2020-02-12 20:20:53 +00:00
|
|
|
|
|
|
|
CWD=$(pwd)
|
|
|
|
LIBBPF_PATH=$(pwd)
|
|
|
|
REPO_PATH=$1
|
|
|
|
|
2021-07-09 13:39:29 +00:00
|
|
|
KERNEL_ORIGIN=${KERNEL_ORIGIN:-https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git}
|
|
|
|
KERNEL_BRANCH=${KERNEL_BRANCH:-CHECKPOINT}
|
|
|
|
if [[ "${KERNEL_BRANCH}" = 'CHECKPOINT' ]]; then
|
|
|
|
echo "using CHECKPOINT sha1"
|
|
|
|
LINUX_SHA=$(cat ${LIBBPF_PATH}/CHECKPOINT-COMMIT)
|
|
|
|
else
|
|
|
|
echo "using ${KERNEL_BRANCH} sha1"
|
|
|
|
LINUX_SHA=$(git ls-remote ${KERNEL_ORIGIN} ${KERNEL_BRANCH} | awk '{print $1}')
|
|
|
|
fi
|
|
|
|
SNAPSHOT_URL=${KERNEL_ORIGIN}/snapshot/bpf-next-${LINUX_SHA}.tar.gz
|
2020-02-12 20:20:53 +00:00
|
|
|
|
|
|
|
echo REPO_PATH = ${REPO_PATH}
|
2021-07-09 13:39:29 +00:00
|
|
|
|
|
|
|
echo KERNEL_ORIGIN = ${KERNEL_ORIGIN}
|
2020-02-12 20:20:53 +00:00
|
|
|
echo LINUX_SHA = ${LINUX_SHA}
|
2021-07-09 13:39:29 +00:00
|
|
|
echo SNAPSHOT_URL = ${SNAPSHOT_URL}
|
2020-02-12 20:20:53 +00:00
|
|
|
|
|
|
|
if [ ! -d "${REPO_PATH}" ]; then
|
2020-08-22 02:06:43 +00:00
|
|
|
echo
|
|
|
|
travis_fold start pull_kernel_srcs "Fetching kernel sources"
|
|
|
|
|
2020-08-11 04:51:53 +00:00
|
|
|
mkdir -p $(dirname "${REPO_PATH}")
|
|
|
|
cd $(dirname "${REPO_PATH}")
|
|
|
|
# attempt to fetch desired bpf-next repo snapshot
|
2021-08-05 01:32:14 +00:00
|
|
|
if wget -nv ${SNAPSHOT_URL} && tar xf bpf-next-${LINUX_SHA}.tar.gz --totals ; then
|
2020-08-11 04:51:53 +00:00
|
|
|
mv bpf-next-${LINUX_SHA} $(basename ${REPO_PATH})
|
|
|
|
else
|
|
|
|
# but fallback to git fetch approach if that fails
|
2020-08-18 18:05:55 +00:00
|
|
|
mkdir -p $(basename ${REPO_PATH})
|
|
|
|
cd $(basename ${REPO_PATH})
|
2020-08-11 04:51:53 +00:00
|
|
|
git init
|
2021-07-09 13:39:29 +00:00
|
|
|
git remote add bpf-next ${KERNEL_ORIGIN}
|
2020-08-11 04:51:53 +00:00
|
|
|
# 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}
|
|
|
|
fi
|
2020-08-22 02:06:43 +00:00
|
|
|
|
|
|
|
travis_fold end pull_kernel_srcs
|
2020-02-12 20:20:53 +00:00
|
|
|
fi
|