| @@ -1,349 +1,350 @@ | | | @@ -1,349 +1,350 @@ |
1 | # $NetBSD: fetch.mk,v 1.68 2016/01/06 07:38:25 dholland Exp $ | | 1 | # $NetBSD: fetch.mk,v 1.69 2017/08/01 13:15:32 jperkin Exp $ |
2 | | | 2 | |
3 | .if empty(INTERACTIVE_STAGE:Mfetch) && empty(FETCH_MESSAGE:U) | | 3 | .if empty(INTERACTIVE_STAGE:Mfetch) && empty(FETCH_MESSAGE:U) |
4 | _MASTER_SITE_BACKUP= ${MASTER_SITE_BACKUP:=${DIST_SUBDIR}${DIST_SUBDIR:D/}} | | 4 | _MASTER_SITE_BACKUP= ${MASTER_SITE_BACKUP:=${DIST_SUBDIR}${DIST_SUBDIR:D/}} |
5 | .endif | | 5 | .endif |
6 | _MASTER_SITE_OVERRIDE= ${MASTER_SITE_OVERRIDE:=${DIST_SUBDIR}${DIST_SUBDIR:D/}} | | 6 | _MASTER_SITE_OVERRIDE= ${MASTER_SITE_OVERRIDE:=${DIST_SUBDIR}${DIST_SUBDIR:D/}} |
7 | | | 7 | |
8 | # Where to put distfiles that don't have any other master site | | 8 | # Where to put distfiles that don't have any other master site |
9 | MASTER_SITE_LOCAL?= ${MASTER_SITE_BACKUP:=LOCAL_PORTS/} | | 9 | MASTER_SITE_LOCAL?= ${MASTER_SITE_BACKUP:=LOCAL_PORTS/} |
10 | | | 10 | |
11 | # Set up _ORDERED_SITES to work out the exact list of sites for every file, | | 11 | # Set up _ORDERED_SITES to work out the exact list of sites for every file, |
12 | # using the dynamic sites script, or ordering according to the master site | | 12 | # using the dynamic sites script, or ordering according to the master site |
13 | # list, MASTER_SORT_RANDOM randomization feature, or the patterns in | | 13 | # list, MASTER_SORT_RANDOM randomization feature, or the patterns in |
14 | # MASTER_SORT or MASTER_SORT_REGEX as appropriate. | | 14 | # MASTER_SORT or MASTER_SORT_REGEX as appropriate. |
15 | # No actual sorting is done until _ORDERED_SITES is expanded. | | 15 | # No actual sorting is done until _ORDERED_SITES is expanded. |
16 | # | | 16 | # |
17 | .if defined(MASTER_SORT_RANDOM) && !empty(MASTER_SORT_RANDOM:M[yY][eE][sS]) | | 17 | .if defined(MASTER_SORT_RANDOM) && !empty(MASTER_SORT_RANDOM:M[yY][eE][sS]) |
18 | _MASTER_RAND_AWK= BEGIN { srand(seed); ORS = " " } { \ | | 18 | _MASTER_RAND_AWK= BEGIN { srand(seed); ORS = " " } { \ |
19 | n = split($$0, site); \ | | 19 | n = split($$0, site); \ |
20 | for (i = n; i > 0; i--) { \ | | 20 | for (i = n; i > 0; i--) { \ |
21 | ir = int(rand() * i + 1); \ | | 21 | ir = int(rand() * i + 1); \ |
22 | t = site[i]; site[i] = site[ir]; site[ir] = t; \ | | 22 | t = site[i]; site[i] = site[ir]; site[ir] = t; \ |
23 | print site[i]; } } | | 23 | print site[i]; } } |
24 | _RAND_SITES_CMD= | ${AWK} -v seed=$$$$ '${_MASTER_RAND_AWK}' | | 24 | _RAND_SITES_CMD= | ${AWK} -v seed=$$$$ '${_MASTER_RAND_AWK}' |
25 | .endif | | 25 | .endif |
26 | | | 26 | |
27 | .if defined(MASTER_SORT) || defined(MASTER_SORT_REGEX) | | 27 | .if defined(MASTER_SORT) || defined(MASTER_SORT_REGEX) |
28 | MASTER_SORT?= | | 28 | MASTER_SORT?= |
29 | MASTER_SORT_REGEX?= | | 29 | MASTER_SORT_REGEX?= |
30 | MASTER_SORT_REGEX+= ${MASTER_SORT:S/./\\./g:C/.*/:\/\/[^\/]*&\//} | | 30 | MASTER_SORT_REGEX+= ${MASTER_SORT:S/./\\./g:C/.*/:\/\/[^\/]*&\//} |
31 | | | 31 | |
32 | _MASTER_SORT_AWK= BEGIN { RS = " "; ORS = " "; IGNORECASE = 1 ; gl = "${MASTER_SORT_REGEX:S/\\/\\\\/g}"; } | | 32 | _MASTER_SORT_AWK= BEGIN { RS = " "; ORS = " "; IGNORECASE = 1 ; gl = "${MASTER_SORT_REGEX:S/\\/\\\\/g}"; } |
33 | . for srt in ${MASTER_SORT_REGEX} | | 33 | . for srt in ${MASTER_SORT_REGEX} |
34 | _MASTER_SORT_AWK+= /${srt:C/\//\\\//g}/ { good["${srt:S/\\/\\\\/g}"] = good["${srt:S/\\/\\\\/g}"] " " $$0 ; next; } | | 34 | _MASTER_SORT_AWK+= /${srt:C/\//\\\//g}/ { good["${srt:S/\\/\\\\/g}"] = good["${srt:S/\\/\\\\/g}"] " " $$0 ; next; } |
35 | . endfor | | 35 | . endfor |
36 | _MASTER_SORT_AWK+= { rest = rest " " $$0; } END { n=split(gl, gla); for(i=1;i<=n;i++) { print good[gla[i]]; } print rest; } | | 36 | _MASTER_SORT_AWK+= { rest = rest " " $$0; } END { n=split(gl, gla); for(i=1;i<=n;i++) { print good[gla[i]]; } print rest; } |
37 | _SORT_SITES_CMD= | ${AWK} '${_MASTER_SORT_AWK}' | | 37 | _SORT_SITES_CMD= | ${AWK} '${_MASTER_SORT_AWK}' |
38 | .endif | | 38 | .endif |
39 | | | 39 | |
40 | .if defined(_RAND_SITES_CMD) || defined(_SORT_SITES_CMD) | | 40 | .if defined(_RAND_SITES_CMD) || defined(_SORT_SITES_CMD) |
41 | _SORT_SITES_FULL_CMD= ${ECHO} $$unsorted_sites ${_RAND_SITES_CMD} ${_SORT_SITES_CMD} | | 41 | _SORT_SITES_FULL_CMD= ${ECHO} $$unsorted_sites ${_RAND_SITES_CMD} ${_SORT_SITES_CMD} |
42 | _ORDERED_SITES= ${_MASTER_SITE_OVERRIDE} `${_SORT_SITES_FULL_CMD:S/\\/\\\\/g:C/"/\"/g}` | | 42 | _ORDERED_SITES= ${_MASTER_SITE_OVERRIDE} `${_SORT_SITES_FULL_CMD:S/\\/\\\\/g:C/"/\"/g}` |
43 | .else | | 43 | .else |
44 | _ORDERED_SITES= ${_MASTER_SITE_OVERRIDE} $$unsorted_sites | | 44 | _ORDERED_SITES= ${_MASTER_SITE_OVERRIDE} $$unsorted_sites |
45 | .endif | | 45 | .endif |
46 | | | 46 | |
47 | # | | 47 | # |
48 | # Associate each file to fetch with the correct site(s). | | 48 | # Associate each file to fetch with the correct site(s). |
49 | # | | 49 | # |
50 | DYNAMIC_SITES_SCRIPT?= ${FILESDIR}/getsite.sh | | 50 | DYNAMIC_SITES_SCRIPT?= ${FILESDIR}/getsite.sh |
51 | DYNAMIC_SITES_CMD?= ${PKGSRC_SETENV} PATH=${PATH:Q} ${SH} ${DYNAMIC_SITES_SCRIPT} | | 51 | DYNAMIC_SITES_CMD?= ${PKGSRC_SETENV} PATH=${PATH:Q} ${SH} ${DYNAMIC_SITES_SCRIPT} |
52 | .if exists(${DYNAMIC_SITES_SCRIPT}) | | 52 | .if exists(${DYNAMIC_SITES_SCRIPT}) |
53 | . for fetchfile in ${_ALLFILES} | | 53 | . for fetchfile in ${_ALLFILES} |
54 | SITES.${fetchfile:T:S/=/--/}?= `${DYNAMIC_SITES_CMD} ${fetchfile:T}` | | 54 | SITES.${fetchfile:T:S/=/--/}?= `${DYNAMIC_SITES_CMD} ${fetchfile:T}` |
55 | . endfor | | 55 | . endfor |
56 | .endif | | 56 | .endif |
57 | .if !empty(_DISTFILES) | | 57 | .if !empty(_DISTFILES) |
58 | . for fetchfile in ${_DISTFILES} | | 58 | . for fetchfile in ${_DISTFILES} |
59 | SITES.${fetchfile:T:S/=/--/}?= ${MASTER_SITES} | | 59 | SITES.${fetchfile:T:S/=/--/}?= ${MASTER_SITES} |
60 | . endfor | | 60 | . endfor |
61 | .endif | | 61 | .endif |
62 | .if !empty(_PATCHFILES) | | 62 | .if !empty(_PATCHFILES) |
63 | . for fetchfile in ${_PATCHFILES} | | 63 | . for fetchfile in ${_PATCHFILES} |
64 | SITES.${fetchfile:T:S/=/--/}?= ${PATCH_SITES} | | 64 | SITES.${fetchfile:T:S/=/--/}?= ${PATCH_SITES} |
65 | . endfor | | 65 | . endfor |
66 | .endif | | 66 | .endif |
67 | | | 67 | |
68 | ###################################################################### | | 68 | ###################################################################### |
69 | ### fetch (PUBLIC) | | 69 | ### fetch (PUBLIC) |
70 | ###################################################################### | | 70 | ###################################################################### |
71 | ### fetch is a public target to fetch all of the package distribution | | 71 | ### fetch is a public target to fetch all of the package distribution |
72 | ### files. | | 72 | ### files. |
73 | ### | | 73 | ### |
74 | _FETCH_TARGETS+= ${_PKG_INSTALL_DEPENDS:Dpkg_install-depends} | | 74 | _FETCH_TARGETS+= ${_PKG_INSTALL_DEPENDS:Dpkg_install-depends} |
75 | _FETCH_TARGETS+= bootstrap-depends | | 75 | _FETCH_TARGETS+= bootstrap-depends |
76 | _FETCH_TARGETS+= check-vulnerable | | 76 | _FETCH_TARGETS+= check-vulnerable |
77 | _FETCH_TARGETS+= pre-fetch | | 77 | _FETCH_TARGETS+= pre-fetch |
78 | _FETCH_TARGETS+= do-fetch | | 78 | _FETCH_TARGETS+= do-fetch |
79 | _FETCH_TARGETS+= post-fetch | | 79 | _FETCH_TARGETS+= post-fetch |
80 | | | 80 | |
81 | .PHONY: fetch | | 81 | .PHONY: fetch |
82 | .if !target(fetch) | | 82 | .if !target(fetch) |
83 | fetch: ${_FETCH_TARGETS} | | 83 | fetch: ${_FETCH_TARGETS} |
84 | .endif | | 84 | .endif |
85 | | | 85 | |
86 | ###################################################################### | | 86 | ###################################################################### |
87 | ### pre-fetch, do-fetch, post-fetch (PUBLIC, override) | | 87 | ### pre-fetch, do-fetch, post-fetch (PUBLIC, override) |
88 | ###################################################################### | | 88 | ###################################################################### |
89 | ### {pre,do,post}-fetch are the heart of the package-customizable | | 89 | ### {pre,do,post}-fetch are the heart of the package-customizable |
90 | ### fetch targets, and may be overridden within a package Makefile. | | 90 | ### fetch targets, and may be overridden within a package Makefile. |
91 | ### | | 91 | ### |
92 | .PHONY: pre-fetch do-fetch post-fetch | | 92 | .PHONY: pre-fetch do-fetch post-fetch |
93 | | | 93 | |
94 | .if !target(do-fetch) | | 94 | .if !target(do-fetch) |
95 | . if !empty(_ALLFILES) | | 95 | . if !empty(_ALLFILES) |
96 | do-fetch: ${_ALLFILES:S/^/${DISTDIR}\//} | | 96 | do-fetch: ${_ALLFILES:S/^/${DISTDIR}\//} |
97 | @${DO_NADA} | | 97 | @${DO_NADA} |
98 | . else | | 98 | . else |
99 | do-fetch: | | 99 | do-fetch: |
100 | @${DO_NADA} | | 100 | @${DO_NADA} |
101 | . endif | | 101 | . endif |
102 | .endif | | 102 | .endif |
103 | | | 103 | |
104 | .if !target(pre-fetch) | | 104 | .if !target(pre-fetch) |
105 | pre-fetch: | | 105 | pre-fetch: |
106 | @${DO_NADA} | | 106 | @${DO_NADA} |
107 | .endif | | 107 | .endif |
108 | | | 108 | |
109 | .if !target(post-fetch) | | 109 | .if !target(post-fetch) |
110 | post-fetch: | | 110 | post-fetch: |
111 | @${DO_NADA} | | 111 | @${DO_NADA} |
112 | .endif | | 112 | .endif |
113 | | | 113 | |
114 | .for _file_ in ${_ALLFILES} | | 114 | .for _file_ in ${_ALLFILES} |
115 | . if empty(PKG_RESUME_TRANSFERS:M[yY][eE][sS]) && \ | | 115 | . if empty(PKG_RESUME_TRANSFERS:M[yY][eE][sS]) && \ |
116 | exists(${DISTDIR}/${_file_}) | | 116 | exists(${DISTDIR}/${_file_}) |
117 | ${DISTDIR}/${_file_}: | | 117 | ${DISTDIR}/${_file_}: |
118 | @${DO_NADA} | | 118 | @${DO_NADA} |
119 | . else | | 119 | . else |
120 | . if empty(IGNORE_INTERACTIVE_FETCH:Uno:M[yY][eE][sS]) | | 120 | . if empty(IGNORE_INTERACTIVE_FETCH:Uno:M[yY][eE][sS]) |
121 | ${DISTDIR}/${_file_}: fetch-check-interactive | | 121 | ${DISTDIR}/${_file_}: fetch-check-interactive |
122 | . endif | | 122 | . endif |
123 | ${DISTDIR}/${_file_}: do-fetch-file error-check | | 123 | ${DISTDIR}/${_file_}: do-fetch-file error-check |
124 | . endif | | 124 | . endif |
125 | .endfor | | 125 | .endfor |
126 | | | 126 | |
127 | ###################################################################### | | 127 | ###################################################################### |
128 | ### fetch-check-interactive (PRIVATE) | | 128 | ### fetch-check-interactive (PRIVATE) |
129 | ###################################################################### | | 129 | ###################################################################### |
130 | ### fetch-check-interactive is a macro target that is inserted at the | | 130 | ### fetch-check-interactive is a macro target that is inserted at the |
131 | ### head of a target's command list, and will check whether the fetch | | 131 | ### head of a target's command list, and will check whether the fetch |
132 | ### stage for this package requires user interaction to proceed. | | 132 | ### stage for this package requires user interaction to proceed. |
133 | ### | | 133 | ### |
134 | .PHONY: fetch-check-interactive | | 134 | .PHONY: fetch-check-interactive |
135 | fetch-check-interactive: .USEBEFORE | | 135 | fetch-check-interactive: .USEBEFORE |
136 | .if !empty(INTERACTIVE_STAGE:Mfetch) && defined(BATCH) && !defined(FETCH_MESSAGE) | | 136 | .if !empty(INTERACTIVE_STAGE:Mfetch) && defined(BATCH) && !defined(FETCH_MESSAGE) |
137 | @${TEST} ! -f ${.TARGET} || exit 0; \ | | 137 | @${TEST} ! -f ${.TARGET} || exit 0; \ |
138 | ${ERROR_MSG} "The fetch stage of this package requires user interaction to download"; \ | | 138 | ${ERROR_MSG} "The fetch stage of this package requires user interaction to download"; \ |
139 | ${ERROR_MSG} "the distfiles. Please fetch the distfiles manually and place them in:"; \ | | 139 | ${ERROR_MSG} "the distfiles. Please fetch the distfiles manually and place them in:"; \ |
140 | ${ERROR_MSG} " ${_DISTDIR}"; \ | | 140 | ${ERROR_MSG} " ${_DISTDIR}"; \ |
141 | if ${TEST} -n ${MASTER_SITES:Q}""; then \ | | 141 | if ${TEST} -n ${MASTER_SITES:Q}""; then \ |
142 | ${ERROR_MSG} "The distfiles are available from:"; \ | | 142 | ${ERROR_MSG} "The distfiles are available from:"; \ |
143 | for site in ${MASTER_SITES}; do \ | | 143 | for site in ${MASTER_SITES}; do \ |
144 | ${ERROR_MSG} " $$site"; \ | | 144 | ${ERROR_MSG} " $$site"; \ |
145 | done; \ | | 145 | done; \ |
146 | fi; \ | | 146 | fi; \ |
147 | if ${TEST} -n ${HOMEPAGE:Q}""; then \ | | 147 | if ${TEST} -n ${HOMEPAGE:Q}""; then \ |
148 | ${ERROR_MSG} "See the following URL for more details:"; \ | | 148 | ${ERROR_MSG} "See the following URL for more details:"; \ |
149 | ${ERROR_MSG} " "${HOMEPAGE:Q}; \ | | 149 | ${ERROR_MSG} " "${HOMEPAGE:Q}; \ |
150 | fi; \ | | 150 | fi; \ |
151 | exit 1 | | 151 | exit 1 |
152 | .elif defined(FETCH_MESSAGE) && !empty(FETCH_MESSAGE) | | 152 | .elif defined(FETCH_MESSAGE) && !empty(FETCH_MESSAGE) |
153 | @${TEST} ! -f ${.TARGET} || exit 0; \ | | 153 | @${TEST} ! -f ${.TARGET} || exit 0; \ |
154 | ${ERROR_MSG} "======================================================================"; \ | | 154 | ${ERROR_MSG} "======================================================================"; \ |
155 | ${ERROR_MSG} ""; \ | | 155 | ${ERROR_MSG} ""; \ |
156 | for line in ${FETCH_MESSAGE}; do ${ERROR_MSG} "$$line"; done; \ | | 156 | for line in ${FETCH_MESSAGE}; do ${ERROR_MSG} "$$line"; done; \ |
157 | ${ERROR_MSG} ""; \ | | 157 | ${ERROR_MSG} ""; \ |
158 | ${ERROR_MSG} "======================================================================"; \ | | 158 | ${ERROR_MSG} "======================================================================"; \ |
159 | exit 1 | | 159 | exit 1 |
160 | .else | | 160 | .else |
161 | @${DO_NADA} | | 161 | @${DO_NADA} |
162 | .endif | | 162 | .endif |
163 | | | 163 | |
164 | ###################################################################### | | 164 | ###################################################################### |
165 | ### do-fetch-file (PRIVATE) | | 165 | ### do-fetch-file (PRIVATE) |
166 | ###################################################################### | | 166 | ###################################################################### |
167 | ### do-fetch-file is a macro target that runs the "fetch" script to | | 167 | ### do-fetch-file is a macro target that runs the "fetch" script to |
168 | ### transfer the files from the appropriate sites if needed. | | 168 | ### transfer the files from the appropriate sites if needed. |
169 | ### | | 169 | ### |
170 | # | | 170 | # |
171 | # FETCH_CMD is the program used to fetch files for FETCH_USING=custom. | | 171 | # FETCH_CMD is the program used to fetch files for FETCH_USING=custom. |
172 | # It must understand fetching files located via URLs, | | 172 | # It must understand fetching files located via URLs, |
173 | # e.g. NetBSD's ftp, net/tnftp, etc. | | 173 | # e.g. NetBSD's ftp, net/tnftp, etc. |
174 | # | | 174 | # |
175 | # The following variables are all lists of options to pass to the command | | 175 | # The following variables are all lists of options to pass to the command |
176 | # used to do the actual fetching of the file. | | 176 | # used to do the actual fetching of the file. |
177 | # | | 177 | # |
178 | # FETCH_BEFORE_ARGS appear before all other options on the command line. | | 178 | # FETCH_BEFORE_ARGS appear before all other options on the command line. |
179 | # | | 179 | # |
180 | # FETCH_AFTER_ARGS appear after all other options on the command line. | | 180 | # FETCH_AFTER_ARGS appear after all other options on the command line. |
181 | # | | 181 | # |
182 | # FETCH_RESUME_ARGS appears just after FETCH_BEFORE_ARGS and is the set | | 182 | # FETCH_RESUME_ARGS appears just after FETCH_BEFORE_ARGS and is the set |
183 | # of options for causing the command to resume a previous transfer. | | 183 | # of options for causing the command to resume a previous transfer. |
184 | # | | 184 | # |
185 | # FETCH_OUTPUT_ARGS is a set of options for specifying the name of the | | 185 | # FETCH_OUTPUT_ARGS is a set of options for specifying the name of the |
186 | # local file that will hold the contents of the fetched file. | | 186 | # local file that will hold the contents of the fetched file. |
187 | # | | 187 | # |
188 | # FAILOVER_FETCH, if defined, will cause a checksum to be performed during | | 188 | # FAILOVER_FETCH, if defined, will cause a checksum to be performed during |
189 | # a fetch to verify the transferred file is correct; if the checksum | | 189 | # a fetch to verify the transferred file is correct; if the checksum |
190 | # is incorrect, then the next site will be tried. | | 190 | # is incorrect, then the next site will be tried. |
191 | # | | 191 | # |
192 | # PKG_RESUME_TRANSFERS is a yes/no variable that causes the fetch script | | 192 | # PKG_RESUME_TRANSFERS is a yes/no variable that causes the fetch script |
193 | # to try to resume interrupted file transfers to avoid downloading | | 193 | # to try to resume interrupted file transfers to avoid downloading |
194 | # the whole file. The default is set in pkgsrc/mk/defaults/mk.conf. | | 194 | # the whole file. The default is set in pkgsrc/mk/defaults/mk.conf. |
195 | # | | 195 | # |
196 | # FETCH_TIMEOUT, if defined, will cause the fetch command to quit on stalled | | 196 | # FETCH_TIMEOUT, if defined, will cause the fetch command to quit on stalled |
197 | # connections after the given amount of seconds. | | 197 | # connections after the given amount of seconds. |
198 | # The specific behavior depends on the command used. | | 198 | # The specific behavior depends on the command used. |
199 | # | | 199 | # |
200 | # FETCH_USE_IPV4_ONLY, if defined, will cause the fetch command to force | | 200 | # FETCH_USE_IPV4_ONLY, if defined, will cause the fetch command to force |
201 | # connecting to only IPv4 addresses. | | 201 | # connecting to only IPv4 addresses. |
202 | # | | 202 | # |
203 | | | 203 | |
204 | # If this host is behind a filtering firewall, use passive ftp(1) | | 204 | # If this host is behind a filtering firewall, use passive ftp(1) |
205 | _FETCH_BEFORE_ARGS.ftp= ${PASSIVE_FETCH:D-p} \ | | 205 | _FETCH_BEFORE_ARGS.ftp= ${PASSIVE_FETCH:D-p} \ |
206 | ${FETCH_TIMEOUT:D-q ${FETCH_TIMEOUT}} \ | | 206 | ${FETCH_TIMEOUT:D-q ${FETCH_TIMEOUT}} \ |
207 | ${FETCH_USE_IPV4_ONLY:D-4} | | 207 | ${FETCH_USE_IPV4_ONLY:D-4} |
208 | _FETCH_AFTER_ARGS.ftp= # empty | | 208 | _FETCH_AFTER_ARGS.ftp= # empty |
209 | _FETCH_RESUME_ARGS.ftp= -R | | 209 | _FETCH_RESUME_ARGS.ftp= -R |
210 | _FETCH_OUTPUT_ARGS.ftp= -o | | 210 | _FETCH_OUTPUT_ARGS.ftp= -o |
211 | _FETCH_CMD.ftp= ${TOOLS_PATH.ftp} | | 211 | _FETCH_CMD.ftp= ${TOOLS_PATH.ftp} |
212 | | | 212 | |
213 | _FETCH_BEFORE_ARGS.fetch= ${FETCH_TIMEOUT:D-T ${FETCH_TIMEOUT}} \ | | 213 | _FETCH_BEFORE_ARGS.fetch= ${FETCH_TIMEOUT:D-T ${FETCH_TIMEOUT}} \ |
214 | ${FETCH_USE_IPV4_ONLY:D-4} | | 214 | ${FETCH_USE_IPV4_ONLY:D-4} |
215 | _FETCH_AFTER_ARGS.fetch= # empty | | 215 | _FETCH_AFTER_ARGS.fetch= # empty |
216 | _FETCH_RESUME_ARGS.fetch= -r | | 216 | _FETCH_RESUME_ARGS.fetch= -r |
217 | _FETCH_OUTPUT_ARGS.fetch= -o | | 217 | _FETCH_OUTPUT_ARGS.fetch= -o |
218 | _FETCH_CMD.fetch= ${TOOLS_PATH.fetch} | | 218 | _FETCH_CMD.fetch= ${TOOLS_PATH.fetch} |
219 | | | 219 | |
220 | _FETCH_BEFORE_ARGS.wget= ${PASSIVE_FETCH:D--passive-ftp} \ | | 220 | _FETCH_BEFORE_ARGS.wget= ${PASSIVE_FETCH:D--passive-ftp} \ |
221 | --no-check-certificate \ | | 221 | --no-check-certificate \ |
222 | ${FETCH_TIMEOUT:D--timeout=${FETCH_TIMEOUT}} \ | | 222 | ${FETCH_TIMEOUT:D--timeout=${FETCH_TIMEOUT}} \ |
223 | ${FETCH_USE_IPV4_ONLY:D--inet4-only} | | 223 | ${FETCH_USE_IPV4_ONLY:D--inet4-only} |
224 | _FETCH_AFTER_ARGS.wget= # empty | | 224 | _FETCH_AFTER_ARGS.wget= # empty |
225 | _FETCH_RESUME_ARGS.wget= -c | | 225 | _FETCH_RESUME_ARGS.wget= -c |
226 | _FETCH_OUTPUT_ARGS.wget= -O | | 226 | _FETCH_OUTPUT_ARGS.wget= -O |
227 | _FETCH_CMD.wget= ${TOOLS_PATH.wget} | | 227 | _FETCH_CMD.wget= ${TOOLS_PATH.wget} |
228 | | | 228 | |
229 | _FETCH_BEFORE_ARGS.curl= ${PASSIVE_FETCH:D--ftp-pasv} \ | | 229 | _FETCH_BEFORE_ARGS.curl= ${PASSIVE_FETCH:D--ftp-pasv} \ |
230 | --fail --insecure --location --remote-time \ | | 230 | --fail --insecure --location --remote-time \ |
231 | ${FETCH_TIMEOUT:D--connect-timeout ${FETCH_TIMEOUT}} \ | | 231 | ${FETCH_TIMEOUT:D--connect-timeout ${FETCH_TIMEOUT}} \ |
232 | ${FETCH_TIMEOUT:D--speed-time ${FETCH_TIMEOUT}} \ | | 232 | ${FETCH_TIMEOUT:D--speed-time ${FETCH_TIMEOUT}} \ |
233 | ${FETCH_USE_IPV4_ONLY:D--ipv4} | | 233 | ${FETCH_USE_IPV4_ONLY:D--ipv4} |
234 | _FETCH_AFTER_ARGS.curl= -O # must be here to honor -o option | | 234 | _FETCH_AFTER_ARGS.curl= -O # must be here to honor -o option |
235 | _FETCH_RESUME_ARGS.curl= -C - | | 235 | _FETCH_RESUME_ARGS.curl= -C - |
236 | _FETCH_OUTPUT_ARGS.curl= -o | | 236 | _FETCH_OUTPUT_ARGS.curl= -o |
237 | _FETCH_CMD.curl= ${TOOLS_PATH.curl} | | 237 | _FETCH_CMD.curl= ${TOOLS_PATH.curl} |
238 | | | 238 | |
239 | _FETCH_CMD.manual= ${TOOLS_PATH.false} | | 239 | _FETCH_CMD.manual= ${TOOLS_PATH.false} |
240 | | | 240 | |
241 | _FETCH_CMD.custom= ${FETCH_CMD} | | 241 | _FETCH_CMD.custom= ${FETCH_CMD} |
242 | _FETCH_BEFORE_ARGS.custom= ${FETCH_BEFORE_ARGS} | | 242 | _FETCH_BEFORE_ARGS.custom= ${FETCH_BEFORE_ARGS} |
243 | _FETCH_AFTER_ARGS.custom= ${FETCH_AFTER_ARGS} | | 243 | _FETCH_AFTER_ARGS.custom= ${FETCH_AFTER_ARGS} |
244 | _FETCH_RESUME_ARGS.custom= ${FETCH_RESUME_ARGS} | | 244 | _FETCH_RESUME_ARGS.custom= ${FETCH_RESUME_ARGS} |
245 | _FETCH_OUTPUT_ARGS.custom= ${FETCH_OUTPUT_ARGS} | | 245 | _FETCH_OUTPUT_ARGS.custom= ${FETCH_OUTPUT_ARGS} |
246 | | | 246 | |
247 | _FETCH_CMD= ${PKGSRC_SETENV} CHECKSUM=${_CHECKSUM_CMD:Q} \ | | 247 | _FETCH_CMD= ${PKGSRC_SETENV} CHECKSUM=${_CHECKSUM_CMD:Q} \ |
248 | CP=${TOOLS_CP:Q} \ | | 248 | CP=${TOOLS_CP:Q} \ |
249 | ECHO=${TOOLS_ECHO:Q} \ | | 249 | ECHO=${TOOLS_ECHO:Q} \ |
250 | FETCH_CMD=${_FETCH_CMD.${FETCH_USING}:Q} \ | | 250 | FETCH_CMD=${_FETCH_CMD.${FETCH_USING}:Q} \ |
251 | FETCH_BEFORE_ARGS=${_FETCH_BEFORE_ARGS.${FETCH_USING}:Q} \ | | 251 | FETCH_BEFORE_ARGS=${_FETCH_BEFORE_ARGS.${FETCH_USING}:Q} \ |
252 | FETCH_AFTER_ARGS=${_FETCH_AFTER_ARGS.${FETCH_USING}:Q} \ | | 252 | FETCH_AFTER_ARGS=${_FETCH_AFTER_ARGS.${FETCH_USING}:Q} \ |
253 | FETCH_RESUME_ARGS=${_FETCH_RESUME_ARGS.${FETCH_USING}:Q} \ | | 253 | FETCH_RESUME_ARGS=${_FETCH_RESUME_ARGS.${FETCH_USING}:Q} \ |
254 | FETCH_OUTPUT_ARGS=${_FETCH_OUTPUT_ARGS.${FETCH_USING}:Q} \ | | 254 | FETCH_OUTPUT_ARGS=${_FETCH_OUTPUT_ARGS.${FETCH_USING}:Q} \ |
255 | MKDIR=${TOOLS_MKDIR:Q} MV=${TOOLS_MV:Q} \ | | 255 | MKDIR=${TOOLS_MKDIR:Q} MV=${TOOLS_MV:Q} \ |
256 | RM=${TOOLS_RM:Q} \ | | 256 | RM=${TOOLS_RM:Q} \ |
257 | TEST=${TOOLS_TEST:Q} TOUCH=${TOOLS_TOUCH:Q} \ | | 257 | TEST=${TOOLS_TEST:Q} TOUCH=${TOOLS_TOUCH:Q} \ |
258 | WC=${TOOLS_WC:Q} \ | | 258 | WC=${TOOLS_WC:Q} \ |
259 | ${SH} ${PKGSRCDIR}/mk/fetch/fetch | | 259 | ${SH} ${PKGSRCDIR}/mk/fetch/fetch |
260 | | | 260 | |
261 | _FETCH_ARGS+= ${PKG_VERBOSE:D-v} | | 261 | _FETCH_ARGS+= ${PKG_VERBOSE:D-v} |
262 | .if exists(${DISTINFO_FILE}) | | 262 | .if exists(${DISTINFO_FILE}) && !make(distinfo) && !make(makesum) \ |
| | | 263 | && !make(makedistinfo) && !make(mdi) |
263 | _FETCH_ARGS+= ${FAILOVER_FETCH:D-c} -f ${DISTINFO_FILE:tA:Q} | | 264 | _FETCH_ARGS+= ${FAILOVER_FETCH:D-c} -f ${DISTINFO_FILE:tA:Q} |
264 | .endif | | 265 | .endif |
265 | .if !empty(PKG_RESUME_TRANSFERS:M[yY][eE][sS]) | | 266 | .if !empty(PKG_RESUME_TRANSFERS:M[yY][eE][sS]) |
266 | _FETCH_ARGS+= -r | | 267 | _FETCH_ARGS+= -r |
267 | .endif | | 268 | .endif |
268 | .if defined(DIST_SUBDIR) && !empty(DIST_SUBDIR) | | 269 | .if defined(DIST_SUBDIR) && !empty(DIST_SUBDIR) |
269 | _FETCH_ARGS+= -d ${DIST_SUBDIR} | | 270 | _FETCH_ARGS+= -d ${DIST_SUBDIR} |
270 | .endif | | 271 | .endif |
271 | .if defined(POST_FETCH_HOOK) && !empty(POST_FETCH_HOOK) | | 272 | .if defined(POST_FETCH_HOOK) && !empty(POST_FETCH_HOOK) |
272 | _FETCH_ARGS+= -p ${POST_FETCH_HOOK:Q} | | 273 | _FETCH_ARGS+= -p ${POST_FETCH_HOOK:Q} |
273 | .endif | | 274 | .endif |
274 | | | 275 | |
275 | .PHONY: do-fetch-file | | 276 | .PHONY: do-fetch-file |
276 | do-fetch-file: .USE | | 277 | do-fetch-file: .USE |
277 | @${STEP_MSG} "Fetching ${.TARGET:T}" | | 278 | @${STEP_MSG} "Fetching ${.TARGET:T}" |
278 | ${RUN} ${MKDIR} ${.TARGET:H} | | 279 | ${RUN} ${MKDIR} ${.TARGET:H} |
279 | ${RUN} \ | | 280 | ${RUN} \ |
280 | for d in "" ${DIST_PATH:S/:/ /g}; do \ | | 281 | for d in "" ${DIST_PATH:S/:/ /g}; do \ |
281 | case $$d in \ | | 282 | case $$d in \ |
282 | ""|${DISTDIR}) continue ;; \ | | 283 | ""|${DISTDIR}) continue ;; \ |
283 | esac; \ | | 284 | esac; \ |
284 | file="$$d/${DIST_SUBDIR}/${.TARGET:T}"; \ | | 285 | file="$$d/${DIST_SUBDIR}/${.TARGET:T}"; \ |
285 | if ${TEST} -f $$file; then \ | | 286 | if ${TEST} -f $$file; then \ |
286 | ${ECHO} "Using $$file"; \ | | 287 | ${ECHO} "Using $$file"; \ |
287 | ${RM} -f ${.TARGET}; \ | | 288 | ${RM} -f ${.TARGET}; \ |
288 | ${LN} -s $$file ${.TARGET}; \ | | 289 | ${LN} -s $$file ${.TARGET}; \ |
289 | fi; \ | | 290 | fi; \ |
290 | done | | 291 | done |
291 | ${RUN} \ | | 292 | ${RUN} \ |
292 | unsorted_sites="${SITES.${.TARGET:T:S/=/--/}}"; \ | | 293 | unsorted_sites="${SITES.${.TARGET:T:S/=/--/}}"; \ |
293 | sites="${_ORDERED_SITES} ${_MASTER_SITE_BACKUP}"; \ | | 294 | sites="${_ORDERED_SITES} ${_MASTER_SITE_BACKUP}"; \ |
294 | cd ${.TARGET:H:S/\/${DIST_SUBDIR}$//} && \ | | 295 | cd ${.TARGET:H:S/\/${DIST_SUBDIR}$//} && \ |
295 | ${_FETCH_CMD} ${_FETCH_ARGS} ${.TARGET:T} $$sites | | 296 | ${_FETCH_CMD} ${_FETCH_ARGS} ${.TARGET:T} $$sites |
296 | ${RUN} \ | | 297 | ${RUN} \ |
297 | if ${TEST} ! -f ${.TARGET}; then \ | | 298 | if ${TEST} ! -f ${.TARGET}; then \ |
298 | ${ERROR_MSG} "Could not fetch the following file:"; \ | | 299 | ${ERROR_MSG} "Could not fetch the following file:"; \ |
299 | ${ERROR_MSG} " ${.TARGET:T}"; \ | | 300 | ${ERROR_MSG} " ${.TARGET:T}"; \ |
300 | ${ERROR_MSG} ""; \ | | 301 | ${ERROR_MSG} ""; \ |
301 | ${ERROR_MSG} "Please retrieve this file manually into:"; \ | | 302 | ${ERROR_MSG} "Please retrieve this file manually into:"; \ |
302 | ${ERROR_MSG} " ${.TARGET:H}"; \ | | 303 | ${ERROR_MSG} " ${.TARGET:H}"; \ |
303 | exit 1; \ | | 304 | exit 1; \ |
304 | fi | | 305 | fi |
305 | | | 306 | |
306 | ###################################################################### | | 307 | ###################################################################### |
307 | ### mirror-distfiles (PUBLIC) | | 308 | ### mirror-distfiles (PUBLIC) |
308 | ###################################################################### | | 309 | ###################################################################### |
309 | ### mirror-distfiles is a public target that is mostly of use only to | | 310 | ### mirror-distfiles is a public target that is mostly of use only to |
310 | ### sites that wish to provide distfiles that others may fetch. It | | 311 | ### sites that wish to provide distfiles that others may fetch. It |
311 | ### only fetches distfiles that are freely re-distributable by setting | | 312 | ### only fetches distfiles that are freely re-distributable by setting |
312 | ### NO_SKIP (see bsd.fetch-vars.mk). | | 313 | ### NO_SKIP (see bsd.fetch-vars.mk). |
313 | ### | | 314 | ### |
314 | .PHONY: mirror-distfiles | | 315 | .PHONY: mirror-distfiles |
315 | .if defined(NO_SRC_ON_FTP) | | 316 | .if defined(NO_SRC_ON_FTP) |
316 | mirror-distfiles: | | 317 | mirror-distfiles: |
317 | @${DO_NADA} | | 318 | @${DO_NADA} |
318 | .elif defined(EMUL_PLATFORMS) && !empty(EMUL_PLATFORMS) | | 319 | .elif defined(EMUL_PLATFORMS) && !empty(EMUL_PLATFORMS) |
319 | mirror-distfiles: emul-fetch | | 320 | mirror-distfiles: emul-fetch |
320 | .else | | 321 | .else |
321 | mirror-distfiles: fetch | | 322 | mirror-distfiles: fetch |
322 | .endif | | 323 | .endif |
323 | | | 324 | |
324 | # XXX | | 325 | # XXX |
325 | # XXX Is this target actually used? (jlam 20060718) | | 326 | # XXX Is this target actually used? (jlam 20060718) |
326 | # XXX | | 327 | # XXX |
327 | .PHONY: show-distfiles | | 328 | .PHONY: show-distfiles |
328 | .if !target(show-distfiles) | | 329 | .if !target(show-distfiles) |
329 | show-distfiles: | | 330 | show-distfiles: |
330 | . if defined(PKG_FAIL_REASON) | | 331 | . if defined(PKG_FAIL_REASON) |
331 | ${RUN} ${DO_NADA} | | 332 | ${RUN} ${DO_NADA} |
332 | . else | | 333 | . else |
333 | ${RUN} \ | | 334 | ${RUN} \ |
334 | for file in "" ${_CKSUMFILES}; do \ | | 335 | for file in "" ${_CKSUMFILES}; do \ |
335 | if [ "X$$file" = "X" ]; then continue; fi; \ | | 336 | if [ "X$$file" = "X" ]; then continue; fi; \ |
336 | ${ECHO} $$file; \ | | 337 | ${ECHO} $$file; \ |
337 | done | | 338 | done |
338 | . endif | | 339 | . endif |
339 | .endif | | 340 | .endif |
340 | | | 341 | |
341 | .PHONY: depends-fetch | | 342 | .PHONY: depends-fetch |
342 | depends-fetch: | | 343 | depends-fetch: |
343 | ${RUN} \ | | 344 | ${RUN} \ |
344 | ${_DEPENDS_WALK_CMD} ${PKGPATH} | \ | | 345 | ${_DEPENDS_WALK_CMD} ${PKGPATH} | \ |
345 | while read dir; do \ | | 346 | while read dir; do \ |
346 | ${ECHO} "===> Fetching for $${dir}" && \ | | 347 | ${ECHO} "===> Fetching for $${dir}" && \ |
347 | cd ${.CURDIR}/../../$$dir && \ | | 348 | cd ${.CURDIR}/../../$$dir && \ |
348 | ${RECURSIVE_MAKE} ${MAKEFLAGS} fetch || exit 1; \ | | 349 | ${RECURSIVE_MAKE} ${MAKEFLAGS} fetch || exit 1; \ |
349 | done | | 350 | done |