Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 37 additions & 41 deletions prerequisites/build-functions/set_or_print_downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# shellcheck disable=SC2154
set_or_print_downloader()
{

# Verify requirements
[ ! -z "${arg_D}" ] && [ ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}" ] &&
emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
Expand All @@ -14,48 +13,45 @@ set_or_print_downloader()
if [[ "${package_name}" == "ofp" ]]; then
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
exit 0
fi
if [[ $(uname) == "Darwin" ]]; then
wget_or_curl=curl
ftp_or_curl=curl
fi

# Choose the first available download mechanism, prioritizing first any absolute requirement
# (svn for gcc development branches) and second robustness:
info "Checking available download mechanisms: ftp, wget, and curl."
info "\${package_name}=${package_name} \${arg_b:-\${arg_B:-}}=${arg_b:-${arg_B:-}}"

if [[ "${package_name}" == "gcc" && ! -z "${arg_b:-${arg_B:-}}" ]]; then

if type svn &> /dev/null; then
fetch=svn
else
tried="svn"
fi

elif type curl &> /dev/null; then
fetch=curl
elif type wget &> /dev/null; then
fetch=wget
elif type ftp &> /dev/null; then
if [[ "${package_name}" == "gcc" || "${package_name}" == "wget" || "${package_name}" == "make" ||
"${package_name}" == "bison" || "${package_name}" == "m4" ]]; then
fetch=ftp-url
fi
else
wget_or_curl=wget
ftp_or_curl=ftp-url
fi
if [[ "${package_name}" == "gcc" ]]; then
if [[ -z "${arg_b:-${arg_B:-}}" ]]; then
gcc_fetch="${ftp_or_curl}"
else
gcc_fetch="svn"
tried="curl, wget, and ftp"
fi

if [[ -z "${fetch:-}" ]]; then
if [[ -z "${arg_B:-}" ]]; then
warning "No available download mechanism. Options tried: ${tried}"
else
emergency "No available download mechanism. Option tried: ${tried}"
fi
fi
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
package_fetch=(
"gcc:${gcc_fetch-}"
"wget:${ftp_or_curl-}"
"cmake:${wget_or_curl-}"
"mpich:${wget_or_curl-}"
"flex:${wget_or_curl-}"
"bison:${ftp_or_curl-}"
"pkg-config:${wget_or_curl-}"
"make:${ftp_or_curl-}"
"m4:${ftp_or_curl-}"
"subversion:${wget_or_curl-}"
)
for package in "${package_fetch[@]}" ; do
KEY="${package%%:*}"
VALUE="${package##*:}"
if [[ "${package_name}" == "${KEY}" ]]; then
# We recognize the package name so we set the download mechanism:
fetch=${VALUE}
# If a printout of the download mechanism was requested, then print it and exit with normal status
[[ ! -z "${arg_D}" ]] && printf "%s\n" "${fetch}" && exit 0
break # exit the for loop
fi
done
if [[ -z "${fetch:-}" ]]; then
emergency "Package ${package_name:-} not recognized. Use --l or --list-packages to list the allowable names."

# If a printout of the download mechanism was requested, then print it and exit with normal status
if [[ ! -z "${arg_D}" ]]; then
printf "%s\n" "${fetch}"
exit 0
fi
}
4 changes: 2 additions & 2 deletions prerequisites/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ info "-V (--print-version): ${arg_V} "
if [[ -z "${arg_B}" ]]; then
# shellcheck source=./build-functions/set_or_print_default_version.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh"
set_or_print_default_version "${@}"
set_or_print_default_version
export version_to_build="${arg_I:-${arg_b:-${default_version}}}"
fi

# shellcheck source=./build-functions/set_or_print_downloader.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_downloader.sh"
set_or_print_downloader "${@}"
set_or_print_downloader

# shellcheck source=./build-functions/set_or_print_url.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_url.sh"
Expand Down
5 changes: 3 additions & 2 deletions prerequisites/install-ofp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export __flag_present=1

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

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