Skip to content

Commit 0ee3c9f

Browse files
author
Damian Rouson
committed
No longer edit download_prerequisites for GCC 7
GCC revision r246845 eliminates the need to patch the above file
1 parent 3de11c3 commit 0ee3c9f

File tree

1 file changed

+34
-84
lines changed

1 file changed

+34
-84
lines changed
Lines changed: 34 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11

22
# shellcheck disable=SC2154
33

4-
edit_GCC_download_prereqs_file_if_necessary()
4+
replace_wget()
55
{
6-
__operating_system=$(uname)
7-
download_prereqs_file="${PWD}/contrib/download_prerequisites"
8-
9-
# Grab the line with the first occurence of 'wget'
10-
wget_line=`grep wget "${download_prereqs_file}" | head -1` || true
11-
12-
# Check for wget format used before GCC 7
13-
if [[ "${wget_line}" == *"ftp"* ]]; then
14-
gcc7_format="false"
15-
wget_command="${wget_line%%ftp*}" # grab everything before ftp
16-
17-
# Check for wget format adopted in GCC 7
18-
elif [[ "${wget_line}" == *"base_url"* ]]; then
19-
gcc7_format="true"
20-
fi
21-
226
# Define a file extension for the download_prerequisites backup
237
backup_extension=".original"
248
backup_file="${download_prereqs_file}${backup_extension}"
@@ -29,58 +13,36 @@ edit_GCC_download_prereqs_file_if_necessary()
2913

3014
# Modify download_prerequisites if wget is unavailable
3115
if type wget &> /dev/null; then
32-
info "wget available. Leavingh wget invocations unmodified in the GCC script contrib/download_prerequisites."
16+
info "wget available. Leaving wget invocations unmodified in the GCC script contrib/download_prerequisites."
3317
else
3418
info "wget unavailable. Editing GCC contrib/download_prerequisites to replace it with ${gcc_prereqs_fetch}"
3519

36-
if [[ ! -z "${wget_line:-}" ]]; then
37-
# Download_prerequisites contains wget so we haven't modified it
38-
already_modified_downloader="false"
39-
else
20+
if [[ -z "${wget_line:-}" ]]; then
21+
4022
# Check whether a backup file already exists
4123
if [[ ! -f "${backup_file}" ]]; then
42-
emergency ": gcc contrib/download_prerequisites does not use wget"
43-
else
44-
already_modified_downloader="true"
24+
emergency "replace_wget: gcc contrib/download_prerequisites does not use wget"
4525
fi
46-
fi
47-
48-
# Only modify download_prerequisites once
49-
if [[ ${already_modified_downloader} != "true" ]]; then
50-
51-
if [[ "${gcc7_format}" == "true" ]]; then
5226

53-
case "${gcc_prereqs_fetch}" in
54-
"ftp_url")
55-
# Insert a new line after line 2 to include ftp_url.sh as a download option
56-
sed -i${backup_extension} -e '2 a\'$'\n'". ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"$'\n' "${download_prereqs_file}"
57-
wget_command='wget --no-verbose -O "${directory}\/${ar}"'
58-
;;
59-
"curl")
60-
wget_command="${wget_line%%\"\$\{directory\}*}" # grab everything before "${base_url}
61-
wget_command="wget${wget_command#*wget}" # keep everything from wget forward
62-
;;
63-
*)
64-
emergency "Unknown download program ${gcc_prereqs_fetch} in edit_GCC_download_prereqs_file_if_necessary.sh"
65-
;;
66-
esac
67-
68-
else
69-
emergency "gcc contrib/download_prerequisites does not use a known URL format"
70-
fi
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
7143

7244
arg_string="${gcc_prereqs_fetch_args[@]:-} "
7345

74-
if [[ ${gcc7_format} == "true" ]]; then
75-
case "${gcc_prereqs_fetch}" in
76-
"curl")
77-
arg_string="${arg_string} -o "
78-
;;
79-
*)
80-
debug "if problem downloading, ensure that the gcc download_prerequisites edits are compatible with ${gcc_prereqs_fetch}"
81-
;;
82-
esac
83-
fi
8446
info "Using the following command to replace wget in the GCC download_prerequisites file:"
8547
info "sed -i${backup_extension} s/\"${wget_command}\"/\"${gcc_prereqs_fetch} ${arg_string} \"/ \"${download_prereqs_file}\""
8648
if [[ "${__operating_system}" == "Linux" ]]; then
@@ -89,35 +51,23 @@ edit_GCC_download_prereqs_file_if_necessary()
8951
sed -i "${backup_extension}" s/"${wget_command}"/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
9052
fi
9153

92-
fi # end if [[ ${already_modified_downloader:-} != "true" ]];
54+
fi # end if [[ -z "${wget_line:-}" ]]; then
55+
9356
fi # end if ! type wget &> /dev/null;
9457

95-
if [[ "${gcc7_format:-}" == "true" ]]; then
96-
97-
# Protect against missing sha512sum command adopted in GCC 7 but unavailable on
98-
# 1. Some Linux distributions (e.g., older Lubuntu distributions)
99-
# 2. macOS, where the replacement is "shasum -a 512"
100-
101-
if ! type sha512sum &> /dev/null; then
58+
}
10259

103-
info "sha512sum unavailable."
104-
case "${__operating_system}" in
105-
"Darwin" )
106-
info "Substituting shasum -a 512"
107-
sed -i "${backup_extension}" s/"\"\${chksum}sum\" --check"/"shasum -a 512 --check"/ "${download_prereqs_file}"
108-
;;
109-
"Linux" )
110-
info "Turning off file integrity verification in GCC contrib/download_prerequisites."
111-
sed -i"${backup_extension}" s/"verify=1"/"verify=0"/ "${download_prereqs_file}"
112-
;;
113-
*)
114-
warning "Unrecognized operating system. Attempting to modify download_prerequisites with a 'sed' command synatax that assumes POSIX compliance."
115-
info "Turning off file integrity verification in GCC contrib/download_prerequisites."
116-
sed -i "${backup_extension}" s/"verify=1"/"verify=0"/ "${download_prereqs_file}"
117-
;;
118-
esac
60+
edit_GCC_download_prereqs_file_if_necessary()
61+
{
62+
__operating_system=$(uname)
63+
download_prereqs_file="${PWD}/contrib/download_prerequisites"
11964

120-
fi
65+
# Grab the line with the first occurence of 'wget'
66+
wget_line=`grep wget "${download_prereqs_file}" | head -1` || true
12167

68+
# Check for wget format used before GCC 7
69+
if [[ "${wget_line}" == *"ftp"* ]]; then
70+
replace_wget
12271
fi
72+
12373
}

0 commit comments

Comments
 (0)