|
1 | 1 | # Make the build directory, configure, and build |
2 | 2 | # shellcheck disable=SC2154 |
3 | 3 |
|
4 | | -edit_GCC_download_prereqs_file_if_necessary() |
5 | | -{ |
6 | | - # 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 |
10 | | - info "wget unavailable. Editing GCC contrib/download_prerequisites to replace it with ${gcc_prereqs_fetch}" |
11 | | - |
12 | | - download_prereqs_file="${PWD}/contrib/download_prerequisites" |
13 | | - |
14 | | - # Define a file extension for the download_prerequisites backup |
15 | | - backup_extension=".original" |
16 | | - 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 |
21 | | - if [[ -f ${backup_file} ]]; then |
22 | | - # Prevent overwriting an existing backup: |
23 | | - backup_extension="" |
24 | | - fi |
25 | | - |
26 | | - # Grab the line with the first occurence of 'wget' |
27 | | - wget_line=`grep wget "${download_prereqs_file}" | head -1` || true |
28 | | - if [[ ! -z "${wget_line:-}" ]]; then |
29 | | - # Download_prerequisites contains wget so we haven't modified it |
30 | | - already_modified_downloader="false" |
31 | | - else |
32 | | - # Check whether a backup file already exists |
33 | | - if [[ ! -f "${backup_file}" ]]; then |
34 | | - emergency ": gcc contrib/download_prerequisites does not use wget" |
35 | | - else |
36 | | - already_modified_downloader="true" |
37 | | - fi |
38 | | - fi |
39 | | - |
40 | | - # Only modify download_prerequisites once |
41 | | - if [[ ${already_modified_downloader} != "true" ]]; then |
42 | | - |
43 | | - # Check for wget format used before GCC 7 |
44 | | - if [[ "${wget_line}" == *"ftp"* ]]; then |
45 | | - gcc7_format="false" |
46 | | - wget_command="${wget_line%%ftp*}" # grab everything before "ftp" |
47 | | - |
48 | | - # Check for wget format adopted in GCC 7 |
49 | | - elif [[ "${wget_line}" == *"base_url"* ]]; then |
50 | | - 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 |
59 | | - |
60 | | - else |
61 | | - emergency "gcc contrib/download_prerequisites does not use a known URL format" |
62 | | - fi |
63 | | - info "GCC contrib/download_prerequisites wget command is ${wget_command}" |
64 | | - |
65 | | - arg_string="${gcc_prereqs_fetch_args[@]:-} " |
66 | | - |
67 | | - if [[ ${gcc7_format} == "true" ]]; then |
68 | | - case "${gcc_prereqs_fetch}" in |
69 | | - "curl") |
70 | | - arg_string="${arg_string} -o " |
71 | | - ;; |
72 | | - *) |
73 | | - debug "if problem downloading, ensure that the gcc download_prerequisites edits are compatible with ${gcc_prereqs_fetch}" |
74 | | - ;; |
75 | | - esac |
76 | | - # Protect against missing sha512sum command adopted in GCC 7 (not available by on a default on all Linux platforms) |
77 | | - if ! type sha512sum &> /dev/null; then |
78 | | - 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 | | - fi |
81 | | - fi |
82 | | - |
83 | | - info "Using the following command to replacing wget in the GCC download_prerequisites file:" |
84 | | - 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}" |
86 | | - |
87 | | - fi # end if [[ ${already_modified_downloader:-} != "true" ]]; |
88 | | - fi # end if ! type wget &> /dev/null; |
89 | | -} |
| 4 | +source ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh |
90 | 5 |
|
91 | 6 | build_and_install() |
92 | 7 | { |
|
0 commit comments