@@ -10,6 +10,32 @@ download_if_necessary()
1010{
1111 download_path=" ${OPENCOARRAYS_SRC_DIR} /prerequisites/downloads"
1212 set_SUDO_if_needed_to_write_to_directory " ${download_path} "
13+
14+ # We set args regardless of whether this function performs a download because
15+ # GCC builds will need this to modify GCC's contrib/download_prerequisites script
16+ if [[ " ${fetch} " == " svn" ]]; then
17+ if [[ " ${arg_B:- } " == " gcc" ]]; then
18+ args=(" ls" )
19+ else
20+ args=(" checkout" )
21+ fi
22+ elif [[ " ${fetch} " == " wget" ]]; then
23+ args=(" --no-check-certificate" )
24+ elif [[ " ${fetch} " == " ftp-url" ]]; then
25+ args=(" -n" )
26+ elif [[ " ${fetch} " == " git" ]]; then
27+ args=(" clone" )
28+ elif [[ " ${fetch} " == " curl" ]]; then
29+ first_three_characters=$( echo " ${package_url} " | cut -c1-3)
30+ if [[ " ${first_three_characters} " == " ftp" ]]; then
31+ args=(" -LO" " -u" " anonymous:" )
32+ elif [[ " ${first_three_characters} " == " htt" ]]; then
33+ args=(" -LO" )
34+ else
35+ emergency " download_if_necessary.sh: Unrecognized URL."
36+ fi
37+ fi
38+
1339 if [[ -f " ${download_path} /${url_tail} " || -d " ${download_path} /${url_tail} " ]] ; then
1440 info " Found '${url_tail} ' in ${download_path} ."
1541 info " If it resulted from an incomplete download, building ${package_name} could fail."
@@ -35,29 +61,6 @@ download_if_necessary()
3561 info " Place the downloaded file in ${download_path} and restart this script."
3662 emergency " Aborting [exit 90]"
3763 else
38- # The download mechanism is in the path.
39- if [[ " ${fetch} " == " svn" ]]; then
40- if [[ " ${arg_B:- } " == " gcc" ]]; then
41- args=" ls"
42- else
43- args=" checkout"
44- fi
45- elif [[ " ${fetch} " == " wget" ]]; then
46- args=" --no-check-certificate"
47- elif [[ " ${fetch} " == " ftp-url" ]]; then
48- args=" -n"
49- elif [[ " ${fetch} " == " git" ]]; then
50- args=" clone"
51- elif [[ " ${fetch} " == " curl" ]]; then
52- first_three_characters=$( echo " ${package_url} " | cut -c1-3)
53- if [[ " ${first_three_characters} " == " ftp" ]]; then
54- args=" -LO -u anonymous:"
55- elif [[ " ${first_three_characters} " == " htt" ]]; then
56- args=" -LO"
57- else
58- emergency " download_if_necessary.sh: Unrecognized URL."
59- fi
60- fi
6164
6265 if [[ " ${fetch} " == " svn" || " ${fetch} " == " git" ]]; then
6366 package_source_directory=" ${url_tail} "
@@ -66,11 +69,10 @@ download_if_necessary()
6669 fi
6770 info " Downloading ${package_name} ${version_to_build-} to the following location:"
6871 info " ${download_path} /${package_source_directory} "
69- info " Download command: \" ${fetch} \" ${args:- } ${package_url} "
72+ info " Download command: \" ${fetch} \" ${args[@] :- } ${package_url} "
7073 info " Depending on the file size and network bandwidth, this could take several minutes or longer."
7174 pushd " ${download_path} "
72- # args should be an array. Then "${args[@]:-}" will prevent shellcheck from complaining
73- " ${fetch} " ${args:- } " ${package_url} "
75+ " ${fetch} " ${args[@]:- } " ${package_url} "
7476 popd
7577 if [[ ! -z " ${arg_B:- } " ]]; then
7678 return
0 commit comments