├── .gitignore
├── LICENSE
├── README.md
├── appveyor.yml
├── aria2-0001-options-change-default-path-to-current-dir.patch
├── aria2-0002-options-unlock-connection-per-server-limit.patch
├── aria2-0003-download-retry-on-slow-speed-and-reset.patch
├── aria2-0004-option_processing-make-use-of-deamon-on-mingw.patch
├── aria2-0005-option-add-option-to-retry-on-http-4xx.patch
├── aria2-0006-feature-config-add-os-info-for-newer-windows.patch
├── build-aria2.sh
├── c-ares-1.17.1-fix-autotools-static-library.patch
├── init-msys2.bat
└── libssh2-1.9.0-wincng-multiple-definition.patch
/.gitignore:
--------------------------------------------------------------------------------
1 | # Packages
2 | *.gz
3 | *.bz2
4 | *.xz
5 | *.7z
6 | *.zip
7 | *.tar
8 |
9 | # Extracted folders
10 | aria2/*
11 | jemalloc/*
12 | expat-*/*
13 | sqlite-autoconf-*/*
14 | c-ares-*/*
15 | libssh2-*/*
16 |
17 | # Test scripts
18 | *_test.*
19 |
20 | # Prerequisites
21 | *.d
22 |
23 | # Object files
24 | *.o
25 | *.ko
26 | *.obj
27 | *.elf
28 |
29 | # Linker output
30 | *.ilk
31 | *.map
32 | *.exp
33 |
34 | # Precompiled Headers
35 | *.gch
36 | *.pch
37 |
38 | # Libraries
39 | *.lib
40 | *.a
41 | *.la
42 | *.lo
43 |
44 | # Shared objects (inc. Windows DLLs)
45 | *.dll
46 | *.so
47 | *.so.*
48 | *.dylib
49 |
50 | # Executables
51 | *.exe
52 | *.out
53 | *.app
54 | *.i*86
55 | *.x86_64
56 | *.hex
57 |
58 | # Debug files
59 | *.dSYM/
60 | *.su
61 | *.idb
62 | *.pdb
63 |
64 | # Kernel Module Compile Results
65 | *.mod*
66 | *.cmd
67 | .tmp_versions/
68 | modules.order
69 | Module.symvers
70 | Mkfile.old
71 | dkms.conf
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Readme
2 | aria2 build scripts for `msys2` with custom patches.
3 |
4 | ### Build Status
5 | [](https://ci.appveyor.com/project/myfreeer/aria2-build-msys2)
6 |
7 | ### License
8 | [](LICENSE)
9 |
10 | ### Changes
11 | * option `max-connection-per-server`: change maximum value to `*`, default value to `16`
12 | * option `min-split-size`: change minimum value to `1K`, default value to `1M`
13 | * option `piece-length`: change minimum value to `1K`, default value to `1M`
14 | * option `connect-timeout`: change default value to `30`
15 | * option `split`: change default value to `128`
16 | * option `continue`: change default value to `true`
17 | * option `retry-wait`: change default value to `1`
18 | * option `max-concurrent-downloads`: change default value to `16`
19 | * option `netrc-path` `conf-path` `dht-file-path` `dht-file-path6`: change default value to sub-folder of current directory
20 | * option `deamon`: make use of it on mingw
21 | * download: retry on slow speed and connection close
22 | * download: add option `retry-on-400` to retry on http 400 bad request, which only effective if retry-wait > 0
23 | * download: add option `retry-on-403` to retry on http 403 forbidden, which only effective if retry-wait > 0
24 | * download: add option `retry-on-406` to retry on http 406 not acceptable, which only effective if retry-wait > 0
25 | * ~~http: add option `http-want-digest` to choose whether to send the generated `Want-Digest` HTTP header or not ([#10](https://github.com/myfreeer/aria2-build-msys2/issues/10))~~
26 | * Removed in favor of upstream [`no-want-digest-header`](https://aria2.github.io/manual/en/html/aria2c.html#cmdoption-no-want-digest-header) option after [release-1.37.0](https://github.com/aria2/aria2/releases/tag/release-1.37.0) by commit [839dd2ca](https://github.com/aria2/aria2/commit/839dd2caf77863503d18252a1aff16cd1dde274c)
27 |
28 | ### Environment
29 | [MSYS2](http://www.msys2.org/)
30 | Should be set up with commands below:
31 | ```sh
32 | pacman -Syyuu --noconfirm
33 | pacman -Su --noconfirm
34 | pacman -S --noconfirm --needed base-devel zlib-devel sqlite git unzip zip tar gmp gmp-devel libssh2 libssh2-devel openssl-devel
35 | ```
36 |
37 | ### Artifacts
38 | * x86_64 (64-bits) version: [](https://ci.appveyor.com/api/projects/myfreeer/aria2-build-msys2/artifacts/aria2c.7z)
39 | * x86 (32-bits) version: [](https://ci.appveyor.com/api/projects/myfreeer/aria2-build-msys2/artifacts/aria2c_x86.7z)
40 |
41 | ### Credits
42 | * https://github.com/aria2/aria2
43 | * https://gist.github.com/zhangyubaka/fb56f6bf9be50dbd28e64809cdc659be
44 | * https://github.com/jb-alvarado/media-autobuild_suite
45 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 1.37.0-{build}
2 | skip_tags: true
3 | install:
4 | - ps: >-
5 | $gitData = ConvertFrom-StringData (git log -1 --format=format:"commitId=%H%nmessage=%s%ncommitted=%aD" | out-string)
6 |
7 | if ($gitData['message'] -eq "") { $gitData['message'] = "No commit message available for $($gitData['commitid'])" }
8 |
9 | # View the data with Write-Output @gitData
10 |
11 | Update-AppveyorBuild @gitData
12 | build_script:
13 | - cmd: >-
14 | C:\msys64\usr\bin\pacman -S --noconfirm --needed --ask=20 base-devel git unzip zip tar
15 |
16 | set MSYSTEM=MINGW64
17 |
18 | C:\msys64\usr\bin\bash -lc "cd \"$APPVEYOR_BUILD_FOLDER\" && exec ./build-aria2.sh"
19 |
20 | 7z a aria2c.7z .\aria2\src\aria2c.exe
21 |
22 | appveyor PushArtifact aria2c.7z
23 |
24 | rd /s /q aria2
25 |
26 | set MSYSTEM=MINGW32
27 |
28 | C:\msys64\usr\bin\bash -lc "cd \"$APPVEYOR_BUILD_FOLDER\" && exec ./build-aria2.sh"
29 |
30 | 7z a aria2c_x86.7z .\aria2\src\aria2c.exe
31 |
32 | appveyor PushArtifact aria2c_x86.7z
33 | test: off
34 | skip_commits:
35 | files:
36 | - 'LICENSE'
37 | - '*.md'
38 | - '.gitingore'
39 |
--------------------------------------------------------------------------------
/aria2-0001-options-change-default-path-to-current-dir.patch:
--------------------------------------------------------------------------------
1 | From c33446e390e8d4fc79d69031d391eaf12dce1766 Mon Sep 17 00:00:00 2001
2 | From: myfreeer
3 | Date: Tue, 5 Jun 2018 16:49:07 +0800
4 | Subject: [PATCH 1/4] options: change default path to current dir
5 |
6 | and try to load config files in current dir if exists
7 | ---
8 | src/OptionHandlerFactory.cc | 2 +-
9 | src/OptionHandlerImpl.cc | 2 +-
10 | src/util.cc | 14 ++++++++++----
11 | 3 files changed, 12 insertions(+), 6 deletions(-)
12 |
13 | diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
14 | index 3d76d33..cd00881 100644
15 | --- a/src/OptionHandlerFactory.cc
16 | +++ b/src/OptionHandlerFactory.cc
17 | @@ -1276,7 +1276,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
18 | }
19 | {
20 | OptionHandler* op(new LocalFilePathOptionHandler(
21 | - PREF_NETRC_PATH, TEXT_NETRC_PATH, util::getHomeDir() + "/.netrc",
22 | + PREF_NETRC_PATH, TEXT_NETRC_PATH, File::getCurrentDir() + "/.netrc",
23 | /* acceptStdin = */ false, 0, /* mustExist = */ false));
24 | handlers.push_back(op);
25 | }
26 | diff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc
27 | index 6214e84..7f89226 100644
28 | --- a/src/OptionHandlerImpl.cc
29 | +++ b/src/OptionHandlerImpl.cc
30 | @@ -548,7 +548,7 @@ void LocalFilePathOptionHandler::parseArg(Option& option,
31 | option.put(pref_, DEV_STDIN);
32 | }
33 | else {
34 | - auto path = util::replace(optarg, "${HOME}", util::getHomeDir());
35 | + auto path = util::replace(optarg, "${HOME}", File::getCurrentDir());
36 | if (mustExist_) {
37 | File f(path);
38 | std::string err;
39 | diff --git a/src/util.cc b/src/util.cc
40 | index 2e700de..cc2531d 100644
41 | --- a/src/util.cc
42 | +++ b/src/util.cc
43 | @@ -1805,9 +1805,12 @@ std::string getXDGDir(const std::string& environmentVariable,
44 |
45 | std::string getConfigFile()
46 | {
47 | - std::string filename = getHomeDir() + "/.aria2/aria2.conf";
48 | + std::string filename = File::getCurrentDir() + "/.aria2/aria2.conf";
49 | if (!File(filename).exists()) {
50 | - filename = getXDGDir("XDG_CONFIG_HOME", getHomeDir() + "/.config") +
51 | + filename = File::getCurrentDir() + "/aria2.conf";
52 | + }
53 | + if (!File(filename).exists()) {
54 | + filename = getXDGDir("XDG_CONFIG_HOME", File::getCurrentDir() + "/.config") +
55 | "/aria2/aria2.conf";
56 | }
57 | return filename;
58 | @@ -1816,9 +1819,12 @@ std::string getConfigFile()
59 | std::string getDHTFile(bool ipv6)
60 | {
61 | std::string filename =
62 | - getHomeDir() + (ipv6 ? "/.aria2/dht6.dat" : "/.aria2/dht.dat");
63 | + File::getCurrentDir() + (ipv6 ? "/.aria2/dht6.dat" : "/.aria2/dht.dat");
64 | + if (!File(filename).exists()) {
65 | + filename = File::getCurrentDir() + (ipv6 ? "/dht6.dat" : "/dht.dat");
66 | + }
67 | if (!File(filename).exists()) {
68 | - filename = getXDGDir("XDG_CACHE_HOME", getHomeDir() + "/.cache") +
69 | + filename = getXDGDir("XDG_CACHE_HOME", File::getCurrentDir() + "/.cache") +
70 | (ipv6 ? "/aria2/dht6.dat" : "/aria2/dht.dat");
71 | }
72 | return filename;
73 | --
74 | 2.17.1
75 |
76 |
--------------------------------------------------------------------------------
/aria2-0002-options-unlock-connection-per-server-limit.patch:
--------------------------------------------------------------------------------
1 | From 733fa35774821b7c955a9f018d43de570aa98d17 Mon Sep 17 00:00:00 2001
2 | From: myfreeer
3 | Date: Mon, 29 May 2017 22:11:33 +0800
4 | Subject: [PATCH 2/4] options: unlock connection-per-server limit
5 |
6 | ---
7 | src/OptionHandlerFactory.cc | 16 ++++++++--------
8 | 1 file changed, 8 insertions(+), 8 deletions(-)
9 |
10 | diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
11 | index cd00881..5768f7b 100644
12 | --- a/src/OptionHandlerFactory.cc
13 | +++ b/src/OptionHandlerFactory.cc
14 | @@ -158,7 +158,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
15 | }
16 | {
17 | OptionHandler* op(new BooleanOptionHandler(
18 | - PREF_CONTINUE, TEXT_CONTINUE, A2_V_FALSE, OptionHandler::OPT_ARG, 'c'));
19 | + PREF_CONTINUE, TEXT_CONTINUE, A2_V_TRUE, OptionHandler::OPT_ARG, 'c'));
20 | op->addTag(TAG_BASIC);
21 | op->addTag(TAG_FTP);
22 | op->addTag(TAG_HTTP);
23 | @@ -432,7 +432,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
24 | {
25 | OptionHandler* op(new NumberOptionHandler(PREF_MAX_CONCURRENT_DOWNLOADS,
26 | TEXT_MAX_CONCURRENT_DOWNLOADS,
27 | - "5", 1, -1, 'j'));
28 | + "16", 1, -1, 'j'));
29 | op->addTag(TAG_BASIC);
30 | op->setChangeGlobalOption(true);
31 | handlers.push_back(op);
32 | @@ -440,7 +440,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
33 | {
34 | OptionHandler* op(new NumberOptionHandler(PREF_MAX_CONNECTION_PER_SERVER,
35 | TEXT_MAX_CONNECTION_PER_SERVER,
36 | - "1", 1, 16, 'x'));
37 | + "16", 1, -1, 'x'));
38 | op->addTag(TAG_BASIC);
39 | op->addTag(TAG_FTP);
40 | op->addTag(TAG_HTTP);
41 | @@ -501,7 +501,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
42 | }
43 | {
44 | OptionHandler* op(new UnitNumberOptionHandler(
45 | - PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, "20M", 1_m, 1_g, 'k'));
46 | + PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, "1M", 1_k, 1_g, 'k'));
47 | op->addTag(TAG_BASIC);
48 | op->addTag(TAG_FTP);
49 | op->addTag(TAG_HTTP);
50 | @@ -834,7 +834,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
51 | }
52 | {
53 | OptionHandler* op(new NumberOptionHandler(
54 | - PREF_CONNECT_TIMEOUT, TEXT_CONNECT_TIMEOUT, "60", 1, 600));
55 | + PREF_CONNECT_TIMEOUT, TEXT_CONNECT_TIMEOUT, "30", 1, 600));
56 | op->addTag(TAG_FTP);
57 | op->addTag(TAG_HTTP);
58 | op->setInitialOption(true);
59 | @@ -905,7 +905,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
60 | }
61 | {
62 | OptionHandler* op(new UnitNumberOptionHandler(
63 | - PREF_PIECE_LENGTH, TEXT_PIECE_LENGTH, "1M", 1_m, 1_g));
64 | + PREF_PIECE_LENGTH, TEXT_PIECE_LENGTH, "1M", 1_k, 1_g));
65 | op->addTag(TAG_ADVANCED);
66 | op->addTag(TAG_FTP);
67 | op->addTag(TAG_HTTP);
68 | @@ -926,7 +926,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
69 | }
70 | {
71 | OptionHandler* op(
72 | - new NumberOptionHandler(PREF_RETRY_WAIT, TEXT_RETRY_WAIT, "0", 0, 600));
73 | + new NumberOptionHandler(PREF_RETRY_WAIT, TEXT_RETRY_WAIT, "1", 0, 600));
74 | op->addTag(TAG_FTP);
75 | op->addTag(TAG_HTTP);
76 | op->setInitialOption(true);
77 | @@ -971,7 +971,7 @@ std::vector OptionHandlerFactory::createOptionHandlers()
78 | }
79 | {
80 | OptionHandler* op(
81 | - new NumberOptionHandler(PREF_SPLIT, TEXT_SPLIT, "5", 1, -1, 's'));
82 | + new NumberOptionHandler(PREF_SPLIT, TEXT_SPLIT, "128", 1, -1, 's'));
83 | op->addTag(TAG_BASIC);
84 | op->addTag(TAG_FTP);
85 | op->addTag(TAG_HTTP);
86 | --
87 | 2.17.1
88 |
89 |
--------------------------------------------------------------------------------
/aria2-0003-download-retry-on-slow-speed-and-reset.patch:
--------------------------------------------------------------------------------
1 | From 66524bee738e98742c908d93c993d0a78a2d9891 Mon Sep 17 00:00:00 2001
2 | From: myfreeer
3 | Date: Sat, 18 Nov 2017 11:55:04 +0800
4 | Subject: [PATCH 3/4] download: retry on slow speed and conection close
5 |
6 | This would provide better speed on bad network conditions
7 | ---
8 | src/DownloadCommand.cc | 2 +-
9 | src/SocketBuffer.cc | 3 ++-
10 | src/SocketCore.cc | 2 +-
11 | 3 files changed, 4 insertions(+), 3 deletions(-)
12 |
13 | diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc
14 | index 2db41e4..f49eb80 100644
15 | --- a/src/DownloadCommand.cc
16 | +++ b/src/DownloadCommand.cc
17 | @@ -306,7 +306,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const
18 | startupIdleTime_) {
19 | int nowSpeed = peerStat_->calculateDownloadSpeed();
20 | if (nowSpeed <= lowestDownloadSpeedLimit_) {
21 | - throw DL_ABORT_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,
22 | + throw DL_RETRY_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,
23 | lowestDownloadSpeedLimit_,
24 | getRequest()->getHost().c_str()),
25 | error_code::TOO_SLOW_DOWNLOAD_SPEED);
26 | diff --git a/src/SocketBuffer.cc b/src/SocketBuffer.cc
27 | index 62862ff..1906173 100644
28 | --- a/src/SocketBuffer.cc
29 | +++ b/src/SocketBuffer.cc
30 | @@ -39,6 +39,7 @@
31 |
32 | #include "SocketCore.h"
33 | #include "DlAbortEx.h"
34 | +#include "DlRetryEx.h"
35 | #include "message.h"
36 | #include "fmt.h"
37 | #include "LogFactory.h"
38 | @@ -158,7 +159,7 @@ ssize_t SocketBuffer::send()
39 | }
40 | ssize_t slen = socket_->writeVector(iov, num);
41 | if (slen == 0 && !socket_->wantRead() && !socket_->wantWrite()) {
42 | - throw DL_ABORT_EX(fmt(EX_SOCKET_SEND, "Connection closed."));
43 | + throw DL_RETRY_EX(fmt(EX_SOCKET_SEND, "Connection closed."));
44 | }
45 | // A2_LOG_NOTICE(fmt("num=%zu, amount=%d, bufq.size()=%zu, SEND=%d",
46 | // num, amount, bufq_.size(), slen));
47 | diff --git a/src/SocketCore.cc b/src/SocketCore.cc
48 | index 77dc30c..537375a 100644
49 | --- a/src/SocketCore.cc
50 | +++ b/src/SocketCore.cc
51 | @@ -1009,7 +1009,7 @@ bool SocketCore::tlsHandshake(TLSContext* tlsctx, const std::string& hostname)
52 |
53 | if (rv == TLS_ERR_ERROR) {
54 | // Damn those error.
55 | - throw DL_ABORT_EX(fmt("SSL/TLS handshake failure: %s",
56 | + throw DL_RETRY_EX(fmt("SSL/TLS handshake failure: %s",
57 | handshakeError.empty()
58 | ? tlsSession_->getLastErrorString().c_str()
59 | : handshakeError.c_str()));
60 | --
61 | 2.17.1
62 |
63 |
--------------------------------------------------------------------------------
/aria2-0004-option_processing-make-use-of-deamon-on-mingw.patch:
--------------------------------------------------------------------------------
1 | From 26816f5deb196c7000244b56edd55b17385381db Mon Sep 17 00:00:00 2001
2 | From: myfreeer
3 | Date: Sat, 9 Jun 2018 15:24:29 +0800
4 | Subject: [PATCH 4/4] option_processing: make use of --deamon on mingw
5 |
6 | ---
7 | src/option_processing.cc | 17 +++++++++++++++++
8 | 1 file changed, 17 insertions(+)
9 |
10 | diff --git a/src/option_processing.cc b/src/option_processing.cc
11 | index f9891fe..3952ed6 100644
12 | --- a/src/option_processing.cc
13 | +++ b/src/option_processing.cc
14 | @@ -319,6 +319,22 @@ error_code::Value option_processing(Option& op, bool standalone,
15 | }
16 | }
17 | if (standalone && op.getAsBool(PREF_DAEMON)) {
18 | +#ifdef __MINGW32__
19 | + std::wstring daemonCmdLine = GetCommandLineW();
20 | + daemonCmdLine.append(L" --daemon=false");
21 | + STARTUPINFOW si = {};
22 | + PROCESS_INFORMATION pi = {};
23 | + si.dwFlags = STARTF_USESHOWWINDOW;
24 | + si.wShowWindow = FALSE;
25 | + BOOL bRet = CreateProcessW(
26 | + NULL, const_cast(daemonCmdLine.c_str()), NULL, NULL,
27 | + FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
28 | + if (bRet) {
29 | + CloseHandle(pi.hThread);
30 | + CloseHandle(pi.hProcess);
31 | + ExitProcess(0);
32 | + }
33 | +#else // !__MINGW32__
34 | #if defined(__GNUC__) && defined(__APPLE__)
35 | // daemon() is deprecated on OSX since... forever.
36 | // Silence the warning for good, so that -Werror becomes feasible.
37 | @@ -334,6 +350,7 @@ error_code::Value option_processing(Option& op, bool standalone,
38 | perror(MSG_DAEMON_FAILED);
39 | return error_code::UNKNOWN_ERROR;
40 | }
41 | +#endif // __MINGW32__
42 | }
43 | if (op.getAsBool(PREF_DEFERRED_INPUT) && op.defined(PREF_SAVE_SESSION)) {
44 | A2_LOG_WARN("--deferred-input is disabled because of the presence of "
45 | --
46 | 2.17.1
47 |
48 |
--------------------------------------------------------------------------------
/aria2-0005-option-add-option-to-retry-on-http-4xx.patch:
--------------------------------------------------------------------------------
1 | From 8adbc01dc5975a64c55fe594d8c758c71e8183b3 Mon Sep 17 00:00:00 2001
2 | From: myfreeer
3 | Date: Sun, 22 Jul 2018 19:59:02 +0800
4 | Subject: [PATCH] option: add option to retry on http 400, 403, 406, or unknown
5 |
6 | --retry-on-400[=true|false] Configure whether retry or not when
7 | HTTP server returns 400 Bad Request.
8 | Only effective if retry-wait > 0.
9 |
10 | Possible Values: true, false
11 | Default: false
12 | Tags: #advanced, #http
13 |
14 | --retry-on-403[=true|false] Configure whether retry or not when
15 | HTTP server returns 403 Forbidden.
16 | Only effective if retry-wait > 0.
17 |
18 | Possible Values: true, false
19 | Default: false
20 | Tags: #advanced, #http
21 |
22 | --retry-on-406[=true|false] Configure whether retry or not when
23 | HTTP server returns 406 Not Acceptable.
24 | Only effective if retry-wait > 0.
25 |
26 | Possible Values: true, false
27 | Default: false
28 | Tags: #advanced, #http
29 |
30 | --retry-on-unknown[=true|false] Configure whether retry or not when
31 | HTTP server returns unknown status code.
32 | Only effective if retry-wait > 0.
33 |
34 | Possible Values: true, false
35 | Default: false
36 | Tags: #advanced, #http
37 | ---
38 | src/HttpSkipResponseCommand.cc | 42 +++++++++++++++++++++++++++++-----
39 | src/OptionHandlerFactory.cc | 40 ++++++++++++++++++++++++++++++++
40 | src/prefs.cc | 8 +++++++
41 | src/prefs.h | 8 +++++++
42 | src/usage_text.h | 16 +++++++++++++
43 | 5 files changed, 108 insertions(+), 6 deletions(-)
44 |
45 | diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc
46 | index a722d77..de4ad6c 100644
47 | --- a/src/HttpSkipResponseCommand.cc
48 | +++ b/src/HttpSkipResponseCommand.cc
49 | @@ -204,7 +204,7 @@ bool HttpSkipResponseCommand::processResponse()
50 | auto statusCode = httpResponse_->getStatusCode();
51 | if (statusCode >= 400) {
52 | switch (statusCode) {
53 | - case 401:
54 | + case 401: // Unauthorized
55 | if (getOption()->getAsBool(PREF_HTTP_AUTH_CHALLENGE) &&
56 | !httpResponse_->getHttpRequest()->authenticationUsed() &&
57 | getDownloadEngine()->getAuthConfigFactory()->activateBasicCred(
58 | @@ -213,15 +213,41 @@ bool HttpSkipResponseCommand::processResponse()
59 | return prepareForRetry(0);
60 | }
61 | throw DL_ABORT_EX2(EX_AUTH_FAILED, error_code::HTTP_AUTH_FAILED);
62 | - case 404:
63 | + case 404: // Not Found
64 | if (getOption()->getAsInt(PREF_MAX_FILE_NOT_FOUND) == 0) {
65 | throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
66 | error_code::RESOURCE_NOT_FOUND);
67 | }
68 | throw DL_RETRY_EX2(MSG_RESOURCE_NOT_FOUND,
69 | error_code::RESOURCE_NOT_FOUND);
70 | - case 502:
71 | - case 503:
72 | + case 400: // Bad Request
73 | + if (getOption()->getAsBool(PREF_RETRY_ON_400)
74 | + && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {
75 | + throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),
76 | + error_code::HTTP_PROTOCOL_ERROR);
77 | + }
78 | + break;
79 | + case 403: // Forbidden
80 | + if (getOption()->getAsBool(PREF_RETRY_ON_403)
81 | + && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {
82 | + throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),
83 | + error_code::HTTP_PROTOCOL_ERROR);
84 | + }
85 | + break;
86 | + case 406: // Not Acceptable
87 | + if (getOption()->getAsBool(PREF_RETRY_ON_406)
88 | + && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {
89 | + throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),
90 | + error_code::HTTP_PROTOCOL_ERROR);
91 | + }
92 | + break;
93 | + case 408: // Request Timeout
94 | + case 429: // Too Many Requests
95 | + case 502: // Bad Gateway
96 | + case 503: // Service Unavailable
97 | + case 507: // Insufficient Storage
98 | + case 520: // https://github.com/aria2/aria2/issues/1229
99 | + case 521: // https://github.com/aria2/aria2/issues/1229
100 | // Only retry if pretry-wait > 0. Hammering 'busy' server is not
101 | // a good idea.
102 | if (getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {
103 | @@ -230,12 +256,16 @@ bool HttpSkipResponseCommand::processResponse()
104 | }
105 | throw DL_ABORT_EX2(fmt(EX_BAD_STATUS, statusCode),
106 | error_code::HTTP_SERVICE_UNAVAILABLE);
107 | - case 504:
108 | + case 504: // Gateway Timeout
109 | // This is Gateway Timeout, so try again
110 | throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),
111 | error_code::HTTP_SERVICE_UNAVAILABLE);
112 | };
113 | -
114 | + if (getOption()->getAsBool(PREF_RETRY_ON_UNKNOWN)
115 | + && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {
116 | + throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),
117 | + error_code::HTTP_PROTOCOL_ERROR);
118 | + }
119 | throw DL_ABORT_EX2(fmt(EX_BAD_STATUS, statusCode),
120 | error_code::HTTP_PROTOCOL_ERROR);
121 | }
122 | diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
123 | index 5768f7b..decb03e 100644
124 | --- a/src/OptionHandlerFactory.cc
125 | +++ b/src/OptionHandlerFactory.cc
126 | @@ -934,6 +934,46 @@ std::vector OptionHandlerFactory::createOptionHandlers()
127 | op->setChangeOptionForReserved(true);
128 | handlers.push_back(op);
129 | }
130 | + {
131 | + OptionHandler* op(new BooleanOptionHandler(
132 | + PREF_RETRY_ON_400, TEXT_RETRY_ON_400, A2_V_FALSE, OptionHandler::OPT_ARG));
133 | + op->addTag(TAG_ADVANCED);
134 | + op->addTag(TAG_HTTP);
135 | + op->setInitialOption(true);
136 | + op->setChangeGlobalOption(true);
137 | + op->setChangeOptionForReserved(true);
138 | + handlers.push_back(op);
139 | + }
140 | + {
141 | + OptionHandler* op(new BooleanOptionHandler(
142 | + PREF_RETRY_ON_403, TEXT_RETRY_ON_403, A2_V_FALSE, OptionHandler::OPT_ARG));
143 | + op->addTag(TAG_ADVANCED);
144 | + op->addTag(TAG_HTTP);
145 | + op->setInitialOption(true);
146 | + op->setChangeGlobalOption(true);
147 | + op->setChangeOptionForReserved(true);
148 | + handlers.push_back(op);
149 | + }
150 | + {
151 | + OptionHandler* op(new BooleanOptionHandler(
152 | + PREF_RETRY_ON_406, TEXT_RETRY_ON_406, A2_V_FALSE, OptionHandler::OPT_ARG));
153 | + op->addTag(TAG_ADVANCED);
154 | + op->addTag(TAG_HTTP);
155 | + op->setInitialOption(true);
156 | + op->setChangeGlobalOption(true);
157 | + op->setChangeOptionForReserved(true);
158 | + handlers.push_back(op);
159 | + }
160 | + {
161 | + OptionHandler* op(new BooleanOptionHandler(
162 | + PREF_RETRY_ON_UNKNOWN, TEXT_RETRY_ON_UNKNOWN, A2_V_FALSE, OptionHandler::OPT_ARG));
163 | + op->addTag(TAG_ADVANCED);
164 | + op->addTag(TAG_HTTP);
165 | + op->setInitialOption(true);
166 | + op->setChangeGlobalOption(true);
167 | + op->setChangeOptionForReserved(true);
168 | + handlers.push_back(op);
169 | + }
170 | {
171 | OptionHandler* op(new BooleanOptionHandler(
172 | PREF_REUSE_URI, TEXT_REUSE_URI, A2_V_TRUE, OptionHandler::OPT_ARG));
173 | diff --git a/src/prefs.cc b/src/prefs.cc
174 | index 937e927..33eff91 100644
175 | --- a/src/prefs.cc
176 | +++ b/src/prefs.cc
177 | @@ -327,6 +327,14 @@ PrefPtr PREF_ENABLE_ASYNC_DNS6 = makePref("enable-async-dns6");
178 | PrefPtr PREF_MAX_DOWNLOAD_RESULT = makePref("max-download-result");
179 | // value: 1*digit
180 | PrefPtr PREF_RETRY_WAIT = makePref("retry-wait");
181 | +// value: true | false
182 | +PrefPtr PREF_RETRY_ON_400 = makePref("retry-on-400");
183 | +// value: true | false
184 | +PrefPtr PREF_RETRY_ON_403 = makePref("retry-on-403");
185 | +// value: true | false
186 | +PrefPtr PREF_RETRY_ON_406 = makePref("retry-on-406");
187 | +// value: true | false
188 | +PrefPtr PREF_RETRY_ON_UNKNOWN = makePref("retry-on-unknown");
189 | // value: string
190 | PrefPtr PREF_ASYNC_DNS_SERVER = makePref("async-dns-server");
191 | // value: true | false
192 | diff --git a/src/prefs.h b/src/prefs.h
193 | index e1f8397..019e774 100644
194 | --- a/src/prefs.h
195 | +++ b/src/prefs.h
196 | @@ -280,6 +280,14 @@ extern PrefPtr PREF_ENABLE_ASYNC_DNS6;
197 | extern PrefPtr PREF_MAX_DOWNLOAD_RESULT;
198 | // value: 1*digit
199 | extern PrefPtr PREF_RETRY_WAIT;
200 | +// value: true | false
201 | +extern PrefPtr PREF_RETRY_ON_400;
202 | +// value: true | false
203 | +extern PrefPtr PREF_RETRY_ON_403;
204 | +// value: true | false
205 | +extern PrefPtr PREF_RETRY_ON_406;
206 | +// value: true | false
207 | +extern PrefPtr PREF_RETRY_ON_UNKNOWN;
208 | // value: string
209 | extern PrefPtr PREF_ASYNC_DNS_SERVER;
210 | // value: true | false
211 | diff --git a/src/usage_text.h b/src/usage_text.h
212 | index d73b50d..75d34a0 100644
213 | --- a/src/usage_text.h
214 | +++ b/src/usage_text.h
215 | @@ -64,6 +64,22 @@
216 | _(" --retry-wait=SEC Set the seconds to wait between retries. \n" \
217 | " With SEC > 0, aria2 will retry download when the\n" \
218 | " HTTP server returns 503 response.")
219 | +#define TEXT_RETRY_ON_400 \
220 | + _(" --retry-on-400[=true|false] Configure whether retry or not when\n" \
221 | + " HTTP server returns 400 Bad Request.\n" \
222 | + " Only effective if retry-wait > 0.")
223 | +#define TEXT_RETRY_ON_403 \
224 | + _(" --retry-on-403[=true|false] Configure whether retry or not when\n" \
225 | + " HTTP server returns 403 Forbidden.\n" \
226 | + " Only effective if retry-wait > 0.")
227 | +#define TEXT_RETRY_ON_406 \
228 | + _(" --retry-on-406[=true|false] Configure whether retry or not when\n" \
229 | + " HTTP server returns 406 Not Acceptable.\n" \
230 | + " Only effective if retry-wait > 0.")
231 | +#define TEXT_RETRY_ON_UNKNOWN \
232 | + _(" --retry-on-unknown[=true|false] Configure whether retry or not when\n" \
233 | + " HTTP server returns unknown status code.\n" \
234 | + " Only effective if retry-wait > 0.")
235 | #define TEXT_TIMEOUT \
236 | _(" -t, --timeout=SEC Set timeout in seconds.")
237 | #define TEXT_MAX_TRIES \
238 | --
239 | 2.18.0
240 |
241 |
--------------------------------------------------------------------------------
/aria2-0006-feature-config-add-os-info-for-newer-windows.patch:
--------------------------------------------------------------------------------
1 | From d36a15f8330057cee7c32b4035c8824bb03787af Mon Sep 17 00:00:00 2001
2 | From: myfreeer
3 | Date: Fri, 10 Aug 2018 11:31:06 +0800
4 | Subject: [PATCH] FeatureConfig: add os info for newer windows
5 |
6 | getOperatingSystemInfo: partial refactor
7 | replace GetVersionEx with RtlGetVersion, and link with ntdll
8 | ---
9 | configure.ac | 2 +-
10 | src/FeatureConfig.cc | 69 +++++++++++++++++++++++++++-----------------
11 | src/FeatureConfig.h | 14 +++++++++
12 | 3 files changed, 58 insertions(+), 27 deletions(-)
13 |
14 | diff --git a/configure.ac b/configure.ac
15 | index 1ab1d32..55c5c07 100644
16 | --- a/configure.ac
17 | +++ b/configure.ac
18 | @@ -34,7 +34,7 @@ EXTRALIBS=
19 | case "$host" in
20 | *mingw*)
21 | win_build=yes
22 | - EXTRALIBS="-lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi $EXTRALIBS"
23 | + EXTRALIBS="-lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi -lntdll $EXTRALIBS"
24 | # Define _POSIX_C_SOURCE to 1. This makes {asc,local}time_r
25 | # available from even without (un)helpful interference
26 | # from , and also defines __USE_MINGW_ANSI_STDIO.
27 | diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc
28 | index 2b43c8b..e477aa9 100644
29 | --- a/src/FeatureConfig.cc
30 | +++ b/src/FeatureConfig.cc
31 | @@ -305,8 +305,8 @@ std::string getOperatingSystemInfo()
32 | #ifdef _WIN32
33 | std::stringstream rv;
34 | rv << "Windows ";
35 | - OSVERSIONINFOEX ovi = {sizeof(OSVERSIONINFOEX)};
36 | - if (!GetVersionEx((LPOSVERSIONINFO)&ovi)) {
37 | + RTL_OSVERSIONINFOEXW ovi = {sizeof(RTL_OSVERSIONINFOEXW)};
38 | + if (RtlGetVersion((PRTL_OSVERSIONINFOEXW)&ovi) != STATUS_SUCCESS) {
39 | rv << "Unknown";
40 | return rv.str();
41 | }
42 | @@ -314,37 +314,54 @@ std::string getOperatingSystemInfo()
43 | rv << "Legacy, probably XP";
44 | return rv.str();
45 | }
46 | - switch (ovi.dwMinorVersion) {
47 | - case 0:
48 | - if (ovi.wProductType == VER_NT_WORKSTATION) {
49 | + DWORD dwVersion = (ovi.dwMajorVersion << 24U) | (ovi.dwMinorVersion << 8U) |
50 | + ovi.wProductType;
51 | +#define WIN32_VERSION(major, minor, type) \
52 | + ((major##U << 24U) | (minor##U << 8U) | type)
53 | + switch (dwVersion) {
54 | + case WIN32_VERSION(6, 0, VER_NT_WORKSTATION):
55 | rv << "Vista";
56 | - }
57 | - else {
58 | + break;
59 | + case WIN32_VERSION(6, 0, VER_NT_SERVER):
60 | rv << "Server 2008";
61 | - }
62 | - break;
63 | -
64 | - case 1:
65 | - if (ovi.wProductType == VER_NT_WORKSTATION) {
66 | + break;
67 | + case WIN32_VERSION(6, 1, VER_NT_WORKSTATION):
68 | rv << "7";
69 | - }
70 | - else {
71 | + break;
72 | + case WIN32_VERSION(6, 1, VER_NT_SERVER):
73 | rv << "Server 2008 R2";
74 | - }
75 | - break;
76 | -
77 | + break;
78 | + case WIN32_VERSION(6, 2, VER_NT_WORKSTATION):
79 | + rv << "8";
80 | + break;
81 | + case WIN32_VERSION(6, 2, VER_NT_SERVER):
82 | + rv << "Server 2012";
83 | + break;
84 | + case WIN32_VERSION(6, 3, VER_NT_WORKSTATION):
85 | + rv << "8.1";
86 | + break;
87 | + case WIN32_VERSION(6, 3, VER_NT_SERVER):
88 | + rv << "Server 2012 R2";
89 | + break;
90 | + case WIN32_VERSION(10, 0, VER_NT_WORKSTATION):
91 | + rv << "10";
92 | + break;
93 | + case WIN32_VERSION(10, 0, VER_NT_SERVER):
94 | + rv << "Server 2016";
95 | + break;
96 | default:
97 | - // Windows above 6.2 does not actually say so. :p
98 | + // Windows above 6.2 does not actually say so. :p
99 |
100 | - rv << ovi.dwMajorVersion;
101 | - if (ovi.dwMinorVersion) {
102 | - rv << "." << ovi.dwMinorVersion;
103 | - }
104 | - if (ovi.wProductType != VER_NT_WORKSTATION) {
105 | - rv << " Server";
106 | - }
107 | - break;
108 | + rv << ovi.dwMajorVersion;
109 | + if (ovi.dwMinorVersion) {
110 | + rv << "." << ovi.dwMinorVersion;
111 | + }
112 | + if (ovi.wProductType != VER_NT_WORKSTATION) {
113 | + rv << " Server";
114 | + }
115 | + break;
116 | }
117 | +#undef WIN32_VERSION
118 | if (ovi.szCSDVersion[0]) {
119 | rv << " (" << ovi.szCSDVersion << ")";
120 | }
121 | diff --git a/src/FeatureConfig.h b/src/FeatureConfig.h
122 | index 214dca2..55a3975 100644
123 | --- a/src/FeatureConfig.h
124 | +++ b/src/FeatureConfig.h
125 | @@ -76,4 +76,18 @@ std::string getOperatingSystemInfo();
126 |
127 | } // namespace aria2
128 |
129 | +#ifdef _WIN32
130 | +
131 | +typedef LONG NTSTATUS;
132 | +
133 | +#ifndef STATUS_SUCCESS
134 | +#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth
135 | +#endif
136 | +
137 | +extern "C" NTSYSAPI NTSTATUS NTAPI RtlGetVersion(
138 | + _Out_ PRTL_OSVERSIONINFOEXW lpVersionInformation
139 | +);
140 | +
141 | +#endif // _WIN32
142 | +
143 | #endif // D_FEATURE_CONFIG_H
144 | --
145 | 2.18.0
146 |
147 |
--------------------------------------------------------------------------------
/build-aria2.sh:
--------------------------------------------------------------------------------
1 | #!bash
2 | case $MSYSTEM in
3 | MINGW32)
4 | export MINGW_PACKAGE_PREFIX=mingw-w64-i686
5 | export HOST=i686-w64-mingw32
6 | ;;
7 | MINGW64)
8 | export MINGW_PACKAGE_PREFIX=mingw-w64-x86_64
9 | export HOST=x86_64-w64-mingw32
10 | ;;
11 | esac
12 |
13 | # workaround git user name and email not set
14 | GIT_USER_NAME="$(git config --global user.name)"
15 | GIT_USER_EMAIL="$(git config --global user.email)"
16 | if [[ "${GIT_USER_NAME}" = "" ]]; then
17 | git config --global user.name "Name"
18 | fi
19 | if [[ "${GIT_USER_EMAIL}" = "" ]]; then
20 | git config --global user.email "you@example.com"
21 | fi
22 |
23 | pacman -S --noconfirm --needed $MINGW_PACKAGE_PREFIX-gcc \
24 | $MINGW_PACKAGE_PREFIX-winpthreads
25 |
26 | PREFIX=/usr/local/$HOST
27 | CPUCOUNT=$(grep -c ^processor /proc/cpuinfo)
28 | curl_opts=(/usr/bin/curl --connect-timeout 15 --retry 3
29 | --retry-delay 5 --silent --location --insecure --fail)
30 |
31 | clean_html_index() {
32 | local url="$1"
33 | local filter="${2:-(?<=href=\")[^\"]+\.(tar\.(gz|bz2|xz)|7z)}"
34 | "${curl_opts[@]}" -l "$url" | grep -ioP "$filter" | sort -uV
35 | }
36 |
37 | clean_html_index_sqlite() {
38 | local url="$1"
39 | local filter="${2:-(\d+\/sqlite-autoconf-\d+\.tar\.gz)}"
40 | "${curl_opts[@]}" -l "$url" | grep -ioP "$filter" | sort -uV | tail -1
41 | }
42 |
43 | get_last_version() {
44 | local filelist="$1"
45 | local filter="$2"
46 | local version="$3"
47 | local ret
48 | ret="$(echo "$filelist" | /usr/bin/grep -E "$filter" | sort -V | tail -1)"
49 | [[ -n "$version" ]] && ret="$(echo "$ret" | /usr/bin/grep -oP "$version")"
50 | echo "$ret"
51 | }
52 |
53 | # expat
54 | expat_ver="$(clean_html_index https://sourceforge.net/projects/expat/files/expat/ 'expat/[0-9]+\.[0-9]+\.[0-9]+')"
55 | expat_ver="$(get_last_version "${expat_ver}" expat '2\.\d+\.\d+')"
56 | expat_ver="${expat_ver:-2.2.10}"
57 | wget -c --no-check-certificate "https://downloads.sourceforge.net/project/expat/expat/${expat_ver}/expat-${expat_ver}.tar.bz2"
58 | tar xf "expat-${expat_ver}.tar.bz2"
59 | cd "expat-${expat_ver}" || exit 1
60 | ./configure \
61 | --disable-shared \
62 | --enable-static \
63 | --prefix=/usr/local/$HOST \
64 | --host=$HOST
65 | make install -j$CPUCOUNT
66 | cd ..
67 | rm -rf "expat-${expat_ver}"
68 |
69 | # sqlite
70 | sqlite_ver=$(clean_html_index_sqlite "https://www.sqlite.org/download.html")
71 | [[ ! "$sqlite_ver" ]] && sqlite_ver="2020/sqlite-autoconf-3340000.tar.gz"
72 | sqlite_file=$(echo ${sqlite_ver} | grep -ioP "(sqlite-autoconf-\d+\.tar\.gz)")
73 | wget -c --no-check-certificate "https://www.sqlite.org/${sqlite_ver}"
74 | tar xf "${sqlite_file}"
75 | echo ${sqlite_ver}
76 | sqlite_name=$(echo ${sqlite_ver} | grep -ioP "(sqlite-autoconf-\d+)")
77 | cd "${sqlite_name}" || exit 1
78 | ./configure \
79 | --disable-shared \
80 | --enable-static \
81 | --prefix=/usr/local/$HOST \
82 | --host=$HOST
83 | make install -j$CPUCOUNT
84 | cd ..
85 | rm -rf "${sqlite_name}"
86 |
87 | # c-ares: Async DNS support
88 | [[ ! "$cares_ver" ]] &&
89 | cares_ver="$(clean_html_index https://c-ares.org/)" &&
90 | cares_ver="$(get_last_version "$cares_ver" c-ares "1\.\d+\.\d")"
91 | echo "current latest c-ares: ${cares_ver}"
92 | cares_ver="1.19.1"
93 | echo "c-ares-${cares_ver}"
94 | # for newer version:
95 | # https://github.com/c-ares/c-ares/releases/download/v${cares_ver}/c-ares-${cares_ver}.tar.gz
96 | wget -c --no-check-certificate "https://github.com/c-ares/c-ares/releases/download/cares-1_19_1/c-ares-1.19.1.tar.gz"
97 | tar xf "c-ares-${cares_ver}.tar.gz"
98 | cd "c-ares-${cares_ver}" || exit 1
99 | # https://github.com/c-ares/c-ares/issues/384
100 | # https://github.com/c-ares/c-ares/commit/c35f8ff50710cd38776e9560389504dbd96307fa
101 | if [ "${cares_ver}" = "1.17.1" ]; then
102 | patch -p1 < ../c-ares-1.17.1-fix-autotools-static-library.patch
103 | autoreconf -fi || autoreconf -fiv
104 | fi
105 | ./configure \
106 | --disable-shared \
107 | --enable-static \
108 | --without-random \
109 | --disable-tests \
110 | --prefix=/usr/local/$HOST \
111 | --host=$HOST
112 | make install -j$CPUCOUNT
113 | cd ..
114 | rm -rf "c-ares-${cares_ver}"
115 |
116 | # libssh2
117 | [[ ! "$ssh_ver" ]] &&
118 | ssh_ver="$(clean_html_index https://libssh2.org/download/)" &&
119 | ssh_ver="$(get_last_version "$ssh_ver" tar.gz "1\.\d+\.\d")"
120 | ssh_ver="${ssh_ver:-1.9.0}"
121 | echo "${ssh_ver}"
122 | wget -c --no-check-certificate "https://libssh2.org/download/libssh2-${ssh_ver}.tar.gz"
123 | tar xf "libssh2-${ssh_ver}.tar.gz"
124 | cd "libssh2-${ssh_ver}"
125 | # https://github.com/libssh2/libssh2/pull/479
126 | # https://github.com/libssh2/libssh2/commit/ba149e804ef653cc05ed9803dfc94519ce9328f7
127 | if [ "${ssh_ver}" = "1.9.0" ]; then
128 | patch -p1 < ../libssh2-1.9.0-wincng-multiple-definition.patch
129 | fi
130 | ./configure \
131 | --disable-shared \
132 | --enable-static \
133 | --prefix=/usr/local/$HOST \
134 | --host=$HOST \
135 | --with-crypto=wincng \
136 | LIBS="-lws2_32"
137 | make install -j$CPUCOUNT
138 | cd ..
139 | rm -rf "libssh2-${ssh_ver}"
140 |
141 | if [[ -d aria2 ]]; then
142 | cd aria2
143 | git checkout master || git checkout HEAD
144 | git reset --hard origin || git reset --hard
145 | git pull
146 | else
147 | git clone https://github.com/aria2/aria2 --depth=1 --config http.sslVerify=false
148 | cd aria2 || exit 1
149 | fi
150 | git checkout -b patch
151 | git am -3 ../aria2-*.patch
152 |
153 | autoreconf -fi || autoreconf -fiv
154 | ./configure \
155 | --host=$HOST \
156 | --prefix=$PREFIX \
157 | --without-included-gettext \
158 | --disable-nls \
159 | --with-libcares \
160 | --without-gnutls \
161 | --without-openssl \
162 | --with-sqlite3 \
163 | --without-libxml2 \
164 | --with-libexpat \
165 | --with-libz \
166 | --with-libgmp \
167 | --with-libssh2 \
168 | --without-libgcrypt \
169 | --without-libnettle \
170 | --with-cppunit-prefix=$PREFIX \
171 | ARIA2_STATIC=yes \
172 | CPPFLAGS="-I$PREFIX/include" \
173 | LDFLAGS="-L$PREFIX/lib -Wl,--gc-sections,--build-id=none" \
174 | PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
175 | make -j$CPUCOUNT
176 | strip -s src/aria2c.exe
177 | git checkout master
178 | git branch patch -D
179 | cd ..
180 |
--------------------------------------------------------------------------------
/c-ares-1.17.1-fix-autotools-static-library.patch:
--------------------------------------------------------------------------------
1 | From c35f8ff50710cd38776e9560389504dbd96307fa Mon Sep 17 00:00:00 2001
2 | From: bradh352
3 | Date: Mon, 23 Nov 2020 08:07:30 -0500
4 | Subject: [PATCH] Win32: Fix tools build with autotools static library When
5 | c-ares is being built as static on Win32, CARES_STATICLIB must be defined,
6 | but it wasn't being pulled in for the tools.
7 |
8 | Fixes: #384
9 | Fix By: Brad House (@bradh352)
10 | ---
11 | src/tools/Makefile.am | 4 ++++
12 | 1 file changed, 4 insertions(+)
13 |
14 | diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
15 | index 3fe28143..c503723c 100644
16 | --- a/src/tools/Makefile.am
17 | +++ b/src/tools/Makefile.am
18 | @@ -15,6 +15,10 @@ AM_CPPFLAGS = -I$(top_builddir)/include \
19 | -I$(top_srcdir)/include \
20 | -I$(top_srcdir)/src/lib
21 |
22 | +if USE_CPPFLAG_CARES_STATICLIB
23 | +AM_CPPFLAGS += $(CPPFLAG_CARES_STATICLIB)
24 | +endif
25 | +
26 | include Makefile.inc
27 |
28 | LDADD = $(top_builddir)/src/lib/libcares.la
29 |
--------------------------------------------------------------------------------
/init-msys2.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | pushd "%~dp0"
3 | setlocal EnableExtensions EnableDelayedExpansion
4 |
5 | :Deps
6 | set MSYSTEM=MINGW64
7 | REM MINGW64 means 64-bit build; MINGW32 means 32-bit build;
8 |
9 | set msysbin=msys64\usr\bin
10 | set sh=%msysbin%\bash
11 | set pacman=%msysbin%\pacman
12 | if exist msys64\mingw64.exe goto :Update
13 | if exist busybox.exe if exist msys2-x86_64-latest.tar.xz goto :Extract
14 | echo. dependency broken. download msys2-x86_64-latest.tar.xz and busybox.exe and put them in the same folder of the script.
15 | echo. download busybox.exe from https://frippery.org/files/busybox/busybox.exe
16 | echo. and deonload msys2-x86_64-latest.tar.xz from http://repo.msys2.org/distrib/msys2-x86_64-latest.tar.xz
17 | pause
18 | exit /B -1
19 |
20 | :Extract
21 | busybox tar -Jxvf msys2-x86_64-latest.tar.xz
22 |
23 | :Init
24 | %sh% -lc "pacman-key --init && exit" 2>&1 | busybox tee -a init.log
25 |
26 | :Chi_Mirror
27 | for %%i in (mirrorlist.mingw32 mirrorlist.mingw64 mirrorlist.msys) do if exist %%i copy /y %%i msys64\etc\pacman.d\
28 |
29 | :Update
30 | %pacman% -Syyuu --needed --noconfirm --ask=20 2>&1 | busybox tee -a update.log
31 | %pacman% -Suu --needed --noconfirm --ask=20 2>&1 | busybox tee -a update.log
32 |
33 | :Install
34 | %pacman% -S --needed --noconfirm base-devel zlib-devel sqlite git unzip zip tar gmp gmp-devel libssh2 libssh2-devel openssl-devel 2>&1 | busybox tee -a install.log
35 | %pacman% -Sc --noconfirm 2>&1 | busybox tee -a install.log
36 |
37 | :Clone
38 | %sh% -lc "if [[ -d ~/aria2 ]]; then cd aria2; git pull; else git clone https://github.com/myfreeer/aria2-build-msys2.git aria2; cd aria2; git pull; fi" 2>&1 | busybox tee -a clone.log
39 |
40 | :Build
41 | %sh% -lc "cd ~/aria2 && exec ./build-aria2.sh" 2>&1 | busybox tee -a build.log
42 | pause
43 |
--------------------------------------------------------------------------------
/libssh2-1.9.0-wincng-multiple-definition.patch:
--------------------------------------------------------------------------------
1 | From ba149e804ef653cc05ed9803dfc94519ce9328f7 Mon Sep 17 00:00:00 2001
2 | From: Marc Hoersken
3 | Date: Sun, 31 May 2020 21:24:58 +0200
4 | Subject: [PATCH] wincng: fix multiple definition of `_libssh2_wincng' (#479)
5 |
6 | Add missing include guard and move global state
7 | from header to source file by using extern.
8 | ---
9 | src/wincng.c | 2 ++
10 | src/wincng.h | 8 ++++++--
11 | 2 files changed, 8 insertions(+), 2 deletions(-)
12 |
13 | diff --git a/src/wincng.c b/src/wincng.c
14 | index 4bebc6407..dffd2ed36 100755
15 | --- a/src/wincng.c
16 | +++ b/src/wincng.c
17 | @@ -208,6 +208,8 @@
18 | * Windows CNG backend: Generic functions
19 | */
20 |
21 | +struct _libssh2_wincng_ctx _libssh2_wincng;
22 | +
23 | void
24 | _libssh2_wincng_init(void)
25 | {
26 | diff --git a/src/wincng.h b/src/wincng.h
27 | index f5838d0e6..c817f090c 100755
28 | --- a/src/wincng.h
29 | +++ b/src/wincng.h
30 | @@ -1,5 +1,7 @@
31 | +#ifndef __LIBSSH2_WINCNG_H
32 | +#define __LIBSSH2_WINCNG_H
33 | /*
34 | - * Copyright (C) 2013-2015 Marc Hoersken
35 | + * Copyright (C) 2013-2020 Marc Hoersken
36 | * All rights reserved.
37 | *
38 | * Redistribution and use in source and binary forms,
39 | @@ -101,7 +103,7 @@ struct _libssh2_wincng_ctx {
40 | BCRYPT_ALG_HANDLE hAlg3DES_CBC;
41 | };
42 |
43 | -struct _libssh2_wincng_ctx _libssh2_wincng;
44 | +extern struct _libssh2_wincng_ctx _libssh2_wincng;
45 |
46 |
47 | /*******************************************************************/
48 | @@ -569,3 +571,5 @@ _libssh2_dh_secret(_libssh2_dh_ctx *dhctx, _libssh2_bn *secret,
49 | _libssh2_bn *f, _libssh2_bn *p);
50 | extern void
51 | _libssh2_dh_dtor(_libssh2_dh_ctx *dhctx);
52 | +
53 | +#endif /* __LIBSSH2_WINCNG_H */
54 |
--------------------------------------------------------------------------------