@@ -10,10 +10,12 @@ download_source() {
1010 local distfiles=${1}
1111 local url=${2}
1212 shift 2
13- if [[ ${url} == git://* ]]; then
14- url=${1}
15- shift
16- fi
13+ case $url in
14+ ' git://' * )
15+ url=${1}
16+ shift
17+ ;;
18+ esac
1719 local checksum=${1}
1820 local fname=${2}
1921 # Default to basename of url if not given
@@ -22,13 +24,12 @@ download_source() {
2224 echo " ERROR: ${url} must have a filename specified"
2325 exit 1
2426 fi
25-
2627 local dest_path=${distfiles} /${fname}
2728 if ! [ -e " ${dest_path} " ]; then
2829 echo " Downloading ${fname} "
2930 if [ " ${mirrors_len} " -ne 0 ]; then
30- local mirror_ix=$(( RANDOM % mirrors_len))
31- url=${mirrors[${ mirror_ix}]} /${fname}
31+ local mirror_ix=$(( RANDOM % mirrors_len + 1 ))
32+ eval " url=\"\$ {mirror_ $ mirror_ix }/${fname} \" "
3233 fi
3334 curl --fail --location " ${url} " --output " ${dest_path} " || true
3435 fi
@@ -38,10 +39,12 @@ check_source() {
3839 local distfiles=${1}
3940 local url=${2}
4041 shift 2
41- if [[ ${url} == git://* ]]; then
42- url=${1}
43- shift
44- fi
42+ case $url in
43+ ' git://' * )
44+ url=${1}
45+ shift
46+ ;;
47+ esac
4548 local checksum=${1}
4649 local fname=${2}
4750 # Default to basename of url if not given
@@ -51,34 +54,39 @@ check_source() {
5154 echo " ${checksum} ${dest_path} " | sha256sum -c
5255}
5356
57+ walk_manifest_sources () {
58+ local action=$1
59+ local manifest_entry=
60+ local entry=
61+
62+ while read -r manifest_entry || test -n " $manifest_entry " ; do
63+ case $manifest_entry in
64+ ' build:' * )
65+ entry=" ${manifest_entry# ' build: ' } "
66+ [ -e " ./steps/${entry} /sources" ] || continue
67+ while read -r line; do
68+ # This is intentional - we want to split out ${line} into separate arguments.
69+ # shellcheck disable=SC2086
70+ $action distfiles ${line}
71+ done < " ./steps/${entry} /sources"
72+ ;;
73+ esac
74+ done < " ./steps/manifest"
75+ }
76+
5477set -e
5578
56- mirrors=( " $@ " )
5779mirrors_len=$#
80+ while test $# -gt 0; do
81+ eval " mirror_$# =$1 "
82+ shift
83+ done
5884
5985cd " $( dirname " $( readlink -f " $0 " ) " ) "
6086mkdir -p distfiles
6187
6288# First, try to download anything missing - ignore failing mirrors
63- for entry in steps/* ; do
64- [ -e " ${entry} /sources" ] || continue
65-
66- # shellcheck disable=SC2162
67- while read line; do
68- # This is intentional - we want to split out ${line} into separate arguments.
69- # shellcheck disable=SC2086
70- download_source distfiles ${line}
71- done < " ${entry} /sources"
72- done
73-
89+ walk_manifest_sources download_source
7490# Then, check if everything has been obtained at least once
75- for entry in steps/* ; do
76- [ -e " ${entry} /sources" ] || continue
91+ walk_manifest_sources check_source
7792
78- # shellcheck disable=SC2162
79- while read line; do
80- # This is intentional - we want to split out ${line} into separate arguments.
81- # shellcheck disable=SC2086
82- check_source distfiles ${line}
83- done < " ${entry} /sources"
84- done
0 commit comments