Skip to content

Commit 706ea5a

Browse files
author
Damian Rouson
committed
Use any of ftp wget curl (#196)
Removed download-mechanism platform-dependence. Use svn for all branch builds or branch list queries Use curl, wget, or ftp in decreasing order of preference as measured by robustness. * Restrict ftp to sites that offer anonymous ftp * Improve error output when non-OSX OFP build required
1 parent 67ecc3b commit 706ea5a

File tree

3 files changed

+42
-45
lines changed

3 files changed

+42
-45
lines changed

prerequisites/build-functions/set_or_print_downloader.sh

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# shellcheck disable=SC2154
55
set_or_print_downloader()
66
{
7-
87
# Verify requirements
98
[ ! -z "${arg_D}" ] && [ ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}" ] &&
109
emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
@@ -14,48 +13,45 @@ set_or_print_downloader()
1413
if [[ "${package_name}" == "ofp" ]]; then
1514
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
1615
exit 0
17-
fi
18-
if [[ $(uname) == "Darwin" ]]; then
19-
wget_or_curl=curl
20-
ftp_or_curl=curl
16+
fi
17+
18+
# Choose the first available download mechanism, prioritizing first any absolute requirement
19+
# (svn for gcc development branches) and second robustness:
20+
info "Checking available download mechanisms: ftp, wget, and curl."
21+
info "\${package_name}=${package_name} \${arg_b:-\${arg_B:-}}=${arg_b:-${arg_B:-}}"
22+
23+
if [[ "${package_name}" == "gcc" && ! -z "${arg_b:-${arg_B:-}}" ]]; then
24+
25+
if type svn &> /dev/null; then
26+
fetch=svn
27+
else
28+
tried="svn"
29+
fi
30+
31+
elif type curl &> /dev/null; then
32+
fetch=curl
33+
elif type wget &> /dev/null; then
34+
fetch=wget
35+
elif type ftp &> /dev/null; then
36+
if [[ "${package_name}" == "gcc" || "${package_name}" == "wget" || "${package_name}" == "make" ||
37+
"${package_name}" == "bison" || "${package_name}" == "m4" ]]; then
38+
fetch=ftp-url
39+
fi
2140
else
22-
wget_or_curl=wget
23-
ftp_or_curl=ftp-url
24-
fi
25-
if [[ "${package_name}" == "gcc" ]]; then
26-
if [[ -z "${arg_b:-${arg_B:-}}" ]]; then
27-
gcc_fetch="${ftp_or_curl}"
28-
else
29-
gcc_fetch="svn"
41+
tried="curl, wget, and ftp"
42+
fi
43+
44+
if [[ -z "${fetch:-}" ]]; then
45+
if [[ -z "${arg_B:-}" ]]; then
46+
warning "No available download mechanism. Options tried: ${tried}"
47+
else
48+
emergency "No available download mechanism. Option tried: ${tried}"
3049
fi
3150
fi
32-
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
33-
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
34-
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
35-
package_fetch=(
36-
"gcc:${gcc_fetch-}"
37-
"wget:${ftp_or_curl-}"
38-
"cmake:${wget_or_curl-}"
39-
"mpich:${wget_or_curl-}"
40-
"flex:${wget_or_curl-}"
41-
"bison:${ftp_or_curl-}"
42-
"pkg-config:${wget_or_curl-}"
43-
"make:${ftp_or_curl-}"
44-
"m4:${ftp_or_curl-}"
45-
"subversion:${wget_or_curl-}"
46-
)
47-
for package in "${package_fetch[@]}" ; do
48-
KEY="${package%%:*}"
49-
VALUE="${package##*:}"
50-
if [[ "${package_name}" == "${KEY}" ]]; then
51-
# We recognize the package name so we set the download mechanism:
52-
fetch=${VALUE}
53-
# If a printout of the download mechanism was requested, then print it and exit with normal status
54-
[[ ! -z "${arg_D}" ]] && printf "%s\n" "${fetch}" && exit 0
55-
break # exit the for loop
56-
fi
57-
done
58-
if [[ -z "${fetch:-}" ]]; then
59-
emergency "Package ${package_name:-} not recognized. Use --l or --list-packages to list the allowable names."
51+
52+
# If a printout of the download mechanism was requested, then print it and exit with normal status
53+
if [[ ! -z "${arg_D}" ]]; then
54+
printf "%s\n" "${fetch}"
55+
exit 0
6056
fi
6157
}

prerequisites/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ info "-V (--print-version): ${arg_V} "
115115
if [[ -z "${arg_B}" ]]; then
116116
# shellcheck source=./build-functions/set_or_print_default_version.sh
117117
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh"
118-
set_or_print_default_version "${@}"
118+
set_or_print_default_version
119119
export version_to_build="${arg_I:-${arg_b:-${default_version}}}"
120120
fi
121121

122122
# shellcheck source=./build-functions/set_or_print_downloader.sh
123123
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_downloader.sh"
124-
set_or_print_downloader "${@}"
124+
set_or_print_downloader
125125

126126
# shellcheck source=./build-functions/set_or_print_url.sh
127127
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_url.sh"

prerequisites/install-ofp.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ export __flag_present=1
6060

6161
# shellcheck disable=SC2154
6262
if [[ "${__os}" != "OSX" ]]; then
63-
info "${__base} currently installs binaries that work only on OS X"
64-
emergency "To request other platforms, please submit an issue at http://github.com/sourceryinstitute/opencoarrays/issues"
63+
echo "Source tranlsation via OFP is currently supported only on OS X."
64+
echo "Please submit an issue at http://github.com/sourceryinstitute/opencoarrays/issues."
65+
emergency "${PWD}/install-ofp.sh: Aborting."
6566
fi
6667

6768
if [[ $(uname) == "Darwin" ]]; then

0 commit comments

Comments
 (0)