#!/usr/bin/sh

set -eu

DOWNLOAD_BASE="https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin"
OUTPUT_DIR=$1
HOST_ARCH=$2
VERSION=$3

# create the OUTPUT_DIR, if it does not exist
mkdir -p $OUTPUT_DIR

echo "kernel.org gcc toolchain ${VERSION}, download in progress ..."
wget --quiet -nc -c -t 10 --retry-connrefused -nd -np -r -P ${OUTPUT_DIR} -e robots=off -A gz ${DOWNLOAD_BASE}/${HOST_ARCH}/${VERSION}/
wget --quiet -nc -c -t 10 --retry-connrefused -nd -np -r -P ${OUTPUT_DIR}/signatures -e robots=off -A sign ${DOWNLOAD_BASE}/${HOST_ARCH}/${VERSION}/
