Skip to content

Commit fd83657

Browse files
author
Damian Rouson
committed
Port previous commit to macOS
1 parent 0ee3c9f commit fd83657

File tree

1 file changed

+18
-45
lines changed

1 file changed

+18
-45
lines changed

prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,20 @@ replace_wget()
1111
backup_extension=""
1212
fi
1313

14-
# Modify download_prerequisites if wget is unavailable
15-
if type wget &> /dev/null; then
16-
info "wget available. Leaving wget invocations unmodified in the GCC script contrib/download_prerequisites."
17-
else
18-
info "wget unavailable. Editing GCC contrib/download_prerequisites to replace it with ${gcc_prereqs_fetch}"
19-
20-
if [[ -z "${wget_line:-}" ]]; then
21-
22-
# Check whether a backup file already exists
23-
if [[ ! -f "${backup_file}" ]]; then
24-
emergency "replace_wget: gcc contrib/download_prerequisites does not use wget"
25-
fi
26-
27-
else # Download_prerequisites contains wget so we haven't modified it
28-
29-
case "${gcc_prereqs_fetch}" in
30-
"ftp_url")
31-
# Insert a new line after line 2 to include ftp_url.sh as a download option
32-
sed -i${backup_extension} -e '2 a\'$'\n'". ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"$'\n' "${download_prereqs_file}"
33-
wget_command='wget --no-verbose -O "${directory}\/${ar}"'
34-
;;
35-
"curl")
36-
wget_command="${wget_line%%\"\$\{directory\}*}" # grab everything before "${base_url}
37-
wget_command="wget${wget_command#*wget}" # keep everything from wget forward
38-
;;
39-
*)
40-
emergency "Unknown download program ${gcc_prereqs_fetch} in edit_GCC_download_prereqs_file_if_necessary.sh"
41-
;;
42-
esac
43-
44-
arg_string="${gcc_prereqs_fetch_args[@]:-} "
45-
46-
info "Using the following command to replace wget in the GCC download_prerequisites file:"
47-
info "sed -i${backup_extension} s/\"${wget_command}\"/\"${gcc_prereqs_fetch} ${arg_string} \"/ \"${download_prereqs_file}\""
48-
if [[ "${__operating_system}" == "Linux" ]]; then
49-
sed -i"${backup_extension}" s/"${wget_command}"/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
50-
else
51-
sed -i "${backup_extension}" s/"${wget_command}"/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
52-
fi
14+
if [[ "${gcc_prereqs_fetch}" == "ftp_url" ]]; then
15+
# Insert a new line after line 2 to include ftp_url.sh as a download option
16+
sed -i${backup_extension} -e '2 a\'$'\n'". ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"$'\n' "${download_prereqs_file}"
17+
fi
5318

54-
fi # end if [[ -z "${wget_line:-}" ]]; then
55-
56-
fi # end if ! type wget &> /dev/null;
19+
arg_string="${gcc_prereqs_fetch_args[@]:-} "
5720

21+
info "Using the following command to replace wget in the GCC download_prerequisites file:"
22+
info "sed -i${backup_extension} s/\"${wget_command}\"/\"${gcc_prereqs_fetch} ${arg_string} \"/ \"${download_prereqs_file}\""
23+
if [[ "${__operating_system}" == "Linux" ]]; then
24+
sed -i"${backup_extension}" s/wget/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
25+
else
26+
sed -i "${backup_extension}" s/wget/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
27+
fi
5828
}
5929

6030
edit_GCC_download_prereqs_file_if_necessary()
@@ -64,10 +34,13 @@ edit_GCC_download_prereqs_file_if_necessary()
6434

6535
# Grab the line with the first occurence of 'wget'
6636
wget_line=`grep wget "${download_prereqs_file}" | head -1` || true
37+
wget_command="${wget_line%%ftp*}" # grab everything before ftp
6738

6839
# Check for wget format used before GCC 7
69-
if [[ "${wget_line}" == *"ftp"* ]]; then
70-
replace_wget
40+
if [[ ! -z "${wget_command}" ]]; then
41+
# Check whether wget is available on this system
42+
if ! type wget &> /dev/null; then
43+
replace_wget
44+
fi
7145
fi
72-
7346
}

0 commit comments

Comments
 (0)