@@ -76,22 +76,19 @@ Authentication is not supported.
76
76
URLs are tried in order until one succeeds, so you should list local mirrors first.
77
77
If all downloads fail, the rule will fail."""
78
78
79
- def _get_all_urls (ctx ):
80
- """Returns all urls provided via the url, urls and remote_patches attributes.
79
+ def _get_source_urls (ctx ):
80
+ """Returns source urls provided via the url, urls attributes.
81
81
82
82
Also checks that at least one url is provided."""
83
83
if not ctx .attr .url and not ctx .attr .urls :
84
84
fail ("At least one of url and urls must be provided" )
85
85
86
- all_urls = []
86
+ source_urls = []
87
87
if ctx .attr .urls :
88
- all_urls = ctx .attr .urls
88
+ source_urls = ctx .attr .urls
89
89
if ctx .attr .url :
90
- all_urls = [ctx .attr .url ] + all_urls
91
- if hasattr (ctx .attr , "remote_patches" ) and ctx .attr .remote_patches :
92
- all_urls = all_urls + ctx .attr .remote_patches .keys ()
93
-
94
- return all_urls
90
+ source_urls = [ctx .attr .url ] + source_urls
91
+ return source_urls
95
92
96
93
_AUTH_PATTERN_DOC = """An optional dict mapping host names to custom authorization patterns.
97
94
@@ -136,25 +133,21 @@ def _http_archive_impl(ctx):
136
133
if ctx .attr .build_file and ctx .attr .build_file_content :
137
134
fail ("Only one of build_file and build_file_content can be provided." )
138
135
139
- all_urls = _get_all_urls (ctx )
140
- auth = get_auth (ctx , all_urls )
141
-
136
+ source_urls = _get_source_urls (ctx )
142
137
download_info = ctx .download_and_extract (
143
- # TODO(fzakaria): all_urls here has the remote_patch URL which is incorrect
144
- # I believe this to be a file
145
- all_urls ,
138
+ source_urls ,
146
139
ctx .attr .add_prefix ,
147
140
ctx .attr .sha256 ,
148
141
ctx .attr .type ,
149
142
ctx .attr .strip_prefix ,
150
- canonical_id = ctx .attr .canonical_id or get_default_canonical_id (ctx , all_urls ),
151
- auth = auth ,
143
+ canonical_id = ctx .attr .canonical_id or get_default_canonical_id (ctx , source_urls ),
144
+ auth = get_auth ( ctx , source_urls ) ,
152
145
integrity = ctx .attr .integrity ,
153
146
)
154
147
workspace_and_buildfile (ctx )
155
148
156
- download_remote_files (ctx , auth = auth )
157
- patch (ctx , auth = auth )
149
+ download_remote_files (ctx )
150
+ patch (ctx )
158
151
159
152
return _update_integrity_attr (ctx , _http_archive_attrs , download_info )
160
153
@@ -182,15 +175,14 @@ def _http_file_impl(ctx):
182
175
download_path = ctx .path ("file/" + downloaded_file_path )
183
176
if download_path in forbidden_files or not str (download_path ).startswith (str (repo_root )):
184
177
fail ("'%s' cannot be used as downloaded_file_path in http_file" % ctx .attr .downloaded_file_path )
185
- all_urls = _get_all_urls (ctx )
186
- auth = get_auth (ctx , all_urls )
178
+ source_urls = _get_source_urls (ctx )
187
179
download_info = ctx .download (
188
- all_urls ,
180
+ source_urls ,
189
181
"file/" + downloaded_file_path ,
190
182
ctx .attr .sha256 ,
191
183
ctx .attr .executable ,
192
- canonical_id = ctx .attr .canonical_id or get_default_canonical_id (ctx , all_urls ),
193
- auth = auth ,
184
+ canonical_id = ctx .attr .canonical_id or get_default_canonical_id (ctx , source_urls ),
185
+ auth = get_auth ( ctx , source_urls ) ,
194
186
integrity = ctx .attr .integrity ,
195
187
)
196
188
ctx .file ("WORKSPACE" , "workspace(name = \" {name}\" )" .format (name = ctx .name ))
@@ -217,15 +209,14 @@ filegroup(
217
209
218
210
def _http_jar_impl (ctx ):
219
211
"""Implementation of the http_jar rule."""
220
- all_urls = _get_all_urls (ctx )
221
- auth = get_auth (ctx , all_urls )
212
+ source_urls = _get_source_urls (ctx )
222
213
downloaded_file_name = ctx .attr .downloaded_file_name
223
214
download_info = ctx .download (
224
- all_urls ,
215
+ source_urls ,
225
216
"jar/" + downloaded_file_name ,
226
217
ctx .attr .sha256 ,
227
- canonical_id = ctx .attr .canonical_id or get_default_canonical_id (ctx , all_urls ),
228
- auth = auth ,
218
+ canonical_id = ctx .attr .canonical_id or get_default_canonical_id (ctx , source_urls ),
219
+ auth = get_auth ( ctx , source_urls ) ,
229
220
integrity = ctx .attr .integrity ,
230
221
)
231
222
ctx .file ("WORKSPACE" , "workspace(name = \" {name}\" )" .format (name = ctx .name ))
0 commit comments