├── .gitignore ├── LICENSE ├── README.md ├── dune ├── dune-project ├── opam-ed.opam ├── src ├── dune └── opamEdMain.ml └── tests ├── dune └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /_build/ 2 | /opam-ed.install 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | All files in libs/ are distributed under GNU LESSER GENERAL PUBLIC 2 | LICENSE v2.1 with STATIC LINKING EXCEPTION as written below. All 3 | other files are under GNU GENERAL PUBLIC LICENSE v3. 4 | 5 | If you wish to get copies of this software, either source or binary, 6 | under other licenses, please contact us at . 7 | 8 | If you want to contribute to this software, before sending your 9 | patches to OCamlPro's online versioned source repositories, you should 10 | send us by email a signed version of OCamlPro Contributor License 11 | Agreement, either Individual (if you are contributing outside of any 12 | corporate entity) or Corporate. Both CLAs can be find at the end of 13 | this file. 14 | 15 | ======================================================================= 16 | 17 | STATIC LINKING EXCEPTION 18 | 19 | As a special exception to the GNU Lesser General Public License, you 20 | may link, statically or dynamically, a "work that uses the library" 21 | with a publicly distributed version of the library to produce an 22 | executable file containing portions of the library, and distribute 23 | that executable file under terms of your choice, without any of the 24 | additional requirements listed in clause 6 of the GNU Lesser General 25 | Public License. By "a publicly distributed version of the library", 26 | we mean either the unmodified library as distributed by OCamlPro, or a 27 | modified version of the library that is distributed under the 28 | conditions defined in clause 2 of the GNU Lesser General Public 29 | License. This exception does not however invalidate any other reasons 30 | why the executable file might be covered by the GNU Lesser General 31 | Public License. 32 | 33 | ======================================================================== 34 | 35 | GNU GENERAL PUBLIC LICENSE 36 | Version 3, 29 June 2007 37 | 38 | Copyright (C) 2007 Free Software Foundation, Inc. 39 | Everyone is permitted to copy and distribute verbatim copies 40 | of this license document, but changing it is not allowed. 41 | 42 | Preamble 43 | 44 | The GNU General Public License is a free, copyleft license for 45 | software and other kinds of works. 46 | 47 | The licenses for most software and other practical works are designed 48 | to take away your freedom to share and change the works. By contrast, 49 | the GNU General Public License is intended to guarantee your freedom to 50 | share and change all versions of a program--to make sure it remains free 51 | software for all its users. We, the Free Software Foundation, use the 52 | GNU General Public License for most of our software; it applies also to 53 | any other work released this way by its authors. You can apply it to 54 | your programs, too. 55 | 56 | When we speak of free software, we are referring to freedom, not 57 | price. Our General Public Licenses are designed to make sure that you 58 | have the freedom to distribute copies of free software (and charge for 59 | them if you wish), that you receive source code or can get it if you 60 | want it, that you can change the software or use pieces of it in new 61 | free programs, and that you know you can do these things. 62 | 63 | To protect your rights, we need to prevent others from denying you 64 | these rights or asking you to surrender the rights. Therefore, you have 65 | certain responsibilities if you distribute copies of the software, or if 66 | you modify it: responsibilities to respect the freedom of others. 67 | 68 | For example, if you distribute copies of such a program, whether 69 | gratis or for a fee, you must pass on to the recipients the same 70 | freedoms that you received. You must make sure that they, too, receive 71 | or can get the source code. And you must show them these terms so they 72 | know their rights. 73 | 74 | Developers that use the GNU GPL protect your rights with two steps: 75 | (1) assert copyright on the software, and (2) offer you this License 76 | giving you legal permission to copy, distribute and/or modify it. 77 | 78 | For the developers' and authors' protection, the GPL clearly explains 79 | that there is no warranty for this free software. For both users' and 80 | authors' sake, the GPL requires that modified versions be marked as 81 | changed, so that their problems will not be attributed erroneously to 82 | authors of previous versions. 83 | 84 | Some devices are designed to deny users access to install or run 85 | modified versions of the software inside them, although the manufacturer 86 | can do so. This is fundamentally incompatible with the aim of 87 | protecting users' freedom to change the software. The systematic 88 | pattern of such abuse occurs in the area of products for individuals to 89 | use, which is precisely where it is most unacceptable. Therefore, we 90 | have designed this version of the GPL to prohibit the practice for those 91 | products. If such problems arise substantially in other domains, we 92 | stand ready to extend this provision to those domains in future versions 93 | of the GPL, as needed to protect the freedom of users. 94 | 95 | Finally, every program is threatened constantly by software patents. 96 | States should not allow patents to restrict development and use of 97 | software on general-purpose computers, but in those that do, we wish to 98 | avoid the special danger that patents applied to a free program could 99 | make it effectively proprietary. To prevent this, the GPL assures that 100 | patents cannot be used to render the program non-free. 101 | 102 | The precise terms and conditions for copying, distribution and 103 | modification follow. 104 | 105 | TERMS AND CONDITIONS 106 | 107 | 0. Definitions. 108 | 109 | "This License" refers to version 3 of the GNU General Public License. 110 | 111 | "Copyright" also means copyright-like laws that apply to other kinds of 112 | works, such as semiconductor masks. 113 | 114 | "The Program" refers to any copyrightable work licensed under this 115 | License. Each licensee is addressed as "you". "Licensees" and 116 | "recipients" may be individuals or organizations. 117 | 118 | To "modify" a work means to copy from or adapt all or part of the work 119 | in a fashion requiring copyright permission, other than the making of an 120 | exact copy. The resulting work is called a "modified version" of the 121 | earlier work or a work "based on" the earlier work. 122 | 123 | A "covered work" means either the unmodified Program or a work based 124 | on the Program. 125 | 126 | To "propagate" a work means to do anything with it that, without 127 | permission, would make you directly or secondarily liable for 128 | infringement under applicable copyright law, except executing it on a 129 | computer or modifying a private copy. Propagation includes copying, 130 | distribution (with or without modification), making available to the 131 | public, and in some countries other activities as well. 132 | 133 | To "convey" a work means any kind of propagation that enables other 134 | parties to make or receive copies. Mere interaction with a user through 135 | a computer network, with no transfer of a copy, is not conveying. 136 | 137 | An interactive user interface displays "Appropriate Legal Notices" 138 | to the extent that it includes a convenient and prominently visible 139 | feature that (1) displays an appropriate copyright notice, and (2) 140 | tells the user that there is no warranty for the work (except to the 141 | extent that warranties are provided), that licensees may convey the 142 | work under this License, and how to view a copy of this License. If 143 | the interface presents a list of user commands or options, such as a 144 | menu, a prominent item in the list meets this criterion. 145 | 146 | 1. Source Code. 147 | 148 | The "source code" for a work means the preferred form of the work 149 | for making modifications to it. "Object code" means any non-source 150 | form of a work. 151 | 152 | A "Standard Interface" means an interface that either is an official 153 | standard defined by a recognized standards body, or, in the case of 154 | interfaces specified for a particular programming language, one that 155 | is widely used among developers working in that language. 156 | 157 | The "System Libraries" of an executable work include anything, other 158 | than the work as a whole, that (a) is included in the normal form of 159 | packaging a Major Component, but which is not part of that Major 160 | Component, and (b) serves only to enable use of the work with that 161 | Major Component, or to implement a Standard Interface for which an 162 | implementation is available to the public in source code form. A 163 | "Major Component", in this context, means a major essential component 164 | (kernel, window system, and so on) of the specific operating system 165 | (if any) on which the executable work runs, or a compiler used to 166 | produce the work, or an object code interpreter used to run it. 167 | 168 | The "Corresponding Source" for a work in object code form means all 169 | the source code needed to generate, install, and (for an executable 170 | work) run the object code and to modify the work, including scripts to 171 | control those activities. However, it does not include the work's 172 | System Libraries, or general-purpose tools or generally available free 173 | programs which are used unmodified in performing those activities but 174 | which are not part of the work. For example, Corresponding Source 175 | includes interface definition files associated with source files for 176 | the work, and the source code for shared libraries and dynamically 177 | linked subprograms that the work is specifically designed to require, 178 | such as by intimate data communication or control flow between those 179 | subprograms and other parts of the work. 180 | 181 | The Corresponding Source need not include anything that users 182 | can regenerate automatically from other parts of the Corresponding 183 | Source. 184 | 185 | The Corresponding Source for a work in source code form is that 186 | same work. 187 | 188 | 2. Basic Permissions. 189 | 190 | All rights granted under this License are granted for the term of 191 | copyright on the Program, and are irrevocable provided the stated 192 | conditions are met. This License explicitly affirms your unlimited 193 | permission to run the unmodified Program. The output from running a 194 | covered work is covered by this License only if the output, given its 195 | content, constitutes a covered work. This License acknowledges your 196 | rights of fair use or other equivalent, as provided by copyright law. 197 | 198 | You may make, run and propagate covered works that you do not 199 | convey, without conditions so long as your license otherwise remains 200 | in force. You may convey covered works to others for the sole purpose 201 | of having them make modifications exclusively for you, or provide you 202 | with facilities for running those works, provided that you comply with 203 | the terms of this License in conveying all material for which you do 204 | not control copyright. Those thus making or running the covered works 205 | for you must do so exclusively on your behalf, under your direction 206 | and control, on terms that prohibit them from making any copies of 207 | your copyrighted material outside their relationship with you. 208 | 209 | Conveying under any other circumstances is permitted solely under 210 | the conditions stated below. Sublicensing is not allowed; section 10 211 | makes it unnecessary. 212 | 213 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 214 | 215 | No covered work shall be deemed part of an effective technological 216 | measure under any applicable law fulfilling obligations under article 217 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 218 | similar laws prohibiting or restricting circumvention of such 219 | measures. 220 | 221 | When you convey a covered work, you waive any legal power to forbid 222 | circumvention of technological measures to the extent such circumvention 223 | is effected by exercising rights under this License with respect to 224 | the covered work, and you disclaim any intention to limit operation or 225 | modification of the work as a means of enforcing, against the work's 226 | users, your or third parties' legal rights to forbid circumvention of 227 | technological measures. 228 | 229 | 4. Conveying Verbatim Copies. 230 | 231 | You may convey verbatim copies of the Program's source code as you 232 | receive it, in any medium, provided that you conspicuously and 233 | appropriately publish on each copy an appropriate copyright notice; 234 | keep intact all notices stating that this License and any 235 | non-permissive terms added in accord with section 7 apply to the code; 236 | keep intact all notices of the absence of any warranty; and give all 237 | recipients a copy of this License along with the Program. 238 | 239 | You may charge any price or no price for each copy that you convey, 240 | and you may offer support or warranty protection for a fee. 241 | 242 | 5. Conveying Modified Source Versions. 243 | 244 | You may convey a work based on the Program, or the modifications to 245 | produce it from the Program, in the form of source code under the 246 | terms of section 4, provided that you also meet all of these conditions: 247 | 248 | a) The work must carry prominent notices stating that you modified 249 | it, and giving a relevant date. 250 | 251 | b) The work must carry prominent notices stating that it is 252 | released under this License and any conditions added under section 253 | 7. This requirement modifies the requirement in section 4 to 254 | "keep intact all notices". 255 | 256 | c) You must license the entire work, as a whole, under this 257 | License to anyone who comes into possession of a copy. This 258 | License will therefore apply, along with any applicable section 7 259 | additional terms, to the whole of the work, and all its parts, 260 | regardless of how they are packaged. This License gives no 261 | permission to license the work in any other way, but it does not 262 | invalidate such permission if you have separately received it. 263 | 264 | d) If the work has interactive user interfaces, each must display 265 | Appropriate Legal Notices; however, if the Program has interactive 266 | interfaces that do not display Appropriate Legal Notices, your 267 | work need not make them do so. 268 | 269 | A compilation of a covered work with other separate and independent 270 | works, which are not by their nature extensions of the covered work, 271 | and which are not combined with it such as to form a larger program, 272 | in or on a volume of a storage or distribution medium, is called an 273 | "aggregate" if the compilation and its resulting copyright are not 274 | used to limit the access or legal rights of the compilation's users 275 | beyond what the individual works permit. Inclusion of a covered work 276 | in an aggregate does not cause this License to apply to the other 277 | parts of the aggregate. 278 | 279 | 6. Conveying Non-Source Forms. 280 | 281 | You may convey a covered work in object code form under the terms 282 | of sections 4 and 5, provided that you also convey the 283 | machine-readable Corresponding Source under the terms of this License, 284 | in one of these ways: 285 | 286 | a) Convey the object code in, or embodied in, a physical product 287 | (including a physical distribution medium), accompanied by the 288 | Corresponding Source fixed on a durable physical medium 289 | customarily used for software interchange. 290 | 291 | b) Convey the object code in, or embodied in, a physical product 292 | (including a physical distribution medium), accompanied by a 293 | written offer, valid for at least three years and valid for as 294 | long as you offer spare parts or customer support for that product 295 | model, to give anyone who possesses the object code either (1) a 296 | copy of the Corresponding Source for all the software in the 297 | product that is covered by this License, on a durable physical 298 | medium customarily used for software interchange, for a price no 299 | more than your reasonable cost of physically performing this 300 | conveying of source, or (2) access to copy the 301 | Corresponding Source from a network server at no charge. 302 | 303 | c) Convey individual copies of the object code with a copy of the 304 | written offer to provide the Corresponding Source. This 305 | alternative is allowed only occasionally and noncommercially, and 306 | only if you received the object code with such an offer, in accord 307 | with subsection 6b. 308 | 309 | d) Convey the object code by offering access from a designated 310 | place (gratis or for a charge), and offer equivalent access to the 311 | Corresponding Source in the same way through the same place at no 312 | further charge. You need not require recipients to copy the 313 | Corresponding Source along with the object code. If the place to 314 | copy the object code is a network server, the Corresponding Source 315 | may be on a different server (operated by you or a third party) 316 | that supports equivalent copying facilities, provided you maintain 317 | clear directions next to the object code saying where to find the 318 | Corresponding Source. Regardless of what server hosts the 319 | Corresponding Source, you remain obligated to ensure that it is 320 | available for as long as needed to satisfy these requirements. 321 | 322 | e) Convey the object code using peer-to-peer transmission, provided 323 | you inform other peers where the object code and Corresponding 324 | Source of the work are being offered to the general public at no 325 | charge under subsection 6d. 326 | 327 | A separable portion of the object code, whose source code is excluded 328 | from the Corresponding Source as a System Library, need not be 329 | included in conveying the object code work. 330 | 331 | A "User Product" is either (1) a "consumer product", which means any 332 | tangible personal property which is normally used for personal, family, 333 | or household purposes, or (2) anything designed or sold for incorporation 334 | into a dwelling. In determining whether a product is a consumer product, 335 | doubtful cases shall be resolved in favor of coverage. For a particular 336 | product received by a particular user, "normally used" refers to a 337 | typical or common use of that class of product, regardless of the status 338 | of the particular user or of the way in which the particular user 339 | actually uses, or expects or is expected to use, the product. A product 340 | is a consumer product regardless of whether the product has substantial 341 | commercial, industrial or non-consumer uses, unless such uses represent 342 | the only significant mode of use of the product. 343 | 344 | "Installation Information" for a User Product means any methods, 345 | procedures, authorization keys, or other information required to install 346 | and execute modified versions of a covered work in that User Product from 347 | a modified version of its Corresponding Source. The information must 348 | suffice to ensure that the continued functioning of the modified object 349 | code is in no case prevented or interfered with solely because 350 | modification has been made. 351 | 352 | If you convey an object code work under this section in, or with, or 353 | specifically for use in, a User Product, and the conveying occurs as 354 | part of a transaction in which the right of possession and use of the 355 | User Product is transferred to the recipient in perpetuity or for a 356 | fixed term (regardless of how the transaction is characterized), the 357 | Corresponding Source conveyed under this section must be accompanied 358 | by the Installation Information. But this requirement does not apply 359 | if neither you nor any third party retains the ability to install 360 | modified object code on the User Product (for example, the work has 361 | been installed in ROM). 362 | 363 | The requirement to provide Installation Information does not include a 364 | requirement to continue to provide support service, warranty, or updates 365 | for a work that has been modified or installed by the recipient, or for 366 | the User Product in which it has been modified or installed. Access to a 367 | network may be denied when the modification itself materially and 368 | adversely affects the operation of the network or violates the rules and 369 | protocols for communication across the network. 370 | 371 | Corresponding Source conveyed, and Installation Information provided, 372 | in accord with this section must be in a format that is publicly 373 | documented (and with an implementation available to the public in 374 | source code form), and must require no special password or key for 375 | unpacking, reading or copying. 376 | 377 | 7. Additional Terms. 378 | 379 | "Additional permissions" are terms that supplement the terms of this 380 | License by making exceptions from one or more of its conditions. 381 | Additional permissions that are applicable to the entire Program shall 382 | be treated as though they were included in this License, to the extent 383 | that they are valid under applicable law. If additional permissions 384 | apply only to part of the Program, that part may be used separately 385 | under those permissions, but the entire Program remains governed by 386 | this License without regard to the additional permissions. 387 | 388 | When you convey a copy of a covered work, you may at your option 389 | remove any additional permissions from that copy, or from any part of 390 | it. (Additional permissions may be written to require their own 391 | removal in certain cases when you modify the work.) You may place 392 | additional permissions on material, added by you to a covered work, 393 | for which you have or can give appropriate copyright permission. 394 | 395 | Notwithstanding any other provision of this License, for material you 396 | add to a covered work, you may (if authorized by the copyright holders of 397 | that material) supplement the terms of this License with terms: 398 | 399 | a) Disclaiming warranty or limiting liability differently from the 400 | terms of sections 15 and 16 of this License; or 401 | 402 | b) Requiring preservation of specified reasonable legal notices or 403 | author attributions in that material or in the Appropriate Legal 404 | Notices displayed by works containing it; or 405 | 406 | c) Prohibiting misrepresentation of the origin of that material, or 407 | requiring that modified versions of such material be marked in 408 | reasonable ways as different from the original version; or 409 | 410 | d) Limiting the use for publicity purposes of names of licensors or 411 | authors of the material; or 412 | 413 | e) Declining to grant rights under trademark law for use of some 414 | trade names, trademarks, or service marks; or 415 | 416 | f) Requiring indemnification of licensors and authors of that 417 | material by anyone who conveys the material (or modified versions of 418 | it) with contractual assumptions of liability to the recipient, for 419 | any liability that these contractual assumptions directly impose on 420 | those licensors and authors. 421 | 422 | All other non-permissive additional terms are considered "further 423 | restrictions" within the meaning of section 10. If the Program as you 424 | received it, or any part of it, contains a notice stating that it is 425 | governed by this License along with a term that is a further 426 | restriction, you may remove that term. If a license document contains 427 | a further restriction but permits relicensing or conveying under this 428 | License, you may add to a covered work material governed by the terms 429 | of that license document, provided that the further restriction does 430 | not survive such relicensing or conveying. 431 | 432 | If you add terms to a covered work in accord with this section, you 433 | must place, in the relevant source files, a statement of the 434 | additional terms that apply to those files, or a notice indicating 435 | where to find the applicable terms. 436 | 437 | Additional terms, permissive or non-permissive, may be stated in the 438 | form of a separately written license, or stated as exceptions; 439 | the above requirements apply either way. 440 | 441 | 8. Termination. 442 | 443 | You may not propagate or modify a covered work except as expressly 444 | provided under this License. Any attempt otherwise to propagate or 445 | modify it is void, and will automatically terminate your rights under 446 | this License (including any patent licenses granted under the third 447 | paragraph of section 11). 448 | 449 | However, if you cease all violation of this License, then your 450 | license from a particular copyright holder is reinstated (a) 451 | provisionally, unless and until the copyright holder explicitly and 452 | finally terminates your license, and (b) permanently, if the copyright 453 | holder fails to notify you of the violation by some reasonable means 454 | prior to 60 days after the cessation. 455 | 456 | Moreover, your license from a particular copyright holder is 457 | reinstated permanently if the copyright holder notifies you of the 458 | violation by some reasonable means, this is the first time you have 459 | received notice of violation of this License (for any work) from that 460 | copyright holder, and you cure the violation prior to 30 days after 461 | your receipt of the notice. 462 | 463 | Termination of your rights under this section does not terminate the 464 | licenses of parties who have received copies or rights from you under 465 | this License. If your rights have been terminated and not permanently 466 | reinstated, you do not qualify to receive new licenses for the same 467 | material under section 10. 468 | 469 | 9. Acceptance Not Required for Having Copies. 470 | 471 | You are not required to accept this License in order to receive or 472 | run a copy of the Program. Ancillary propagation of a covered work 473 | occurring solely as a consequence of using peer-to-peer transmission 474 | to receive a copy likewise does not require acceptance. However, 475 | nothing other than this License grants you permission to propagate or 476 | modify any covered work. These actions infringe copyright if you do 477 | not accept this License. Therefore, by modifying or propagating a 478 | covered work, you indicate your acceptance of this License to do so. 479 | 480 | 10. Automatic Licensing of Downstream Recipients. 481 | 482 | Each time you convey a covered work, the recipient automatically 483 | receives a license from the original licensors, to run, modify and 484 | propagate that work, subject to this License. You are not responsible 485 | for enforcing compliance by third parties with this License. 486 | 487 | An "entity transaction" is a transaction transferring control of an 488 | organization, or substantially all assets of one, or subdividing an 489 | organization, or merging organizations. If propagation of a covered 490 | work results from an entity transaction, each party to that 491 | transaction who receives a copy of the work also receives whatever 492 | licenses to the work the party's predecessor in interest had or could 493 | give under the previous paragraph, plus a right to possession of the 494 | Corresponding Source of the work from the predecessor in interest, if 495 | the predecessor has it or can get it with reasonable efforts. 496 | 497 | You may not impose any further restrictions on the exercise of the 498 | rights granted or affirmed under this License. For example, you may 499 | not impose a license fee, royalty, or other charge for exercise of 500 | rights granted under this License, and you may not initiate litigation 501 | (including a cross-claim or counterclaim in a lawsuit) alleging that 502 | any patent claim is infringed by making, using, selling, offering for 503 | sale, or importing the Program or any portion of it. 504 | 505 | 11. Patents. 506 | 507 | A "contributor" is a copyright holder who authorizes use under this 508 | License of the Program or a work on which the Program is based. The 509 | work thus licensed is called the contributor's "contributor version". 510 | 511 | A contributor's "essential patent claims" are all patent claims 512 | owned or controlled by the contributor, whether already acquired or 513 | hereafter acquired, that would be infringed by some manner, permitted 514 | by this License, of making, using, or selling its contributor version, 515 | but do not include claims that would be infringed only as a 516 | consequence of further modification of the contributor version. For 517 | purposes of this definition, "control" includes the right to grant 518 | patent sublicenses in a manner consistent with the requirements of 519 | this License. 520 | 521 | Each contributor grants you a non-exclusive, worldwide, royalty-free 522 | patent license under the contributor's essential patent claims, to 523 | make, use, sell, offer for sale, import and otherwise run, modify and 524 | propagate the contents of its contributor version. 525 | 526 | In the following three paragraphs, a "patent license" is any express 527 | agreement or commitment, however denominated, not to enforce a patent 528 | (such as an express permission to practice a patent or covenant not to 529 | sue for patent infringement). To "grant" such a patent license to a 530 | party means to make such an agreement or commitment not to enforce a 531 | patent against the party. 532 | 533 | If you convey a covered work, knowingly relying on a patent license, 534 | and the Corresponding Source of the work is not available for anyone 535 | to copy, free of charge and under the terms of this License, through a 536 | publicly available network server or other readily accessible means, 537 | then you must either (1) cause the Corresponding Source to be so 538 | available, or (2) arrange to deprive yourself of the benefit of the 539 | patent license for this particular work, or (3) arrange, in a manner 540 | consistent with the requirements of this License, to extend the patent 541 | license to downstream recipients. "Knowingly relying" means you have 542 | actual knowledge that, but for the patent license, your conveying the 543 | covered work in a country, or your recipient's use of the covered work 544 | in a country, would infringe one or more identifiable patents in that 545 | country that you have reason to believe are valid. 546 | 547 | If, pursuant to or in connection with a single transaction or 548 | arrangement, you convey, or propagate by procuring conveyance of, a 549 | covered work, and grant a patent license to some of the parties 550 | receiving the covered work authorizing them to use, propagate, modify 551 | or convey a specific copy of the covered work, then the patent license 552 | you grant is automatically extended to all recipients of the covered 553 | work and works based on it. 554 | 555 | A patent license is "discriminatory" if it does not include within 556 | the scope of its coverage, prohibits the exercise of, or is 557 | conditioned on the non-exercise of one or more of the rights that are 558 | specifically granted under this License. You may not convey a covered 559 | work if you are a party to an arrangement with a third party that is 560 | in the business of distributing software, under which you make payment 561 | to the third party based on the extent of your activity of conveying 562 | the work, and under which the third party grants, to any of the 563 | parties who would receive the covered work from you, a discriminatory 564 | patent license (a) in connection with copies of the covered work 565 | conveyed by you (or copies made from those copies), or (b) primarily 566 | for and in connection with specific products or compilations that 567 | contain the covered work, unless you entered into that arrangement, 568 | or that patent license was granted, prior to 28 March 2007. 569 | 570 | Nothing in this License shall be construed as excluding or limiting 571 | any implied license or other defenses to infringement that may 572 | otherwise be available to you under applicable patent law. 573 | 574 | 12. No Surrender of Others' Freedom. 575 | 576 | If conditions are imposed on you (whether by court order, agreement or 577 | otherwise) that contradict the conditions of this License, they do not 578 | excuse you from the conditions of this License. If you cannot convey a 579 | covered work so as to satisfy simultaneously your obligations under this 580 | License and any other pertinent obligations, then as a consequence you may 581 | not convey it at all. For example, if you agree to terms that obligate you 582 | to collect a royalty for further conveying from those to whom you convey 583 | the Program, the only way you could satisfy both those terms and this 584 | License would be to refrain entirely from conveying the Program. 585 | 586 | 13. Use with the GNU Affero General Public License. 587 | 588 | Notwithstanding any other provision of this License, you have 589 | permission to link or combine any covered work with a work licensed 590 | under version 3 of the GNU Affero General Public License into a single 591 | combined work, and to convey the resulting work. The terms of this 592 | License will continue to apply to the part which is the covered work, 593 | but the special requirements of the GNU Affero General Public License, 594 | section 13, concerning interaction through a network will apply to the 595 | combination as such. 596 | 597 | 14. Revised Versions of this License. 598 | 599 | The Free Software Foundation may publish revised and/or new versions of 600 | the GNU General Public License from time to time. Such new versions will 601 | be similar in spirit to the present version, but may differ in detail to 602 | address new problems or concerns. 603 | 604 | Each version is given a distinguishing version number. If the 605 | Program specifies that a certain numbered version of the GNU General 606 | Public License "or any later version" applies to it, you have the 607 | option of following the terms and conditions either of that numbered 608 | version or of any later version published by the Free Software 609 | Foundation. If the Program does not specify a version number of the 610 | GNU General Public License, you may choose any version ever published 611 | by the Free Software Foundation. 612 | 613 | If the Program specifies that a proxy can decide which future 614 | versions of the GNU General Public License can be used, that proxy's 615 | public statement of acceptance of a version permanently authorizes you 616 | to choose that version for the Program. 617 | 618 | Later license versions may give you additional or different 619 | permissions. However, no additional obligations are imposed on any 620 | author or copyright holder as a result of your choosing to follow a 621 | later version. 622 | 623 | 15. Disclaimer of Warranty. 624 | 625 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 626 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 627 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 628 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 629 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 630 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 631 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 632 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 633 | 634 | 16. Limitation of Liability. 635 | 636 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 637 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 638 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 639 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 640 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 641 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 642 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 643 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 644 | SUCH DAMAGES. 645 | 646 | 17. Interpretation of Sections 15 and 16. 647 | 648 | If the disclaimer of warranty and limitation of liability provided 649 | above cannot be given local legal effect according to their terms, 650 | reviewing courts shall apply local law that most closely approximates 651 | an absolute waiver of all civil liability in connection with the 652 | Program, unless a warranty or assumption of liability accompanies a 653 | copy of the Program in return for a fee. 654 | 655 | END OF TERMS AND CONDITIONS 656 | 657 | How to Apply These Terms to Your New Programs 658 | 659 | If you develop a new program, and you want it to be of the greatest 660 | possible use to the public, the best way to achieve this is to make it 661 | free software which everyone can redistribute and change under these terms. 662 | 663 | To do so, attach the following notices to the program. It is safest 664 | to attach them to the start of each source file to most effectively 665 | state the exclusion of warranty; and each file should have at least 666 | the "copyright" line and a pointer to where the full notice is found. 667 | 668 | 669 | Copyright (C) 670 | 671 | This program is free software: you can redistribute it and/or modify 672 | it under the terms of the GNU General Public License as published by 673 | the Free Software Foundation, either version 3 of the License, or 674 | (at your option) any later version. 675 | 676 | This program is distributed in the hope that it will be useful, 677 | but WITHOUT ANY WARRANTY; without even the implied warranty of 678 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 679 | GNU General Public License for more details. 680 | 681 | You should have received a copy of the GNU General Public License 682 | along with this program. If not, see . 683 | 684 | Also add information on how to contact you by electronic and paper mail. 685 | 686 | If the program does terminal interaction, make it output a short 687 | notice like this when it starts in an interactive mode: 688 | 689 | Copyright (C) 690 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 691 | This is free software, and you are welcome to redistribute it 692 | under certain conditions; type `show c' for details. 693 | 694 | The hypothetical commands `show w' and `show c' should show the appropriate 695 | parts of the General Public License. Of course, your program's commands 696 | might be different; for a GUI interface, you would use an "about box". 697 | 698 | You should also get your employer (if you work as a programmer) or school, 699 | if any, to sign a "copyright disclaimer" for the program, if necessary. 700 | For more information on this, and how to apply and follow the GNU GPL, see 701 | . 702 | 703 | The GNU General Public License does not permit incorporating your program 704 | into proprietary programs. If your program is a subroutine library, you 705 | may consider it more useful to permit linking proprietary applications with 706 | the library. If this is what you want to do, use the GNU Lesser General 707 | Public License instead of this License. But first, please read 708 | . 709 | 710 | ======================================================================== 711 | 712 | 713 | GNU LESSER GENERAL PUBLIC LICENSE 714 | Version 2.1, February 1999 715 | 716 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 717 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 718 | Everyone is permitted to copy and distribute verbatim copies 719 | of this license document, but changing it is not allowed. 720 | 721 | [This is the first released version of the Lesser GPL. It also counts 722 | as the successor of the GNU Library Public License, version 2, hence 723 | the version number 2.1.] 724 | 725 | Preamble 726 | 727 | The licenses for most software are designed to take away your 728 | freedom to share and change it. By contrast, the GNU General Public 729 | Licenses are intended to guarantee your freedom to share and change 730 | free software--to make sure the software is free for all its users. 731 | 732 | This license, the Lesser General Public License, applies to some 733 | specially designated software packages--typically libraries--of the 734 | Free Software Foundation and other authors who decide to use it. You 735 | can use it too, but we suggest you first think carefully about whether 736 | this license or the ordinary General Public License is the better 737 | strategy to use in any particular case, based on the explanations below. 738 | 739 | When we speak of free software, we are referring to freedom of use, 740 | not price. Our General Public Licenses are designed to make sure that 741 | you have the freedom to distribute copies of free software (and charge 742 | for this service if you wish); that you receive source code or can get 743 | it if you want it; that you can change the software and use pieces of 744 | it in new free programs; and that you are informed that you can do 745 | these things. 746 | 747 | To protect your rights, we need to make restrictions that forbid 748 | distributors to deny you these rights or to ask you to surrender these 749 | rights. These restrictions translate to certain responsibilities for 750 | you if you distribute copies of the library or if you modify it. 751 | 752 | For example, if you distribute copies of the library, whether gratis 753 | or for a fee, you must give the recipients all the rights that we gave 754 | you. You must make sure that they, too, receive or can get the source 755 | code. If you link other code with the library, you must provide 756 | complete object files to the recipients, so that they can relink them 757 | with the library after making changes to the library and recompiling 758 | it. And you must show them these terms so they know their rights. 759 | 760 | We protect your rights with a two-step method: (1) we copyright the 761 | library, and (2) we offer you this license, which gives you legal 762 | permission to copy, distribute and/or modify the library. 763 | 764 | To protect each distributor, we want to make it very clear that 765 | there is no warranty for the free library. Also, if the library is 766 | modified by someone else and passed on, the recipients should know 767 | that what they have is not the original version, so that the original 768 | author's reputation will not be affected by problems that might be 769 | introduced by others. 770 | 771 | Finally, software patents pose a constant threat to the existence of 772 | any free program. We wish to make sure that a company cannot 773 | effectively restrict the users of a free program by obtaining a 774 | restrictive license from a patent holder. Therefore, we insist that 775 | any patent license obtained for a version of the library must be 776 | consistent with the full freedom of use specified in this license. 777 | 778 | Most GNU software, including some libraries, is covered by the 779 | ordinary GNU General Public License. This license, the GNU Lesser 780 | General Public License, applies to certain designated libraries, and 781 | is quite different from the ordinary General Public License. We use 782 | this license for certain libraries in order to permit linking those 783 | libraries into non-free programs. 784 | 785 | When a program is linked with a library, whether statically or using 786 | a shared library, the combination of the two is legally speaking a 787 | combined work, a derivative of the original library. The ordinary 788 | General Public License therefore permits such linking only if the 789 | entire combination fits its criteria of freedom. The Lesser General 790 | Public License permits more lax criteria for linking other code with 791 | the library. 792 | 793 | We call this license the "Lesser" General Public License because it 794 | does Less to protect the user's freedom than the ordinary General 795 | Public License. It also provides other free software developers Less 796 | of an advantage over competing non-free programs. These disadvantages 797 | are the reason we use the ordinary General Public License for many 798 | libraries. However, the Lesser license provides advantages in certain 799 | special circumstances. 800 | 801 | For example, on rare occasions, there may be a special need to 802 | encourage the widest possible use of a certain library, so that it becomes 803 | a de-facto standard. To achieve this, non-free programs must be 804 | allowed to use the library. A more frequent case is that a free 805 | library does the same job as widely used non-free libraries. In this 806 | case, there is little to gain by limiting the free library to free 807 | software only, so we use the Lesser General Public License. 808 | 809 | In other cases, permission to use a particular library in non-free 810 | programs enables a greater number of people to use a large body of 811 | free software. For example, permission to use the GNU C Library in 812 | non-free programs enables many more people to use the whole GNU 813 | operating system, as well as its variant, the GNU/Linux operating 814 | system. 815 | 816 | Although the Lesser General Public License is Less protective of the 817 | users' freedom, it does ensure that the user of a program that is 818 | linked with the Library has the freedom and the wherewithal to run 819 | that program using a modified version of the Library. 820 | 821 | The precise terms and conditions for copying, distribution and 822 | modification follow. Pay close attention to the difference between a 823 | "work based on the library" and a "work that uses the library". The 824 | former contains code derived from the library, whereas the latter must 825 | be combined with the library in order to run. 826 | 827 | GNU LESSER GENERAL PUBLIC LICENSE 828 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 829 | 830 | 0. This License Agreement applies to any software library or other 831 | program which contains a notice placed by the copyright holder or 832 | other authorized party saying it may be distributed under the terms of 833 | this Lesser General Public License (also called "this License"). 834 | Each licensee is addressed as "you". 835 | 836 | A "library" means a collection of software functions and/or data 837 | prepared so as to be conveniently linked with application programs 838 | (which use some of those functions and data) to form executables. 839 | 840 | The "Library", below, refers to any such software library or work 841 | which has been distributed under these terms. A "work based on the 842 | Library" means either the Library or any derivative work under 843 | copyright law: that is to say, a work containing the Library or a 844 | portion of it, either verbatim or with modifications and/or translated 845 | straightforwardly into another language. (Hereinafter, translation is 846 | included without limitation in the term "modification".) 847 | 848 | "Source code" for a work means the preferred form of the work for 849 | making modifications to it. For a library, complete source code means 850 | all the source code for all modules it contains, plus any associated 851 | interface definition files, plus the scripts used to control compilation 852 | and installation of the library. 853 | 854 | Activities other than copying, distribution and modification are not 855 | covered by this License; they are outside its scope. The act of 856 | running a program using the Library is not restricted, and output from 857 | such a program is covered only if its contents constitute a work based 858 | on the Library (independent of the use of the Library in a tool for 859 | writing it). Whether that is true depends on what the Library does 860 | and what the program that uses the Library does. 861 | 862 | 1. You may copy and distribute verbatim copies of the Library's 863 | complete source code as you receive it, in any medium, provided that 864 | you conspicuously and appropriately publish on each copy an 865 | appropriate copyright notice and disclaimer of warranty; keep intact 866 | all the notices that refer to this License and to the absence of any 867 | warranty; and distribute a copy of this License along with the 868 | Library. 869 | 870 | You may charge a fee for the physical act of transferring a copy, 871 | and you may at your option offer warranty protection in exchange for a 872 | fee. 873 | 874 | 2. You may modify your copy or copies of the Library or any portion 875 | of it, thus forming a work based on the Library, and copy and 876 | distribute such modifications or work under the terms of Section 1 877 | above, provided that you also meet all of these conditions: 878 | 879 | a) The modified work must itself be a software library. 880 | 881 | b) You must cause the files modified to carry prominent notices 882 | stating that you changed the files and the date of any change. 883 | 884 | c) You must cause the whole of the work to be licensed at no 885 | charge to all third parties under the terms of this License. 886 | 887 | d) If a facility in the modified Library refers to a function or a 888 | table of data to be supplied by an application program that uses 889 | the facility, other than as an argument passed when the facility 890 | is invoked, then you must make a good faith effort to ensure that, 891 | in the event an application does not supply such function or 892 | table, the facility still operates, and performs whatever part of 893 | its purpose remains meaningful. 894 | 895 | (For example, a function in a library to compute square roots has 896 | a purpose that is entirely well-defined independent of the 897 | application. Therefore, Subsection 2d requires that any 898 | application-supplied function or table used by this function must 899 | be optional: if the application does not supply it, the square 900 | root function must still compute square roots.) 901 | 902 | These requirements apply to the modified work as a whole. If 903 | identifiable sections of that work are not derived from the Library, 904 | and can be reasonably considered independent and separate works in 905 | themselves, then this License, and its terms, do not apply to those 906 | sections when you distribute them as separate works. But when you 907 | distribute the same sections as part of a whole which is a work based 908 | on the Library, the distribution of the whole must be on the terms of 909 | this License, whose permissions for other licensees extend to the 910 | entire whole, and thus to each and every part regardless of who wrote 911 | it. 912 | 913 | Thus, it is not the intent of this section to claim rights or contest 914 | your rights to work written entirely by you; rather, the intent is to 915 | exercise the right to control the distribution of derivative or 916 | collective works based on the Library. 917 | 918 | In addition, mere aggregation of another work not based on the Library 919 | with the Library (or with a work based on the Library) on a volume of 920 | a storage or distribution medium does not bring the other work under 921 | the scope of this License. 922 | 923 | 3. You may opt to apply the terms of the ordinary GNU General Public 924 | License instead of this License to a given copy of the Library. To do 925 | this, you must alter all the notices that refer to this License, so 926 | that they refer to the ordinary GNU General Public License, version 2, 927 | instead of to this License. (If a newer version than version 2 of the 928 | ordinary GNU General Public License has appeared, then you can specify 929 | that version instead if you wish.) Do not make any other change in 930 | these notices. 931 | 932 | Once this change is made in a given copy, it is irreversible for 933 | that copy, so the ordinary GNU General Public License applies to all 934 | subsequent copies and derivative works made from that copy. 935 | 936 | This option is useful when you wish to copy part of the code of 937 | the Library into a program that is not a library. 938 | 939 | 4. You may copy and distribute the Library (or a portion or 940 | derivative of it, under Section 2) in object code or executable form 941 | under the terms of Sections 1 and 2 above provided that you accompany 942 | it with the complete corresponding machine-readable source code, which 943 | must be distributed under the terms of Sections 1 and 2 above on a 944 | medium customarily used for software interchange. 945 | 946 | If distribution of object code is made by offering access to copy 947 | from a designated place, then offering equivalent access to copy the 948 | source code from the same place satisfies the requirement to 949 | distribute the source code, even though third parties are not 950 | compelled to copy the source along with the object code. 951 | 952 | 5. A program that contains no derivative of any portion of the 953 | Library, but is designed to work with the Library by being compiled or 954 | linked with it, is called a "work that uses the Library". Such a 955 | work, in isolation, is not a derivative work of the Library, and 956 | therefore falls outside the scope of this License. 957 | 958 | However, linking a "work that uses the Library" with the Library 959 | creates an executable that is a derivative of the Library (because it 960 | contains portions of the Library), rather than a "work that uses the 961 | library". The executable is therefore covered by this License. 962 | Section 6 states terms for distribution of such executables. 963 | 964 | When a "work that uses the Library" uses material from a header file 965 | that is part of the Library, the object code for the work may be a 966 | derivative work of the Library even though the source code is not. 967 | Whether this is true is especially significant if the work can be 968 | linked without the Library, or if the work is itself a library. The 969 | threshold for this to be true is not precisely defined by law. 970 | 971 | If such an object file uses only numerical parameters, data 972 | structure layouts and accessors, and small macros and small inline 973 | functions (ten lines or less in length), then the use of the object 974 | file is unrestricted, regardless of whether it is legally a derivative 975 | work. (Executables containing this object code plus portions of the 976 | Library will still fall under Section 6.) 977 | 978 | Otherwise, if the work is a derivative of the Library, you may 979 | distribute the object code for the work under the terms of Section 6. 980 | Any executables containing that work also fall under Section 6, 981 | whether or not they are linked directly with the Library itself. 982 | 983 | 6. As an exception to the Sections above, you may also combine or 984 | link a "work that uses the Library" with the Library to produce a 985 | work containing portions of the Library, and distribute that work 986 | under terms of your choice, provided that the terms permit 987 | modification of the work for the customer's own use and reverse 988 | engineering for debugging such modifications. 989 | 990 | You must give prominent notice with each copy of the work that the 991 | Library is used in it and that the Library and its use are covered by 992 | this License. You must supply a copy of this License. If the work 993 | during execution displays copyright notices, you must include the 994 | copyright notice for the Library among them, as well as a reference 995 | directing the user to the copy of this License. Also, you must do one 996 | of these things: 997 | 998 | a) Accompany the work with the complete corresponding 999 | machine-readable source code for the Library including whatever 1000 | changes were used in the work (which must be distributed under 1001 | Sections 1 and 2 above); and, if the work is an executable linked 1002 | with the Library, with the complete machine-readable "work that 1003 | uses the Library", as object code and/or source code, so that the 1004 | user can modify the Library and then relink to produce a modified 1005 | executable containing the modified Library. (It is understood 1006 | that the user who changes the contents of definitions files in the 1007 | Library will not necessarily be able to recompile the application 1008 | to use the modified definitions.) 1009 | 1010 | b) Use a suitable shared library mechanism for linking with the 1011 | Library. A suitable mechanism is one that (1) uses at run time a 1012 | copy of the library already present on the user's computer system, 1013 | rather than copying library functions into the executable, and (2) 1014 | will operate properly with a modified version of the library, if 1015 | the user installs one, as long as the modified version is 1016 | interface-compatible with the version that the work was made with. 1017 | 1018 | c) Accompany the work with a written offer, valid for at 1019 | least three years, to give the same user the materials 1020 | specified in Subsection 6a, above, for a charge no more 1021 | than the cost of performing this distribution. 1022 | 1023 | d) If distribution of the work is made by offering access to copy 1024 | from a designated place, offer equivalent access to copy the above 1025 | specified materials from the same place. 1026 | 1027 | e) Verify that the user has already received a copy of these 1028 | materials or that you have already sent this user a copy. 1029 | 1030 | For an executable, the required form of the "work that uses the 1031 | Library" must include any data and utility programs needed for 1032 | reproducing the executable from it. However, as a special exception, 1033 | the materials to be distributed need not include anything that is 1034 | normally distributed (in either source or binary form) with the major 1035 | components (compiler, kernel, and so on) of the operating system on 1036 | which the executable runs, unless that component itself accompanies 1037 | the executable. 1038 | 1039 | It may happen that this requirement contradicts the license 1040 | restrictions of other proprietary libraries that do not normally 1041 | accompany the operating system. Such a contradiction means you cannot 1042 | use both them and the Library together in an executable that you 1043 | distribute. 1044 | 1045 | 7. You may place library facilities that are a work based on the 1046 | Library side-by-side in a single library together with other library 1047 | facilities not covered by this License, and distribute such a combined 1048 | library, provided that the separate distribution of the work based on 1049 | the Library and of the other library facilities is otherwise 1050 | permitted, and provided that you do these two things: 1051 | 1052 | a) Accompany the combined library with a copy of the same work 1053 | based on the Library, uncombined with any other library 1054 | facilities. This must be distributed under the terms of the 1055 | Sections above. 1056 | 1057 | b) Give prominent notice with the combined library of the fact 1058 | that part of it is a work based on the Library, and explaining 1059 | where to find the accompanying uncombined form of the same work. 1060 | 1061 | 8. You may not copy, modify, sublicense, link with, or distribute 1062 | the Library except as expressly provided under this License. Any 1063 | attempt otherwise to copy, modify, sublicense, link with, or 1064 | distribute the Library is void, and will automatically terminate your 1065 | rights under this License. However, parties who have received copies, 1066 | or rights, from you under this License will not have their licenses 1067 | terminated so long as such parties remain in full compliance. 1068 | 1069 | 9. You are not required to accept this License, since you have not 1070 | signed it. However, nothing else grants you permission to modify or 1071 | distribute the Library or its derivative works. These actions are 1072 | prohibited by law if you do not accept this License. Therefore, by 1073 | modifying or distributing the Library (or any work based on the 1074 | Library), you indicate your acceptance of this License to do so, and 1075 | all its terms and conditions for copying, distributing or modifying 1076 | the Library or works based on it. 1077 | 1078 | 10. Each time you redistribute the Library (or any work based on the 1079 | Library), the recipient automatically receives a license from the 1080 | original licensor to copy, distribute, link with or modify the Library 1081 | subject to these terms and conditions. You may not impose any further 1082 | restrictions on the recipients' exercise of the rights granted herein. 1083 | You are not responsible for enforcing compliance by third parties with 1084 | this License. 1085 | 1086 | 11. If, as a consequence of a court judgment or allegation of patent 1087 | infringement or for any other reason (not limited to patent issues), 1088 | conditions are imposed on you (whether by court order, agreement or 1089 | otherwise) that contradict the conditions of this License, they do not 1090 | excuse you from the conditions of this License. If you cannot 1091 | distribute so as to satisfy simultaneously your obligations under this 1092 | License and any other pertinent obligations, then as a consequence you 1093 | may not distribute the Library at all. For example, if a patent 1094 | license would not permit royalty-free redistribution of the Library by 1095 | all those who receive copies directly or indirectly through you, then 1096 | the only way you could satisfy both it and this License would be to 1097 | refrain entirely from distribution of the Library. 1098 | 1099 | If any portion of this section is held invalid or unenforceable under any 1100 | particular circumstance, the balance of the section is intended to apply, 1101 | and the section as a whole is intended to apply in other circumstances. 1102 | 1103 | It is not the purpose of this section to induce you to infringe any 1104 | patents or other property right claims or to contest validity of any 1105 | such claims; this section has the sole purpose of protecting the 1106 | integrity of the free software distribution system which is 1107 | implemented by public license practices. Many people have made 1108 | generous contributions to the wide range of software distributed 1109 | through that system in reliance on consistent application of that 1110 | system; it is up to the author/donor to decide if he or she is willing 1111 | to distribute software through any other system and a licensee cannot 1112 | impose that choice. 1113 | 1114 | This section is intended to make thoroughly clear what is believed to 1115 | be a consequence of the rest of this License. 1116 | 1117 | 12. If the distribution and/or use of the Library is restricted in 1118 | certain countries either by patents or by copyrighted interfaces, the 1119 | original copyright holder who places the Library under this License may add 1120 | an explicit geographical distribution limitation excluding those countries, 1121 | so that distribution is permitted only in or among countries not thus 1122 | excluded. In such case, this License incorporates the limitation as if 1123 | written in the body of this License. 1124 | 1125 | 13. The Free Software Foundation may publish revised and/or new 1126 | versions of the Lesser General Public License from time to time. 1127 | Such new versions will be similar in spirit to the present version, 1128 | but may differ in detail to address new problems or concerns. 1129 | 1130 | Each version is given a distinguishing version number. If the Library 1131 | specifies a version number of this License which applies to it and 1132 | "any later version", you have the option of following the terms and 1133 | conditions either of that version or of any later version published by 1134 | the Free Software Foundation. If the Library does not specify a 1135 | license version number, you may choose any version ever published by 1136 | the Free Software Foundation. 1137 | 1138 | 14. If you wish to incorporate parts of the Library into other free 1139 | programs whose distribution conditions are incompatible with these, 1140 | write to the author to ask for permission. For software which is 1141 | copyrighted by the Free Software Foundation, write to the Free 1142 | Software Foundation; we sometimes make exceptions for this. Our 1143 | decision will be guided by the two goals of preserving the free status 1144 | of all derivatives of our free software and of promoting the sharing 1145 | and reuse of software generally. 1146 | 1147 | NO WARRANTY 1148 | 1149 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 1150 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 1151 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 1152 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 1153 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 1154 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1155 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 1156 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 1157 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 1158 | 1159 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 1160 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 1161 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 1162 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 1163 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 1164 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 1165 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 1166 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 1167 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1168 | DAMAGES. 1169 | 1170 | END OF TERMS AND CONDITIONS 1171 | 1172 | How to Apply These Terms to Your New Libraries 1173 | 1174 | If you develop a new library, and you want it to be of the greatest 1175 | possible use to the public, we recommend making it free software that 1176 | everyone can redistribute and change. You can do so by permitting 1177 | redistribution under these terms (or, alternatively, under the terms of the 1178 | ordinary General Public License). 1179 | 1180 | To apply these terms, attach the following notices to the library. It is 1181 | safest to attach them to the start of each source file to most effectively 1182 | convey the exclusion of warranty; and each file should have at least the 1183 | "copyright" line and a pointer to where the full notice is found. 1184 | 1185 | 1186 | Copyright (C) 1187 | 1188 | This library is free software; you can redistribute it and/or 1189 | modify it under the terms of the GNU Lesser General Public 1190 | License as published by the Free Software Foundation; either 1191 | version 2.1 of the License, or (at your option) any later version. 1192 | 1193 | This library is distributed in the hope that it will be useful, 1194 | but WITHOUT ANY WARRANTY; without even the implied warranty of 1195 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1196 | Lesser General Public License for more details. 1197 | 1198 | You should have received a copy of the GNU Lesser General Public 1199 | License along with this library; if not, write to the Free Software 1200 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 1201 | 1202 | Also add information on how to contact you by electronic and paper mail. 1203 | 1204 | You should also get your employer (if you work as a programmer) or your 1205 | school, if any, to sign a "copyright disclaimer" for the library, if 1206 | necessary. Here is a sample; alter the names: 1207 | 1208 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 1209 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 1210 | 1211 | , 1 April 1990 1212 | Ty Coon, President of Vice 1213 | 1214 | That's all there is to it! 1215 | 1216 | 1217 | ======================================================================= 1218 | 1219 | OCAMLPRO INDIVIDUAL CONTRIBUTOR LICENSE AGREEMENT 1220 | 1221 | 1222 | http://www.ocamlpro.com/files/CLA-OCamlPro-individual.txt 1223 | 1224 | In order to clarify the intellectual property license granted with 1225 | Contributions from any person or entity, OCamlPro SAS ("OCamlPro") must 1226 | have a Contributor License Agreement ("CLA") on file that has been 1227 | signed by each Contributor, indicating agreement to the license terms 1228 | below. This license is for your protection as a Contributor as well as 1229 | the protection of OCamlPro; it does not change your rights to use your 1230 | own Contributions for any other purpose. If you have not already done 1231 | so, please send a message to cla@ocamlpro.com with the following 1232 | content: 1233 | 1234 | -------------------------------------------------------- BEGIN EMAIL 1235 | I agree with the Contributor License Agreement in 1236 | http://www.ocamlpro.com/files/CLA-OCamlPro-individual.txt 1237 | that I have read carefully. 1238 | 1239 | FULL NAME: _______________ 1240 | EMAIL: _____@_________ 1241 | MAILING ADDRESS: 1242 | ______________________________ 1243 | ______________________________ 1244 | ______________________________ 1245 | COUNTRY: 1246 | PHONE: 1247 | 1248 | -------------------------------------------------------- END EMAIL 1249 | 1250 | You accept and agree to the following terms and conditions for Your 1251 | present and future Contributions submitted to OCamlPro. Except for the 1252 | license granted herein to OCamlPro and recipients of software 1253 | distributed by OCamlPro, You reserve all right, title, and interest in 1254 | and to Your Contributions. 1255 | 1256 | 1. Definitions. 1257 | 1258 | "You" (or "Your") shall mean the copyright owner or legal entity 1259 | authorized by the copyright owner that is making this Agreement with 1260 | OCamlPro. For legal entities, the entity making a Contribution and all 1261 | other entities that control, are controlled by, or are under common 1262 | control with that entity are considered to be a single 1263 | Contributor. For the purposes of this definition, "control" means (i) 1264 | the power, direct or indirect, to cause the direction or management of 1265 | such entity, whether by contract or otherwise, or (ii) ownership of 1266 | fifty percent (50%) or more of the outstanding shares, or (iii) 1267 | beneficial ownership of such entity. 1268 | 1269 | "Contribution" shall mean any original work of authorship, including 1270 | any modifications or additions to an existing work, that is 1271 | intentionally submitted by You to OCamlPro for inclusion in, or 1272 | documentation of, any of the products owned or managed by OCamlPro 1273 | (the "Work"). For the purposes of this definition, "submitted" means 1274 | any form of electronic, verbal, or written communication sent to 1275 | OCamlPro or its representatives, including but not limited to 1276 | communication on electronic mailing lists, source code control 1277 | systems, and issue tracking systems that are managed by, or on behalf 1278 | of, OCamlPro for the purpose of discussing and improving the Work, but 1279 | excluding communication that is conspicuously marked or otherwise 1280 | designated in writing by You as "Not a Contribution." 1281 | 1282 | 2. Grant of Copyright License. 1283 | 1284 | Subject to the terms and conditions of this Agreement, You hereby 1285 | grant to OCamlPro and to recipients of software distributed by 1286 | OCamlPro a perpetual, worldwide, non-exclusive, no-charge, 1287 | royalty-free, irrevocable copyright license to reproduce, prepare 1288 | derivative works of, publicly display, publicly perform, sublicense, 1289 | and distribute Your Contributions and such derivative works. 1290 | 1291 | 3. Grant of Patent License. 1292 | 1293 | Subject to the terms and conditions of this Agreement, You hereby 1294 | grant to OCamlPro and to recipients of software distributed by 1295 | OCamlPro a perpetual, worldwide, non-exclusive, no-charge, 1296 | royalty-free, irrevocable (except as stated in this section) patent 1297 | license to make, have made, use, offer to sell, sell, import, and 1298 | otherwise transfer the Work, where such license applies only to those 1299 | patent claims licensable by You that are necessarily infringed by Your 1300 | Contribution(s) alone or by combination of Your Contribution(s) with 1301 | the Work to which such Contribution(s) was submitted. If any entity 1302 | institutes patent litigation against You or any other entity 1303 | (including a cross-claim or counterclaim in a lawsuit) alleging that 1304 | your Contribution, or the Work to which you have contributed, 1305 | constitutes direct or contributory patent infringement, then any 1306 | patent licenses granted to that entity under this Agreement for that 1307 | Contribution or Work shall terminate as of the date such litigation is 1308 | filed. 1309 | 1310 | 4. You represent that you are legally entitled to grant the above 1311 | license. If your employer(s) has rights to intellectual property that 1312 | you create that includes your Contributions, you represent that you 1313 | have received permission to make Contributions on behalf of that 1314 | employer, that your employer has waived such rights for your 1315 | Contributions to OCamlPro, or that your employer has executed a 1316 | separate Corporate CLA with OCamlPro. 1317 | 1318 | 5. You represent that each of Your Contributions is Your original 1319 | creation (see section 7 for submissions on behalf of others). You 1320 | represent that Your Contribution submissions include complete details 1321 | of any third-party license or other restriction (including, but not 1322 | limited to, related patents and trademarks) of which you are 1323 | personally aware and which are associated with any part of Your 1324 | Contributions. 1325 | 1326 | 6. You are not expected to provide support for Your Contributions, 1327 | except to the extent You desire to provide support. You may provide 1328 | support for free, for a fee, or not at all. Unless required by 1329 | applicable law or agreed to in writing, You provide Your Contributions 1330 | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 1331 | either express or implied, including, without limitation, any 1332 | warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, 1333 | or FITNESS FOR A PARTICULAR PURPOSE. 1334 | 1335 | 7. Should You wish to submit work that is not Your original creation, 1336 | You may submit it to OCamlPro separately from any Contribution, 1337 | identifying the complete details of its source and of any license or 1338 | other restriction (including, but not limited to, related patents, 1339 | trademarks, and license agreements) of which you are personally aware, 1340 | and conspicuously marking the work as "Submitted on behalf of a 1341 | third-party: [[]named here]". 1342 | 1343 | 8. You agree to notify OCamlPro of any facts or circumstances of which 1344 | you become aware that would make these representations inaccurate in 1345 | any respect. 1346 | 1347 | ======================================================================= 1348 | 1349 | OCAMLPRO CONTRIBUTOR LICENSE AGREMENT 1350 | FOR CORPORATE CONTRIBUTOR 1351 | ------------------------------------- 1352 | 1353 | In order to clarify the intellectual property license granted with 1354 | Contributions from any person or entity, OCamlPro SAS ("OCamlPro") 1355 | must have a Contributor License Agreement (CLA) on file that has been 1356 | signed by each Contributor, indicating agreement to the license terms 1357 | below. This license is for your protection as a Contributor as well 1358 | as the protection of OCamlPro and its users; it does not change your 1359 | rights to use your own Contributions for any other purpose. 1360 | 1361 | This version of the Agreement allows an entity (the "Corporation") 1362 | to submit Contributions to OCamlPro, to authorize Contributions 1363 | submitted by its designated employees to OCamlPro, and to grant 1364 | copyright and patent licenses thereto. 1365 | 1366 | If you have not already done so, please complete and sign, then scan and 1367 | email a pdf file of this Agreement to contact@ocamlpro.com. 1368 | 1369 | Corporation name: ________________________________________________ 1370 | 1371 | Corporation address: ________________________________________________ 1372 | 1373 | ________________________________________________ 1374 | 1375 | ________________________________________________ 1376 | 1377 | Point of Contact: ________________________________________________ 1378 | 1379 | E-Mail: ________________________________________________ 1380 | 1381 | Telephone: _____________________ Fax: _____________________ 1382 | 1383 | 1384 | You accept and agree to the following terms and conditions for Your 1385 | present and future Contributions submitted to OCamlPro. In 1386 | return, OCamlPro shall not use Your Contributions in a way that 1387 | is contrary to the public benefit or inconsistent with its nonprofit 1388 | status and bylaws in effect at the time of the Contribution. Except 1389 | for the license granted herein to OCamlPro and recipients of 1390 | software distributed by OCamlPro, You reserve all right, title, 1391 | and interest in and to Your Contributions. 1392 | 1393 | 1. Definitions. 1394 | 1395 | "You" (or "Your") shall mean the copyright owner or legal entity 1396 | authorized by the copyright owner that is making this Agreement 1397 | with OCamlPro. For legal entities, the entity making a 1398 | Contribution and all other entities that control, are controlled by, 1399 | or are under common control with that entity are considered to be a 1400 | single Contributor. For the purposes of this definition, "control" 1401 | means (i) the power, direct or indirect, to cause the direction or 1402 | management of such entity, whether by contract or otherwise, or 1403 | (ii) ownership of fifty percent (50%) or more of the outstanding 1404 | shares, or (iii) beneficial ownership of such entity. 1405 | 1406 | "Contribution" shall mean the code, documentation or other original 1407 | works of authorship expressly identified in Schedule B, as well as 1408 | any original work of authorship, including 1409 | any modifications or additions to an existing work, that is intentionally 1410 | submitted by You to OCamlPro for inclusion in, or 1411 | documentation of, any of the products owned or managed by 1412 | OCamlPro (the "Work"). For the purposes of this definition, 1413 | "submitted" means any form of electronic, verbal, or written 1414 | communication sent to OCamlPro or its representatives, 1415 | including but not limited to communication on electronic mailing 1416 | lists, source code control systems, and issue tracking systems 1417 | that are managed by, or on behalf of, OCamlPro for the 1418 | purpose of discussing and improving the Work, but excluding 1419 | communication that is conspicuously marked or otherwise designated 1420 | in writing by You as "Not a Contribution." 1421 | 1422 | 2. Grant of Copyright License. Subject to the terms and conditions 1423 | of this Agreement, You hereby grant to OCamlPro and to 1424 | recipients of software distributed by OCamlPro a perpetual, 1425 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 1426 | copyright license to reproduce, prepare derivative works of, 1427 | publicly display, publicly perform, sublicense, and distribute 1428 | Your Contributions and such derivative works. 1429 | 1430 | 3. Grant of Patent License. Subject to the terms and conditions of 1431 | this Agreement, You hereby grant to OCamlPro and to recipients 1432 | of software distributed by OCamlPro a perpetual, worldwide, 1433 | non-exclusive, no-charge, royalty-free, irrevocable (except as 1434 | stated in this section) patent license to make, have made, use, 1435 | offer to sell, sell, import, and otherwise transfer the Work, 1436 | where such license applies only to those patent claims licensable 1437 | by You that are necessarily infringed by Your Contribution(s) 1438 | alone or by combination of Your Contribution(s) with the Work to 1439 | which such Contribution(s) were submitted. If any entity institutes 1440 | patent litigation against You or any other entity (including a 1441 | cross-claim or counterclaim in a lawsuit) alleging that your 1442 | Contribution, or the Work to which you have contributed, constitutes 1443 | direct or contributory patent infringement, then any patent licenses 1444 | granted to that entity under this Agreement for that Contribution or 1445 | Work shall terminate as of the date such litigation is filed. 1446 | 1447 | 4. You represent that You are legally entitled to grant the above 1448 | license. You represent further that each employee of the 1449 | Corporation designated on Schedule A below (or in a subsequent 1450 | written modification to that Schedule) is authorized to submit 1451 | Contributions on behalf of the Corporation. 1452 | 1453 | 5. You represent that each of Your Contributions is Your original 1454 | creation (see section 7 for submissions on behalf of others). 1455 | 1456 | 6. You are not expected to provide support for Your Contributions, 1457 | except to the extent You desire to provide support. You may provide 1458 | support for free, for a fee, or not at all. Unless required by 1459 | applicable law or agreed to in writing, You provide Your 1460 | Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 1461 | OF ANY KIND, either express or implied, including, without 1462 | limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, 1463 | MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. 1464 | 1465 | 7. Should You wish to submit work that is not Your original creation, 1466 | You may submit it to OCamlPro separately from any 1467 | Contribution, identifying the complete details of its source and 1468 | of any license or other restriction (including, but not limited 1469 | to, related patents, trademarks, and license agreements) of which 1470 | you are personally aware, and conspicuously marking the work as 1471 | "Submitted on behalf of a third-party: [named here]". 1472 | 1473 | 8. It is your responsibility to notify OCamlPro when any change 1474 | is required to the list of designated employees authorized to submit 1475 | Contributions on behalf of the Corporation, or to the Corporation's 1476 | Point of Contact with OCamlPro. 1477 | 1478 | 1479 | 1480 | Please sign: __________________________________ Date: _______________ 1481 | 1482 | Title: __________________________________ 1483 | 1484 | Corporation: __________________________________ 1485 | 1486 | 1487 | Schedule A 1488 | 1489 | [Initial list of designated employees. NB: authorization is not 1490 | tied to particular Contributions.] 1491 | 1492 | 1493 | 1494 | 1495 | Schedule B 1496 | 1497 | [Identification of optional concurrent software grant. Would be 1498 | left blank or omitted if there is no concurrent software grant.] 1499 | 1500 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # opam-ed: a small command-line edition tool for the opam syntax 2 | 3 | `opam-ed` can read and write files in the general 4 | [opam syntax](http://opam.ocaml.org/doc/2.0/Manual.html#Commonfileformat). It 5 | provides a small CLI with some useful commands for extracting or modifying the 6 | file contents. 7 | 8 | The program reads from stdin, writes to stdout, and processes each argument as 9 | one of the commands listed below. See `opam-ed --help` for more options. 10 | 11 | ### Commands 12 | 13 | (as extracted from the generated manpage) 14 | 15 | - `get FIELD` 16 | Print out the value of the named FIELD. 17 | 18 | - `field-list` 19 | List the field names present in the input. 20 | 21 | - `field-items FIELD` 22 | Print out the items of FIELD, understood as a list, separated by 23 | newlines. 24 | 25 | - `get-section SECTION` 26 | Extract and print the contents of the given SECTION. 27 | 28 | - `add FIELD value` 29 | Add the given FIELD, with the given contents, to the file, if it 30 | didn't exist already 31 | 32 | - `remove FIELD` 33 | Remove the given FIELD from the file, if present. 34 | 35 | - `replace FIELD value` 36 | Replace the contents of the given FIELD, if found, by the given 37 | value. 38 | 39 | - `add-replace FIELD value` 40 | Replace the contents of the given FIELD by the given value, adding 41 | the field if not present already. This is equivalent to the 42 | sequence 'remove FIELD' 'add FIELD value' 43 | 44 | - `append FIELD value` 45 | Append the given value to the given FIELD, treated as a list. The 46 | field is created as a singleton if it didn't exist 47 | 48 | - `prepend FIELD value` 49 | Prepend the given value to the given FIELD, treated as a list. The 50 | field is created as a singleton if it didn't exist 51 | 52 | - `map FIELD command` 53 | Run the given shell command with each member of FIELD, treated as 54 | a list, as input, and replace it by the output of the command. 55 | 56 | - `filter FIELD cmd` 57 | Run the given shell command with each member of FIELD, treated as 58 | a list, as input, and remove any member for which the command 59 | doesn't return 0. 60 | 61 | - `replace-item FIELD value replacement` 62 | Replace the first item of the contents of FIELD, treated as a 63 | list, that is equal to value, with replacement. Nothing happens if 64 | value is not a member of the FIELD. 65 | 66 | - `add-replace-item FIELD value replacement` 67 | Replace the first item of the contents of FIELD, treated as a 68 | list, that is equal to value, with replacement. replacement is 69 | appended to FIELD if value was not found. 70 | 71 | - `remove-item FIELD value` 72 | Remove the first item of the contents of FIELD, treated as a list, 73 | that is equal to value, if any. 74 | 75 | ### License 76 | 77 | Copyright 2017-2023 OCamlPro. 78 | opam-ed is distributed under the terms of the GNU General Public License 79 | version 2.1, with the special exception on linking describted in the file 80 | LICENSE. 81 | -------------------------------------------------------------------------------- /dune: -------------------------------------------------------------------------------- 1 | ; Make partial-match an error to make sure the tool matches the AST from opam-file-format 2 | (env (_ (flags :standard -w @8))) 3 | -------------------------------------------------------------------------------- /dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.0) 2 | (name opam-ed) 3 | (version 0.4) 4 | (formatting disabled) 5 | -------------------------------------------------------------------------------- /opam-ed.opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | version: "0.4" 3 | maintainer: "Louis Gesbert " 4 | authors: "Louis Gesbert " 5 | license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" 6 | homepage: "https://github.com/AltGr/opam-ed" 7 | bug-reports: "https://github.com/AltGr/opam-ed/issues" 8 | depends: [ 9 | "ocaml" {>= "4.03.0"} 10 | "dune" {>= "2.0"} 11 | "cmdliner" {>= "1.0.0"} 12 | "opam-file-format" {>= "2.0.0"} 13 | ] 14 | build: ["dune" "build" "-p" name "-j" jobs] 15 | run-test: ["dune" "runtest" "-p" name "-j" jobs] 16 | dev-repo: "git+https://github.com/AltGr/opam-ed.git" 17 | synopsis: "Command-line edition tool for handling the opam file syntax" 18 | description: """ 19 | opam-ed can read and write files in the general opam syntax. It provides a small CLI with some useful commands for mechanically extracting or modifying the file contents. 20 | 21 | The specification for the syntax itself is available at: 22 | http://opam.ocaml.org/doc/Manual.html#Common-file-format 23 | """ 24 | -------------------------------------------------------------------------------- /src/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name opamEdMain) 3 | (public_name opam-ed) 4 | (libraries unix cmdliner opam-file-format)) 5 | 6 | (rule 7 | (target opam-ed.1) 8 | (action 9 | (with-stdout-to %{target} 10 | (run opam-ed --help=groff)))) 11 | 12 | (install (files opam-ed.1) (section man)) 13 | -------------------------------------------------------------------------------- /src/opamEdMain.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2016 OCamlPro *) 4 | (* *) 5 | (* All rights reserved. This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 2.1, with the special *) 7 | (* exception on linking described in the file LICENSE. *) 8 | (* *) 9 | (**************************************************************************) 10 | 11 | open OpamParserTypes 12 | open Cmdliner 13 | 14 | type path = string list 15 | type shell_command = string 16 | 17 | let fatal_exn = function 18 | | Sys.Break as e -> raise e 19 | | _ -> () 20 | 21 | let string_cut c s = 22 | try 23 | let i = String.index s c in 24 | String.sub s 0 i, Some (String.sub s (i+1) (String.length s - i - 1)) 25 | with Not_found -> 26 | s, None 27 | 28 | let rec string_split c s = 29 | match string_cut c s with 30 | | s, None -> [s] 31 | | s, Some s' -> s :: string_split c s' 32 | 33 | let path_of_string s = string_split '.' s 34 | let string_of_path f = String.concat "." f 35 | let shell_command_of_string s = s 36 | let string_of_shell_command c = c 37 | 38 | type command = 39 | (* extraction commands *) 40 | | Get of path 41 | | Field_list 42 | | Field_items of path 43 | | Get_section of path 44 | (* edition commands *) 45 | | Add of path * value 46 | | Remove of path 47 | | Replace of path * value 48 | | Add_replace of path * value 49 | | Append of path * value 50 | | Prepend of path * value 51 | | Map of path * shell_command 52 | | Filter of path * shell_command 53 | | Replace_item of path * value * value 54 | | Add_replace_item of path * value * value 55 | | Remove_item of path * value 56 | 57 | let command_of_string s = 58 | let value_of_strings ss = 59 | let s = String.concat " " ss in 60 | try OpamParser.value_from_string s "" 61 | with Parsing.Parse_error -> 62 | Printf.ksprintf failwith "Syntax error in value in %S" s 63 | in 64 | let check_empty r = 65 | if r <> [] then 66 | Printf.kprintf failwith "Invalid extra argument %S" 67 | (String.concat " " r) 68 | in 69 | match string_split ' ' s with 70 | | "get" :: f :: r -> check_empty r; 71 | Get (path_of_string f) 72 | | "field-list" :: r -> check_empty r; 73 | Field_list 74 | | "field-items" :: f :: r -> check_empty r; 75 | Field_items (path_of_string f) 76 | | "get-section" :: sec :: r -> check_empty r; 77 | Get_section (path_of_string sec) 78 | | "add" :: f :: v -> 79 | Add (path_of_string f, value_of_strings v) 80 | | "remove" :: s :: r -> check_empty r; 81 | Remove (path_of_string s) 82 | | "replace" :: s :: v -> 83 | Replace (path_of_string s, value_of_strings v) 84 | | "add-replace" :: s :: v -> 85 | Add_replace (path_of_string s, value_of_strings v) 86 | | "append" :: s :: v -> 87 | Append (path_of_string s, value_of_strings v) 88 | | "prepend":: s :: v -> 89 | Prepend (path_of_string s, value_of_strings v) 90 | | "map" :: s :: cmd -> 91 | Map (path_of_string s, shell_command_of_string (String.concat " " cmd)) 92 | | "filter" :: s :: cmd -> 93 | Filter (path_of_string s, shell_command_of_string (String.concat " " cmd)) 94 | | "replace-item" :: s :: vs -> 95 | begin match value_of_strings ("[" :: vs @ ["]"]) with 96 | | List (_, [v1; v2]) -> Replace_item (path_of_string s, v1, v2) 97 | | _ -> 98 | failwith "replace-item expects 3 arguments: field name, expression to \ 99 | replace, and replacement" 100 | end 101 | | "add-replace-item" :: s :: vs -> 102 | begin match value_of_strings ("[" :: vs @ ["]"]) with 103 | | List (_, [v1; v2]) -> Add_replace_item (path_of_string s, v1, v2) 104 | | _ -> 105 | failwith "replace-item expects 3 arguments: field name, expression to \ 106 | replace, and replacement" 107 | end 108 | | "remove-item" :: s :: v -> 109 | Remove_item (path_of_string s, value_of_strings v) 110 | | _ -> 111 | Printf.ksprintf failwith "Invalid command: %S" s 112 | 113 | let string_of_command = 114 | let (!) f = fun () -> f in 115 | function 116 | | Get f -> 117 | Printf.sprintf "get %a" !string_of_path f 118 | | Field_list -> 119 | "field-list" 120 | | Field_items f -> 121 | Printf.sprintf "field-items %a" !string_of_path f 122 | | Get_section sec -> 123 | Printf.sprintf "get-section %a" !string_of_path sec 124 | | Add (f, v) -> 125 | Printf.sprintf "add %a %a" !string_of_path f !OpamPrinter.value v 126 | | Remove f -> 127 | Printf.sprintf "remove %a" !string_of_path f 128 | | Replace (f, v) -> 129 | Printf.sprintf "replace %a %a" !string_of_path f !OpamPrinter.value v 130 | | Add_replace (f, v) -> 131 | Printf.sprintf "add-replace %a %a" !string_of_path f !OpamPrinter.value v 132 | | Append (f, v) -> 133 | Printf.sprintf "append %a %a" !string_of_path f !OpamPrinter.value v 134 | | Prepend (f, v) -> 135 | Printf.sprintf "prepend %a %a" !string_of_path f !OpamPrinter.value v 136 | | Map (f, cmd) -> 137 | Printf.sprintf "map %a %a" !string_of_path f !string_of_shell_command cmd 138 | | Filter (f, cmd) -> 139 | Printf.sprintf "filter %a %a" !string_of_path f 140 | !string_of_shell_command cmd 141 | | Replace_item (f, v1, v2) -> 142 | Printf.sprintf "replace-item %a %a %a" !string_of_path f 143 | !OpamPrinter.value v1 144 | !OpamPrinter.value v2 145 | | Add_replace_item (f, v1, v2) -> 146 | Printf.sprintf "add-replace-item %a %a %a" !string_of_path f 147 | !OpamPrinter.value v1 148 | !OpamPrinter.value v2 149 | | Remove_item (f, v) -> 150 | Printf.sprintf "remove-item %a %a" !string_of_path f !OpamPrinter.value v 151 | 152 | let is_extraction_command = function 153 | | Get _ | Field_list | Field_items _ | Get_section _ -> true 154 | | _ -> false 155 | 156 | let is_edition_command c = not (is_extraction_command c) 157 | 158 | let arg_files = 159 | let doc = 160 | "File to process. If unspecified, stdin is used. Can be repeated." 161 | in 162 | Arg.(value & opt_all file [] & info ~docv:"FILE" ~doc ["file"; "f"]) 163 | 164 | let arg_inplace = 165 | let doc = 166 | "When editing files, overwrite them rather than print the result to \ 167 | standard output." 168 | in 169 | Arg.(value & flag & info ~doc ["inplace"; "i"]) 170 | 171 | let arg_normalise = 172 | Arg.(value & vflag `Preserve [ 173 | `Preserve, info ["preserve"] ~doc: 174 | "Preserve the formatting of unchanged parts of the file."; 175 | `Reformat, info ["reformat"] ~doc: 176 | "Reformat the file contents when printing. This discards comments."; 177 | `Canonical, info ["canonical"] ~doc: 178 | "Output the file in canonical format (ordered fields, minimal \ 179 | formatting), for reproducible signatures." 180 | ]) 181 | 182 | let arg_commands = 183 | let doc = "Specify the commands to process" in 184 | let cmd = 185 | Arg.conv ~docv:"COMMAND" 186 | ((fun s -> try Ok (command_of_string s) with Failure m -> Error (`Msg m)), 187 | (fun fmt cmd -> Format.pp_print_string fmt (string_of_command cmd))) 188 | in 189 | Arg.(value & pos_all cmd [] & info ~docv:"COMMAND" ~doc []) 190 | 191 | let string_of_channel ic = 192 | let b = Buffer.create 4096 in 193 | try while true do Buffer.add_channel b ic 4096 done; assert false 194 | with End_of_file -> Buffer.contents b 195 | 196 | let shell_command cmd text = 197 | let ic, oc as process = Unix.open_process cmd in 198 | output_string oc text; 199 | close_out oc; 200 | let s = string_of_channel ic in 201 | match Unix.close_process process with 202 | | Unix.WEXITED 0 -> Some s 203 | | Unix.WSIGNALED i when i = Sys.sigint -> raise Sys.Break 204 | | _ -> None 205 | 206 | let rec get_field fld = function 207 | | [] -> raise Not_found 208 | | Variable (_, f, v) :: _ when f = fld -> v 209 | | _ :: r -> get_field fld r 210 | 211 | let rec get_section sec = function 212 | | [] -> raise Not_found 213 | | Section (_, {section_kind; section_items}) :: _ when section_kind = sec -> 214 | section_items 215 | | _ :: r -> get_section sec r 216 | 217 | let rec get_path path items = 218 | match path with 219 | | [] -> failwith "Invalid empty field specification" 220 | | [fld] -> get_field fld items 221 | | sec::path -> get_path path (get_section sec items) 222 | 223 | let pos_null = "", -1, -1 224 | 225 | let rec map_field ?absent f fld = function 226 | | Variable (pos, name, v) :: r when name = fld -> 227 | (match f v with 228 | | None -> r 229 | | Some v -> Variable (pos, name, v) :: r) 230 | | x :: r -> x :: map_field ?absent f fld r 231 | | [] -> match absent with 232 | | None -> [] 233 | | Some v -> [Variable (pos_null, fld, v ())] 234 | 235 | let rec map_section ?absent f sec = function 236 | | Section (pos, ({section_kind; _} as s)) :: r when section_kind = sec -> 237 | (match f s.section_items with 238 | | None -> r 239 | | Some section_items -> Section (pos, {s with section_items}) :: r) 240 | | x :: r -> x :: map_section ?absent f sec r 241 | | [] -> match absent with 242 | | None -> [] 243 | | Some v -> 244 | let s = { 245 | section_kind = sec; 246 | section_name = None; 247 | section_items = v (); 248 | } in 249 | [Section (pos_null, s)] 250 | 251 | let rec map_path ?absent f path items = 252 | match path with 253 | | [] -> failwith "Invalid empty field specification" 254 | | [fld] -> map_field ?absent f fld items 255 | | sec::path -> 256 | let abs = match absent with 257 | | None -> None 258 | | Some a -> Some (fun () -> map_path ~absent:a f path []) 259 | in 260 | map_section ?absent:abs 261 | (fun it -> Some (map_path ?absent f path it)) 262 | sec items 263 | 264 | let get_list = function 265 | | List (_, l) -> l 266 | | elt -> [elt] 267 | 268 | let list ?(pos=pos_null) = function 269 | | [] -> None 270 | | its -> Some (List (pos, its)) 271 | 272 | let map_list f = function 273 | | List (pos, l) -> list ~pos (f l) 274 | | elt -> 275 | match f [elt] with 276 | | [e] -> Some e 277 | | l -> list l 278 | 279 | let singleton x = List (pos_null, [x]) 280 | 281 | let rec value_equals v1 v2 = match v1, v2 with 282 | | Bool (_, b1), Bool (_, b2) -> b1 = b2 283 | | Int (_, i1), Int (_, i2) -> i1 = i2 284 | | String (_, s1), String (_, s2) -> s1 = s2 285 | | Relop (_, r1, va1, vb1), Relop (_, r2, va2, vb2) -> 286 | r1 = r2 && value_equals va1 va2 && value_equals vb1 vb2 287 | | Prefix_relop (_, r1, v1), Prefix_relop (_, r2, v2) -> 288 | r1 = r2 && value_equals v1 v2 289 | | Logop (_, l1, va1, vb1), Logop (_, l2, va2, vb2) -> 290 | l1 = l2 && value_equals va1 va2 && value_equals vb1 vb2 291 | | Pfxop (_, p1, v1), Pfxop (_, p2, v2) -> 292 | p1 = p2 && value_equals v1 v2 293 | | Ident (_, s1), Ident (_, s2) -> 294 | s1 = s2 295 | | List (_, vl1), List (_, vl2) -> 296 | (try List.for_all2 value_equals vl1 vl2 with Invalid_argument _ -> false) 297 | | Group (_, vl1), Group (_, vl2) -> 298 | (try List.for_all2 value_equals vl1 vl2 with Invalid_argument _ -> false) 299 | | Option (_, v1, vl1), Option (_, v2, vl2) -> 300 | value_equals v1 v2 && 301 | (try List.for_all2 value_equals vl1 vl2 with Invalid_argument _ -> false) 302 | | Env_binding (_, v1, op1, vx1), Env_binding (_, v2, op2, vx2) -> 303 | op1 = op2 && value_equals v1 v2 && value_equals vx1 vx2 304 | | _ -> false 305 | 306 | let exec_command f cmd = 307 | let contents = f.file_contents in 308 | let msg = 309 | match cmd with 310 | | Get path -> Some (OpamPrinter.value (get_path path contents)) 311 | | Field_list -> 312 | let rec list_fields pfx = function 313 | | Section (_, {section_kind; section_items; _}) :: r -> 314 | list_fields (pfx^section_kind^".") section_items @ 315 | list_fields pfx r 316 | | Variable (_, fld, _) :: r -> 317 | (pfx ^ fld) :: list_fields pfx r 318 | | [] -> [] 319 | in 320 | let flds = list_fields "" contents in 321 | Some (String.concat "\n" flds) 322 | | Field_items path -> 323 | let l = get_list (get_path path contents) in 324 | let items = List.map OpamPrinter.value l in 325 | Some (String.concat "\n" items) 326 | | Get_section path -> 327 | let rec get contents = function 328 | | [] -> contents 329 | | sec :: path -> get (get_section sec contents) path 330 | in 331 | Some (OpamPrinter.items (get contents path)) 332 | | _ -> None 333 | in 334 | (match msg with Some m -> print_endline m | None -> ()); 335 | let contents = 336 | match cmd with 337 | | Get _ | Field_list | Field_items _ | Get_section _ -> contents 338 | | Add (path, v) -> 339 | map_path ~absent:(fun () -> v) 340 | (fun _ -> Printf.ksprintf failwith "Field %s exists already" 341 | (string_of_path path)) 342 | path contents 343 | | Remove path -> 344 | map_path (fun _ -> None) path contents 345 | | Replace (path, v) -> 346 | map_path (fun _ -> Some v) path contents 347 | | Add_replace (path, v) -> 348 | map_path ~absent:(fun () -> v) 349 | (fun _ -> Some v) path contents 350 | | Append (path, v) -> 351 | map_path ~absent:(fun () -> singleton v) 352 | (map_list (fun l -> l @ [v])) 353 | path contents 354 | | Prepend (path, v) -> 355 | map_path ~absent:(fun () -> singleton v) 356 | (map_list (fun l -> v :: l)) 357 | path contents 358 | | Map (path, cmd) -> 359 | map_path 360 | (map_list @@ List.map @@ fun v -> 361 | let s = OpamPrinter.value v in 362 | match shell_command cmd s with 363 | | None -> 364 | Printf.eprintf "Error while running command %S on %S\n" cmd s; 365 | v 366 | | Some s -> 367 | try OpamParser.value_from_string s f.file_name 368 | with Parsing.Parse_error -> 369 | Printf.eprintf 370 | "Error: command %S returned %S, which doesn't parse\n" 371 | cmd s; 372 | v) 373 | path contents 374 | | Filter (path, cmd) -> 375 | map_path 376 | (map_list @@ List.filter @@ fun v -> 377 | shell_command cmd (OpamPrinter.value v) <> None) 378 | path contents 379 | | Replace_item (path, v1, v2) -> 380 | let rec repl = function 381 | | [] -> [] 382 | | x::r when value_equals x v1 -> v2 :: r 383 | | x::r -> x :: repl r 384 | in 385 | map_path (map_list repl) path contents 386 | | Add_replace_item (path, v1, v2) -> 387 | let rec repl = function 388 | | [] -> [v2] 389 | | x::r when value_equals x v1 -> v2 :: r 390 | | x::r -> x :: repl r 391 | in 392 | map_path (map_list repl) path contents 393 | | Remove_item (path, v) -> 394 | let rec rem = function 395 | | [] -> [] 396 | | x::r when value_equals x v -> r 397 | | x::r -> x :: rem r 398 | in 399 | map_path (map_list rem) path contents 400 | in 401 | {f with file_contents = contents} 402 | 403 | let run files inplace normalise commands = 404 | let print txt orig f = 405 | match normalise with 406 | | `Preserve -> OpamPrinter.Preserved.items txt orig.file_contents f.file_contents 407 | | `Reformat -> OpamPrinter.opamfile f ^ "\n" 408 | | `Canonical -> OpamPrinter.Normalise.opamfile f 409 | in 410 | let needs_reprint = 411 | commands = [] || List.exists is_edition_command commands || 412 | inplace && normalise <> `Preserve 413 | in 414 | if files = [] then 415 | try 416 | let txt = try string_of_channel stdin with Sys_error _ -> "" in 417 | let orig = OpamParser.string txt "/dev/stdin" in 418 | let f = List.fold_left exec_command orig commands in 419 | if needs_reprint then print_string (print txt orig f) 420 | with e -> 421 | fatal_exn e; 422 | Printf.eprintf "Error on input from stdin: %s\n" 423 | (Printexc.to_string e); 424 | exit 10 425 | else 426 | let ok = 427 | List.fold_left (fun ok file -> 428 | try 429 | let txt = 430 | let ic = open_in file in 431 | try 432 | let s = string_of_channel ic in 433 | close_in ic; s 434 | with e -> close_in ic; raise e 435 | in 436 | let orig = OpamParser.string txt file in 437 | let f = List.fold_left exec_command orig commands in 438 | if not needs_reprint then ok else 439 | let s = print txt orig f in 440 | if inplace then 441 | let oc = open_out file in 442 | output_string oc s; 443 | close_out oc; 444 | ok 445 | else 446 | (output_string stdout s; 447 | flush stdout; 448 | ok) 449 | with e -> 450 | fatal_exn e; 451 | Printf.eprintf "Error on file %s: %s\n" file 452 | (Printexc.to_string e); 453 | false 454 | ) true files 455 | in 456 | if not ok then exit 10 457 | 458 | let cmd = 459 | Term.(pure run $ arg_files $ arg_inplace $ arg_normalise $ arg_commands) 460 | 461 | let man = [ 462 | `S "ARGUMENTS"; 463 | `S "COMMANDS"; 464 | `P "A list of commands, each as one argument, can be specified on the \ 465 | command-line. $(i,FIELD) and $(i,SECTION) arguments can be specified as \ 466 | paths separated with dots for accessing in-section elements (e.g. \ 467 | $(i,section.field))."; 468 | `P "$(b,extraction commands) always print their results to stdout, and don't \ 469 | modify the file:"; 470 | `I ("$(b,get) $(i,FIELD)", 471 | "Print out the value of the named $(i,FIELD)."); 472 | `I ("$(b,field-list)", 473 | "List the field names present in the input."); 474 | `I ("$(b,field-items) $(i,FIELD)", 475 | "Print out the items of $(i,FIELD), understood as a list, separated by \ 476 | newlines."); 477 | `I ("$(b,get-section) $(i,SECTION)", 478 | "Extract and print the contents of the given $(i,SECTION)."); 479 | `P "$(b,edition commands) modify the contents, and write to stdout, or back \ 480 | to the original file if $(b,--inplace) was specified:"; 481 | `I ("$(b,add) $(i,FIELD) $(i,value)", 482 | "Add the given $(i,FIELD), with the given contents, to the file, if it \ 483 | didn't exist already"); 484 | `I ("$(b,remove) $(i,FIELD)", 485 | "Remove the given $(i,FIELD) from the file, if present."); 486 | `I ("$(b,replace) $(i,FIELD) $(i,value)", 487 | "Replace the contents of the given $(i,FIELD), if found, by the given \ 488 | value."); 489 | `I ("$(b,add-replace) $(i,FIELD) $(i,value)", 490 | "Replace the contents of the given $(i,FIELD) by the given value, adding \ 491 | the field if not present already. This is equivalent to the sequence \ 492 | 'remove $(i,FIELD)' 'add $(i,FIELD) $(i,value)'"); 493 | `I ("$(b,append) $(i,FIELD) $(i,value)", 494 | "Append the given value to the given $(i,FIELD), treated as a list. The \ 495 | field is created as a singleton if it didn't exist"); 496 | `I ("$(b,prepend) $(i,FIELD) $(i,value)", 497 | "Prepend the given value to the given $(i,FIELD), treated as a list. The \ 498 | field is created as a singleton if it didn't exist"); 499 | `I ("$(b,map) $(i,FIELD) $(i,command)", 500 | "Run the given shell command with each member of $(i,FIELD), treated as \ 501 | a list, as input, and replace it by the output of the command."); 502 | `I ("$(b,filter) $(i,FIELD) $(i,cmd)", 503 | "Run the given shell command with each member of $(i,FIELD), treated as \ 504 | a list, as input, and remove any member for which the command doesn't \ 505 | return 0."); 506 | `I ("$(b,replace-item) $(i,FIELD) $(i,value) $(i,replacement)", 507 | "Replace the first item of the contents of $(i,FIELD), treated as a \ 508 | list, that is equal to $(i,value), with $(i,replacement). Nothing \ 509 | happens if $(i,value) is not a member of the $(i,FIELD)."); 510 | `I ("$(b,add-replace-item) $(i,FIELD) $(i,value) $(i,replacement)", 511 | "Replace the first item of the contents of $(i,FIELD), treated as a \ 512 | list, that is equal to $(i,value), with $(i,replacement). \ 513 | $(i,replacement) is appended to $(i,FIELD) if $(i,value) was not \ 514 | found."); 515 | `I ("$(b,remove-item) $(i,FIELD) $(i,value)", 516 | "Remove the first item of the contents of $(i,FIELD), treated as a \ 517 | list, that is equal to $(i,value), if any."); 518 | ] 519 | 520 | let main_cmd_info = 521 | Term.info "opam-ed" ~version:"0.4" 522 | ~doc:"A command-line editor for the opam file format" 523 | ~man 524 | 525 | let () = 526 | Sys.catch_break true; 527 | try 528 | let r = Term.eval (cmd, main_cmd_info) in 529 | Term.exit r 530 | with Sys.Break -> 531 | prerr_endline "Interrupted"; 532 | exit 130 533 | -------------------------------------------------------------------------------- /tests/dune: -------------------------------------------------------------------------------- 1 | (rule 2 | (alias runtest) 3 | (deps 4 | run.sh 5 | (package opam-ed)) 6 | (action (bash "./run.sh"))) 7 | -------------------------------------------------------------------------------- /tests/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ue 3 | #set -x 4 | 5 | echo "## Testing empty stdin" 6 | diff -u <(opam-ed "add bin [\"foo\"]" <&-) <(echo "bin: [\"foo\"]") 7 | 8 | file=./opam 9 | if [ -e $file ]; then rm $file; fi 10 | touch $file 11 | 12 | # populate 13 | for field in 'opam-version "2.0"' \ 14 | 'name "foo"' \ 15 | 'version "4.2"' \ 16 | 'depends ["ocaml" "bar" "quz"]' \ 17 | 'synopsis "Package descr"' \ 18 | 'description "Syn"' \ 19 | 'maintainer "Maintained"' \ 20 | 'authors "Auth"' \ 21 | 'homepage "url"' \ 22 | 'bug-reports "url"' \ 23 | 'tags "comp"' \ 24 | ; do 25 | opam-ed "add $field" -f $file --inplace 26 | done 27 | 28 | opam lint $file 29 | 30 | diff -u <(opam-ed field-list -f $file) - << EOF 31 | opam-version 32 | name 33 | version 34 | depends 35 | synopsis 36 | description 37 | maintainer 38 | authors 39 | homepage 40 | bug-reports 41 | tags 42 | EOF 43 | 44 | check-field () { 45 | op=$1 46 | field=$2 47 | in=$3 48 | if [ $# -eq 4 ]; then 49 | out=$4 50 | else 51 | out="" 52 | fi 53 | echo "## Testing $3" 54 | case $op in 55 | existent) 56 | diff -u <(opam-ed "$in" -f $file | grep "^$field") <(echo "$out") 57 | ;; 58 | missing) 59 | test ! `grep $field <(opam-ed "$in" -f $file)` 60 | ;; 61 | first) 62 | diff -u <(opam-ed "$in" -f $file | head -1) <(echo "$out") 63 | ;; 64 | last) 65 | diff -u <(opam-ed "$in" -f $file | tail -n 1) <(echo "$out") 66 | ;; 67 | esac 68 | } 69 | 70 | check-field missing "description" 'remove description' 'opam-version: "2.0"' 71 | check-field existent "version" 'replace version "2.4"' 'version: "2.4"' 72 | check-field existent "version" 'add-replace version "4.2"' 'version: "4.2"' 73 | check-field existent "description" 'add-replace description "snd one"' 'description: "snd one"' 74 | check-field existent "depext" 'append depext "m4"' 'depext: ["m4"]' 75 | check-field existent "tags" 'append tags "ap"' 'tags: ["comp" "ap"]' 76 | check-field existent "tags" 'prepend tags "pre"' 'tags: ["pre" "comp"]' 77 | check-field existent "depext" 'prepend depext "m4"' 'depext: ["m4"]' 78 | check-field existent "depends" 'map depends tr a A' 'depends: ["ocAml" "bAr" "quz"]' 79 | check-field existent "depends" 'filter depends grep a' 'depends: ["ocaml" "bar"]' 80 | check-field existent "depends" 'replace-item depends "quz" "baz"' 'depends: ["ocaml" "bar" "baz"]' 81 | check-field existent "depends" 'add-replace-item depends "quz" "baz"' 'depends: ["ocaml" "bar" "baz"]' 82 | check-field existent "depends" 'add-replace-item depends "miss" "baz"' 'depends: ["ocaml" "bar" "quz" "baz"]' 83 | check-field existent "depends" 'remove-item depends "quz"' 'depends: ["ocaml" "bar"]' 84 | 85 | rm $file 86 | --------------------------------------------------------------------------------