#!/usr/bin/env build build_make_fetch_cleanup() { for arg in ${BUILD_FETCH_CLEAN}; do if [ -d "${arg}" ]; then rm -rf "${arg}" elif [ -f "${arg}" ]; then rm "${arg}" fi done } build_make_fetch() { trap build_make_fetch_cleanup 0 echo "trying: fetch ${1}" FETCH_LOG="${BUILDER_TMPDIR}/fetch/$(build-url --archive "${1}").log" if ! test -d "${BUILDER_TMPDIR}/fetch"; then mkdir -p "${BUILDER_TMPDIR}/fetch" fi build_fetch_proto="$(build-url --proto "${1}")" if ! test -x "${BUILDER_LIBDIR}/build-fetch-${build_fetch_proto}"; then die "do not know how to handle '${build_fetch_proto}'" fi set -- "build-fetch-${build_fetch_proto}" "${1}" unset build_fetch_proto "$@" } if test "${BUILDER_CALL_STACK}" = '__main__'; then simple_usage 'fetch' '[all|[/]]' "$@" build_fetch_file="$(build-url --archive "${1}")" for mirror in ${MIRRORS}; do build_make_fetch "${mirror}/${build_fetch_file}" && exit done unset build_fetch_file build_make_fetch "${@}" fi # vim: filetype=sh