Skip to content

Commit a21c54f

Browse files
author
Damian Rouson
committed
Patch GCC's contrib/download_prerequisites script
GCC's script is hardwired to use wget for downloading prerequisites. This commit modifies GCC's script to use whichever download mechanism the OpenCoarrays build system's prefers for the given platform: curl, wget, or ftp.
1 parent f6a091c commit a21c54f

File tree

6 files changed

+62
-43
lines changed

6 files changed

+62
-43
lines changed

prerequisites/build-functions/build_and_install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ build_and_install()
1717
if [[ "${package_to_build}" == "gcc" ]]; then
1818
info "pushd ${download_path}/${package_source_directory} "
1919
pushd "${download_path}/${package_source_directory}"
20+
arg_string="${args[@]:-}"
21+
if [[ "$(uname)" == "Linux" ]]; then
22+
sed -i'' "s/wget/${fetch} ${arg_string}/g" "${PWD}/contrib/download_prerequisites"
23+
else
24+
# This works on OS X and other POSIX-compliant operating systems:
25+
sed -i '' "s/wget/${fetch} ${arg_string}/g" "${PWD}/contrib/download_prerequisites"
26+
fi
2027
"${PWD}"/contrib/download_prerequisites
2128
info "popd"
2229
popd

prerequisites/build-functions/download_if_necessary.sh

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

prerequisites/build-functions/ftp-url.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
# Download a file from an anonymous ftp site
22
#
33
# Usage:
4-
# ftp-url <ftp-mode> <ftp-site-address>:/<path-to-file>/<file-name>
4+
# ftp-url <ftp-mode> ftp://<fully-qualified-domain>:/<path-to-file>/<file-name>
55
#
66
# Example:
7-
# ftp-url -n ftp.gnu.org:/gnu/m4/m4-1.4.17.tar.bz2
7+
# ftp-url -n ftp://ftp.gnu.org:/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2
88
ftp-url()
99
{
1010
ftp_mode="${1}"
1111
url="${2}"
1212

13-
text_before_colon="${url%%:*}"
14-
FTP_SERVER="${text_before_colon}"
13+
if [[ "${ftp_mode}" != "-n" ]]; then
14+
emergency "Unexpected ftp mode received by ftp-url.sh: ${ftp_mode}"
15+
fi
1516

16-
text_after_colon="${url##*:}"
17-
text_after_final_slash="${text_after_colon##*/}"
18-
FILE_NAME="${text_after_final_slash}"
17+
protocol="${url%%:*}" # grab text_before_first_colon
18+
if [[ "${protocol}" != "ftp" ]]; then
19+
emergency "URL with unexpected protocol received by ftp-url.sh: ${text_before_first_colon}"
20+
fi
1921

20-
text_before_final_slash="${text_after_colon%/*}"
21-
FILE_PATH="${text_before_final_slash}"
22+
text_after_double_slash="${url##*//}"
23+
FTP_SERVER="${text_after_double_slash%:*}" # grab remaining text before colon
24+
25+
text_after_final_colon="${url##*:}"
26+
FILE_NAME="${url##*/}" # grab text after final slash
27+
FILE_PATH="${text_after_final_colon%/*}" # grab remaining text before final slash
2228

2329
USERNAME=anonymous
2430
PASSWORD=""
25-
info "starting anonymous download: ftp ${ftp_mode} ${FTP_SERVER}... cd ${FILE_PATH}... get ${FILE_NAME}"
31+
info "starting anonymous download: ${protocol} ${ftp_mode} ${FTP_SERVER}... cd ${FILE_PATH}... get ${FILE_NAME}"
2632

2733
ftp "${ftp_mode}" "${FTP_SERVER}" <<Done-ftp
2834
user "${USERNAME}" "${PASSWORD}"

prerequisites/build-functions/set_or_print_url.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ set_or_print_url()
1414
major_minor="${version_to_build%.*}"
1515
elif [[ "${package_to_build}" == "gcc" ]]; then
1616
if [[ -z "${arg_b:-${arg_B}}" ]]; then
17-
gcc_url_head="ftp.gnu.org:/gnu/gcc/gcc-${version_to_build}/"
17+
gcc_url_head="ftp://ftp.gnu.org:/gnu/gcc/gcc-${version_to_build}/"
1818
else
1919
gcc_url_head="svn://gcc.gnu.org/svn/gcc/"
2020
fi
2121
fi
2222
package_url_head=(
2323
"gcc;${gcc_url_head-}"
24-
"wget;ftp.gnu.org:/gnu/wget/"
25-
"m4;ftp.gnu.org:/gnu/m4/"
24+
"wget;ftp://ftp.gnu.org:/gnu/wget/"
25+
"m4;ftp://ftp.gnu.org:/gnu/m4/"
2626
"pkg-config;http://pkgconfig.freedesktop.org/releases/"
2727
"mpich;http://www.mpich.org/static/downloads/${version_to_build-}/"
2828
"flex;http://sourceforge.net/projects/flex/files/"
2929
"make;ftp://ftp.gnu.org/gnu/make/"
30-
"bison;ftp.gnu.org:/gnu/bison/"
30+
"bison;ftp://ftp.gnu.org:/gnu/bison/"
3131
"cmake;http://www.cmake.org/files/v${major_minor-}/"
3232
"subversion;http://www.eu.apache.org/dist/subversion/"
3333
)

prerequisites/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ if [[ -z "${arg_B}" ]]; then
149149
# shellcheck source=./build-functions/set_compilers.sh
150150
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_compilers.sh"
151151
set_compilers
152-
152+
153153
# shellcheck source=./build-functions/build_and_install.sh
154154
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/build_and_install.sh"
155155
build_and_install

prerequisites/install-functions/find_or_install.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,13 @@ find_or_install()
578578
default_package_version=$(./build.sh -V "${package}")
579579
package_install_prefix="${package_install_path%${package}/${arg_I:-${default_package_version}}*}"
580580

581+
if [[ "${arg_y}" == "${__flag_present}" ]]; then
582+
yes_to_all="-y"
583+
fi
584+
581585
echo -e "$this_script: Downloading, building, and installing $package \n"
582-
echo "$this_script: Build command: FC=$FC CC=$CC CXX=$CXX ./build.sh -p $package -i $package_install_prefix -j $num_threads"
583-
FC="$FC" CC="$CC" CXX="$CXX" ./build.sh -p "$package" -i "$package_install_prefix" -j "$num_threads"
586+
echo "$this_script: Build command: FC=$FC CC=$CC CXX=$CXX ./build.sh -p $package -i $package_install_prefix -j $num_threads ${yes_to_all:-}"
587+
FC="$FC" CC="$CC" CXX="$CXX" ./build.sh -p "$package" -i "$package_install_prefix" -j "$num_threads" "${yes_to_all:-}"
584588

585589
if [[ -x "$package_install_path/bin/$executable" ]]; then
586590
echo -e "$this_script: Installation successful.\n"

0 commit comments

Comments
 (0)