From 28bbf55b85e39dbc942ed98183bfdcffe57f09e3 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 17 Mar 2014 15:17:02 -0400 Subject: bootstrap-prepare.sh: Add archive download funcs. --- diff --git a/bootstrap-prepare.sh b/bootstrap-prepare.sh index 2b8282e..23b6ffa 100755 --- a/bootstrap-prepare.sh +++ b/bootstrap-prepare.sh @@ -21,6 +21,7 @@ set -e +IDX_SHA256SUM='adefcf8322bfab117c9c5295ca5a97b067957382902154605080de6a8a1003b5' SCRIPT_DIR= ARCH= PLAT= @@ -138,6 +139,69 @@ prepare_packages_from_ftp() cd .. } +prepare_packages() +{ + local mirror rand line filename sha256sum + + log 'Selecting package archive mirror...' + if [ -r "${SCRIPT_DIR}/mirror" ]; then + mirror="$(cat "${SCRIPT_DIR}/mirror")" + else + rand=$(date '+%S') + rand=$(($rand % 2)) + case ${rand} in + 0) + mirror='http://proteanos.mirror.gnu.dk' + mirror="${mirror}/pub/proteanos" + ;; + 1) + mirror='http://mirror.oss.maxcdn.com/proteanos' + ;; + esac + fi + + log 'Downloading Packages index file...' + wget -O Packages "${mirror}/feeds/dev/trunk/src/all/base/Packages" + if ! printf '%s Packages\n' "${IDX_SHA256SUM}" | sha256sum -c -; then + printf 'ERROR: Checksum of Packages index file failed!\n' >&2 + exit 1 + fi + + log 'Downloading source packages...' + while IFS='' read -r line; do + if [ "x${line%: *}" = 'xFilename' ]; then + filename="${line}" + filename="${filename#Filename: }" + elif [ "x${line%: *}" = 'xSHA256sum' ]; then + sha256sum="${line}" + sha256sum="${sha256sum#SHA256sum: }" + get_pkg "${mirror}" "${filename}" "${sha256sum}" + fi + done