1
1
2
2
# shellcheck disable=SC2154
3
3
4
- edit_GCC_download_prereqs_file_if_necessary ()
4
+ replace_wget ()
5
5
{
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
-
22
6
# Define a file extension for the download_prerequisites backup
23
7
backup_extension=" .original"
24
8
backup_file=" ${download_prereqs_file}${backup_extension} "
@@ -29,58 +13,36 @@ edit_GCC_download_prereqs_file_if_necessary()
29
13
30
14
# Modify download_prerequisites if wget is unavailable
31
15
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."
33
17
else
34
18
info " wget unavailable. Editing GCC contrib/download_prerequisites to replace it with ${gcc_prereqs_fetch} "
35
19
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
+
40
22
# Check whether a backup file already exists
41
23
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"
45
25
fi
46
- fi
47
-
48
- # Only modify download_prerequisites once
49
- if [[ ${already_modified_downloader} != " true" ]]; then
50
-
51
- if [[ " ${gcc7_format} " == " true" ]]; then
52
26
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
71
43
72
44
arg_string=" ${gcc_prereqs_fetch_args[@]:- } "
73
45
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
84
46
info " Using the following command to replace wget in the GCC download_prerequisites file:"
85
47
info " sed -i${backup_extension} s/\" ${wget_command} \" /\" ${gcc_prereqs_fetch} ${arg_string} \" / \" ${download_prereqs_file} \" "
86
48
if [[ " ${__operating_system} " == " Linux" ]]; then
@@ -89,35 +51,23 @@ edit_GCC_download_prereqs_file_if_necessary()
89
51
sed -i " ${backup_extension} " s/" ${wget_command} " /" ${gcc_prereqs_fetch} ${arg_string} " / " ${download_prereqs_file} "
90
52
fi
91
53
92
- fi # end if [[ ${already_modified_downloader:-} != "true" ]];
54
+ fi # end if [[ -z "${wget_line:-}" ]]; then
55
+
93
56
fi # end if ! type wget &> /dev/null;
94
57
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
+ }
102
59
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"
119
64
120
- fi
65
+ # Grab the line with the first occurence of 'wget'
66
+ wget_line=` grep wget " ${download_prereqs_file} " | head -1` || true
121
67
68
+ # Check for wget format used before GCC 7
69
+ if [[ " ${wget_line} " == * " ftp" * ]]; then
70
+ replace_wget
122
71
fi
72
+
123
73
}
0 commit comments