···11+ GNU GENERAL PUBLIC LICENSE
22+ Version 3, 29 June 2007
33+44+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
55+ Everyone is permitted to copy and distribute verbatim copies
66+ of this license document, but changing it is not allowed.
77+88+ Preamble
99+1010+ The GNU General Public License is a free, copyleft license for
1111+software and other kinds of works.
1212+1313+ The licenses for most software and other practical works are designed
1414+to take away your freedom to share and change the works. By contrast,
1515+the GNU General Public License is intended to guarantee your freedom to
1616+share and change all versions of a program--to make sure it remains free
1717+software for all its users. We, the Free Software Foundation, use the
1818+GNU General Public License for most of our software; it applies also to
1919+any other work released this way by its authors. You can apply it to
2020+your programs, too.
2121+2222+ When we speak of free software, we are referring to freedom, not
2323+price. Our General Public Licenses are designed to make sure that you
2424+have the freedom to distribute copies of free software (and charge for
2525+them if you wish), that you receive source code or can get it if you
2626+want it, that you can change the software or use pieces of it in new
2727+free programs, and that you know you can do these things.
2828+2929+ To protect your rights, we need to prevent others from denying you
3030+these rights or asking you to surrender the rights. Therefore, you have
3131+certain responsibilities if you distribute copies of the software, or if
3232+you modify it: responsibilities to respect the freedom of others.
3333+3434+ For example, if you distribute copies of such a program, whether
3535+gratis or for a fee, you must pass on to the recipients the same
3636+freedoms that you received. You must make sure that they, too, receive
3737+or can get the source code. And you must show them these terms so they
3838+know their rights.
3939+4040+ Developers that use the GNU GPL protect your rights with two steps:
4141+(1) assert copyright on the software, and (2) offer you this License
4242+giving you legal permission to copy, distribute and/or modify it.
4343+4444+ For the developers' and authors' protection, the GPL clearly explains
4545+that there is no warranty for this free software. For both users' and
4646+authors' sake, the GPL requires that modified versions be marked as
4747+changed, so that their problems will not be attributed erroneously to
4848+authors of previous versions.
4949+5050+ Some devices are designed to deny users access to install or run
5151+modified versions of the software inside them, although the manufacturer
5252+can do so. This is fundamentally incompatible with the aim of
5353+protecting users' freedom to change the software. The systematic
5454+pattern of such abuse occurs in the area of products for individuals to
5555+use, which is precisely where it is most unacceptable. Therefore, we
5656+have designed this version of the GPL to prohibit the practice for those
5757+products. If such problems arise substantially in other domains, we
5858+stand ready to extend this provision to those domains in future versions
5959+of the GPL, as needed to protect the freedom of users.
6060+6161+ Finally, every program is threatened constantly by software patents.
6262+States should not allow patents to restrict development and use of
6363+software on general-purpose computers, but in those that do, we wish to
6464+avoid the special danger that patents applied to a free program could
6565+make it effectively proprietary. To prevent this, the GPL assures that
6666+patents cannot be used to render the program non-free.
6767+6868+ The precise terms and conditions for copying, distribution and
6969+modification follow.
7070+7171+ TERMS AND CONDITIONS
7272+7373+ 0. Definitions.
7474+7575+ "This License" refers to version 3 of the GNU General Public License.
7676+7777+ "Copyright" also means copyright-like laws that apply to other kinds of
7878+works, such as semiconductor masks.
7979+8080+ "The Program" refers to any copyrightable work licensed under this
8181+License. Each licensee is addressed as "you". "Licensees" and
8282+"recipients" may be individuals or organizations.
8383+8484+ To "modify" a work means to copy from or adapt all or part of the work
8585+in a fashion requiring copyright permission, other than the making of an
8686+exact copy. The resulting work is called a "modified version" of the
8787+earlier work or a work "based on" the earlier work.
8888+8989+ A "covered work" means either the unmodified Program or a work based
9090+on the Program.
9191+9292+ To "propagate" a work means to do anything with it that, without
9393+permission, would make you directly or secondarily liable for
9494+infringement under applicable copyright law, except executing it on a
9595+computer or modifying a private copy. Propagation includes copying,
9696+distribution (with or without modification), making available to the
9797+public, and in some countries other activities as well.
9898+9999+ To "convey" a work means any kind of propagation that enables other
100100+parties to make or receive copies. Mere interaction with a user through
101101+a computer network, with no transfer of a copy, is not conveying.
102102+103103+ An interactive user interface displays "Appropriate Legal Notices"
104104+to the extent that it includes a convenient and prominently visible
105105+feature that (1) displays an appropriate copyright notice, and (2)
106106+tells the user that there is no warranty for the work (except to the
107107+extent that warranties are provided), that licensees may convey the
108108+work under this License, and how to view a copy of this License. If
109109+the interface presents a list of user commands or options, such as a
110110+menu, a prominent item in the list meets this criterion.
111111+112112+ 1. Source Code.
113113+114114+ The "source code" for a work means the preferred form of the work
115115+for making modifications to it. "Object code" means any non-source
116116+form of a work.
117117+118118+ A "Standard Interface" means an interface that either is an official
119119+standard defined by a recognized standards body, or, in the case of
120120+interfaces specified for a particular programming language, one that
121121+is widely used among developers working in that language.
122122+123123+ The "System Libraries" of an executable work include anything, other
124124+than the work as a whole, that (a) is included in the normal form of
125125+packaging a Major Component, but which is not part of that Major
126126+Component, and (b) serves only to enable use of the work with that
127127+Major Component, or to implement a Standard Interface for which an
128128+implementation is available to the public in source code form. A
129129+"Major Component", in this context, means a major essential component
130130+(kernel, window system, and so on) of the specific operating system
131131+(if any) on which the executable work runs, or a compiler used to
132132+produce the work, or an object code interpreter used to run it.
133133+134134+ The "Corresponding Source" for a work in object code form means all
135135+the source code needed to generate, install, and (for an executable
136136+work) run the object code and to modify the work, including scripts to
137137+control those activities. However, it does not include the work's
138138+System Libraries, or general-purpose tools or generally available free
139139+programs which are used unmodified in performing those activities but
140140+which are not part of the work. For example, Corresponding Source
141141+includes interface definition files associated with source files for
142142+the work, and the source code for shared libraries and dynamically
143143+linked subprograms that the work is specifically designed to require,
144144+such as by intimate data communication or control flow between those
145145+subprograms and other parts of the work.
146146+147147+ The Corresponding Source need not include anything that users
148148+can regenerate automatically from other parts of the Corresponding
149149+Source.
150150+151151+ The Corresponding Source for a work in source code form is that
152152+same work.
153153+154154+ 2. Basic Permissions.
155155+156156+ All rights granted under this License are granted for the term of
157157+copyright on the Program, and are irrevocable provided the stated
158158+conditions are met. This License explicitly affirms your unlimited
159159+permission to run the unmodified Program. The output from running a
160160+covered work is covered by this License only if the output, given its
161161+content, constitutes a covered work. This License acknowledges your
162162+rights of fair use or other equivalent, as provided by copyright law.
163163+164164+ You may make, run and propagate covered works that you do not
165165+convey, without conditions so long as your license otherwise remains
166166+in force. You may convey covered works to others for the sole purpose
167167+of having them make modifications exclusively for you, or provide you
168168+with facilities for running those works, provided that you comply with
169169+the terms of this License in conveying all material for which you do
170170+not control copyright. Those thus making or running the covered works
171171+for you must do so exclusively on your behalf, under your direction
172172+and control, on terms that prohibit them from making any copies of
173173+your copyrighted material outside their relationship with you.
174174+175175+ Conveying under any other circumstances is permitted solely under
176176+the conditions stated below. Sublicensing is not allowed; section 10
177177+makes it unnecessary.
178178+179179+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180180+181181+ No covered work shall be deemed part of an effective technological
182182+measure under any applicable law fulfilling obligations under article
183183+11 of the WIPO copyright treaty adopted on 20 December 1996, or
184184+similar laws prohibiting or restricting circumvention of such
185185+measures.
186186+187187+ When you convey a covered work, you waive any legal power to forbid
188188+circumvention of technological measures to the extent such circumvention
189189+is effected by exercising rights under this License with respect to
190190+the covered work, and you disclaim any intention to limit operation or
191191+modification of the work as a means of enforcing, against the work's
192192+users, your or third parties' legal rights to forbid circumvention of
193193+technological measures.
194194+195195+ 4. Conveying Verbatim Copies.
196196+197197+ You may convey verbatim copies of the Program's source code as you
198198+receive it, in any medium, provided that you conspicuously and
199199+appropriately publish on each copy an appropriate copyright notice;
200200+keep intact all notices stating that this License and any
201201+non-permissive terms added in accord with section 7 apply to the code;
202202+keep intact all notices of the absence of any warranty; and give all
203203+recipients a copy of this License along with the Program.
204204+205205+ You may charge any price or no price for each copy that you convey,
206206+and you may offer support or warranty protection for a fee.
207207+208208+ 5. Conveying Modified Source Versions.
209209+210210+ You may convey a work based on the Program, or the modifications to
211211+produce it from the Program, in the form of source code under the
212212+terms of section 4, provided that you also meet all of these conditions:
213213+214214+ a) The work must carry prominent notices stating that you modified
215215+ it, and giving a relevant date.
216216+217217+ b) The work must carry prominent notices stating that it is
218218+ released under this License and any conditions added under section
219219+ 7. This requirement modifies the requirement in section 4 to
220220+ "keep intact all notices".
221221+222222+ c) You must license the entire work, as a whole, under this
223223+ License to anyone who comes into possession of a copy. This
224224+ License will therefore apply, along with any applicable section 7
225225+ additional terms, to the whole of the work, and all its parts,
226226+ regardless of how they are packaged. This License gives no
227227+ permission to license the work in any other way, but it does not
228228+ invalidate such permission if you have separately received it.
229229+230230+ d) If the work has interactive user interfaces, each must display
231231+ Appropriate Legal Notices; however, if the Program has interactive
232232+ interfaces that do not display Appropriate Legal Notices, your
233233+ work need not make them do so.
234234+235235+ A compilation of a covered work with other separate and independent
236236+works, which are not by their nature extensions of the covered work,
237237+and which are not combined with it such as to form a larger program,
238238+in or on a volume of a storage or distribution medium, is called an
239239+"aggregate" if the compilation and its resulting copyright are not
240240+used to limit the access or legal rights of the compilation's users
241241+beyond what the individual works permit. Inclusion of a covered work
242242+in an aggregate does not cause this License to apply to the other
243243+parts of the aggregate.
244244+245245+ 6. Conveying Non-Source Forms.
246246+247247+ You may convey a covered work in object code form under the terms
248248+of sections 4 and 5, provided that you also convey the
249249+machine-readable Corresponding Source under the terms of this License,
250250+in one of these ways:
251251+252252+ a) Convey the object code in, or embodied in, a physical product
253253+ (including a physical distribution medium), accompanied by the
254254+ Corresponding Source fixed on a durable physical medium
255255+ customarily used for software interchange.
256256+257257+ b) Convey the object code in, or embodied in, a physical product
258258+ (including a physical distribution medium), accompanied by a
259259+ written offer, valid for at least three years and valid for as
260260+ long as you offer spare parts or customer support for that product
261261+ model, to give anyone who possesses the object code either (1) a
262262+ copy of the Corresponding Source for all the software in the
263263+ product that is covered by this License, on a durable physical
264264+ medium customarily used for software interchange, for a price no
265265+ more than your reasonable cost of physically performing this
266266+ conveying of source, or (2) access to copy the
267267+ Corresponding Source from a network server at no charge.
268268+269269+ c) Convey individual copies of the object code with a copy of the
270270+ written offer to provide the Corresponding Source. This
271271+ alternative is allowed only occasionally and noncommercially, and
272272+ only if you received the object code with such an offer, in accord
273273+ with subsection 6b.
274274+275275+ d) Convey the object code by offering access from a designated
276276+ place (gratis or for a charge), and offer equivalent access to the
277277+ Corresponding Source in the same way through the same place at no
278278+ further charge. You need not require recipients to copy the
279279+ Corresponding Source along with the object code. If the place to
280280+ copy the object code is a network server, the Corresponding Source
281281+ may be on a different server (operated by you or a third party)
282282+ that supports equivalent copying facilities, provided you maintain
283283+ clear directions next to the object code saying where to find the
284284+ Corresponding Source. Regardless of what server hosts the
285285+ Corresponding Source, you remain obligated to ensure that it is
286286+ available for as long as needed to satisfy these requirements.
287287+288288+ e) Convey the object code using peer-to-peer transmission, provided
289289+ you inform other peers where the object code and Corresponding
290290+ Source of the work are being offered to the general public at no
291291+ charge under subsection 6d.
292292+293293+ A separable portion of the object code, whose source code is excluded
294294+from the Corresponding Source as a System Library, need not be
295295+included in conveying the object code work.
296296+297297+ A "User Product" is either (1) a "consumer product", which means any
298298+tangible personal property which is normally used for personal, family,
299299+or household purposes, or (2) anything designed or sold for incorporation
300300+into a dwelling. In determining whether a product is a consumer product,
301301+doubtful cases shall be resolved in favor of coverage. For a particular
302302+product received by a particular user, "normally used" refers to a
303303+typical or common use of that class of product, regardless of the status
304304+of the particular user or of the way in which the particular user
305305+actually uses, or expects or is expected to use, the product. A product
306306+is a consumer product regardless of whether the product has substantial
307307+commercial, industrial or non-consumer uses, unless such uses represent
308308+the only significant mode of use of the product.
309309+310310+ "Installation Information" for a User Product means any methods,
311311+procedures, authorization keys, or other information required to install
312312+and execute modified versions of a covered work in that User Product from
313313+a modified version of its Corresponding Source. The information must
314314+suffice to ensure that the continued functioning of the modified object
315315+code is in no case prevented or interfered with solely because
316316+modification has been made.
317317+318318+ If you convey an object code work under this section in, or with, or
319319+specifically for use in, a User Product, and the conveying occurs as
320320+part of a transaction in which the right of possession and use of the
321321+User Product is transferred to the recipient in perpetuity or for a
322322+fixed term (regardless of how the transaction is characterized), the
323323+Corresponding Source conveyed under this section must be accompanied
324324+by the Installation Information. But this requirement does not apply
325325+if neither you nor any third party retains the ability to install
326326+modified object code on the User Product (for example, the work has
327327+been installed in ROM).
328328+329329+ The requirement to provide Installation Information does not include a
330330+requirement to continue to provide support service, warranty, or updates
331331+for a work that has been modified or installed by the recipient, or for
332332+the User Product in which it has been modified or installed. Access to a
333333+network may be denied when the modification itself materially and
334334+adversely affects the operation of the network or violates the rules and
335335+protocols for communication across the network.
336336+337337+ Corresponding Source conveyed, and Installation Information provided,
338338+in accord with this section must be in a format that is publicly
339339+documented (and with an implementation available to the public in
340340+source code form), and must require no special password or key for
341341+unpacking, reading or copying.
342342+343343+ 7. Additional Terms.
344344+345345+ "Additional permissions" are terms that supplement the terms of this
346346+License by making exceptions from one or more of its conditions.
347347+Additional permissions that are applicable to the entire Program shall
348348+be treated as though they were included in this License, to the extent
349349+that they are valid under applicable law. If additional permissions
350350+apply only to part of the Program, that part may be used separately
351351+under those permissions, but the entire Program remains governed by
352352+this License without regard to the additional permissions.
353353+354354+ When you convey a copy of a covered work, you may at your option
355355+remove any additional permissions from that copy, or from any part of
356356+it. (Additional permissions may be written to require their own
357357+removal in certain cases when you modify the work.) You may place
358358+additional permissions on material, added by you to a covered work,
359359+for which you have or can give appropriate copyright permission.
360360+361361+ Notwithstanding any other provision of this License, for material you
362362+add to a covered work, you may (if authorized by the copyright holders of
363363+that material) supplement the terms of this License with terms:
364364+365365+ a) Disclaiming warranty or limiting liability differently from the
366366+ terms of sections 15 and 16 of this License; or
367367+368368+ b) Requiring preservation of specified reasonable legal notices or
369369+ author attributions in that material or in the Appropriate Legal
370370+ Notices displayed by works containing it; or
371371+372372+ c) Prohibiting misrepresentation of the origin of that material, or
373373+ requiring that modified versions of such material be marked in
374374+ reasonable ways as different from the original version; or
375375+376376+ d) Limiting the use for publicity purposes of names of licensors or
377377+ authors of the material; or
378378+379379+ e) Declining to grant rights under trademark law for use of some
380380+ trade names, trademarks, or service marks; or
381381+382382+ f) Requiring indemnification of licensors and authors of that
383383+ material by anyone who conveys the material (or modified versions of
384384+ it) with contractual assumptions of liability to the recipient, for
385385+ any liability that these contractual assumptions directly impose on
386386+ those licensors and authors.
387387+388388+ All other non-permissive additional terms are considered "further
389389+restrictions" within the meaning of section 10. If the Program as you
390390+received it, or any part of it, contains a notice stating that it is
391391+governed by this License along with a term that is a further
392392+restriction, you may remove that term. If a license document contains
393393+a further restriction but permits relicensing or conveying under this
394394+License, you may add to a covered work material governed by the terms
395395+of that license document, provided that the further restriction does
396396+not survive such relicensing or conveying.
397397+398398+ If you add terms to a covered work in accord with this section, you
399399+must place, in the relevant source files, a statement of the
400400+additional terms that apply to those files, or a notice indicating
401401+where to find the applicable terms.
402402+403403+ Additional terms, permissive or non-permissive, may be stated in the
404404+form of a separately written license, or stated as exceptions;
405405+the above requirements apply either way.
406406+407407+ 8. Termination.
408408+409409+ You may not propagate or modify a covered work except as expressly
410410+provided under this License. Any attempt otherwise to propagate or
411411+modify it is void, and will automatically terminate your rights under
412412+this License (including any patent licenses granted under the third
413413+paragraph of section 11).
414414+415415+ However, if you cease all violation of this License, then your
416416+license from a particular copyright holder is reinstated (a)
417417+provisionally, unless and until the copyright holder explicitly and
418418+finally terminates your license, and (b) permanently, if the copyright
419419+holder fails to notify you of the violation by some reasonable means
420420+prior to 60 days after the cessation.
421421+422422+ Moreover, your license from a particular copyright holder is
423423+reinstated permanently if the copyright holder notifies you of the
424424+violation by some reasonable means, this is the first time you have
425425+received notice of violation of this License (for any work) from that
426426+copyright holder, and you cure the violation prior to 30 days after
427427+your receipt of the notice.
428428+429429+ Termination of your rights under this section does not terminate the
430430+licenses of parties who have received copies or rights from you under
431431+this License. If your rights have been terminated and not permanently
432432+reinstated, you do not qualify to receive new licenses for the same
433433+material under section 10.
434434+435435+ 9. Acceptance Not Required for Having Copies.
436436+437437+ You are not required to accept this License in order to receive or
438438+run a copy of the Program. Ancillary propagation of a covered work
439439+occurring solely as a consequence of using peer-to-peer transmission
440440+to receive a copy likewise does not require acceptance. However,
441441+nothing other than this License grants you permission to propagate or
442442+modify any covered work. These actions infringe copyright if you do
443443+not accept this License. Therefore, by modifying or propagating a
444444+covered work, you indicate your acceptance of this License to do so.
445445+446446+ 10. Automatic Licensing of Downstream Recipients.
447447+448448+ Each time you convey a covered work, the recipient automatically
449449+receives a license from the original licensors, to run, modify and
450450+propagate that work, subject to this License. You are not responsible
451451+for enforcing compliance by third parties with this License.
452452+453453+ An "entity transaction" is a transaction transferring control of an
454454+organization, or substantially all assets of one, or subdividing an
455455+organization, or merging organizations. If propagation of a covered
456456+work results from an entity transaction, each party to that
457457+transaction who receives a copy of the work also receives whatever
458458+licenses to the work the party's predecessor in interest had or could
459459+give under the previous paragraph, plus a right to possession of the
460460+Corresponding Source of the work from the predecessor in interest, if
461461+the predecessor has it or can get it with reasonable efforts.
462462+463463+ You may not impose any further restrictions on the exercise of the
464464+rights granted or affirmed under this License. For example, you may
465465+not impose a license fee, royalty, or other charge for exercise of
466466+rights granted under this License, and you may not initiate litigation
467467+(including a cross-claim or counterclaim in a lawsuit) alleging that
468468+any patent claim is infringed by making, using, selling, offering for
469469+sale, or importing the Program or any portion of it.
470470+471471+ 11. Patents.
472472+473473+ A "contributor" is a copyright holder who authorizes use under this
474474+License of the Program or a work on which the Program is based. The
475475+work thus licensed is called the contributor's "contributor version".
476476+477477+ A contributor's "essential patent claims" are all patent claims
478478+owned or controlled by the contributor, whether already acquired or
479479+hereafter acquired, that would be infringed by some manner, permitted
480480+by this License, of making, using, or selling its contributor version,
481481+but do not include claims that would be infringed only as a
482482+consequence of further modification of the contributor version. For
483483+purposes of this definition, "control" includes the right to grant
484484+patent sublicenses in a manner consistent with the requirements of
485485+this License.
486486+487487+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488488+patent license under the contributor's essential patent claims, to
489489+make, use, sell, offer for sale, import and otherwise run, modify and
490490+propagate the contents of its contributor version.
491491+492492+ In the following three paragraphs, a "patent license" is any express
493493+agreement or commitment, however denominated, not to enforce a patent
494494+(such as an express permission to practice a patent or covenant not to
495495+sue for patent infringement). To "grant" such a patent license to a
496496+party means to make such an agreement or commitment not to enforce a
497497+patent against the party.
498498+499499+ If you convey a covered work, knowingly relying on a patent license,
500500+and the Corresponding Source of the work is not available for anyone
501501+to copy, free of charge and under the terms of this License, through a
502502+publicly available network server or other readily accessible means,
503503+then you must either (1) cause the Corresponding Source to be so
504504+available, or (2) arrange to deprive yourself of the benefit of the
505505+patent license for this particular work, or (3) arrange, in a manner
506506+consistent with the requirements of this License, to extend the patent
507507+license to downstream recipients. "Knowingly relying" means you have
508508+actual knowledge that, but for the patent license, your conveying the
509509+covered work in a country, or your recipient's use of the covered work
510510+in a country, would infringe one or more identifiable patents in that
511511+country that you have reason to believe are valid.
512512+513513+ If, pursuant to or in connection with a single transaction or
514514+arrangement, you convey, or propagate by procuring conveyance of, a
515515+covered work, and grant a patent license to some of the parties
516516+receiving the covered work authorizing them to use, propagate, modify
517517+or convey a specific copy of the covered work, then the patent license
518518+you grant is automatically extended to all recipients of the covered
519519+work and works based on it.
520520+521521+ A patent license is "discriminatory" if it does not include within
522522+the scope of its coverage, prohibits the exercise of, or is
523523+conditioned on the non-exercise of one or more of the rights that are
524524+specifically granted under this License. You may not convey a covered
525525+work if you are a party to an arrangement with a third party that is
526526+in the business of distributing software, under which you make payment
527527+to the third party based on the extent of your activity of conveying
528528+the work, and under which the third party grants, to any of the
529529+parties who would receive the covered work from you, a discriminatory
530530+patent license (a) in connection with copies of the covered work
531531+conveyed by you (or copies made from those copies), or (b) primarily
532532+for and in connection with specific products or compilations that
533533+contain the covered work, unless you entered into that arrangement,
534534+or that patent license was granted, prior to 28 March 2007.
535535+536536+ Nothing in this License shall be construed as excluding or limiting
537537+any implied license or other defenses to infringement that may
538538+otherwise be available to you under applicable patent law.
539539+540540+ 12. No Surrender of Others' Freedom.
541541+542542+ If conditions are imposed on you (whether by court order, agreement or
543543+otherwise) that contradict the conditions of this License, they do not
544544+excuse you from the conditions of this License. If you cannot convey a
545545+covered work so as to satisfy simultaneously your obligations under this
546546+License and any other pertinent obligations, then as a consequence you may
547547+not convey it at all. For example, if you agree to terms that obligate you
548548+to collect a royalty for further conveying from those to whom you convey
549549+the Program, the only way you could satisfy both those terms and this
550550+License would be to refrain entirely from conveying the Program.
551551+552552+ 13. Use with the GNU Affero General Public License.
553553+554554+ Notwithstanding any other provision of this License, you have
555555+permission to link or combine any covered work with a work licensed
556556+under version 3 of the GNU Affero General Public License into a single
557557+combined work, and to convey the resulting work. The terms of this
558558+License will continue to apply to the part which is the covered work,
559559+but the special requirements of the GNU Affero General Public License,
560560+section 13, concerning interaction through a network will apply to the
561561+combination as such.
562562+563563+ 14. Revised Versions of this License.
564564+565565+ The Free Software Foundation may publish revised and/or new versions of
566566+the GNU General Public License from time to time. Such new versions will
567567+be similar in spirit to the present version, but may differ in detail to
568568+address new problems or concerns.
569569+570570+ Each version is given a distinguishing version number. If the
571571+Program specifies that a certain numbered version of the GNU General
572572+Public License "or any later version" applies to it, you have the
573573+option of following the terms and conditions either of that numbered
574574+version or of any later version published by the Free Software
575575+Foundation. If the Program does not specify a version number of the
576576+GNU General Public License, you may choose any version ever published
577577+by the Free Software Foundation.
578578+579579+ If the Program specifies that a proxy can decide which future
580580+versions of the GNU General Public License can be used, that proxy's
581581+public statement of acceptance of a version permanently authorizes you
582582+to choose that version for the Program.
583583+584584+ Later license versions may give you additional or different
585585+permissions. However, no additional obligations are imposed on any
586586+author or copyright holder as a result of your choosing to follow a
587587+later version.
588588+589589+ 15. Disclaimer of Warranty.
590590+591591+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592592+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593593+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594594+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595595+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596596+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597597+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598598+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599599+600600+ 16. Limitation of Liability.
601601+602602+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603603+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604604+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605605+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606606+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607607+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608608+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609609+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610610+SUCH DAMAGES.
611611+612612+ 17. Interpretation of Sections 15 and 16.
613613+614614+ If the disclaimer of warranty and limitation of liability provided
615615+above cannot be given local legal effect according to their terms,
616616+reviewing courts shall apply local law that most closely approximates
617617+an absolute waiver of all civil liability in connection with the
618618+Program, unless a warranty or assumption of liability accompanies a
619619+copy of the Program in return for a fee.
620620+621621+ END OF TERMS AND CONDITIONS
622622+623623+ How to Apply These Terms to Your New Programs
624624+625625+ If you develop a new program, and you want it to be of the greatest
626626+possible use to the public, the best way to achieve this is to make it
627627+free software which everyone can redistribute and change under these terms.
628628+629629+ To do so, attach the following notices to the program. It is safest
630630+to attach them to the start of each source file to most effectively
631631+state the exclusion of warranty; and each file should have at least
632632+the "copyright" line and a pointer to where the full notice is found.
633633+634634+ <one line to give the program's name and a brief idea of what it does.>
635635+ Copyright (C) <year> <name of author>
636636+637637+ This program is free software: you can redistribute it and/or modify
638638+ it under the terms of the GNU General Public License as published by
639639+ the Free Software Foundation, either version 3 of the License, or
640640+ (at your option) any later version.
641641+642642+ This program is distributed in the hope that it will be useful,
643643+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644644+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645645+ GNU General Public License for more details.
646646+647647+ You should have received a copy of the GNU General Public License
648648+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649649+650650+Also add information on how to contact you by electronic and paper mail.
651651+652652+ If the program does terminal interaction, make it output a short
653653+notice like this when it starts in an interactive mode:
654654+655655+ <program> Copyright (C) <year> <name of author>
656656+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657+ This is free software, and you are welcome to redistribute it
658658+ under certain conditions; type `show c' for details.
659659+660660+The hypothetical commands `show w' and `show c' should show the appropriate
661661+parts of the General Public License. Of course, your program's commands
662662+might be different; for a GUI interface, you would use an "about box".
663663+664664+ You should also get your employer (if you work as a programmer) or school,
665665+if any, to sign a "copyright disclaimer" for the program, if necessary.
666666+For more information on this, and how to apply and follow the GNU GPL, see
667667+<https://www.gnu.org/licenses/>.
668668+669669+ The GNU General Public License does not permit incorporating your program
670670+into proprietary programs. If your program is a subroutine library, you
671671+may consider it more useful to permit linking proprietary applications with
672672+the library. If this is what you want to do, use the GNU Lesser General
673673+Public License instead of this License. But first, please read
674674+<https://www.gnu.org/licenses/why-not-lgpl.html>.
···11+# graft
22+33+A daemon that mirrors repositories between Forgejo and Radicle: git content, issues, and pull requests / patches.
44+55+It runs on a timer, keeps state in a local SQLite file, and never force-pushes — a real divergence between the two sides is reported and left for a human to resolve.
66+77+## What it syncs
88+99+- **Git content**: the default branch, fast-forward only.
1010+- **Issues**: Forgejo issues become Radicle issues and vice versa. Create-only for now — edits made after the first mirror aren't propagated yet.
1111+- **Patches / pull requests**: a Forgejo PR opens a Radicle patch (and back), by pushing the PR's head commit to `refs/patches` on the Radicle side, or as a branch + PR on the Forgejo side.
1212+1313+## Why
1414+1515+Forgejo and Radicle solve the same problem — hosting and reviewing changes to a git repository — with opposite architectures: one is a server you point a browser at, the other is a peer-to-peer protocol with no server at all. `graft` lets a project exist properly on both without anyone choosing sides or doing the mirroring by hand.
1616+1717+## Requirements
1818+1919+- Go 1.23+ to build
2020+- `git`
2121+- the `rad` CLI, with `git-remote-rad` on `PATH`, and a Radicle node already running with its own identity (`rad auth`)
2222+- a Forgejo access token scoped to `write:repository` and `write:issue` on the repo you're syncing
2323+2424+## Build
2525+2626+```sh
2727+go build -o graft ./cmd/sync
2828+```
2929+3030+## Config
3131+3232+```yaml
3333+sync_interval: 5m
3434+state_db: /var/lib/graft/state.db
3535+3636+repos:
3737+ - name: my-project
3838+ forgejo:
3939+ base_url: https://git.example.org
4040+ owner: alice
4141+ repo: my-project
4242+ token_file: /etc/graft/my-project.token
4343+ radicle:
4444+ rid: rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
4545+ http_base_url: https://seed.example.org
4646+ rad_home: /home/graft/.radicle
4747+ sync:
4848+ git: true
4949+ issues: true
5050+ patches: true
5151+```
5252+5353+Tokens live in their own files, never inline in the config. `graft` reads them at startup and expects `chmod 600`.
5454+5555+## Run
5656+5757+```sh
5858+graft -config /etc/graft/config.yaml # loop forever, per sync_interval
5959+graft -config /etc/graft/config.yaml -once # one pass, then exit
6060+```
6161+6262+A systemd unit is in `systemd/graft.service`.
6363+6464+Full walkthrough, from a blank server to a running mirror: [TUTORIAL.md](TUTORIAL.md).
6565+6666+## License
6767+6868+GPLv3. See [LICENSE](LICENSE).
···11+# Tutorial
22+33+This walks through mirroring one repository between a Forgejo instance and a Radicle node, from nothing. Replace the names below with your own:
44+55+| Placeholder | Stands for |
66+|---|---|
77+| `git.example.org` | your Forgejo instance |
88+| `seed.example.org` | your Radicle node's `radicle-httpd` address |
99+| `alice` | the Forgejo account that owns the repo |
1010+| `my-project` | the repository |
1111+1212+## Prerequisites
1313+1414+- A Forgejo instance you can create repos and tokens on.
1515+- A machine with `git`, the `rad` CLI, and a running `radicle-node` — see [Radicle's own seeder guide](https://radicle.dev/guides/seeder) if you don't have one yet.
1616+- Go 1.23+, to build `graft`.
1717+1818+## 1. Build graft
1919+2020+```sh
2121+git clone https://git.example.org/alice/graft.git
2222+cd graft
2323+go build -o graft ./cmd/sync
2424+sudo mv graft /usr/local/bin/graft
2525+```
2626+2727+## 2. Create a Forgejo token
2828+2929+`graft` needs a token scoped to `write:repository` and `write:issue` on the repo it syncs.
3030+3131+```sh
3232+curl -X POST -H "Authorization: token $ADMIN_TOKEN" \
3333+ -H "Content-Type: application/json" \
3434+ -d '{"name":"graft","scopes":["write:repository","write:issue"]}' \
3535+ https://git.example.org/api/v1/users/alice/tokens
3636+```
3737+3838+Save the returned token somewhere `graft` can read and nowhere else can:
3939+4040+```sh
4141+mkdir -p /etc/graft
4242+echo "$TOKEN" > /etc/graft/my-project.token
4343+chmod 600 /etc/graft/my-project.token
4444+```
4545+4646+## 3. Create the repo on Forgejo
4747+4848+```sh
4949+curl -X POST -H "Authorization: token $TOKEN" \
5050+ -H "Content-Type: application/json" \
5151+ -d '{"name":"my-project","auto_init":true,"default_branch":"main"}' \
5252+ https://git.example.org/api/v1/user/repos
5353+```
5454+5555+`auto_init` gives it one commit, so there's something to mirror.
5656+5757+## 4. Create the repo on Radicle
5858+5959+Radicle repos are created from an existing git checkout. Clone the one you just made and initialize it:
6060+6161+```sh
6262+git clone https://git.example.org/alice/my-project.git
6363+cd my-project
6464+rad init --name my-project --default-branch main --public
6565+```
6666+6767+This prints a Repository ID (RID), something like `rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5`. Write it down — the config needs it.
6868+6969+If you have other Radicle nodes that should also carry this repo, tell them to seed it:
7070+7171+```sh
7272+rad seed rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
7373+```
7474+7575+## 5. Write the config
7676+7777+```yaml
7878+# /etc/graft/config.yaml
7979+sync_interval: 5m
8080+state_db: /var/lib/graft/state.db
8181+8282+repos:
8383+ - name: my-project
8484+ forgejo:
8585+ base_url: https://git.example.org
8686+ owner: alice
8787+ repo: my-project
8888+ token_file: /etc/graft/my-project.token
8989+ radicle:
9090+ rid: rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
9191+ http_base_url: https://seed.example.org
9292+ rad_home: /home/graft/.radicle
9393+ sync:
9494+ git: true
9595+ issues: true
9696+ patches: true
9797+```
9898+9999+`rad_home` is the `RAD_HOME` of the identity `graft` pushes as — usually a dedicated one, created with `rad auth` under whatever user runs `graft`.
100100+101101+## 6. Run it once
102102+103103+```sh
104104+mkdir -p /var/lib/graft
105105+graft -config /etc/graft/config.yaml -once
106106+```
107107+108108+No output means no errors. Check both sides:
109109+110110+```sh
111111+curl -s https://seed.example.org/api/v1/repos/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
112112+```
113113+114114+If you open an issue on the Forgejo repo and run `graft -once` again, it shows up on Radicle within that one pass.
115115+116116+## 7. Run it as a service
117117+118118+```sh
119119+sudo cp systemd/graft.service /etc/systemd/system/
120120+sudo systemctl daemon-reload
121121+sudo systemctl enable --now graft
122122+```
123123+124124+It now mirrors both repos every `sync_interval`, in both directions, on its own.
125125+126126+## Troubleshooting
127127+128128+**"token does not have at least one of required scope(s)"** — the Forgejo token is missing `write:issue` or `write:repository`. Regenerate it with both.
129129+130130+**"forgejo and rad diverged since last sync"** — both sides got commits since the last pass that aren't ancestors of each other. `graft` won't guess which one wins; merge them by hand on either side and it'll pick up cleanly next pass.
131131+132132+**"'remote-rad' is not a git command"** — `git-remote-rad` (installed alongside `rad`) isn't on `PATH` for the user running `graft`. Add its directory to the systemd unit's `Environment=PATH=...`.
133133+134134+**A patch/PR never shows up on the other side** — check that the corresponding repo isn't still empty on the destination. The first git sync has to land before patches/issues referencing that content can be mirrored.
···11+// Package sync is the actual synchronization brick: it takes a Forgejo
22+// client and a Radicle client for one repo pair and mirrors content between
33+// them, using the state store to stay idempotent across runs.
44+//
55+// Scope of this first version, deliberately: fast-forward-only git mirroring
66+// (a real divergence is logged and skipped, never force-pushed), and
77+// create-only issue/patch mirroring (edits made after the initial mirror are
88+// not propagated — that needs per-item diffing, left for a follow-up once
99+// the create path is proven in practice).
1010+package sync
1111+1212+import (
1313+ "bytes"
1414+ "fmt"
1515+ "os"
1616+ "os/exec"
1717+ "path/filepath"
1818+ "strings"
1919+2020+ "graft/internal/state"
2121+)
2222+2323+// GitSyncer mirrors a repository's default branch between Forgejo and
2424+// Radicle using a local working clone with two remotes.
2525+type GitSyncer struct {
2626+ RepoPair string // key used in the state store
2727+ WorkDir string // local clone, created on first run if absent
2828+ ForgejoURL string // authenticated clone URL (token embedded)
2929+ ForgejoBranch string
3030+ RID string
3131+ RadHome string
3232+ State *state.Store
3333+}
3434+3535+func (g *GitSyncer) run(args ...string) (string, error) {
3636+ cmd := exec.Command("git", args...)
3737+ cmd.Dir = g.WorkDir
3838+ cmd.Env = append(os.Environ(), "RAD_HOME="+g.RadHome)
3939+ var out bytes.Buffer
4040+ cmd.Stdout = &out
4141+ cmd.Stderr = &out
4242+ err := cmd.Run()
4343+ if err != nil {
4444+ return out.String(), fmt.Errorf("git %v: %w: %s", args, err, out.String())
4545+ }
4646+ return out.String(), nil
4747+}
4848+4949+// ensureClone creates the working clone and its two remotes if this is the
5050+// first run for this repo pair. The rad remote mirrors exactly what
5151+// `rad init` itself sets up (verified against a live repo): a fetch URL of
5252+// rad://<rid>, and a separate push URL of rad://<rid>/<local-node-id> —
5353+// git-remote-rad needs the pushing node's own id in the push URL.
5454+func (g *GitSyncer) ensureClone() error {
5555+ if _, err := os.Stat(filepath.Join(g.WorkDir, ".git")); err == nil {
5656+ return nil
5757+ }
5858+ if err := os.MkdirAll(g.WorkDir, 0o700); err != nil {
5959+ return fmt.Errorf("create work dir: %w", err)
6060+ }
6161+ if _, err := g.run("init", "-q", "-b", g.ForgejoBranch); err != nil {
6262+ return err
6363+ }
6464+ if _, err := g.run("remote", "add", "forgejo", g.ForgejoURL); err != nil {
6565+ return err
6666+ }
6767+6868+ ridBare := strings.TrimPrefix(g.RID, "rad:")
6969+ nid, err := g.localNodeID()
7070+ if err != nil {
7171+ return fmt.Errorf("resolve local node id: %w", err)
7272+ }
7373+ if _, err := g.run("remote", "add", "rad", "rad://"+ridBare); err != nil {
7474+ return err
7575+ }
7676+ if _, err := g.run("remote", "set-url", "--push", "rad", "rad://"+ridBare+"/"+nid); err != nil {
7777+ return err
7878+ }
7979+ return nil
8080+}
8181+8282+// localNodeID returns the Radicle node id (DID, without the did:key:
8383+// prefix) that owns g.RadHome.
8484+func (g *GitSyncer) localNodeID() (string, error) {
8585+ // --nid is deprecated in favor of `rad node status --only nid` and
8686+ // prints a warning to stderr; keep that separate from stdout so it
8787+ // never ends up concatenated into the id itself.
8888+ cmd := exec.Command("rad", "self", "--nid")
8989+ cmd.Env = append(os.Environ(), "RAD_HOME="+g.RadHome)
9090+ var out, errOut bytes.Buffer
9191+ cmd.Stdout = &out
9292+ cmd.Stderr = &errOut
9393+ if err := cmd.Run(); err != nil {
9494+ return "", fmt.Errorf("rad self --nid: %w: %s", err, errOut.String())
9595+ }
9696+ return strings.TrimSpace(out.String()), nil
9797+}
9898+9999+// headOf returns the commit SHA a remote branch currently points to, or ""
100100+// if the branch does not exist yet on that remote.
101101+func (g *GitSyncer) headOf(remote, branch string) (string, error) {
102102+ out, err := g.run("ls-remote", remote, "refs/heads/"+branch)
103103+ if err != nil {
104104+ return "", err
105105+ }
106106+ if out == "" {
107107+ return "", nil
108108+ }
109109+ var sha string
110110+ fmt.Sscanf(out, "%s", &sha)
111111+ return sha, nil
112112+}
113113+114114+// isAncestor reports whether commit a is an ancestor of commit b (i.e.
115115+// fast-forwarding from a to b is safe).
116116+func (g *GitSyncer) isAncestor(a, b string) bool {
117117+ _, err := g.run("merge-base", "--is-ancestor", a, b)
118118+ return err == nil
119119+}
120120+121121+// Sync mirrors the default branch in whichever direction has new,
122122+// fast-forwardable commits. It never force-pushes: a genuine divergence
123123+// (commits on both sides since the last sync, neither an ancestor of the
124124+// other) is reported as an error so the operator can resolve it by hand.
125125+func (g *GitSyncer) Sync() error {
126126+ if err := g.ensureClone(); err != nil {
127127+ return err
128128+ }
129129+130130+ forgejoHead, err := g.headOf("forgejo", g.ForgejoBranch)
131131+ if err != nil {
132132+ return fmt.Errorf("read forgejo head: %w", err)
133133+ }
134134+ radHead, err := g.headOf("rad", g.ForgejoBranch)
135135+ if err != nil {
136136+ return fmt.Errorf("read rad head: %w", err)
137137+ }
138138+139139+ lastForgejo, lastRad, err := g.State.GitCursor(g.RepoPair)
140140+ if err != nil {
141141+ return fmt.Errorf("read cursor: %w", err)
142142+ }
143143+144144+ switch {
145145+ case forgejoHead == radHead:
146146+ // Already in sync; still record the cursor in case this is the
147147+ // first run and it was empty before.
148148+149149+ case radHead == "" || radHead == lastRad:
150150+ // Radicle hasn't moved since we last looked: forgejo is ahead.
151151+ if err := g.pushBranch("forgejo", "rad"); err != nil {
152152+ return fmt.Errorf("mirror forgejo -> rad: %w", err)
153153+ }
154154+155155+ case forgejoHead == "" || forgejoHead == lastForgejo:
156156+ // Forgejo hasn't moved: rad is ahead.
157157+ if err := g.pushBranch("rad", "forgejo"); err != nil {
158158+ return fmt.Errorf("mirror rad -> forgejo: %w", err)
159159+ }
160160+161161+ case g.isAncestor(lastForgejo, forgejoHead) && g.isAncestor(lastRad, radHead) &&
162162+ g.isAncestor(radHead, forgejoHead):
163163+ // Both moved, but rad's tip is contained in forgejo's: forgejo wins.
164164+ if err := g.pushBranch("forgejo", "rad"); err != nil {
165165+ return fmt.Errorf("mirror forgejo -> rad: %w", err)
166166+ }
167167+168168+ case g.isAncestor(forgejoHead, radHead):
169169+ // Symmetric case: forgejo's tip is contained in rad's.
170170+ if err := g.pushBranch("rad", "forgejo"); err != nil {
171171+ return fmt.Errorf("mirror rad -> forgejo: %w", err)
172172+ }
173173+174174+ default:
175175+ return fmt.Errorf(
176176+ "%s: forgejo and rad diverged since last sync (forgejo=%s rad=%s, last forgejo=%s rad=%s); resolve manually, not auto-merging",
177177+ g.RepoPair, forgejoHead, radHead, lastForgejo, lastRad)
178178+ }
179179+180180+ forgejoHead, err = g.headOf("forgejo", g.ForgejoBranch)
181181+ if err != nil {
182182+ return err
183183+ }
184184+ radHead, err = g.headOf("rad", g.ForgejoBranch)
185185+ if err != nil {
186186+ return err
187187+ }
188188+ return g.State.SetGitCursor(g.RepoPair, forgejoHead, radHead)
189189+}
190190+191191+func (g *GitSyncer) pushBranch(from, to string) error {
192192+ if _, err := g.run("fetch", "-q", from, g.ForgejoBranch); err != nil {
193193+ return fmt.Errorf("fetch %s: %w", from, err)
194194+ }
195195+ if _, err := g.run("push", to, "FETCH_HEAD:refs/heads/"+g.ForgejoBranch); err != nil {
196196+ return fmt.Errorf("push %s: %w", to, err)
197197+ }
198198+ return nil
199199+}
···11+[Unit]
22+Description=graft - Forgejo <-> Radicle sync daemon
33+After=network-online.target
44+Wants=network-online.target
55+66+[Service]
77+Type=simple
88+User=sync
99+Group=sync
1010+ExecStart=/usr/local/bin/graft -config /etc/graft/config.yaml
1111+Restart=always
1212+RestartSec=10
1313+1414+# Hardening: the daemon only needs its own state dir, its config dir (for
1515+# reading the token files) and the rad CLI's home directory.
1616+NoNewPrivileges=true
1717+ProtectSystem=strict
1818+ProtectHome=true
1919+ReadWritePaths=/var/lib/graft /home/sync/.radicle
2020+ReadOnlyPaths=/etc/graft
2121+2222+[Install]
2323+WantedBy=multi-user.target