├── .gitignore ├── .travis.opam ├── .travis.yml ├── COPYING ├── COPYING-FR ├── Dockerfile ├── Library ├── Ancillary │ ├── autoinstall │ └── travisci ├── Autoconf │ ├── bsdowl.m4 │ └── ocaml.m4 ├── Configuration │ ├── debug.mk │ └── release.mk └── docker │ ├── Dockerfile │ ├── apt-setup.sh │ ├── auto_install.sh │ └── docker_gc.sh ├── Makefile ├── Makefile.config.in ├── Makefile.inc ├── README.md ├── aclocal.m4 ├── configure.ac ├── docker_gc ├── .ocamlinit ├── Makefile ├── dockerGc_Configuration.ml.in ├── dockerGc_Container.ml ├── dockerGc_Container.mli ├── dockerGc_Image.ml ├── dockerGc_Image.mli ├── dockerGc_Main.ml ├── dockerGc_Policy.ml ├── dockerGc_Policy.mli └── example.conf └── opam ├── descr └── opam /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Autoconf files 3 | # 4 | autom4te.cache/ 5 | config.log 6 | config.status 7 | configure 8 | Makefile.config 9 | Makefile.local 10 | .product 11 | .ocamlinit 12 | .merlin 13 | -------------------------------------------------------------------------------- /.travis.opam: -------------------------------------------------------------------------------- 1 | compiler: 2 | - 4.02.3 3 | repository: 4 | - atdgen 5 | - broken 6 | - ocamlfind 7 | - lwt 8 | - mixture 9 | git: 10 | - https://github.com/michipili/lemonade.git 11 | - https://github.com/michipili/rashell.git 12 | - https://github.com/michipili/gasoline.git 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | addons: 4 | apt: 5 | sources: 6 | - avsm 7 | packages: 8 | - ocaml 9 | - opam 10 | - ocaml-native-compilers 11 | install: sh -ex ./Library/Ancillary/autoinstall bmake bsdowl opam 12 | script: sh -ex ./Library/Ancillary/travisci 13 | cache: 14 | directories: 15 | - ${HOME}/.local 16 | - ${HOME}/.opam 17 | env: 18 | - TRAVIS_OCAML_VERSION=4.02.3 19 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | CeCILL-B FREE SOFTWARE LICENSE AGREEMENT 2 | 3 | 4 | Notice 5 | 6 | This Agreement is a Free Software license agreement that is the result 7 | of discussions between its authors in order to ensure compliance with 8 | the two main principles guiding its drafting: 9 | 10 | * firstly, compliance with the principles governing the distribution 11 | of Free Software: access to source code, broad rights granted to 12 | users, 13 | * secondly, the election of a governing law, French law, with which 14 | it is conformant, both as regards the law of torts and 15 | intellectual property law, and the protection that it offers to 16 | both authors and holders of the economic rights over software. 17 | 18 | The authors of the CeCILL-B (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) 19 | license are: 20 | 21 | Commissariat à l'Energie Atomique - CEA, a public scientific, technical 22 | and industrial research establishment, having its principal place of 23 | business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France. 24 | 25 | Centre National de la Recherche Scientifique - CNRS, a public scientific 26 | and technological establishment, having its principal place of business 27 | at 3 rue Michel-Ange, 75794 Paris cedex 16, France. 28 | 29 | Institut National de Recherche en Informatique et en Automatique - 30 | INRIA, a public scientific and technological establishment, having its 31 | principal place of business at Domaine de Voluceau, Rocquencourt, BP 32 | 105, 78153 Le Chesnay cedex, France. 33 | 34 | 35 | Preamble 36 | 37 | This Agreement is an open source software license intended to give users 38 | significant freedom to modify and redistribute the software licensed 39 | hereunder. 40 | 41 | The exercising of this freedom is conditional upon a strong obligation 42 | of giving credits for everybody that distributes a software 43 | incorporating a software ruled by the current license so as all 44 | contributions to be properly identified and acknowledged. 45 | 46 | In consideration of access to the source code and the rights to copy, 47 | modify and redistribute granted by the license, users are provided only 48 | with a limited warranty and the software's author, the holder of the 49 | economic rights, and the successive licensors only have limited liability. 50 | 51 | In this respect, the risks associated with loading, using, modifying 52 | and/or developing or reproducing the software by the user are brought to 53 | the user's attention, given its Free Software status, which may make it 54 | complicated to use, with the result that its use is reserved for 55 | developers and experienced professionals having in-depth computer 56 | knowledge. Users are therefore encouraged to load and test the 57 | suitability of the software as regards their requirements in conditions 58 | enabling the security of their systems and/or data to be ensured and, 59 | more generally, to use and operate it in the same conditions of 60 | security. This Agreement may be freely reproduced and published, 61 | provided it is not altered, and that no provisions are either added or 62 | removed herefrom. 63 | 64 | This Agreement may apply to any or all software for which the holder of 65 | the economic rights decides to submit the use thereof to its provisions. 66 | 67 | 68 | Article 1 - DEFINITIONS 69 | 70 | For the purpose of this Agreement, when the following expressions 71 | commence with a capital letter, they shall have the following meaning: 72 | 73 | Agreement: means this license agreement, and its possible subsequent 74 | versions and annexes. 75 | 76 | Software: means the software in its Object Code and/or Source Code form 77 | and, where applicable, its documentation, "as is" when the Licensee 78 | accepts the Agreement. 79 | 80 | Initial Software: means the Software in its Source Code and possibly its 81 | Object Code form and, where applicable, its documentation, "as is" when 82 | it is first distributed under the terms and conditions of the Agreement. 83 | 84 | Modified Software: means the Software modified by at least one 85 | Contribution. 86 | 87 | Source Code: means all the Software's instructions and program lines to 88 | which access is required so as to modify the Software. 89 | 90 | Object Code: means the binary files originating from the compilation of 91 | the Source Code. 92 | 93 | Holder: means the holder(s) of the economic rights over the Initial 94 | Software. 95 | 96 | Licensee: means the Software user(s) having accepted the Agreement. 97 | 98 | Contributor: means a Licensee having made at least one Contribution. 99 | 100 | Licensor: means the Holder, or any other individual or legal entity, who 101 | distributes the Software under the Agreement. 102 | 103 | Contribution: means any or all modifications, corrections, translations, 104 | adaptations and/or new functions integrated into the Software by any or 105 | all Contributors, as well as any or all Internal Modules. 106 | 107 | Module: means a set of sources files including their documentation that 108 | enables supplementary functions or services in addition to those offered 109 | by the Software. 110 | 111 | External Module: means any or all Modules, not derived from the 112 | Software, so that this Module and the Software run in separate address 113 | spaces, with one calling the other when they are run. 114 | 115 | Internal Module: means any or all Module, connected to the Software so 116 | that they both execute in the same address space. 117 | 118 | Parties: mean both the Licensee and the Licensor. 119 | 120 | These expressions may be used both in singular and plural form. 121 | 122 | 123 | Article 2 - PURPOSE 124 | 125 | The purpose of the Agreement is the grant by the Licensor to the 126 | Licensee of a non-exclusive, transferable and worldwide license for the 127 | Software as set forth in Article 5 hereinafter for the whole term of the 128 | protection granted by the rights over said Software. 129 | 130 | 131 | Article 3 - ACCEPTANCE 132 | 133 | 3.1 The Licensee shall be deemed as having accepted the terms and 134 | conditions of this Agreement upon the occurrence of the first of the 135 | following events: 136 | 137 | * (i) loading the Software by any or all means, notably, by 138 | downloading from a remote server, or by loading from a physical 139 | medium; 140 | * (ii) the first time the Licensee exercises any of the rights 141 | granted hereunder. 142 | 143 | 3.2 One copy of the Agreement, containing a notice relating to the 144 | characteristics of the Software, to the limited warranty, and to the 145 | fact that its use is restricted to experienced users has been provided 146 | to the Licensee prior to its acceptance as set forth in Article 3.1 147 | hereinabove, and the Licensee hereby acknowledges that it has read and 148 | understood it. 149 | 150 | 151 | Article 4 - EFFECTIVE DATE AND TERM 152 | 153 | 154 | 4.1 EFFECTIVE DATE 155 | 156 | The Agreement shall become effective on the date when it is accepted by 157 | the Licensee as set forth in Article 3.1. 158 | 159 | 160 | 4.2 TERM 161 | 162 | The Agreement shall remain in force for the entire legal term of 163 | protection of the economic rights over the Software. 164 | 165 | 166 | Article 5 - SCOPE OF RIGHTS GRANTED 167 | 168 | The Licensor hereby grants to the Licensee, who accepts, the following 169 | rights over the Software for any or all use, and for the term of the 170 | Agreement, on the basis of the terms and conditions set forth hereinafter. 171 | 172 | Besides, if the Licensor owns or comes to own one or more patents 173 | protecting all or part of the functions of the Software or of its 174 | components, the Licensor undertakes not to enforce the rights granted by 175 | these patents against successive Licensees using, exploiting or 176 | modifying the Software. If these patents are transferred, the Licensor 177 | undertakes to have the transferees subscribe to the obligations set 178 | forth in this paragraph. 179 | 180 | 181 | 5.1 RIGHT OF USE 182 | 183 | The Licensee is authorized to use the Software, without any limitation 184 | as to its fields of application, with it being hereinafter specified 185 | that this comprises: 186 | 187 | 1. permanent or temporary reproduction of all or part of the Software 188 | by any or all means and in any or all form. 189 | 190 | 2. loading, displaying, running, or storing the Software on any or 191 | all medium. 192 | 193 | 3. entitlement to observe, study or test its operation so as to 194 | determine the ideas and principles behind any or all constituent 195 | elements of said Software. This shall apply when the Licensee 196 | carries out any or all loading, displaying, running, transmission 197 | or storage operation as regards the Software, that it is entitled 198 | to carry out hereunder. 199 | 200 | 201 | 5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS 202 | 203 | The right to make Contributions includes the right to translate, adapt, 204 | arrange, or make any or all modifications to the Software, and the right 205 | to reproduce the resulting software. 206 | 207 | The Licensee is authorized to make any or all Contributions to the 208 | Software provided that it includes an explicit notice that it is the 209 | author of said Contribution and indicates the date of the creation thereof. 210 | 211 | 212 | 5.3 RIGHT OF DISTRIBUTION 213 | 214 | In particular, the right of distribution includes the right to publish, 215 | transmit and communicate the Software to the general public on any or 216 | all medium, and by any or all means, and the right to market, either in 217 | consideration of a fee, or free of charge, one or more copies of the 218 | Software by any means. 219 | 220 | The Licensee is further authorized to distribute copies of the modified 221 | or unmodified Software to third parties according to the terms and 222 | conditions set forth hereinafter. 223 | 224 | 225 | 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION 226 | 227 | The Licensee is authorized to distribute true copies of the Software in 228 | Source Code or Object Code form, provided that said distribution 229 | complies with all the provisions of the Agreement and is accompanied by: 230 | 231 | 1. a copy of the Agreement, 232 | 233 | 2. a notice relating to the limitation of both the Licensor's 234 | warranty and liability as set forth in Articles 8 and 9, 235 | 236 | and that, in the event that only the Object Code of the Software is 237 | redistributed, the Licensee allows effective access to the full Source 238 | Code of the Software at a minimum during the entire period of its 239 | distribution of the Software, it being understood that the additional 240 | cost of acquiring the Source Code shall not exceed the cost of 241 | transferring the data. 242 | 243 | 244 | 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE 245 | 246 | If the Licensee makes any Contribution to the Software, the resulting 247 | Modified Software may be distributed under a license agreement other 248 | than this Agreement subject to compliance with the provisions of Article 249 | 5.3.4. 250 | 251 | 252 | 5.3.3 DISTRIBUTION OF EXTERNAL MODULES 253 | 254 | When the Licensee has developed an External Module, the terms and 255 | conditions of this Agreement do not apply to said External Module, that 256 | may be distributed under a separate license agreement. 257 | 258 | 259 | 5.3.4 CREDITS 260 | 261 | Any Licensee who may distribute a Modified Software hereby expressly 262 | agrees to: 263 | 264 | 1. indicate in the related documentation that it is based on the 265 | Software licensed hereunder, and reproduce the intellectual 266 | property notice for the Software, 267 | 268 | 2. ensure that written indications of the Software intended use, 269 | intellectual property notice and license hereunder are included in 270 | easily accessible format from the Modified Software interface, 271 | 272 | 3. mention, on a freely accessible website describing the Modified 273 | Software, at least throughout the distribution term thereof, that 274 | it is based on the Software licensed hereunder, and reproduce the 275 | Software intellectual property notice, 276 | 277 | 4. where it is distributed to a third party that may distribute a 278 | Modified Software without having to make its source code 279 | available, make its best efforts to ensure that said third party 280 | agrees to comply with the obligations set forth in this Article . 281 | 282 | If the Software, whether or not modified, is distributed with an 283 | External Module designed for use in connection with the Software, the 284 | Licensee shall submit said External Module to the foregoing obligations. 285 | 286 | 287 | 5.3.5 COMPATIBILITY WITH THE CeCILL AND CeCILL-C LICENSES 288 | 289 | Where a Modified Software contains a Contribution subject to the CeCILL 290 | license, the provisions set forth in Article 5.3.4 shall be optional. 291 | 292 | A Modified Software may be distributed under the CeCILL-C license. In 293 | such a case the provisions set forth in Article 5.3.4 shall be optional. 294 | 295 | 296 | Article 6 - INTELLECTUAL PROPERTY 297 | 298 | 299 | 6.1 OVER THE INITIAL SOFTWARE 300 | 301 | The Holder owns the economic rights over the Initial Software. Any or 302 | all use of the Initial Software is subject to compliance with the terms 303 | and conditions under which the Holder has elected to distribute its work 304 | and no one shall be entitled to modify the terms and conditions for the 305 | distribution of said Initial Software. 306 | 307 | The Holder undertakes that the Initial Software will remain ruled at 308 | least by this Agreement, for the duration set forth in Article 4.2. 309 | 310 | 311 | 6.2 OVER THE CONTRIBUTIONS 312 | 313 | The Licensee who develops a Contribution is the owner of the 314 | intellectual property rights over this Contribution as defined by 315 | applicable law. 316 | 317 | 318 | 6.3 OVER THE EXTERNAL MODULES 319 | 320 | The Licensee who develops an External Module is the owner of the 321 | intellectual property rights over this External Module as defined by 322 | applicable law and is free to choose the type of agreement that shall 323 | govern its distribution. 324 | 325 | 326 | 6.4 JOINT PROVISIONS 327 | 328 | The Licensee expressly undertakes: 329 | 330 | 1. not to remove, or modify, in any manner, the intellectual property 331 | notices attached to the Software; 332 | 333 | 2. to reproduce said notices, in an identical manner, in the copies 334 | of the Software modified or not. 335 | 336 | The Licensee undertakes not to directly or indirectly infringe the 337 | intellectual property rights of the Holder and/or Contributors on the 338 | Software and to take, where applicable, vis-à-vis its staff, any and all 339 | measures required to ensure respect of said intellectual property rights 340 | of the Holder and/or Contributors. 341 | 342 | 343 | Article 7 - RELATED SERVICES 344 | 345 | 7.1 Under no circumstances shall the Agreement oblige the Licensor to 346 | provide technical assistance or maintenance services for the Software. 347 | 348 | However, the Licensor is entitled to offer this type of services. The 349 | terms and conditions of such technical assistance, and/or such 350 | maintenance, shall be set forth in a separate instrument. Only the 351 | Licensor offering said maintenance and/or technical assistance services 352 | shall incur liability therefor. 353 | 354 | 7.2 Similarly, any Licensor is entitled to offer to its licensees, under 355 | its sole responsibility, a warranty, that shall only be binding upon 356 | itself, for the redistribution of the Software and/or the Modified 357 | Software, under terms and conditions that it is free to decide. Said 358 | warranty, and the financial terms and conditions of its application, 359 | shall be subject of a separate instrument executed between the Licensor 360 | and the Licensee. 361 | 362 | 363 | Article 8 - LIABILITY 364 | 365 | 8.1 Subject to the provisions of Article 8.2, the Licensee shall be 366 | entitled to claim compensation for any direct loss it may have suffered 367 | from the Software as a result of a fault on the part of the relevant 368 | Licensor, subject to providing evidence thereof. 369 | 370 | 8.2 The Licensor's liability is limited to the commitments made under 371 | this Agreement and shall not be incurred as a result of in particular: 372 | (i) loss due the Licensee's total or partial failure to fulfill its 373 | obligations, (ii) direct or consequential loss that is suffered by the 374 | Licensee due to the use or performance of the Software, and (iii) more 375 | generally, any consequential loss. In particular the Parties expressly 376 | agree that any or all pecuniary or business loss (i.e. loss of data, 377 | loss of profits, operating loss, loss of customers or orders, 378 | opportunity cost, any disturbance to business activities) or any or all 379 | legal proceedings instituted against the Licensee by a third party, 380 | shall constitute consequential loss and shall not provide entitlement to 381 | any or all compensation from the Licensor. 382 | 383 | 384 | Article 9 - WARRANTY 385 | 386 | 9.1 The Licensee acknowledges that the scientific and technical 387 | state-of-the-art when the Software was distributed did not enable all 388 | possible uses to be tested and verified, nor for the presence of 389 | possible defects to be detected. In this respect, the Licensee's 390 | attention has been drawn to the risks associated with loading, using, 391 | modifying and/or developing and reproducing the Software which are 392 | reserved for experienced users. 393 | 394 | The Licensee shall be responsible for verifying, by any or all means, 395 | the suitability of the product for its requirements, its good working 396 | order, and for ensuring that it shall not cause damage to either persons 397 | or properties. 398 | 399 | 9.2 The Licensor hereby represents, in good faith, that it is entitled 400 | to grant all the rights over the Software (including in particular the 401 | rights set forth in Article 5). 402 | 403 | 9.3 The Licensee acknowledges that the Software is supplied "as is" by 404 | the Licensor without any other express or tacit warranty, other than 405 | that provided for in Article 9.2 and, in particular, without any warranty 406 | as to its commercial value, its secured, safe, innovative or relevant 407 | nature. 408 | 409 | Specifically, the Licensor does not warrant that the Software is free 410 | from any error, that it will operate without interruption, that it will 411 | be compatible with the Licensee's own equipment and software 412 | configuration, nor that it will meet the Licensee's requirements. 413 | 414 | 9.4 The Licensor does not either expressly or tacitly warrant that the 415 | Software does not infringe any third party intellectual property right 416 | relating to a patent, software or any other property right. Therefore, 417 | the Licensor disclaims any and all liability towards the Licensee 418 | arising out of any or all proceedings for infringement that may be 419 | instituted in respect of the use, modification and redistribution of the 420 | Software. Nevertheless, should such proceedings be instituted against 421 | the Licensee, the Licensor shall provide it with technical and legal 422 | assistance for its defense. Such technical and legal assistance shall be 423 | decided on a case-by-case basis between the relevant Licensor and the 424 | Licensee pursuant to a memorandum of understanding. The Licensor 425 | disclaims any and all liability as regards the Licensee's use of the 426 | name of the Software. No warranty is given as regards the existence of 427 | prior rights over the name of the Software or as regards the existence 428 | of a trademark. 429 | 430 | 431 | Article 10 - TERMINATION 432 | 433 | 10.1 In the event of a breach by the Licensee of its obligations 434 | hereunder, the Licensor may automatically terminate this Agreement 435 | thirty (30) days after notice has been sent to the Licensee and has 436 | remained ineffective. 437 | 438 | 10.2 A Licensee whose Agreement is terminated shall no longer be 439 | authorized to use, modify or distribute the Software. However, any 440 | licenses that it may have granted prior to termination of the Agreement 441 | shall remain valid subject to their having been granted in compliance 442 | with the terms and conditions hereof. 443 | 444 | 445 | Article 11 - MISCELLANEOUS 446 | 447 | 448 | 11.1 EXCUSABLE EVENTS 449 | 450 | Neither Party shall be liable for any or all delay, or failure to 451 | perform the Agreement, that may be attributable to an event of force 452 | majeure, an act of God or an outside cause, such as defective 453 | functioning or interruptions of the electricity or telecommunications 454 | networks, network paralysis following a virus attack, intervention by 455 | government authorities, natural disasters, water damage, earthquakes, 456 | fire, explosions, strikes and labor unrest, war, etc. 457 | 458 | 11.2 Any failure by either Party, on one or more occasions, to invoke 459 | one or more of the provisions hereof, shall under no circumstances be 460 | interpreted as being a waiver by the interested Party of its right to 461 | invoke said provision(s) subsequently. 462 | 463 | 11.3 The Agreement cancels and replaces any or all previous agreements, 464 | whether written or oral, between the Parties and having the same 465 | purpose, and constitutes the entirety of the agreement between said 466 | Parties concerning said purpose. No supplement or modification to the 467 | terms and conditions hereof shall be effective as between the Parties 468 | unless it is made in writing and signed by their duly authorized 469 | representatives. 470 | 471 | 11.4 In the event that one or more of the provisions hereof were to 472 | conflict with a current or future applicable act or legislative text, 473 | said act or legislative text shall prevail, and the Parties shall make 474 | the necessary amendments so as to comply with said act or legislative 475 | text. All other provisions shall remain effective. Similarly, invalidity 476 | of a provision of the Agreement, for any reason whatsoever, shall not 477 | cause the Agreement as a whole to be invalid. 478 | 479 | 480 | 11.5 LANGUAGE 481 | 482 | The Agreement is drafted in both French and English and both versions 483 | are deemed authentic. 484 | 485 | 486 | Article 12 - NEW VERSIONS OF THE AGREEMENT 487 | 488 | 12.1 Any person is authorized to duplicate and distribute copies of this 489 | Agreement. 490 | 491 | 12.2 So as to ensure coherence, the wording of this Agreement is 492 | protected and may only be modified by the authors of the License, who 493 | reserve the right to periodically publish updates or new versions of the 494 | Agreement, each with a separate number. These subsequent versions may 495 | address new issues encountered by Free Software. 496 | 497 | 12.3 Any Software distributed under a given version of the Agreement may 498 | only be subsequently distributed under the same version of the Agreement 499 | or a subsequent version. 500 | 501 | 502 | Article 13 - GOVERNING LAW AND JURISDICTION 503 | 504 | 13.1 The Agreement is governed by French law. The Parties agree to 505 | endeavor to seek an amicable solution to any disagreements or disputes 506 | that may arise during the performance of the Agreement. 507 | 508 | 13.2 Failing an amicable solution within two (2) months as from their 509 | occurrence, and unless emergency proceedings are necessary, the 510 | disagreements or disputes shall be referred to the Paris Courts having 511 | jurisdiction, by the more diligent Party. 512 | 513 | 514 | Version 1.0 dated 2006-09-05. 515 | -------------------------------------------------------------------------------- /COPYING-FR: -------------------------------------------------------------------------------- 1 | 2 | CONTRAT DE LICENCE DE LOGICIEL LIBRE CeCILL-B 3 | 4 | 5 | Avertissement 6 | 7 | Ce contrat est une licence de logiciel libre issue d'une concertation 8 | entre ses auteurs afin que le respect de deux grands principes préside à 9 | sa rédaction: 10 | 11 | * d'une part, le respect des principes de diffusion des logiciels 12 | libres: accès au code source, droits étendus conférés aux 13 | utilisateurs, 14 | * d'autre part, la désignation d'un droit applicable, le droit 15 | français, auquel elle est conforme, tant au regard du droit de la 16 | responsabilité civile que du droit de la propriété intellectuelle 17 | et de la protection qu'il offre aux auteurs et titulaires des 18 | droits patrimoniaux sur un logiciel. 19 | 20 | Les auteurs de la licence CeCILL-B (pour Ce[a] C[nrs] I[nria] L[ogiciel] 21 | L[ibre]) sont: 22 | 23 | Commissariat à l'Energie Atomique - CEA, établissement public de 24 | recherche à caractère scientifique, technique et industriel, dont le 25 | siège est situé 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris. 26 | 27 | Centre National de la Recherche Scientifique - CNRS, établissement 28 | public à caractère scientifique et technologique, dont le siège est 29 | situé 3 rue Michel-Ange, 75794 Paris cedex 16. 30 | 31 | Institut National de Recherche en Informatique et en Automatique - 32 | INRIA, établissement public à caractère scientifique et technologique, 33 | dont le siège est situé Domaine de Voluceau, Rocquencourt, BP 105, 78153 34 | Le Chesnay cedex. 35 | 36 | 37 | Préambule 38 | 39 | Ce contrat est une licence de logiciel libre dont l'objectif est de 40 | conférer aux utilisateurs une très large liberté de modification et de 41 | redistribution du logiciel régi par cette licence. 42 | 43 | L'exercice de cette liberté est assorti d'une obligation forte de 44 | citation à la charge de ceux qui distribueraient un logiciel incorporant 45 | un logiciel régi par la présente licence afin d'assurer que les 46 | contributions de tous soient correctement identifiées et reconnues. 47 | 48 | L'accessibilité au code source et les droits de copie, de modification 49 | et de redistribution qui découlent de ce contrat ont pour contrepartie 50 | de n'offrir aux utilisateurs qu'une garantie limitée et de ne faire 51 | peser sur l'auteur du logiciel, le titulaire des droits patrimoniaux et 52 | les concédants successifs qu'une responsabilité restreinte. 53 | 54 | A cet égard l'attention de l'utilisateur est attirée sur les risques 55 | associés au chargement, à l'utilisation, à la modification et/ou au 56 | développement et à la reproduction du logiciel par l'utilisateur étant 57 | donné sa spécificité de logiciel libre, qui peut le rendre complexe à 58 | manipuler et qui le réserve donc à des développeurs ou des 59 | professionnels avertis possédant des connaissances informatiques 60 | approfondies. Les utilisateurs sont donc invités à charger et tester 61 | l'adéquation du logiciel à leurs besoins dans des conditions permettant 62 | d'assurer la sécurité de leurs systèmes et/ou de leurs données et, plus 63 | généralement, à l'utiliser et l'exploiter dans les mêmes conditions de 64 | sécurité. Ce contrat peut être reproduit et diffusé librement, sous 65 | réserve de le conserver en l'état, sans ajout ni suppression de clauses. 66 | 67 | Ce contrat est susceptible de s'appliquer à tout logiciel dont le 68 | titulaire des droits patrimoniaux décide de soumettre l'exploitation aux 69 | dispositions qu'il contient. 70 | 71 | 72 | Article 1 - DEFINITIONS 73 | 74 | Dans ce contrat, les termes suivants, lorsqu'ils seront écrits avec une 75 | lettre capitale, auront la signification suivante: 76 | 77 | Contrat: désigne le présent contrat de licence, ses éventuelles versions 78 | postérieures et annexes. 79 | 80 | Logiciel: désigne le logiciel sous sa forme de Code Objet et/ou de Code 81 | Source et le cas échéant sa documentation, dans leur état au moment de 82 | l'acceptation du Contrat par le Licencié. 83 | 84 | Logiciel Initial: désigne le Logiciel sous sa forme de Code Source et 85 | éventuellement de Code Objet et le cas échéant sa documentation, dans 86 | leur état au moment de leur première diffusion sous les termes du Contrat. 87 | 88 | Logiciel Modifié: désigne le Logiciel modifié par au moins une 89 | Contribution. 90 | 91 | Code Source: désigne l'ensemble des instructions et des lignes de 92 | programme du Logiciel et auquel l'accès est nécessaire en vue de 93 | modifier le Logiciel. 94 | 95 | Code Objet: désigne les fichiers binaires issus de la compilation du 96 | Code Source. 97 | 98 | Titulaire: désigne le ou les détenteurs des droits patrimoniaux d'auteur 99 | sur le Logiciel Initial. 100 | 101 | Licencié: désigne le ou les utilisateurs du Logiciel ayant accepté le 102 | Contrat. 103 | 104 | Contributeur: désigne le Licencié auteur d'au moins une Contribution. 105 | 106 | Concédant: désigne le Titulaire ou toute personne physique ou morale 107 | distribuant le Logiciel sous le Contrat. 108 | 109 | Contribution: désigne l'ensemble des modifications, corrections, 110 | traductions, adaptations et/ou nouvelles fonctionnalités intégrées dans 111 | le Logiciel par tout Contributeur, ainsi que tout Module Interne. 112 | 113 | Module: désigne un ensemble de fichiers sources y compris leur 114 | documentation qui permet de réaliser des fonctionnalités ou services 115 | supplémentaires à ceux fournis par le Logiciel. 116 | 117 | Module Externe: désigne tout Module, non dérivé du Logiciel, tel que ce 118 | Module et le Logiciel s'exécutent dans des espaces d'adressage 119 | différents, l'un appelant l'autre au moment de leur exécution. 120 | 121 | Module Interne: désigne tout Module lié au Logiciel de telle sorte 122 | qu'ils s'exécutent dans le même espace d'adressage. 123 | 124 | Parties: désigne collectivement le Licencié et le Concédant. 125 | 126 | Ces termes s'entendent au singulier comme au pluriel. 127 | 128 | 129 | Article 2 - OBJET 130 | 131 | Le Contrat a pour objet la concession par le Concédant au Licencié d'une 132 | licence non exclusive, cessible et mondiale du Logiciel telle que 133 | définie ci-après à l'article 5 pour toute la durée de protection des droits 134 | portant sur ce Logiciel. 135 | 136 | 137 | Article 3 - ACCEPTATION 138 | 139 | 3.1 L'acceptation par le Licencié des termes du Contrat est réputée 140 | acquise du fait du premier des faits suivants: 141 | 142 | * (i) le chargement du Logiciel par tout moyen notamment par 143 | téléchargement à partir d'un serveur distant ou par chargement à 144 | partir d'un support physique; 145 | * (ii) le premier exercice par le Licencié de l'un quelconque des 146 | droits concédés par le Contrat. 147 | 148 | 3.2 Un exemplaire du Contrat, contenant notamment un avertissement 149 | relatif aux spécificités du Logiciel, à la restriction de garantie et à 150 | la limitation à un usage par des utilisateurs expérimentés a été mis à 151 | disposition du Licencié préalablement à son acceptation telle que 152 | définie à l'article 3.1 ci dessus et le Licencié reconnaît en avoir pris 153 | connaissance. 154 | 155 | 156 | Article 4 - ENTREE EN VIGUEUR ET DUREE 157 | 158 | 159 | 4.1 ENTREE EN VIGUEUR 160 | 161 | Le Contrat entre en vigueur à la date de son acceptation par le Licencié 162 | telle que définie en 3.1. 163 | 164 | 165 | 4.2 DUREE 166 | 167 | Le Contrat produira ses effets pendant toute la durée légale de 168 | protection des droits patrimoniaux portant sur le Logiciel. 169 | 170 | 171 | Article 5 - ETENDUE DES DROITS CONCEDES 172 | 173 | Le Concédant concède au Licencié, qui accepte, les droits suivants sur 174 | le Logiciel pour toutes destinations et pour la durée du Contrat dans 175 | les conditions ci-après détaillées. 176 | 177 | Par ailleurs, si le Concédant détient ou venait à détenir un ou 178 | plusieurs brevets d'invention protégeant tout ou partie des 179 | fonctionnalités du Logiciel ou de ses composants, il s'engage à ne pas 180 | opposer les éventuels droits conférés par ces brevets aux Licenciés 181 | successifs qui utiliseraient, exploiteraient ou modifieraient le 182 | Logiciel. En cas de cession de ces brevets, le Concédant s'engage à 183 | faire reprendre les obligations du présent alinéa aux cessionnaires. 184 | 185 | 186 | 5.1 DROIT D'UTILISATION 187 | 188 | Le Licencié est autorisé à utiliser le Logiciel, sans restriction quant 189 | aux domaines d'application, étant ci-après précisé que cela comporte: 190 | 191 | 1. la reproduction permanente ou provisoire du Logiciel en tout ou 192 | partie par tout moyen et sous toute forme. 193 | 194 | 2. le chargement, l'affichage, l'exécution, ou le stockage du 195 | Logiciel sur tout support. 196 | 197 | 3. la possibilité d'en observer, d'en étudier, ou d'en tester le 198 | fonctionnement afin de déterminer les idées et principes qui sont 199 | à la base de n'importe quel élément de ce Logiciel; et ceci, 200 | lorsque le Licencié effectue toute opération de chargement, 201 | d'affichage, d'exécution, de transmission ou de stockage du 202 | Logiciel qu'il est en droit d'effectuer en vertu du Contrat. 203 | 204 | 205 | 5.2 DROIT D'APPORTER DES CONTRIBUTIONS 206 | 207 | Le droit d'apporter des Contributions comporte le droit de traduire, 208 | d'adapter, d'arranger ou d'apporter toute autre modification au Logiciel 209 | et le droit de reproduire le logiciel en résultant. 210 | 211 | Le Licencié est autorisé à apporter toute Contribution au Logiciel sous 212 | réserve de mentionner, de façon explicite, son nom en tant qu'auteur de 213 | cette Contribution et la date de création de celle-ci. 214 | 215 | 216 | 5.3 DROIT DE DISTRIBUTION 217 | 218 | Le droit de distribution comporte notamment le droit de diffuser, de 219 | transmettre et de communiquer le Logiciel au public sur tout support et 220 | par tout moyen ainsi que le droit de mettre sur le marché à titre 221 | onéreux ou gratuit, un ou des exemplaires du Logiciel par tout procédé. 222 | 223 | Le Licencié est autorisé à distribuer des copies du Logiciel, modifié ou 224 | non, à des tiers dans les conditions ci-après détaillées. 225 | 226 | 227 | 5.3.1 DISTRIBUTION DU LOGICIEL SANS MODIFICATION 228 | 229 | Le Licencié est autorisé à distribuer des copies conformes du Logiciel, 230 | sous forme de Code Source ou de Code Objet, à condition que cette 231 | distribution respecte les dispositions du Contrat dans leur totalité et 232 | soit accompagnée: 233 | 234 | 1. d'un exemplaire du Contrat, 235 | 236 | 2. d'un avertissement relatif à la restriction de garantie et de 237 | responsabilité du Concédant telle que prévue aux articles 8 238 | et 9, 239 | 240 | et que, dans le cas où seul le Code Objet du Logiciel est redistribué, 241 | le Licencié permette un accès effectif au Code Source complet du 242 | Logiciel pendant au moins toute la durée de sa distribution du Logiciel, 243 | étant entendu que le coût additionnel d'acquisition du Code Source ne 244 | devra pas excéder le simple coût de transfert des données. 245 | 246 | 247 | 5.3.2 DISTRIBUTION DU LOGICIEL MODIFIE 248 | 249 | Lorsque le Licencié apporte une Contribution au Logiciel, le Logiciel 250 | Modifié peut être distribué sous un contrat de licence autre que le 251 | présent Contrat sous réserve du respect des dispositions de l'article 252 | 5.3.4. 253 | 254 | 255 | 5.3.3 DISTRIBUTION DES MODULES EXTERNES 256 | 257 | Lorsque le Licencié a développé un Module Externe les conditions du 258 | Contrat ne s'appliquent pas à ce Module Externe, qui peut être distribué 259 | sous un contrat de licence différent. 260 | 261 | 262 | 5.3.4 CITATIONS 263 | 264 | Le Licencié qui distribue un Logiciel Modifié s'engage expressément: 265 | 266 | 1. à indiquer dans sa documentation qu'il a été réalisé à partir du 267 | Logiciel régi par le Contrat, en reproduisant les mentions de 268 | propriété intellectuelle du Logiciel, 269 | 270 | 2. à faire en sorte que l'utilisation du Logiciel, ses mentions de 271 | propriété intellectuelle et le fait qu'il est régi par le Contrat 272 | soient indiqués dans un texte facilement accessible depuis 273 | l'interface du Logiciel Modifié, 274 | 275 | 3. à mentionner, sur un site Web librement accessible décrivant le 276 | Logiciel Modifié, et pendant au moins toute la durée de sa 277 | distribution, qu'il a été réalisé à partir du Logiciel régi par le 278 | Contrat, en reproduisant les mentions de propriété intellectuelle 279 | du Logiciel, 280 | 281 | 4. lorsqu'il le distribue à un tiers susceptible de distribuer 282 | lui-même un Logiciel Modifié, sans avoir à en distribuer le code 283 | source, à faire ses meilleurs efforts pour que les obligations du 284 | présent article 5.3.4 soient reprises par le dit tiers. 285 | 286 | Lorsque le Logiciel modifié ou non est distribué avec un Module Externe 287 | qui a été conçu pour l'utiliser, le Licencié doit soumettre le dit 288 | Module Externe aux obligations précédentes. 289 | 290 | 291 | 5.3.5 COMPATIBILITE AVEC LES LICENCES CeCILL et CeCILL-C 292 | 293 | Lorsqu'un Logiciel Modifié contient une Contribution soumise au contrat 294 | de licence CeCILL, les stipulations prévues à l'article 5.3.4 sont 295 | facultatives. 296 | 297 | Un Logiciel Modifié peut être distribué sous le contrat de licence 298 | CeCILL-C. Les stipulations prévues à l'article 5.3.4 sont alors 299 | facultatives. 300 | 301 | 302 | Article 6 - PROPRIETE INTELLECTUELLE 303 | 304 | 305 | 6.1 SUR LE LOGICIEL INITIAL 306 | 307 | Le Titulaire est détenteur des droits patrimoniaux sur le Logiciel 308 | Initial. Toute utilisation du Logiciel Initial est soumise au respect 309 | des conditions dans lesquelles le Titulaire a choisi de diffuser son 310 | oeuvre et nul autre n'a la faculté de modifier les conditions de 311 | diffusion de ce Logiciel Initial. 312 | 313 | Le Titulaire s'engage à ce que le Logiciel Initial reste au moins régi 314 | par le Contrat et ce, pour la durée visée à l'article 4.2. 315 | 316 | 317 | 6.2 SUR LES CONTRIBUTIONS 318 | 319 | Le Licencié qui a développé une Contribution est titulaire sur celle-ci 320 | des droits de propriété intellectuelle dans les conditions définies par 321 | la législation applicable. 322 | 323 | 324 | 6.3 SUR LES MODULES EXTERNES 325 | 326 | Le Licencié qui a développé un Module Externe est titulaire sur celui-ci 327 | des droits de propriété intellectuelle dans les conditions définies par 328 | la législation applicable et reste libre du choix du contrat régissant 329 | sa diffusion. 330 | 331 | 332 | 6.4 DISPOSITIONS COMMUNES 333 | 334 | Le Licencié s'engage expressément: 335 | 336 | 1. à ne pas supprimer ou modifier de quelque manière que ce soit les 337 | mentions de propriété intellectuelle apposées sur le Logiciel; 338 | 339 | 2. à reproduire à l'identique lesdites mentions de propriété 340 | intellectuelle sur les copies du Logiciel modifié ou non. 341 | 342 | Le Licencié s'engage à ne pas porter atteinte, directement ou 343 | indirectement, aux droits de propriété intellectuelle du Titulaire et/ou 344 | des Contributeurs sur le Logiciel et à prendre, le cas échéant, à 345 | l'égard de son personnel toutes les mesures nécessaires pour assurer le 346 | respect des dits droits de propriété intellectuelle du Titulaire et/ou 347 | des Contributeurs. 348 | 349 | 350 | Article 7 - SERVICES ASSOCIES 351 | 352 | 7.1 Le Contrat n'oblige en aucun cas le Concédant à la réalisation de 353 | prestations d'assistance technique ou de maintenance du Logiciel. 354 | 355 | Cependant le Concédant reste libre de proposer ce type de services. Les 356 | termes et conditions d'une telle assistance technique et/ou d'une telle 357 | maintenance seront alors déterminés dans un acte séparé. Ces actes de 358 | maintenance et/ou assistance technique n'engageront que la seule 359 | responsabilité du Concédant qui les propose. 360 | 361 | 7.2 De même, tout Concédant est libre de proposer, sous sa seule 362 | responsabilité, à ses licenciés une garantie, qui n'engagera que lui, 363 | lors de la redistribution du Logiciel et/ou du Logiciel Modifié et ce, 364 | dans les conditions qu'il souhaite. Cette garantie et les modalités 365 | financières de son application feront l'objet d'un acte séparé entre le 366 | Concédant et le Licencié. 367 | 368 | 369 | Article 8 - RESPONSABILITE 370 | 371 | 8.1 Sous réserve des dispositions de l'article 8.2, le Licencié a la 372 | faculté, sous réserve de prouver la faute du Concédant concerné, de 373 | solliciter la réparation du préjudice direct qu'il subirait du fait du 374 | Logiciel et dont il apportera la preuve. 375 | 376 | 8.2 La responsabilité du Concédant est limitée aux engagements pris en 377 | application du Contrat et ne saurait être engagée en raison notamment: 378 | (i) des dommages dus à l'inexécution, totale ou partielle, de ses 379 | obligations par le Licencié, (ii) des dommages directs ou indirects 380 | découlant de l'utilisation ou des performances du Logiciel subis par le 381 | Licencié et (iii) plus généralement d'un quelconque dommage indirect. En 382 | particulier, les Parties conviennent expressément que tout préjudice 383 | financier ou commercial (par exemple perte de données, perte de 384 | bénéfices, perte d'exploitation, perte de clientèle ou de commandes, 385 | manque à gagner, trouble commercial quelconque) ou toute action dirigée 386 | contre le Licencié par un tiers, constitue un dommage indirect et 387 | n'ouvre pas droit à réparation par le Concédant. 388 | 389 | 390 | Article 9 - GARANTIE 391 | 392 | 9.1 Le Licencié reconnaît que l'état actuel des connaissances 393 | scientifiques et techniques au moment de la mise en circulation du 394 | Logiciel ne permet pas d'en tester et d'en vérifier toutes les 395 | utilisations ni de détecter l'existence d'éventuels défauts. L'attention 396 | du Licencié a été attirée sur ce point sur les risques associés au 397 | chargement, à l'utilisation, la modification et/ou au développement et à 398 | la reproduction du Logiciel qui sont réservés à des utilisateurs avertis. 399 | 400 | Il relève de la responsabilité du Licencié de contrôler, par tous 401 | moyens, l'adéquation du produit à ses besoins, son bon fonctionnement et 402 | de s'assurer qu'il ne causera pas de dommages aux personnes et aux biens. 403 | 404 | 9.2 Le Concédant déclare de bonne foi être en droit de concéder 405 | l'ensemble des droits attachés au Logiciel (comprenant notamment les 406 | droits visés à l'article 5). 407 | 408 | 9.3 Le Licencié reconnaît que le Logiciel est fourni "en l'état" par le 409 | Concédant sans autre garantie, expresse ou tacite, que celle prévue à 410 | l'article 9.2 et notamment sans aucune garantie sur sa valeur commerciale, 411 | son caractère sécurisé, innovant ou pertinent. 412 | 413 | En particulier, le Concédant ne garantit pas que le Logiciel est exempt 414 | d'erreur, qu'il fonctionnera sans interruption, qu'il sera compatible 415 | avec l'équipement du Licencié et sa configuration logicielle ni qu'il 416 | remplira les besoins du Licencié. 417 | 418 | 9.4 Le Concédant ne garantit pas, de manière expresse ou tacite, que le 419 | Logiciel ne porte pas atteinte à un quelconque droit de propriété 420 | intellectuelle d'un tiers portant sur un brevet, un logiciel ou sur tout 421 | autre droit de propriété. Ainsi, le Concédant exclut toute garantie au 422 | profit du Licencié contre les actions en contrefaçon qui pourraient être 423 | diligentées au titre de l'utilisation, de la modification, et de la 424 | redistribution du Logiciel. Néanmoins, si de telles actions sont 425 | exercées contre le Licencié, le Concédant lui apportera son aide 426 | technique et juridique pour sa défense. Cette aide technique et 427 | juridique est déterminée au cas par cas entre le Concédant concerné et 428 | le Licencié dans le cadre d'un protocole d'accord. Le Concédant dégage 429 | toute responsabilité quant à l'utilisation de la dénomination du 430 | Logiciel par le Licencié. Aucune garantie n'est apportée quant à 431 | l'existence de droits antérieurs sur le nom du Logiciel et sur 432 | l'existence d'une marque. 433 | 434 | 435 | Article 10 - RESILIATION 436 | 437 | 10.1 En cas de manquement par le Licencié aux obligations mises à sa 438 | charge par le Contrat, le Concédant pourra résilier de plein droit le 439 | Contrat trente (30) jours après notification adressée au Licencié et 440 | restée sans effet. 441 | 442 | 10.2 Le Licencié dont le Contrat est résilié n'est plus autorisé à 443 | utiliser, modifier ou distribuer le Logiciel. Cependant, toutes les 444 | licences qu'il aura concédées antérieurement à la résiliation du Contrat 445 | resteront valides sous réserve qu'elles aient été effectuées en 446 | conformité avec le Contrat. 447 | 448 | 449 | Article 11 - DISPOSITIONS DIVERSES 450 | 451 | 452 | 11.1 CAUSE EXTERIEURE 453 | 454 | Aucune des Parties ne sera responsable d'un retard ou d'une défaillance 455 | d'exécution du Contrat qui serait dû à un cas de force majeure, un cas 456 | fortuit ou une cause extérieure, telle que, notamment, le mauvais 457 | fonctionnement ou les interruptions du réseau électrique ou de 458 | télécommunication, la paralysie du réseau liée à une attaque 459 | informatique, l'intervention des autorités gouvernementales, les 460 | catastrophes naturelles, les dégâts des eaux, les tremblements de terre, 461 | le feu, les explosions, les grèves et les conflits sociaux, l'état de 462 | guerre... 463 | 464 | 11.2 Le fait, par l'une ou l'autre des Parties, d'omettre en une ou 465 | plusieurs occasions de se prévaloir d'une ou plusieurs dispositions du 466 | Contrat, ne pourra en aucun cas impliquer renonciation par la Partie 467 | intéressée à s'en prévaloir ultérieurement. 468 | 469 | 11.3 Le Contrat annule et remplace toute convention antérieure, écrite 470 | ou orale, entre les Parties sur le même objet et constitue l'accord 471 | entier entre les Parties sur cet objet. Aucune addition ou modification 472 | aux termes du Contrat n'aura d'effet à l'égard des Parties à moins 473 | d'être faite par écrit et signée par leurs représentants dûment habilités. 474 | 475 | 11.4 Dans l'hypothèse où une ou plusieurs des dispositions du Contrat 476 | s'avèrerait contraire à une loi ou à un texte applicable, existants ou 477 | futurs, cette loi ou ce texte prévaudrait, et les Parties feraient les 478 | amendements nécessaires pour se conformer à cette loi ou à ce texte. 479 | Toutes les autres dispositions resteront en vigueur. De même, la 480 | nullité, pour quelque raison que ce soit, d'une des dispositions du 481 | Contrat ne saurait entraîner la nullité de l'ensemble du Contrat. 482 | 483 | 484 | 11.5 LANGUE 485 | 486 | Le Contrat est rédigé en langue française et en langue anglaise, ces 487 | deux versions faisant également foi. 488 | 489 | 490 | Article 12 - NOUVELLES VERSIONS DU CONTRAT 491 | 492 | 12.1 Toute personne est autorisée à copier et distribuer des copies de 493 | ce Contrat. 494 | 495 | 12.2 Afin d'en préserver la cohérence, le texte du Contrat est protégé 496 | et ne peut être modifié que par les auteurs de la licence, lesquels se 497 | réservent le droit de publier périodiquement des mises à jour ou de 498 | nouvelles versions du Contrat, qui posséderont chacune un numéro 499 | distinct. Ces versions ultérieures seront susceptibles de prendre en 500 | compte de nouvelles problématiques rencontrées par les logiciels libres. 501 | 502 | 12.3 Tout Logiciel diffusé sous une version donnée du Contrat ne pourra 503 | faire l'objet d'une diffusion ultérieure que sous la même version du 504 | Contrat ou une version postérieure. 505 | 506 | 507 | Article 13 - LOI APPLICABLE ET COMPETENCE TERRITORIALE 508 | 509 | 13.1 Le Contrat est régi par la loi française. Les Parties conviennent 510 | de tenter de régler à l'amiable les différends ou litiges qui 511 | viendraient à se produire par suite ou à l'occasion du Contrat. 512 | 513 | 13.2 A défaut d'accord amiable dans un délai de deux (2) mois à compter 514 | de leur survenance et sauf situation relevant d'une procédure d'urgence, 515 | les différends ou litiges seront portés par la Partie la plus diligente 516 | devant les Tribunaux compétents de Paris. 517 | 518 | 519 | Version 1.0 du 2006-09-05. 520 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | Library/docker/Dockerfile -------------------------------------------------------------------------------- /Library/Ancillary/autoinstall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### autoinstall -- Autoinstall for Travis CI 4 | 5 | # Docker Toolkit (https://github.com/michipili/dockertk) 6 | # This file is part of Docker Toolkit 7 | # 8 | # Copyright © 2015 Michael Grünewald 9 | # 10 | # This file must be used under the terms of the CeCILL-B. 11 | # This source file is licensed as described in the file COPYING, which 12 | # you should have received as part of this distribution. The terms 13 | # are also available at 14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt 15 | 16 | : ${local:=${HOME}/.local} 17 | : ${srcdir:=${HOME}/.local/sources} 18 | 19 | if [ -f "${local}/.anvil_autoinstall_cached" ]; then exit 0; fi 20 | 21 | git clone 'https://github.com/michipili/anvil' "${srcdir}/anvil" 22 | /bin/sh -ex "${srcdir}/anvil/subr/anvil_travisci_autoinstall.sh" "$@"\ 23 | && touch "${local}/.anvil_autoinstall_cached" 24 | 25 | ### End of file `autoinstall' 26 | -------------------------------------------------------------------------------- /Library/Ancillary/travisci: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### travisci -- Continuous integration test for travis 4 | 5 | # Docker Toolkit (https://github.com/michipili/dockertk) 6 | # This file is part of Docker Toolkit 7 | # 8 | # Copyright © 2015 Michael Grünewald 9 | # 10 | # This file must be used under the terms of the CeCILL-B. 11 | # This source file is licensed as described in the file COPYING, which 12 | # you should have received as part of this distribution. The terms 13 | # are also available at 14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt 15 | 16 | INSTALL_PREFIX="${HOME}/.local" 17 | 18 | eval $(opam config env --switch ${TRAVIS_OCAML_VERSION:?}) 19 | autoconf 20 | ./configure --prefix="${INSTALL_PREFIX}" 21 | bmake -I "${INSTALL_PREFIX}/share/bsdowl" all 22 | bmake -I "${INSTALL_PREFIX}/share/bsdowl" install 23 | 24 | ### End of file `travisci' 25 | -------------------------------------------------------------------------------- /Library/Autoconf/bsdowl.m4: -------------------------------------------------------------------------------- 1 | dnl autoconf macros for BSD Owl 2 | dnl 3 | dnl Copyright © 2015 Michael Grünewald 4 | 5 | # AC_WITH_OCAML_SITE_LIB 6 | # ---------------------- 7 | # Define an option --with-ocaml-site-lib which governs the variable 8 | # WITH_OCAML_SITE_LIB. This variable is substituted. 9 | 10 | AC_DEFUN([AC_WITH_OCAML_SITE_LIB], 11 | [AC_ARG_WITH([ocaml-site-lib], 12 | [AS_HELP_STRING([--with-ocaml-site-lib], 13 | [install under OCaml site-lib's directory])], 14 | [WITH_OCAML_SITE_LIB=${with_ocaml_site_lib}], 15 | [WITH_OCAML_SITE_LIB=no]) 16 | AC_SUBST([WITH_OCAML_SITE_LIB]) 17 | ]) 18 | -------------------------------------------------------------------------------- /Library/Autoconf/ocaml.m4: -------------------------------------------------------------------------------- 1 | dnl autoconf macros for OCaml 2 | dnl 3 | dnl Copyright © 2015 Michael Grünewald 4 | dnl Copyright © 2013 Gabriel Kerneis 5 | dnl Copyright © 2009 Richard W.M. Jones 6 | dnl Copyright © 2009 Stefano Zacchiroli 7 | dnl Copyright © 2000-2005 Olivier Andrieu 8 | dnl Copyright © 2000-2005 Jean-Christophe Filliâtre 9 | dnl Copyright © 2000-2005 Georges Mariano 10 | dnl 11 | dnl For documentation, please read the ocaml.m4 man page. 12 | 13 | 14 | # AC_PROG_OCAML 15 | # ------------- 16 | # This macro detects which tools of the usual OCaml toolchain are 17 | # available. It defines and substitutes the following variables: 18 | # 19 | # OCAMLC set to the name of the bytecode compiler 20 | # (eg. "ocamlc" or "ocamlc.opt"), or "no" if 21 | # no OCaml installation was found 22 | # OCAMLOPT the name of the native-code compiler, eg. "ocamlopt", 23 | # "ocamlopt.opt" or "no" 24 | # OCAMLBEST "byte" (if only the bytecode compiler is available) 25 | # or "opt" (if both bytecode and native code compilers 26 | # are available) 27 | # OCAMLNATDYNLINK "yes" (if native dynlink is available) or "no" 28 | # OCAMLDEP the name of the dependency resolver, eg. "ocamldep" 29 | # OCAMLMKTOP the name of ocamlmktop 30 | # OCAMLMKLIB the name of ocamlmklib 31 | # OCAMLDOC the name of ocamldoc 32 | # OCAMLBUILD the name of ocamlbuild 33 | # OCAMLLIB the OCaml library path (eg. C) 34 | # OCAMLVERSION the compiler version (eg. C<3.11.0>) 35 | 36 | AC_DEFUN([AC_PROG_OCAML], 37 | [dnl 38 | # checking for ocamlc 39 | AC_CHECK_TOOL([OCAMLC],[ocamlc],[no]) 40 | 41 | if test "$OCAMLC" != "no"; then 42 | OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` 43 | AC_MSG_RESULT([OCaml version is $OCAMLVERSION]) 44 | # If OCAMLLIB is set, use it 45 | if test "$OCAMLLIB" = ""; then 46 | OCAMLLIB=`$OCAMLC -where 2>/dev/null | tr -d '\015' || $OCAMLC -v|tail -1|cut -d ' ' -f 4` 47 | else 48 | AC_MSG_RESULT([OCAMLLIB previously set; preserving it.]) 49 | fi 50 | AC_MSG_RESULT([OCaml library path is $OCAMLLIB]) 51 | 52 | AC_SUBST([OCAMLVERSION]) 53 | AC_SUBST([OCAMLLIB]) 54 | 55 | # checking for ocamlopt 56 | AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no]) 57 | OCAMLBEST=byte 58 | if test "$OCAMLOPT" = "no"; then 59 | AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.]) 60 | else 61 | TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` 62 | if test "$TMPVERSION" != "$OCAMLVERSION" ; then 63 | AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.]) 64 | OCAMLOPT=no 65 | else 66 | OCAMLBEST=opt 67 | fi 68 | fi 69 | 70 | AC_SUBST([OCAMLBEST]) 71 | 72 | # checking for ocamlc.opt 73 | AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no]) 74 | if test "$OCAMLCDOTOPT" != "no"; then 75 | TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` 76 | if test "$TMPVERSION" != "$OCAMLVERSION" ; then 77 | AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.]) 78 | else 79 | OCAMLC=$OCAMLCDOTOPT 80 | fi 81 | fi 82 | 83 | # checking for ocamlopt.opt 84 | if test "$OCAMLOPT" != "no" ; then 85 | AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no]) 86 | if test "$OCAMLOPTDOTOPT" != "no"; then 87 | TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` 88 | if test "$TMPVERSION" != "$OCAMLVERSION" ; then 89 | AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.]) 90 | else 91 | OCAMLOPT=$OCAMLOPTDOTOPT 92 | fi 93 | fi 94 | fi 95 | 96 | AC_SUBST([OCAMLOPT]) 97 | fi 98 | 99 | AC_SUBST([OCAMLC]) 100 | 101 | # checking for native dynlink 102 | AC_MSG_CHECKING([for dynlink.cmxa]) 103 | if test -f "$OCAMLLIB/dynlink.cmxa" ; then 104 | OCAMLNATDYNLINK=yes 105 | AC_MSG_RESULT([yes]) 106 | else 107 | OCAMLNATDYNLINK=no 108 | AC_MSG_RESULT([no]) 109 | fi 110 | 111 | AC_SUBST([OCAMLNATDYNLINK]) 112 | 113 | # checking for ocaml toplevel 114 | AC_CHECK_TOOL([OCAML],[ocaml],[no]) 115 | 116 | # checking for ocamldep 117 | AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no]) 118 | 119 | # checking for ocamlmktop 120 | AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no]) 121 | 122 | # checking for ocamlmklib 123 | AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no]) 124 | 125 | # checking for ocamldoc 126 | AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no]) 127 | 128 | # checking for ocamlbuild 129 | AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no]) 130 | ]) 131 | 132 | 133 | # AC_PROG_OCAMLLEX 134 | # ---------------- 135 | # This checks for the ocamllex program and sets OCAMLLEX to the name 136 | # of the program (eg. ocamllex or ocamllex.opt), or no if not found. 137 | 138 | AC_DEFUN([AC_PROG_OCAMLLEX], 139 | [dnl 140 | # checking for ocamllex 141 | AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no]) 142 | if test "$OCAMLLEX" != "no"; then 143 | AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no]) 144 | if test "$OCAMLLEXDOTOPT" != "no"; then 145 | OCAMLLEX=$OCAMLLEXDOTOPT 146 | fi 147 | fi 148 | AC_SUBST([OCAMLLEX]) 149 | ]) 150 | 151 | 152 | # AC_PROG_OCAMLYACC 153 | # ----------------- 154 | # This checks for the ocamlyacc program and sets OCAMLYACC to the name 155 | # of the program, or no if not found. 156 | 157 | AC_DEFUN([AC_PROG_OCAMLYACC], 158 | [dnl 159 | AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no]) 160 | AC_SUBST([OCAMLYACC]) 161 | ]) 162 | 163 | 164 | # AC_PROG_CAMLP4 165 | # -------------- 166 | # This checks for camlp4, and checks that the version matches the 167 | # compiler version found previously. It sets CAMLP4 to the name of the 168 | # basic camlp4 program, or no if not found. 169 | # 170 | # The macro also checks for other tools of the camlp4 suite like 171 | # camlp4o, camlp4orf, etc. For each of them, a fully capitalized 172 | # variable is set to the tool name (or no if not found); all variable 173 | # are substituted for when filling .in files. The full list of tools 174 | # and respective variable names is as follows: 175 | # 176 | # camlp4 CAMLP4 177 | # camlp4boot CAMLP4BOOT 178 | # camlp4o CAMLP4O 179 | # camlp4of CAMLP4OF 180 | # camlp4oof CAMLP4OOF 181 | # camlp4orf CAMLP4ORF 182 | # camlp4prof CAMLP4PROF 183 | # camlp4r CAMLP4R 184 | # camlp4rf CAMLP4RF 185 | 186 | AC_DEFUN([AC_PROG_CAMLP4], 187 | [dnl 188 | AC_REQUIRE([AC_PROG_OCAML])dnl 189 | 190 | # checking for camlp4 191 | AC_CHECK_TOOL([CAMLP4],[camlp4],[no]) 192 | if test "$CAMLP4" != "no"; then 193 | TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'` 194 | if test "$TMPVERSION" != "$OCAMLVERSION" ; then 195 | AC_MSG_RESULT([versions differs from ocamlc]) 196 | CAMLP4=no 197 | fi 198 | fi 199 | AC_SUBST([CAMLP4]) 200 | 201 | # checking for companion tools 202 | AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no]) 203 | AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no]) 204 | AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no]) 205 | AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no]) 206 | AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no]) 207 | AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no]) 208 | AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no]) 209 | AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no]) 210 | AC_SUBST([CAMLP4BOOT]) 211 | AC_SUBST([CAMLP4O]) 212 | AC_SUBST([CAMLP4OF]) 213 | AC_SUBST([CAMLP4OOF]) 214 | AC_SUBST([CAMLP4ORF]) 215 | AC_SUBST([CAMLP4PROF]) 216 | AC_SUBST([CAMLP4R]) 217 | AC_SUBST([CAMLP4RF]) 218 | ]) 219 | 220 | 221 | # AC_PROG_FINDLIB 222 | # --------------- 223 | # This macro checks for the presence of the ocamlfind program (part of 224 | # findlib). It defines and substitutes OCAMLFIND to the name of the 225 | # ocamlfind program, or no if not found. 226 | 227 | AC_DEFUN([AC_PROG_FINDLIB], 228 | [dnl 229 | AC_REQUIRE([AC_PROG_OCAML])dnl 230 | 231 | # checking for ocamlfind 232 | AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no]) 233 | AC_SUBST([OCAMLFIND]) 234 | ]) 235 | 236 | 237 | # AC_CHECK_FINDLIB_PKG(NAME, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 238 | # -------------------------------------------------------------------- 239 | # This is the main macro that can be used to detect the presence of 240 | # OCaml findlib packages. This macro uses ocamlfind to look up findlib 241 | # packages (and thus requires that findlib itself has been installed, 242 | # and that the package has been properly packaged with a META file 243 | # etc.) If you want to find an OCaml findlib package which hasn't been 244 | # installed with findlib then you should try using 245 | # AC_CHECK_OCAML_MODULE instead. 246 | # 247 | # AC_CHECK_FINDLIB_PKG([name]) 248 | # 249 | # checks for an OCaml findlib package with the given name. 250 | 251 | AC_DEFUN([AC_CHECK_FINDLIB_PKG], 252 | [dnl 253 | AC_REQUIRE([AC_PROG_FINDLIB])dnl 254 | 255 | AC_MSG_CHECKING([for findlib package $1]) 256 | 257 | unset found 258 | unset pkg 259 | found=no 260 | for pkg in $1; do 261 | if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then 262 | AC_MSG_RESULT([found]) 263 | found=yes 264 | break 265 | fi 266 | done 267 | if test "$found" = "no" ; then 268 | AC_MSG_RESULT([not found]) 269 | fi 270 | AS_IF([test "$found" = "no"], [$3], [$2])])dnl 271 | ]) 272 | 273 | 274 | # AC_NEED_FINDLIB_PKG(NAME) 275 | # ------------------------- 276 | # If OCaml findlib package name is not found, then terminate the 277 | # configuration script with an appropriate error message. 278 | 279 | AC_DEFUN([AC_NEED_FINDLIB_PKG], 280 | [AC_CHECK_FINDLIB_PKG([$1], 281 | [], [AC_MSG_ERROR([OCaml findlib package $1 not found.])])]) 282 | 283 | 284 | # AC_CHECK_OCAML_MODULE(VARIABLE,NAME,MODULE,INCLUDE-PATHS) 285 | # --------------------------------------------------------- 286 | # AC_CHECK_OCAML_MODULE is the hairier alternative to 287 | # AC_CHECK_OCAML_PKG. You should always use AC_CHECK_OCAML_PKG and 288 | # ocamlfind/findlib if possible. 289 | # 290 | # The parameters are: 291 | # 292 | # VARIABLE 293 | # This is the environment variable that is set. It will either be 294 | # set to the include path, or to no if the module was not found. 295 | # 296 | # NAME 297 | # This is the name of the module we are looking for. This parameter 298 | # is just used for printing messages, and does not affect how the 299 | # module is found. 300 | # 301 | # MODULE 302 | # This should be an OCaml module name, representing the module name 303 | # being looked up. You can put sub-modules here, 304 | # eg. CalendarLib.Date 305 | # 306 | # INCLUDE-PATHS 307 | # This is the default list of include directories to search, 308 | # eg. +calendar 309 | 310 | AC_DEFUN([AC_CHECK_OCAML_MODULE], 311 | [dnl 312 | AC_MSG_CHECKING([for OCaml module $2]) 313 | 314 | cat > conftest.ml <&5 2>&5 ; then 320 | found=yes 321 | break 322 | fi 323 | done 324 | 325 | if test "$found" ; then 326 | AC_MSG_RESULT([$$1]) 327 | else 328 | AC_MSG_RESULT([not found]) 329 | $1=no 330 | fi 331 | AC_SUBST([$1]) 332 | ]) 333 | 334 | 335 | # AC_CHECK_OCAML_WORD_SIZE 336 | # ------------------------ 337 | # This checks the word size of the OCaml compiler, and sets 338 | # OCAML_WORD_SIZE to either 32 or 64. 339 | 340 | AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE], 341 | [dnl 342 | AC_REQUIRE([AC_PROG_OCAML])dnl 343 | AC_MSG_CHECKING([for OCaml compiler word size]) 344 | cat > conftest.ml < conftest.ml <> /etc/apt/sources.list < y :: acc 24 | | None -> acc 25 | in 26 | let rec loop acc r = 27 | match r with 28 | | hd :: tl -> loop (fpack acc hd) tl 29 | | [] -> List.rev acc 30 | in 31 | loop [] lst 32 | 33 | let list () = 34 | Rashell_Docker.ps () 35 | >|= List.map (fun container -> (container.container_id, container)) 36 | 37 | let plan lst = 38 | List.map (fun (container_id, container) -> 39 | let preserve = 40 | container.container_state.state_running 41 | in 42 | (container_id, 43 | (if preserve then "Running" else "Not(Running)"), 44 | preserve)) 45 | lst 46 | 47 | let exec plan = 48 | Lwt.catch 49 | (fun () -> Rashell_Docker.rm 50 | (filtermap (fun (id, _, flag) -> if flag then None else Some(id)) plan)) 51 | (function 52 | | Rashell_Command.Error(cmd, Unix.WEXITED 1, mesg) -> 53 | Lwt.fail_with mesg 54 | | exn -> Lwt.fail exn) 55 | -------------------------------------------------------------------------------- /docker_gc/dockerGc_Container.mli: -------------------------------------------------------------------------------- 1 | (* DockerGc_Container -- Docker GC Containers 2 | 3 | Docker Toolkit (https://github.com/michipili/dockertk) 4 | This file is part of Docker Toolkit 5 | 6 | Copyright © 2015 Michael Grünewald 7 | 8 | This file must be used under the terms of the CeCILL-B. 9 | This source file is licensed as described in the file COPYING, which 10 | you should have received as part of this distribution. The terms 11 | are also available at 12 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) 13 | 14 | type container = Rashell_Docker_t.container 15 | (** The type of docker containers. *) 16 | 17 | type container_id = string 18 | (** The type of container ids. *) 19 | 20 | val list : unit -> (container_id * container) list Lwt.t 21 | (** Return the list of current containers. *) 22 | 23 | val plan : (container_id * container) list -> (container_id * string * bool) list 24 | (** Apply the built-in policy to mark each non-running container to be 25 | deleted. *) 26 | 27 | val exec : (container_id * string * bool) list -> unit Lwt.t 28 | (** Apply the given plan by removing marked containers. *) 29 | -------------------------------------------------------------------------------- /docker_gc/dockerGc_Image.ml: -------------------------------------------------------------------------------- 1 | (* DockerGc_Library -- Docker GC Library 2 | 3 | Docker Toolkit (https://github.com/michipili/dockertk) 4 | This file is part of Docker Toolkit 5 | 6 | Copyright © 2015 Michael Grünewald 7 | 8 | This file must be used under the terms of the CeCILL-B. 9 | This source file is licensed as described in the file COPYING, which 10 | you should have received as part of this distribution. The terms 11 | are also available at 12 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) 13 | open Rashell_Docker_t 14 | 15 | module StringPool = 16 | Set.Make(String) 17 | 18 | type image = Rashell_Docker_t.image 19 | 20 | type image_id = string 21 | 22 | type image_ref = string 23 | 24 | type repository = string 25 | 26 | type tag = string 27 | 28 | type description = { 29 | image: image; 30 | name: (repository * tag) list; 31 | } 32 | 33 | type policy = 34 | DockerGc_Policy.t 35 | 36 | type predicate = 37 | DockerGc_Policy.predicate 38 | 39 | let filtermap f lst = 40 | let fpack acc x = 41 | match f x with 42 | | Some(y) -> y :: acc 43 | | None -> acc 44 | in 45 | let rec loop acc r = 46 | match r with 47 | | hd :: tl -> loop (fpack acc hd) tl 48 | | [] -> List.rev acc 49 | in 50 | loop [] lst 51 | 52 | module LibraryReader = 53 | struct 54 | 55 | module Monad = 56 | Lemonade_Reader.Make(struct type t = (image_id * description) list end) 57 | 58 | include Monad 59 | open Monad.Infix 60 | 61 | let _program_start = 62 | Unix.gettimeofday () 63 | 64 | let _lookup imageid env = 65 | try List.assoc imageid env 66 | with Not_found -> failwith (imageid^": Image not found.") 67 | 68 | let _age n imageid env = 69 | let image = (_lookup imageid env).image in 70 | let seconds_per_day = float_of_int(24 * 60 * 60) in 71 | let t = Rashell_Timestamp.of_string image.image_created in 72 | (_program_start -. t) /. seconds_per_day > (float_of_int n) 73 | 74 | let age n imageid = 75 | _age n imageid <$> read 76 | 77 | let _repositories imageid env = 78 | (_lookup imageid env).name 79 | |> List.map fst 80 | 81 | let _repository s imageid env = 82 | match _repositories imageid env with 83 | | [] -> s = "" 84 | | names -> List.mem s names 85 | 86 | let repository s imageid = 87 | _repository s imageid <$> read 88 | 89 | let _dandling imageid env = 90 | match _lookup imageid env with 91 | | { name = [] } -> true 92 | | _ -> false 93 | 94 | let dandling imageid = 95 | _dandling imageid <$> read 96 | 97 | let _leaves env = 98 | let _is_leaf env imageid = 99 | not(List.exists 100 | (fun (_, { image }) -> image.image_parent = Some(imageid)) env) 101 | in 102 | List.filter (_is_leaf env) (List.map fst env) 103 | 104 | let leaves = 105 | _leaves <$> read 106 | 107 | let _select ids action env = 108 | let open DockerGc_Policy in 109 | let _compare id1 id2 = 110 | (* Smallest for this order is the most recent *) 111 | let { image = img1 } = _lookup id1 env in 112 | let { image = img2 } = _lookup id2 env in 113 | Pervasives.compare img2.image_created img1.image_created 114 | in 115 | let _list_take n lst = 116 | List.fold_left 117 | (fun (acc, k) x -> if k >= n then (acc, k) else (x :: acc, (k+1))) 118 | ([], 0) lst 119 | |> fst 120 | in 121 | match action with 122 | | PreserveRecent(n) -> 123 | StringPool.elements ids 124 | |> List.sort _compare 125 | |> _list_take n 126 | |> StringPool.of_list 127 | | _ -> ids 128 | 129 | 130 | let select ids action = 131 | _select ids action <$> read 132 | 133 | let description imageid = 134 | _lookup imageid <$> read 135 | end 136 | 137 | let list () = 138 | let%lwt images = Rashell_Docker.images () in 139 | let%lwt tags = Rashell_Docker.tags () in 140 | let decorate image = 141 | (image.image_id, { 142 | image; 143 | name = (try List.assoc image.image_id tags with Not_found -> []); 144 | }) 145 | in 146 | Lwt.return (List.map decorate images) 147 | 148 | let rec eval imageid = 149 | let open DockerGc_Policy in 150 | let open LibraryReader.Infix in 151 | function 152 | | True -> LibraryReader.return true 153 | | False -> LibraryReader.return false 154 | | Age(n) -> LibraryReader.age n imageid 155 | | Repository(s)-> LibraryReader.repository s imageid 156 | | Dandling -> LibraryReader.dandling imageid 157 | | Not(expr) -> not <$> (eval imageid expr) 158 | | Or(a,b) -> ( || ) <$> (eval imageid a) <*> (eval imageid b) 159 | | And(a,b) -> ( && ) <$> (eval imageid a) <*> (eval imageid b) 160 | 161 | 162 | let plan_predicate_matching policy imageid_lst = 163 | let open LibraryReader.Infix in 164 | let predicate_matching predicate = 165 | LibraryReader.filter 166 | (fun imageid -> eval imageid predicate) 167 | (List.map LibraryReader.return imageid_lst) 168 | in 169 | let f (predicate, action) = 170 | predicate_matching predicate 171 | >>= fun imageids -> 172 | LibraryReader.return 173 | (StringPool.of_list imageids, 174 | DockerGc_Policy.predicate_to_string predicate, 175 | action) 176 | in 177 | LibraryReader.dist (List.map f policy) 178 | 179 | let plan_integrate ax (ids, reason, action) = 180 | let open LibraryReader.Infix in 181 | let preserve = 182 | let open DockerGc_Policy in 183 | match action with 184 | | Delete -> false 185 | | PreserveAll 186 | | PreserveRecent(_) -> true 187 | in 188 | LibraryReader.select ids action 189 | >>= fun actual_ids -> 190 | (ax >>= (fun (acc, seen) -> 191 | LibraryReader.return 192 | ((actual_ids, reason, preserve, seen)::acc, 193 | (StringPool.union actual_ids seen)))) 194 | 195 | let plan_interpret ax = 196 | List.map 197 | (fun (ids, reason, preserve, seen) -> 198 | StringPool.elements (StringPool.diff ids seen), reason, preserve) 199 | (fst ax) 200 | |> List.map 201 | (fun (ids, reason, preserve) -> List.map 202 | (fun x -> 203 | LibraryReader.bind 204 | (LibraryReader.description x) 205 | (fun descr -> LibraryReader.return (descr, reason, preserve))) 206 | ids) 207 | |> List.concat 208 | |> LibraryReader.dist 209 | 210 | let plan policy env = 211 | let open LibraryReader.Infix in 212 | let prog = 213 | LibraryReader.leaves 214 | >>= plan_predicate_matching policy 215 | >>= List.fold_left plan_integrate (LibraryReader.return ([], StringPool.empty)) 216 | >>= plan_interpret 217 | in 218 | LibraryReader.run env prog 219 | 220 | let rmi descr = 221 | let image_refs = 222 | match descr.name with 223 | | [] -> [descr.image.Rashell_Docker_t.image_id] 224 | | lst -> List.map (fun (repository, tag) -> repository ^ ":" ^ tag) lst 225 | in 226 | Rashell_Docker.rmi image_refs 227 | 228 | let exec plan = 229 | Lwt.catch 230 | (fun () -> Lwt_list.iter_s rmi (filtermap (fun (descr, _, flag) -> if flag then None else Some(descr)) plan)) 231 | (function 232 | | Rashell_Command.Error(cmd, Unix.WEXITED 1, mesg) -> 233 | Lwt.fail_with mesg 234 | | exn -> Lwt.fail exn) 235 | -------------------------------------------------------------------------------- /docker_gc/dockerGc_Image.mli: -------------------------------------------------------------------------------- 1 | (* DockerGc_Image -- Docker GC Image 2 | 3 | Docker Toolkit (https://github.com/michipili/dockertk) 4 | This file is part of Docker Toolkit 5 | 6 | Copyright © 2015 Michael Grünewald 7 | 8 | This file must be used under the terms of the CeCILL-B. 9 | This source file is licensed as described in the file COPYING, which 10 | you should have received as part of this distribution. The terms 11 | are also available at 12 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) 13 | 14 | type image = Rashell_Docker_t.image 15 | (** The type of docker images. *) 16 | 17 | type image_id = string 18 | (** The type of image ids. *) 19 | 20 | type image_ref = string 21 | (** The type of image reference, either an image id or repository:tag name. *) 22 | 23 | type repository = string 24 | (** The type of image repositories. *) 25 | 26 | type tag = string 27 | (** The type of tags. *) 28 | 29 | type description = { 30 | image: image; 31 | name: (repository * tag) list; 32 | } 33 | (** The type of descriptions for the item found in the local libray. *) 34 | 35 | type policy = DockerGc_Policy.t 36 | (** The type of garbage collection policies. *) 37 | 38 | type predicate = DockerGc_Policy.predicate 39 | (** The type of predicates for garbage collection polcies. *) 40 | 41 | val list : unit -> (image_id * description) list Lwt.t 42 | (** Return the contents of the local images library. *) 43 | 44 | val plan : policy -> (image_id * description) list -> (description * string * bool) list 45 | (** Apply the policy to some library contents. The result mentions 46 | each leaf image id, the predicate that matched it, and if the image is 47 | to be preserved. *) 48 | 49 | val exec : (description * string * bool) list -> unit Lwt.t 50 | (** Apply the given plan by removing marked images. *) 51 | -------------------------------------------------------------------------------- /docker_gc/dockerGc_Main.ml: -------------------------------------------------------------------------------- 1 | open Printf 2 | open Lwt.Infix 3 | open Rashell_Docker_t 4 | open DockerGc_Configuration 5 | 6 | module StringPool = 7 | Set.Make(String) 8 | 9 | module Application = 10 | Gasoline_Plain_SecureTool 11 | 12 | let filtermap f lst = 13 | let fpack acc x = 14 | match f x with 15 | | Some(y) -> y :: acc 16 | | None -> acc 17 | in 18 | let rec loop acc r = 19 | match r with 20 | | hd :: tl -> loop (fpack acc hd) tl 21 | | [] -> List.rev acc 22 | in 23 | loop [] lst 24 | 25 | module Component_Policy = 26 | struct 27 | let comp = Application.Component.make 28 | ~name:"policy" 29 | ~description:"Policy for deleting docker images" 30 | () 31 | 32 | module Configuration = 33 | struct 34 | open Application.Configuration 35 | 36 | let file = 37 | make_string comp ~flag:'f' 38 | "file" 39 | (try sprintf "%s/.docker/docker_gc.conf" (Sys.getenv "HOME") 40 | with Not_found -> sprintf "%s/docker/docker_gc.conf" ac_dir_sysconfdir) 41 | "Path to the policy file" 42 | end 43 | 44 | let policy () = 45 | try DockerGc_Policy.from_file (Configuration.file()) 46 | with Sys_error(_) -> DockerGc_Policy.[ 47 | Dandling, Delete; 48 | True, PreserveAll; 49 | ] 50 | end 51 | 52 | 53 | module Component_Plan = 54 | struct 55 | 56 | let comp = Application.Component.make 57 | ~name:"plan" 58 | ~description:"Processing plan for deleting docker images and containers" 59 | () 60 | 61 | module Configuration = 62 | struct 63 | open Application.Configuration 64 | 65 | let dry_run = 66 | make_bool comp ~optarg:"true" ~flag:'n' 67 | "#dry_run" false 68 | "Dry run, only list actions to be taken without executing them" 69 | 70 | let _verbose = 71 | make_bool comp ~optarg:"true" ~flag:'v' 72 | "#verbose" false 73 | "Verbose, list the matching predicate with each action taken" 74 | 75 | let verbose () = 76 | _verbose () || dry_run () 77 | end 78 | 79 | let process policy = 80 | let log_plan item_to_string = 81 | if Configuration.verbose () then 82 | (fun (item, reason, preserve) -> 83 | Lwt_io.eprintf "%8s %s %s\n" 84 | (if preserve then "Preserve" else "Delete") 85 | (item_to_string item) 86 | reason) 87 | else 88 | (fun _ -> Lwt.return_unit) 89 | in 90 | let snoop item_to_string plan = 91 | Lwt_list.iter_s (log_plan item_to_string) plan 92 | >>= fun () -> Lwt.return plan 93 | in 94 | let containers () = 95 | let exec = 96 | if Configuration.dry_run () then 97 | Lwt.wrap1 ignore 98 | else 99 | DockerGc_Container.exec 100 | in 101 | DockerGc_Container.list () 102 | >|= DockerGc_Container.plan 103 | >>= snoop (fun containerid -> containerid) 104 | >>= exec 105 | in 106 | let images () = 107 | let exec = 108 | if Configuration.dry_run () then 109 | Lwt.wrap1 ignore 110 | else 111 | DockerGc_Image.exec 112 | in 113 | DockerGc_Image.list () 114 | >|= DockerGc_Image.plan policy 115 | >>= snoop (fun description -> description.DockerGc_Image.image.Rashell_Docker_t.image_id) 116 | >>= exec 117 | in 118 | containers () >>= images 119 | end 120 | 121 | module Component_Main = 122 | struct 123 | let comp = 124 | Application.Component.make 125 | ~name:"main" 126 | ~description:"Main component" 127 | () 128 | 129 | 130 | module Configuration = 131 | struct 132 | open Application.Configuration 133 | 134 | end 135 | 136 | 137 | let run _ = 138 | Lwt_main.run 139 | (Component_Plan.process (Component_Policy.policy())) 140 | end 141 | 142 | let () = 143 | let open Application.Configuration in 144 | Application.run "docker_gc" 145 | "[-hnv]" 146 | "Remove obsolete containers and images" 147 | Component_Main.run 148 | -------------------------------------------------------------------------------- /docker_gc/dockerGc_Policy.ml: -------------------------------------------------------------------------------- 1 | (* DockerGc_Policy -- Docker GC Policy specification 2 | 3 | Docker Toolkit (https://github.com/michipili/dockertk) 4 | This file is part of Docker Toolkit 5 | 6 | Copyright © 2015 Michael Grünewald 7 | 8 | This file must be used under the terms of the CeCILL-B. 9 | This source file is licensed as described in the file COPYING, which 10 | you should have received as part of this distribution. The terms 11 | are also available at 12 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) 13 | open Printf 14 | 15 | type t = 16 | (predicate * action) list 17 | and predicate = 18 | | True 19 | | False 20 | | Age of int 21 | | Repository of string 22 | | Dandling 23 | | And of predicate * predicate 24 | | Or of predicate * predicate 25 | | Not of predicate 26 | and action = 27 | | Delete 28 | | PreserveAll 29 | | PreserveRecent of int 30 | 31 | let rec pp_print_predicate ppt = 32 | let open Format in 33 | function 34 | | True -> fprintf ppt "True" 35 | | False -> fprintf ppt "False" 36 | | And(a,b) -> fprintf ppt "And(%a, %a)" pp_print_predicate a pp_print_predicate b 37 | | Or(a,b) -> fprintf ppt "Or(%a, %a)" pp_print_predicate a pp_print_predicate b 38 | | Not(a) -> fprintf ppt "Not(%a)" pp_print_predicate a 39 | | Age(n) -> fprintf ppt "Age(%d)" n 40 | | Repository(name) -> fprintf ppt "Repository(%S)" name 41 | | Dandling -> fprintf ppt "Dandling" 42 | 43 | module PredicateFormatBasis = 44 | struct 45 | type t = predicate 46 | let pp_print = pp_print_predicate 47 | end 48 | 49 | module PredicateFormatMethods = 50 | Mixture_Format.Make(PredicateFormatBasis) 51 | 52 | let predicate_to_string = 53 | PredicateFormatMethods.to_string 54 | 55 | let pp_print_action fft = 56 | let open Format in 57 | function 58 | | Delete -> pp_print_string fft "Delete" 59 | | PreserveAll -> pp_print_string fft "PreserveAll" 60 | | PreserveRecent(n) -> fprintf fft "PreserveRecent(%d)" n 61 | 62 | module ActionFormatBasis = 63 | struct 64 | type t = action 65 | let pp_print = pp_print_action 66 | end 67 | 68 | module ActionFormatMethods = 69 | Mixture_Format.Make(ActionFormatBasis) 70 | 71 | let action_to_string = 72 | ActionFormatMethods.to_string 73 | 74 | 75 | type token = 76 | | TRUE 77 | | FALSE 78 | | AGE 79 | | REPOSITORY 80 | | DANDLING 81 | | AND 82 | | OR 83 | | NOT 84 | | DELETE 85 | | PRESERVE_ALL 86 | | PRESERVE_RECENT 87 | | COMMA 88 | | LPAREN 89 | | RPAREN 90 | | IDENT of string 91 | | INTEGER of int 92 | 93 | let table = [ 94 | "True", TRUE; 95 | "False", FALSE; 96 | "Age", AGE; 97 | "Repository", REPOSITORY; 98 | "Dandling", DANDLING; 99 | "And", AND; 100 | "Or", OR; 101 | "Not", NOT; 102 | "Delete", DELETE; 103 | "PreserveAll", PRESERVE_ALL; 104 | "PreserveRecent", PRESERVE_RECENT; 105 | ",", COMMA; 106 | "(", LPAREN; 107 | ")", RPAREN; 108 | ] 109 | 110 | let stream_elements s = 111 | let rec loop ax = 112 | match Stream.peek s with 113 | | Some(x) -> (Stream.junk s; loop (x :: ax)) 114 | | None -> List.rev ax 115 | in 116 | loop [] 117 | 118 | let lexer s = 119 | Stream.of_string s 120 | |> Genlex.make_lexer (List.map fst table) 121 | |> stream_elements 122 | |> List.map 123 | (let open Genlex in function 124 | | Kwd keyword -> 125 | (try List.assoc keyword table 126 | with Not_found -> 127 | ksprintf failwith "DockerGc_Policy.lexer: %S: Not a keyword." keyword) 128 | | Ident(s) -> IDENT(s) 129 | | Int(n) -> INTEGER(n) 130 | | String(s) -> IDENT(s) 131 | | Float(_) 132 | | Char(_) -> failwith "DockerGc_Policy.lexer: Unexpected tokens.") 133 | 134 | let paren_split toks0 = 135 | let rec loop acc n toks = 136 | match n, toks with 137 | | 0, RPAREN :: _ -> 138 | failwith "DockerGc_Policy.parser: Unbalanced parenthesis." 139 | | 1, RPAREN :: tl -> (List.rev acc, tl) 140 | | _, RPAREN :: tl -> loop (RPAREN :: acc) (n-1) tl 141 | | _, LPAREN :: tl -> loop (LPAREN :: acc) (n+1) tl 142 | | _, hd :: tl -> loop (hd :: acc) n tl 143 | | _, [] -> 144 | failwith "DockerGc_Policy.parser: Unbalanced parenthesis." 145 | in 146 | loop [] 1 toks0 147 | 148 | let rec read_argv_loop argv acc n toks = 149 | match n, toks with 150 | | 0, RPAREN :: _ -> 151 | failwith "DockerGc_Policy.parser: Unbalanced parenthesis." 152 | | 1, RPAREN :: [] -> List.rev ((List.rev acc) :: argv) 153 | | 1, RPAREN :: _ -> 154 | failwith "DockerGc_Policy.parser: Unexpected tokens after arguments." 155 | | _, RPAREN :: tl -> read_argv_loop argv (RPAREN :: acc) (n-1) tl 156 | | _, LPAREN :: tl -> read_argv_loop argv (LPAREN :: acc) (n+1) tl 157 | | 1, COMMA :: tl -> read_argv_loop ((List.rev acc) :: argv) [] 1 tl 158 | | _, hd :: tl -> read_argv_loop argv (hd :: acc) n tl 159 | | _, [] -> 160 | failwith "DockerGc_Policy.parser: Unbalanced parenthesis." 161 | 162 | let read_argv toks0 = 163 | read_argv_loop [] [] 1 toks0 164 | 165 | let id x = 166 | x 167 | 168 | let failwith_arity s = 169 | ksprintf failwith 170 | "DockerGc_Policy.parser: %s: Incorrect number of arguments." s 171 | 172 | let rec predicate_entry cont = 173 | function 174 | | [] -> failwith "DockerGc_Policy.parser: Unexpected end of input." 175 | | TRUE :: [] -> cont True 176 | | FALSE :: [] -> cont False 177 | | AGE :: LPAREN :: INTEGER(n) :: RPAREN :: [] -> cont (Age(n)) 178 | | REPOSITORY :: LPAREN :: IDENT(s) :: RPAREN :: [] -> cont (Repository(s)) 179 | | DANDLING :: [] -> cont Dandling 180 | | NOT :: LPAREN :: tl -> 181 | (match read_argv tl with 182 | | [a] -> cont (predicate_entry (fun x -> Not(x)) a) 183 | | _ -> failwith_arity "Not") 184 | | AND :: LPAREN :: tl -> 185 | (match read_argv tl with 186 | | [a; b] -> cont (And(predicate_entry id a, predicate_entry id b)) 187 | | _ -> failwith_arity "And") 188 | | OR :: LPAREN :: tl -> 189 | (match read_argv tl with 190 | | [a; b] -> cont (Or(predicate_entry id a, predicate_entry id b)) 191 | | _ -> failwith_arity "Or") 192 | | _ -> failwith "DockerGc_Policy.parser: Syntax error." 193 | 194 | let predicate_of_string s = 195 | predicate_entry id (lexer s) 196 | 197 | let action_entry cont = 198 | function 199 | | [] -> failwith "DockerGc_Policy.parser: Unexpected end of input." 200 | | DELETE :: [] -> cont Delete 201 | | PRESERVE_ALL :: [] -> cont PreserveAll 202 | | PRESERVE_RECENT :: LPAREN :: INTEGER(n) :: RPAREN :: [] -> 203 | cont(PreserveRecent(n)) 204 | | _ -> failwith "DockerGc_Policy.parser: Syntax error." 205 | 206 | let action_of_string s = 207 | action_entry id (lexer s) 208 | 209 | let lines_from_file s = 210 | let c = open_in s in 211 | let next_line () = 212 | try Some(input_line c) 213 | with End_of_file -> (close_in c; None) 214 | in 215 | let rec loop acc = 216 | match next_line () with 217 | | Some(s) -> loop (s :: acc) 218 | | None -> List.rev acc 219 | in 220 | loop [] 221 | 222 | let from_file s = 223 | let open Str in 224 | let declaration_re = regexp "\\([^:]*\\)[\t ]*:[\t ]*\\(.*\\)" in 225 | let ignore_re = regexp "^#\\|^$" in 226 | let rec loop acc line = 227 | if string_match ignore_re line 0 then 228 | acc 229 | else if string_match declaration_re line 0 then 230 | (predicate_of_string (matched_group 1 line), 231 | action_of_string (matched_group 2 line)) :: acc 232 | else 233 | ksprintf failwith "DockerGc_Policy.from_file: %S: Syntax error." line 234 | in 235 | List.fold_left loop [] (lines_from_file s) 236 | |> List.rev 237 | -------------------------------------------------------------------------------- /docker_gc/dockerGc_Policy.mli: -------------------------------------------------------------------------------- 1 | (* DockerGc_Policy -- Docker GC Policy specification 2 | 3 | Docker Toolkit (https://github.com/michipili/dockertk) 4 | This file is part of Docker Toolkit 5 | 6 | Copyright © 2015 Michael Grünewald 7 | 8 | This file must be used under the terms of the CeCILL-B. 9 | This source file is licensed as described in the file COPYING, which 10 | you should have received as part of this distribution. The terms 11 | are also available at 12 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) 13 | 14 | type t = 15 | (predicate * action) list 16 | and predicate = 17 | | True (** Select all images. *) 18 | | False (** Select no images. *) 19 | | Age of int (** Select images whose age is at least the given number of days. *) 20 | | Repository of string(** Select images belonging to the given repository. *) 21 | | Dandling (** Select dandling images. *) 22 | | And of predicate * predicate 23 | | Or of predicate * predicate 24 | | Not of predicate 25 | and action = 26 | | Delete (** Delete selected images. *) 27 | | PreserveAll (** Preserve all selected images. *) 28 | | PreserveRecent of int (** Preserver at most the given number of selected images. *) 29 | 30 | val pp_print_predicate : Format.formatter -> predicate -> unit 31 | (** Pretty-print the given predicate. *) 32 | 33 | val predicate_to_string : predicate -> string 34 | (** Convert a predicate to a string. *) 35 | 36 | val predicate_of_string : string -> predicate 37 | (** Parse a string to build a predicate. 38 | 39 | @raise Failure when the string cannot be correctly parsed. *) 40 | 41 | val pp_print_action : Format.formatter -> action -> unit 42 | (** Pretty-print the given action. *) 43 | 44 | val action_to_string : action -> string 45 | (** Convert an action to a string. *) 46 | 47 | val action_of_string : string -> action 48 | (** Parse a string to build an action. 49 | 50 | @raise Failure when the string cannot be correctly parsed. *) 51 | 52 | val from_file : string -> t 53 | (** Read a policy from a JSON file. This is an example of a valid file: 54 | 55 | {v 56 | Dandling : Delete 57 | Not(Age(3)) : PreserveAll 58 | Repository("organisation/repo") : PreserveRecent(3) 59 | True : Delete 60 | v} *) 61 | -------------------------------------------------------------------------------- /docker_gc/example.conf: -------------------------------------------------------------------------------- 1 | # This illustrate a comment 2 | 3 | Image("") : Delete 4 | Not(Age(3)) : PreserveAll 5 | Image("organisation/image") : PreserveRecent(3) 6 | True : Delete 7 | -------------------------------------------------------------------------------- /opam/descr: -------------------------------------------------------------------------------- 1 | This addresses a few shortcomings of the base **docker** toolkit. As 2 | this technology currently enjoys a growing user base, I hope that this 3 | toolkit will be helpful to many. This *missing Docker Toolkit* 4 | currently provides a flexible garbage collector. 5 | 6 | WWW: https://github.com/michipili/dockertk 7 | -------------------------------------------------------------------------------- /opam/opam: -------------------------------------------------------------------------------- 1 | opam-version: "1.2" 2 | version: "0.2.0-current" 3 | maintainer: "michipili@gmail.com" 4 | authors: "Michael Grünewald" 5 | license: "CeCILL-B" 6 | homepage: "https://github.com/michipili/dockertk" 7 | bug-reports: "https://github.com/michipili/dockertk/issues" 8 | dev-repo: "https://github.com/michipili/dockertk.git" 9 | available: [ 10 | ocaml-version >= "4.02.1" 11 | ] 12 | tags: [ 13 | "docker" 14 | ] 15 | build: [ 16 | ["./configure" "--prefix" prefix] 17 | ["bmake" "-I%{bsdowl:share}%" "all"] {os != "freebsd"} 18 | ["make" "-I%{bsdowl:share}%" "all"] {os = "freebsd"} 19 | ] 20 | install: [ 21 | ["bmake" "-I%{bsdowl:share}%" "install"] {os != "freebsd"} 22 | ["make" "-I%{bsdowl:share}%" "install"] {os = "freebsd"} 23 | ] 24 | remove: [ 25 | ["ocamlfind" "remove" "dockertk"] 26 | ["rm" "-rf" "%{share}%/doc/dockertk"] 27 | ] 28 | depends: [ 29 | "bsdowl" {>= "3.0.0"} 30 | "gasoline" {>= "0.4.0"} 31 | "lemonade" {>= "0.3.0"} 32 | "ocamlfind" 33 | "rashell" {>= "0.2.0"} 34 | ] 35 | depexts: [ 36 | [["debian"] ["bmake"]] 37 | [["ubuntu"] ["bmake"]] 38 | [["osx" "macports"] ["bmake"]] 39 | ] 40 | --------------------------------------------------------------------------------