diff options
author | P. J. McDermott <pjm@nac.net> | 2014-03-17 15:17:02 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2014-03-17 15:17:02 (EDT) |
commit | 28bbf55b85e39dbc942ed98183bfdcffe57f09e3 (patch) | |
tree | 08a1346b1668b4a160b9e1cf2fad3add51eba865 | |
parent | 7d3a6c2d0cebac2849d9ac81cb5c508bab7a912b (diff) |
bootstrap-prepare.sh: Add archive download funcs.
-rwxr-xr-x | bootstrap-prepare.sh | 64 |
1 files changed, 64 insertions, 0 deletions
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 <Packages +} + +get_pkg() +{ + local mirror="${1}" + local filename="${2}" + local sha256sum="${3}" + + [ -d pkg ] || mkdir pkg + cd pkg + + wget -O "${filename##*/}" \ + "${mirror}/feeds/dev/trunk/src/all/base/${filename}" + + filename="${filename##*/}" + pkg_ver="${filename#src-}" + pkg_ver="${pkg_ver%_src_all.opk}" + tar -xzOf "${filename}" data.tar.gz | tar -xz + mv "usr/src/${pkg_ver}" "${pkg_ver%_*}" + rmdir usr/src usr + + cd .. +} + prepare_file_system() { local ma dir |