@@ -11,50 +11,20 @@ replace_wget()
11
11
backup_extension=" "
12
12
fi
13
13
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
53
18
54
- fi # end if [[ -z "${wget_line:-}" ]]; then
55
-
56
- fi # end if ! type wget &> /dev/null;
19
+ arg_string=" ${gcc_prereqs_fetch_args[@]:- } "
57
20
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
58
28
}
59
29
60
30
edit_GCC_download_prereqs_file_if_necessary ()
@@ -64,10 +34,13 @@ edit_GCC_download_prereqs_file_if_necessary()
64
34
65
35
# Grab the line with the first occurence of 'wget'
66
36
wget_line=` grep wget " ${download_prereqs_file} " | head -1` || true
37
+ wget_command=" ${wget_line%% ftp* } " # grab everything before ftp
67
38
68
39
# 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
71
45
fi
72
-
73
46
}
0 commit comments