#!/bin/bash

set -x

# script to fetch toolchain source tar using ci.netsurf-browser.org as a cache

# Usage fetchsrc <target> <source> <upstream> <sha256sum> <output>

NSSRV="https://ci.netsurf-browser.org/toolchain/"

wget -q --no-use-server-timestamps -O ${5} ${NSSRV}/${1}/${2}
if [ $? -ne 0 ];then
    wget -q --no-use-server-timestamps -O ${5} ${3}
    if [ $? -ne 0 ];then
        rm ${5}
	exit 1
    fi
fi

echo "${4} *${5}" | sha256sum --strict -c -
exit $?
