blob: 8f2bcb7ab265cf24800da5d64a33cc1f7615a191 [file] [log] [blame]
# linux-bundle-clone
# ------------------
# Use this script to clone a Linux repository using a CDN-hosted bundle.
# This is the recommended way to clone Linux in a CI environment where
# the full repository needs to be cloned every time.
[ "${REMOTE:=$1}" ] || {
echo "Please specify the remote to clone"
echo "Example: ${0} linux master"
exit 1
[ "${TARGET:=$2}" ] || {
echo "Please specify the target directory"
echo "Example: ${0} linux master"
exit 1
# You can also use "http" if you are behind a caching proxy and want to
# benefit from a locally stored copy. Initial time to first byte may be
# long if the CDN frontend doesn't have the copy of the bundle yet, but
# repeat requests will use the cached CDN copy.
# NOTICE: Pick the tree that's likely to have most of the objects you want
# We have mainline, stable, and linux-next bundles for you to choose
# We'll put the bundle into a safe temp location, but WARNING -- it's a
# 1Gb+ file, so if you have limited space in /tmp, you should consider
# changing the path here. See "man mktemp".
BUNDLELOCAL=$(mktemp /tmp/linux-bundle.XXXXXXXXXX)
echo "Getting the bundle file"
curl -L "${CDNBUNDLE}" -o "${BUNDLELOCAL}" || {
echo "Getting the clone bundle failed."
# clean up to not litter huge files around
rm -f "${BUNDLELOCAL}"
exit 1
echo "Cloning from the bundle file"
git clone "${BUNDLELOCAL}" "${TARGET}" || {
echo "Cloning from bundle failed."
echo "The bundle is in ${BUNDLELOCAL}"
exit 1
# We're done with the bundle now
rm -f "${BUNDLELOCAL}"
cd "${TARGET}"
echo "Fetching latest objects"
git remote set-url origin "${REMOTE}"
git remote update origin
git checkout "${CHECKOUT}"