@@ -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
@@ -28,7 +30,7 @@ download_source() {
2830 echo " Downloading ${fname} "
2931 if [ " ${mirrors_len} " -ne 0 ]; then
3032 local mirror_ix=$(( RANDOM % mirrors_len))
31- url=${mirrors[${ mirror_ix}]} / ${fname}
33+ eval " url=\$ {mirror_ $ mirror_ix }"
3234 fi
3335 curl --fail --location " ${url} " --output " ${dest_path} " || true
3436 fi
@@ -38,10 +40,12 @@ check_source() {
3840 local distfiles=${1}
3941 local url=${2}
4042 shift 2
41- if [[ ${url} == git://* ]]; then
42- url=${1}
43- shift
44- fi
43+ case $url in
44+ ' git://' * )
45+ url=${1}
46+ shift
47+ ;;
48+ esac
4549 local checksum=${1}
4650 local fname=${2}
4751 # Default to basename of url if not given
@@ -51,34 +55,40 @@ check_source() {
5155 echo " ${checksum} ${dest_path} " | sha256sum -c
5256}
5357
58+ walk_manifest_sources () {
59+ local action=$1
60+ local manifest_entry=
61+ local entry=
62+
63+ while read -r manifest_entry || test -n " $manifest_entry " ; do
64+ case $manifest_entry in
65+ ' build:' * )
66+ entry=" ${manifest_entry# ' build: ' } "
67+ [ -e " ./steps/${entry} /sources" ] || continue
68+ while read -r line; do
69+ # This is intentional - we want to split out ${line} into separate arguments.
70+ # shellcheck disable=SC2086
71+ $action distfiles ${line}
72+ done < " ./steps/${entry} /sources"
73+ ;;
74+ esac
75+ done < " ./steps/manifest"
76+ }
77+
5478set -e
5579
56- mirrors=( " $@ " )
5780mirrors_len=$#
81+ while test $# -gt 0;
82+ do
83+ eval " mirror_$# =$1 "
84+ shift
85+ done
5886
5987cd " $( dirname " $( readlink -f " $0 " ) " ) "
6088mkdir -p distfiles
6189
6290# 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-
91+ walk_manifest_sources download_source
7492# Then, check if everything has been obtained at least once
75- for entry in steps/* ; do
76- [ -e " ${entry} /sources" ] || continue
93+ walk_manifest_sources check_source
7794
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