Skip to content

Commit 68025e3

Browse files
author
Damian Rouson
committed
Merge pull request #181 from sourceryinstitute/use-curl-on-os-x
Use curl on OS X & append version # to install_path
2 parents 2997200 + fbee6aa commit 68025e3

10 files changed

+72
-41
lines changed

prerequisites/build-functions/download_if_necessary.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ download_if_necessary()
4343
args="-n"
4444
elif [[ "${fetch}" == "git" ]]; then
4545
args="clone"
46+
elif [[ "${fetch}" == "curl" ]]; then
47+
args="-LO"
4648
fi
49+
4750
if [[ "${fetch}" == "svn" || "${fetch}" == "git" ]]; then
4851
package_source_directory="${url_tail}"
4952
else
5053
package_source_directory="${package_name}-${version_to_build}"
5154
fi
5255
info "Downloading ${package_name} ${version_to_build} to the following location:"
5356
info "${download_path}/${package_source_directory}"
54-
info "Download command: ${fetch} ${args} ${package_url}"
57+
info "Download command: \"${fetch}\" ${args:-} ${package_url}"
5558
info "Depending on the file size and network bandwidth, this could take several minutes or longer."
5659
pushd "${download_path}"
57-
"${fetch}" "${args}" "${package_url}"
60+
"${fetch}" ${args:-} ${package_url}
5861
popd
5962
if [[ "${version_to_build}" == '--avail' || "${version_to_build}" == '-a' ]]; then
6063
# In this case, args="ls" and the list of available versions has been printed so we can move on.

prerequisites/build-functions/set_or_print_default_version.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ set_or_print_default_version()
1313
fi
1414
# Get package name from argument passed with -p, -V, -D, or -U
1515
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}" # not needed for -l
16+
17+
if [[ "${package_name}" == "ofp" ]]; then
18+
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
19+
exit 0
20+
fi
21+
22+
[ "${package_name}" == "opencoarrays" ] &&
23+
emergency "Please use this script with a previously downloaded opencoarrays source archive. This script does not download opencoarrays "
1624
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
1725
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
1826
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
@@ -26,7 +34,8 @@ set_or_print_default_version()
2634
"pkg-config:0.28"
2735
"make:4.1"
2836
"m4:1.4.17"
29-
"subversion:1.9.2"
37+
"subversion:1.9.4"
38+
"ofp:sdf"
3039
)
3140
for package in "${package_version[@]}" ; do
3241
KEY="${package%%:*}"

prerequisites/build-functions/set_or_print_downloader.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,34 @@ set_or_print_downloader()
99
emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
1010

1111
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}"
12+
if [[ "${package_name}" == "ofp" ]]; then
13+
${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
14+
exit 0
15+
fi
1216
if [[ "${package_name}" == "gcc" && "${version_to_build}" != "trunk" ]]; then
1317
gcc_fetch="ftp-url"
1418
else
1519
gcc_fetch="svn"
1620
fi
21+
if [[ $(uname) == "Darwin" ]]; then
22+
wget_or_curl=curl
23+
else
24+
wget_or_curl=wget
25+
fi
1726
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
1827
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
1928
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
2029
package_fetch=(
2130
"gcc:$gcc_fetch"
2231
"wget:ftp-url"
23-
"cmake:wget"
24-
"mpich:wget"
25-
"flex:wget"
32+
"cmake:${wget_or_curl}"
33+
"mpich:${wget_or_curl}"
34+
"flex:${wget_or_curl}"
2635
"bison:ftp-url"
27-
"pkg-config:wget"
36+
"pkg-config:${wget_or_curl}"
2837
"make:ftp-url"
2938
"m4:ftp-url"
30-
"subversion:wget"
39+
"subversion:${wget_or_curl}"
3140
)
3241
for package in "${package_fetch[@]}" ; do
3342
KEY="${package%%:*}"

prerequisites/build-functions/set_or_print_installation_path.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@ set_or_print_installation_path()
77
[ ! -z "${arg_P}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_U:-${arg_V}}}}" ] &&
88
emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
99

10-
# ../build.sh-usage specifies the following installation path default for illustrative purposes only:
11-
# Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name:-}/"
12-
# When the parse_command_line function executes, ${package_name:-} is empty, but it has
13-
# been set before reaching the current function so now we can get the true values if the
14-
# user didn't override the default:
15-
16-
path_in_usage_file="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations//"
17-
if [[ "${arg_i}" == "${path_in_usage_file}" ]]; then
18-
install_path="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name}/"
19-
else
20-
install_path="${arg_i}"
21-
fi
10+
install_path="${arg_i}/${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}/${version_to_build}"
2211

2312
# If -P is present, print ${install_path} and exit with normal status
2413
if [[ ! -z "${arg_P:-}" ]]; then

prerequisites/build-functions/set_or_print_url.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ set_or_print_url()
5353
"gcc;${gcc_tail:-}"
5454
"wget;wget-${version_to_build}.tar.gz"
5555
"m4;m4-${version_to_build}.tar.bz2"
56-
"pkg-config;pkg-config-$version_to_build}.tar.gz"
56+
"pkg-config;pkg-config-${version_to_build}.tar.gz"
5757
"mpich;mpich-${version_to_build}.tar.gz"
5858
"flex;flex-${version_to_build}.tar.bz2"
5959
"bison;bison-${version_to_build}.tar.gz"

prerequisites/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ info "-V (--print-version): ${arg_V} "
114114
}
115115
# shellcheck source=./build-functions/set_or_print_default_version.sh
116116
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh"
117-
set_or_print_default_version
117+
set_or_print_default_version "${@}"
118118
export version_to_build="${arg_I:-${default_version}}"
119119

120120
# shellcheck source=./build-functions/set_or_print_downloader.sh
121121
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_downloader.sh"
122-
set_or_print_downloader
122+
set_or_print_downloader "${@}"
123123

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

prerequisites/install-binary-functions/set_or_print_downloader.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ set_or_print_downloader()
1111
fi
1212
fi
1313
package_name="${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}}"
14+
if [[ $(uname) == "Darwin" ]]; then
15+
wget_or_curl=curl
16+
else
17+
wget_or_curl=wget
18+
fi
1419
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
1520
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
1621
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
1722
package_fetch=(
18-
"strategoxt-superbundle:wget"
23+
"strategoxt-superbundle:${wget_or_curl}"
1924
)
2025
for package in "${package_fetch[@]}" ; do
2126
KEY="${package%%:*}"

prerequisites/install-binary.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@
3030
# (3) Parse the usage information (default usage file name: current file's name with -usage appended).
3131
# (4) Parse the command line using the usage information.
3232

33-
export __usage="${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh-usage"
3433

3534
### Start of boilerplate -- do not edit this block #######################
35+
export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD}/../}"
36+
if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then
37+
echo "Please run this script inside the top-level OpenCoarrays source \"prerequisites\" "
38+
echo "subdirectory or set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path."
39+
exit 1
40+
fi
41+
export __usage="${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh-usage"
42+
export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}"
3643
if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
3744
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
38-
exit 1
39-
elif [[ ! -d "${OPENCOARRAYS_SRC_DIR:-}" ]]; then
40-
echo "Please set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path."
4145
exit 2
4246
else
43-
# shellcheck source=./use-case/bootstrap.sh
44-
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
47+
# shellcheck source=./prerequisites/use-case/bootstrap.sh
48+
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
4549
fi
4650
### End of boilerplate -- start user edits below #########################
4751

@@ -131,7 +135,7 @@ set_or_print_csv_binary_names
131135

132136
# shellcheck source=./build-functions/set_SUDO_if_needed_to_write_to_directory.sh
133137
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh"
134-
set_SUDO_if_needed_to_write_to_directory /opt
138+
set_SUDO_if_needed_to_write_to_directory "${arg_i}"
135139

136140
# shellcheck source=./install-binary-functions/move_binaries_to_install_path.sh
137141
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/install-binary-functions/move_binaries_to_install_path.sh"

prerequisites/install-binary.sh-usage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-D --print-downloader [arg] Print download program for package specified in argument.
33
-e --verbose Enable verbose mode, print script as it is executed.
44
-h --help This page.
5-
-i --install-dir [arg] Install package in specified path. Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name:-}/${version_to_build:-}/"
5+
-i --install-dir [arg] Install package in specified path. Default="/opt"
66
-I --install-version [arg] Package version to install. (To see default, use -V or --print-version)
77
-l --list-packages List the packages this script can install.
88
-n --no-color Disable color output.

prerequisites/install-ofp.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
# (4) Parse the command line using the usage information.
3232

3333
export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD}/..}"
34-
export __usage="${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh-usage"
3534
if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then
3635
echo "Please run this script inside the OpenCoarrays source \"prerequisites\" subdirectory"
3736
echo "or set OPENCOARRAYS_SRC_DIR to the top-level OpenCoarrays source directory path."
3837
exit 1
3938
fi
39+
export __usage="${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh-usage"
4040
export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}"
4141
if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
4242
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
@@ -64,7 +64,14 @@ if [[ "${__os}" != "OSX" ]]; then
6464
emergency "To request other platforms, please submit an issue at http://github.com/sourceryinstitute/opencoarrays/issues"
6565
fi
6666

67-
default_ofp_downloader=wget
67+
if [[ $(uname) == "Darwin" ]]; then
68+
default_ofp_downloader=curl
69+
args="-LO"
70+
else
71+
default_ofp_downloader=wget
72+
args="--no-check-certificate"
73+
fi
74+
6875
# If -D is passed, print the download programs used for OFP and its prerequisites.
6976
# Then exit with normal status.
7077
# shellcheck disable=SC2154
@@ -76,13 +83,12 @@ fi
7683

7784
# If -P is passed, print the default installation paths for OFP and its prerequisites.
7885
# Then exit with normal status.
79-
default_ofp_install_path="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations"
80-
install_path="${arg_i:-"${default_ofp_install_path}"}"
81-
strategoxt_superbundle_install_path="/opt"
86+
install_path="${arg_i}"
87+
strategoxt_superbundle_install_path=`${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh -P strategoxt-superbundle`
8288
# shellcheck disable=SC2154
8389
if [[ "${arg_P}" == "${__flag_present}" ]]; then
8490
echo "strategoxt-superbundle default installation path: ${strategoxt_superbundle_install_path}"
85-
echo "ofp default installation path: ${default_ofp_install_path}"
91+
echo "ofp default installation path: ${install_path}"
8692
exit 0
8793
fi
8894

@@ -98,11 +104,12 @@ fi
98104

99105
# If -U is passed, print the URLs for OFP and its prerequisites.
100106
# Then exit with normal status.
101-
ofp_URL="https://github.com/sourceryinstitute/opencoarrays/files/213108/ofp-sdf.tar.gz"
107+
ofp_url_head="https://github.com/sourceryinstitute/opencoarrays/files/213108/"
108+
ofp_url_tail="ofp-sdf.tar.gz"
102109
# shellcheck disable=SC2154
103110
if [[ "${arg_U}" == "${__flag_present}" ]]; then
104111
echo "strategoxt-superbundle URL: $("${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh" -U strategoxt-superbundle)"
105-
echo "ofp URL: ${ofp_URL}"
112+
echo "ofp URL: ${ofp_url_head}${ofp_url_tail}"
106113
exit 0
107114
fi
108115

@@ -147,11 +154,16 @@ if [[ ! -d "${install_path}" ]]; then
147154
set_SUDO_if_needed_to_write_to_directory "${install_path}"
148155
${SUDO:-} mkdir -p "${install_path}"
149156
fi
157+
150158
# Install OFP prerequisites to /opt (currently the only option)
151159
"${opencoarrays_prerequisites_dir}"/install-binary.sh -p strategoxt-superbundle -i "${strategoxt_superbundle_install_path}"
160+
152161
# Downlaod OFP
153162
pushd "${install_path}"
154-
${default_ofp_downloader} "${ofp_URL}"
163+
info "OFP Download command: ${default_ofp_downloader} ${args:-} \"${ofp_url_head}${ofp_url_tail}\""
164+
${default_ofp_downloader} ${args:-} "${ofp_url_head}${ofp_url_tail}"
165+
166+
155167
# Uncompress OFP
156168
tar xf ofp-sdf.tar.gz
157169
# Return to the original working directory

0 commit comments

Comments
 (0)