Skip to content

Commit 0cad4cb

Browse files
author
Damian Rouson
committed
adjust edit_GCC... script for use of curl on macOS
1 parent 789be37 commit 0cad4cb

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@
44
edit_GCC_download_prereqs_file_if_necessary()
55
{
66
# Only modify download_prerequisites if wget is unavailable
7-
if type wget &> /dev/null; then
8-
info "wget available. Invoking unmodified GCC script contrib/download_prerequisites."
9-
else
7+
if type wget &> /dev/null; then
8+
info "wget available. Invoking unmodified GCC script contrib/download_prerequisites."
9+
else
1010
info "wget unavailable. Editing GCC contrib/download_prerequisites to replace it with ${gcc_prereqs_fetch}"
1111

1212
download_prereqs_file="${PWD}/contrib/download_prerequisites"
1313

1414
# Define a file extension for the download_prerequisites backup
1515
backup_extension=".original"
1616
backup_file="${download_prereqs_file}${backup_extension}"
17-
if [[ "$(uname)" != "Linux" ]]; then
18-
# Adjust for POSIX OS (e.g., OSX/macOS):
19-
backup_extension=" ${backup_extension}"
20-
fi
2117
if [[ -f ${backup_file} ]]; then
2218
# Prevent overwriting an existing backup:
2319
backup_extension=""
@@ -43,24 +39,29 @@ edit_GCC_download_prereqs_file_if_necessary()
4339
# Check for wget format used before GCC 7
4440
if [[ "${wget_line}" == *"ftp"* ]]; then
4541
gcc7_format="false"
46-
wget_command="${wget_line%%ftp*}" # grab everything before "ftp"
42+
wget_command="${wget_line%%ftp*}" # grab everything before ftp
4743

4844
# Check for wget format adopted in GCC 7
4945
elif [[ "${wget_line}" == *"base_url"* ]]; then
5046
gcc7_format="true"
51-
if [[ "${gcc_prereqs_fetch}" == "ftp_url" ]]; then
52-
# Insert a new line after line 2 to include ftp_url.sh as a download option
53-
sed -i${backup_extension} -e '2 a\'$'\n'". ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"$'\n' "${download_prereqs_file}"
54-
wget_command='wget --no-verbose -O "${directory}\/${ar}"'
55-
else
56-
wget_command="${wget_line%%\"\$\{base_url\}*}" # grab everything before "${base_url}
57-
wget_command="wget${wget_command#*wget}" # keep everything from wget forward
58-
fi
47+
case "${gcc_prereqs_fetch}" in
48+
"ftp_url")
49+
# Insert a new line after line 2 to include ftp_url.sh as a download option
50+
sed -i${backup_extension} -e '2 a\'$'\n'". ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"$'\n' "${download_prereqs_file}"
51+
wget_command='wget --no-verbose -O "${directory}\/${ar}"'
52+
;;
53+
"curl")
54+
wget_command="${wget_line%%\"\$\{directory\}*}" # grab everything before "${base_url}
55+
wget_command="wget${wget_command#*wget}" # keep everything from wget forward
56+
;;
57+
*)
58+
emergency "Unknown download program ${gcc_prereqs_fetch} in edit_GCC_download_prereqs_file_if_necessary.sh"
59+
;;
60+
esac
5961

6062
else
6163
emergency "gcc contrib/download_prerequisites does not use a known URL format"
6264
fi
63-
info "GCC contrib/download_prerequisites wget command is ${wget_command}"
6465

6566
arg_string="${gcc_prereqs_fetch_args[@]:-} "
6667

@@ -73,17 +74,25 @@ edit_GCC_download_prereqs_file_if_necessary()
7374
debug "if problem downloading, ensure that the gcc download_prerequisites edits are compatible with ${gcc_prereqs_fetch}"
7475
;;
7576
esac
76-
# Protect against missing sha512sum command adopted in GCC 7 (not available by on a default on all Linux platforms)
77+
# Protect against missing sha512sum command adopted in GCC 7 (not available by default on Lubuntu Linux)
7778
if ! type sha512sum &> /dev/null; then
7879
info "sha512sum unavailable. Turning off file integrity verification in GCC contrib/download_prerequisites."
79-
sed -i${backup_extension} s/"verify=1"/"verify=0"/ "${download_prereqs_file}"
80+
if [[ "$(uname)" == "Linux" ]]; then
81+
# Adjust for non-POSIX OS
82+
sed -i"${backup_extension}" s/"verify=1"/"verify=0"/ "${download_prereqs_file}"
83+
else
84+
sed -i "${backup_extension}" s/"verify=1"/"verify=0"/ "${download_prereqs_file}"
85+
fi
8086
fi
8187
fi
82-
8388
info "Using the following command to replacing wget in the GCC download_prerequisites file:"
8489
info "sed -i${backup_extension} s/\"${wget_command}\"/\"${gcc_prereqs_fetch} ${arg_string} \"/ \"${download_prereqs_file}\""
85-
sed -i${backup_extension} s/"${wget_command}"/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
90+
if [[ "$(uname)" == "Linux" ]]; then
91+
sed -i"${backup_extension}" s/"${wget_command}"/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
92+
else
93+
sed -i "${backup_extension}" s/"${wget_command}"/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
94+
fi
8695

8796
fi # end if [[ ${already_modified_downloader:-} != "true" ]];
88-
fi # end if ! type wget &> /dev/null;
97+
fi # end if ! type wget &> /dev/null;
8998
}

0 commit comments

Comments
 (0)