├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── README.org ├── THANKS ├── am ├── Makefile.am └── guilec ├── build-aux ├── .gitignore ├── Makefile.am ├── compile ├── config.rpath └── gitlog-to-changelog ├── configure.ac ├── doc ├── .gitignore ├── Makefile.am ├── fdl.texi ├── logo.png ├── logo.svg └── metabash.texi ├── examples ├── group-grep.scm └── kernel-release-diff.scm ├── m4 ├── Makefile.am ├── guile-2.0.m4 └── pkg.m4 ├── modules └── metabash │ ├── Makefile.am │ ├── core │ ├── Makefile.am │ ├── pipeline.scm │ ├── plumbing │ │ ├── Makefile.am │ │ ├── pipe.scm │ │ └── tee.scm │ ├── process.scm │ └── redirection.scm │ ├── diff.scm │ └── plumber.scm └── utils ├── README.org └── supervisor /.gitignore: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | 3 | # Compiled Guile modules 4 | *.go 5 | 6 | # Backup files 7 | *\~ 8 | 9 | # Auto-generated files 10 | Makefile 11 | Makefile.in 12 | configure 13 | aclocal.m4 14 | 15 | config.log 16 | config.status 17 | .deps 18 | autom4te.cache 19 | 20 | TAGS 21 | tags 22 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors of Metabash 2 | 3 | * Artyom V. Poptsov -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | Normally a ChangeLog is generated at "make dist" time and available in 2 | source tarballs. 3 | 4 | If not, see the Git commit log at . 5 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software 5 | Foundation, Inc. 6 | 7 | Copying and distribution of this file, with or without modification, 8 | are permitted in any medium without royalty provided the copyright 9 | notice and this notice are preserved. This file is offered as-is, 10 | without warranty of any kind. 11 | 12 | Basic Installation 13 | ================== 14 | 15 | Briefly, the shell command './configure && make && make install' 16 | should configure, build, and install this package. The following 17 | more-detailed instructions are generic; see the 'README' file for 18 | instructions specific to this package. Some packages provide this 19 | 'INSTALL' file but do not implement all of the features documented 20 | below. The lack of an optional feature in a given package is not 21 | necessarily a bug. More recommendations for GNU packages can be found 22 | in *note Makefile Conventions: (standards)Makefile Conventions. 23 | 24 | The 'configure' shell script attempts to guess correct values for 25 | various system-dependent variables used during compilation. It uses 26 | those values to create a 'Makefile' in each directory of the package. 27 | It may also create one or more '.h' files containing system-dependent 28 | definitions. Finally, it creates a shell script 'config.status' that 29 | you can run in the future to recreate the current configuration, and a 30 | file 'config.log' containing compiler output (useful mainly for 31 | debugging 'configure'). 32 | 33 | It can also use an optional file (typically called 'config.cache' and 34 | enabled with '--cache-file=config.cache' or simply '-C') that saves the 35 | results of its tests to speed up reconfiguring. Caching is disabled by 36 | default to prevent problems with accidental use of stale cache files. 37 | 38 | If you need to do unusual things to compile the package, please try 39 | to figure out how 'configure' could check whether to do them, and mail 40 | diffs or instructions to the address given in the 'README' so they can 41 | be considered for the next release. If you are using the cache, and at 42 | some point 'config.cache' contains results you don't want to keep, you 43 | may remove or edit it. 44 | 45 | The file 'configure.ac' (or 'configure.in') is used to create 46 | 'configure' by a program called 'autoconf'. You need 'configure.ac' if 47 | you want to change it or regenerate 'configure' using a newer version of 48 | 'autoconf'. 49 | 50 | The simplest way to compile this package is: 51 | 52 | 1. 'cd' to the directory containing the package's source code and type 53 | './configure' to configure the package for your system. 54 | 55 | Running 'configure' might take a while. While running, it prints 56 | some messages telling which features it is checking for. 57 | 58 | 2. Type 'make' to compile the package. 59 | 60 | 3. Optionally, type 'make check' to run any self-tests that come with 61 | the package, generally using the just-built uninstalled binaries. 62 | 63 | 4. Type 'make install' to install the programs and any data files and 64 | documentation. When installing into a prefix owned by root, it is 65 | recommended that the package be configured and built as a regular 66 | user, and only the 'make install' phase executed with root 67 | privileges. 68 | 69 | 5. Optionally, type 'make installcheck' to repeat any self-tests, but 70 | this time using the binaries in their final installed location. 71 | This target does not install anything. Running this target as a 72 | regular user, particularly if the prior 'make install' required 73 | root privileges, verifies that the installation completed 74 | correctly. 75 | 76 | 6. You can remove the program binaries and object files from the 77 | source code directory by typing 'make clean'. To also remove the 78 | files that 'configure' created (so you can compile the package for 79 | a different kind of computer), type 'make distclean'. There is 80 | also a 'make maintainer-clean' target, but that is intended mainly 81 | for the package's developers. If you use it, you may have to get 82 | all sorts of other programs in order to regenerate files that came 83 | with the distribution. 84 | 85 | 7. Often, you can also type 'make uninstall' to remove the installed 86 | files again. In practice, not all packages have tested that 87 | uninstallation works correctly, even though it is required by the 88 | GNU Coding Standards. 89 | 90 | 8. Some packages, particularly those that use Automake, provide 'make 91 | distcheck', which can by used by developers to test that all other 92 | targets like 'make install' and 'make uninstall' work correctly. 93 | This target is generally not run by end users. 94 | 95 | Compilers and Options 96 | ===================== 97 | 98 | Some systems require unusual options for compilation or linking that 99 | the 'configure' script does not know about. Run './configure --help' 100 | for details on some of the pertinent environment variables. 101 | 102 | You can give 'configure' initial values for configuration parameters 103 | by setting variables in the command line or in the environment. Here is 104 | an example: 105 | 106 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 107 | 108 | *Note Defining Variables::, for more details. 109 | 110 | Compiling For Multiple Architectures 111 | ==================================== 112 | 113 | You can compile the package for more than one kind of computer at the 114 | same time, by placing the object files for each architecture in their 115 | own directory. To do this, you can use GNU 'make'. 'cd' to the 116 | directory where you want the object files and executables to go and run 117 | the 'configure' script. 'configure' automatically checks for the source 118 | code in the directory that 'configure' is in and in '..'. This is known 119 | as a "VPATH" build. 120 | 121 | With a non-GNU 'make', it is safer to compile the package for one 122 | architecture at a time in the source code directory. After you have 123 | installed the package for one architecture, use 'make distclean' before 124 | reconfiguring for another architecture. 125 | 126 | On MacOS X 10.5 and later systems, you can create libraries and 127 | executables that work on multiple system types--known as "fat" or 128 | "universal" binaries--by specifying multiple '-arch' options to the 129 | compiler but only a single '-arch' option to the preprocessor. Like 130 | this: 131 | 132 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 133 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 134 | CPP="gcc -E" CXXCPP="g++ -E" 135 | 136 | This is not guaranteed to produce working output in all cases, you 137 | may have to build one architecture at a time and combine the results 138 | using the 'lipo' tool if you have problems. 139 | 140 | Installation Names 141 | ================== 142 | 143 | By default, 'make install' installs the package's commands under 144 | '/usr/local/bin', include files under '/usr/local/include', etc. You 145 | can specify an installation prefix other than '/usr/local' by giving 146 | 'configure' the option '--prefix=PREFIX', where PREFIX must be an 147 | absolute file name. 148 | 149 | You can specify separate installation prefixes for 150 | architecture-specific files and architecture-independent files. If you 151 | pass the option '--exec-prefix=PREFIX' to 'configure', the package uses 152 | PREFIX as the prefix for installing programs and libraries. 153 | Documentation and other data files still use the regular prefix. 154 | 155 | In addition, if you use an unusual directory layout you can give 156 | options like '--bindir=DIR' to specify different values for particular 157 | kinds of files. Run 'configure --help' for a list of the directories 158 | you can set and what kinds of files go in them. In general, the default 159 | for these options is expressed in terms of '${prefix}', so that 160 | specifying just '--prefix' will affect all of the other directory 161 | specifications that were not explicitly provided. 162 | 163 | The most portable way to affect installation locations is to pass the 164 | correct locations to 'configure'; however, many packages provide one or 165 | both of the following shortcuts of passing variable assignments to the 166 | 'make install' command line to change installation locations without 167 | having to reconfigure or recompile. 168 | 169 | The first method involves providing an override variable for each 170 | affected directory. For example, 'make install 171 | prefix=/alternate/directory' will choose an alternate location for all 172 | directory configuration variables that were expressed in terms of 173 | '${prefix}'. Any directories that were specified during 'configure', 174 | but not in terms of '${prefix}', must each be overridden at install time 175 | for the entire installation to be relocated. The approach of makefile 176 | variable overrides for each directory variable is required by the GNU 177 | Coding Standards, and ideally causes no recompilation. However, some 178 | platforms have known limitations with the semantics of shared libraries 179 | that end up requiring recompilation when using this method, particularly 180 | noticeable in packages that use GNU Libtool. 181 | 182 | The second method involves providing the 'DESTDIR' variable. For 183 | example, 'make install DESTDIR=/alternate/directory' will prepend 184 | '/alternate/directory' before all installation names. The approach of 185 | 'DESTDIR' overrides is not required by the GNU Coding Standards, and 186 | does not work on platforms that have drive letters. On the other hand, 187 | it does better at avoiding recompilation issues, and works well even 188 | when some directory options were not specified in terms of '${prefix}' 189 | at 'configure' time. 190 | 191 | Optional Features 192 | ================= 193 | 194 | If the package supports it, you can cause programs to be installed 195 | with an extra prefix or suffix on their names by giving 'configure' the 196 | option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. 197 | 198 | Some packages pay attention to '--enable-FEATURE' options to 199 | 'configure', where FEATURE indicates an optional part of the package. 200 | They may also pay attention to '--with-PACKAGE' options, where PACKAGE 201 | is something like 'gnu-as' or 'x' (for the X Window System). The 202 | 'README' should mention any '--enable-' and '--with-' options that the 203 | package recognizes. 204 | 205 | For packages that use the X Window System, 'configure' can usually 206 | find the X include and library files automatically, but if it doesn't, 207 | you can use the 'configure' options '--x-includes=DIR' and 208 | '--x-libraries=DIR' to specify their locations. 209 | 210 | Some packages offer the ability to configure how verbose the 211 | execution of 'make' will be. For these packages, running './configure 212 | --enable-silent-rules' sets the default to minimal output, which can be 213 | overridden with 'make V=1'; while running './configure 214 | --disable-silent-rules' sets the default to verbose, which can be 215 | overridden with 'make V=0'. 216 | 217 | Particular systems 218 | ================== 219 | 220 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC 221 | is not installed, it is recommended to use the following options in 222 | order to use an ANSI C compiler: 223 | 224 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 225 | 226 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 227 | 228 | HP-UX 'make' updates targets which have the same time stamps as their 229 | prerequisites, which makes it generally unusable when shipped generated 230 | files such as 'configure' are involved. Use GNU 'make' instead. 231 | 232 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 233 | parse its '' header file. The option '-nodtk' can be used as a 234 | workaround. If GNU CC is not installed, it is therefore recommended to 235 | try 236 | 237 | ./configure CC="cc" 238 | 239 | and if that doesn't work, try 240 | 241 | ./configure CC="cc -nodtk" 242 | 243 | On Solaris, don't put '/usr/ucb' early in your 'PATH'. This 244 | directory contains several dysfunctional programs; working variants of 245 | these programs are available in '/usr/bin'. So, if you need '/usr/ucb' 246 | in your 'PATH', put it _after_ '/usr/bin'. 247 | 248 | On Haiku, software installed for all users goes in '/boot/common', 249 | not '/usr/local'. It is recommended to use the following options: 250 | 251 | ./configure --prefix=/boot/common 252 | 253 | Specifying the System Type 254 | ========================== 255 | 256 | There may be some features 'configure' cannot figure out 257 | automatically, but needs to determine by the type of machine the package 258 | will run on. Usually, assuming the package is built to be run on the 259 | _same_ architectures, 'configure' can figure that out, but if it prints 260 | a message saying it cannot guess the machine type, give it the 261 | '--build=TYPE' option. TYPE can either be a short name for the system 262 | type, such as 'sun4', or a canonical name which has the form: 263 | 264 | CPU-COMPANY-SYSTEM 265 | 266 | where SYSTEM can have one of these forms: 267 | 268 | OS 269 | KERNEL-OS 270 | 271 | See the file 'config.sub' for the possible values of each field. If 272 | 'config.sub' isn't included in this package, then this package doesn't 273 | need to know the machine type. 274 | 275 | If you are _building_ compiler tools for cross-compiling, you should 276 | use the option '--target=TYPE' to select the type of system they will 277 | produce code for. 278 | 279 | If you want to _use_ a cross compiler, that generates code for a 280 | platform different from the build platform, you should specify the 281 | "host" platform (i.e., that on which the generated programs will 282 | eventually be run) with '--host=TYPE'. 283 | 284 | Sharing Defaults 285 | ================ 286 | 287 | If you want to set default values for 'configure' scripts to share, 288 | you can create a site shell script called 'config.site' that gives 289 | default values for variables like 'CC', 'cache_file', and 'prefix'. 290 | 'configure' looks for 'PREFIX/share/config.site' if it exists, then 291 | 'PREFIX/etc/config.site' if it exists. Or, you can set the 292 | 'CONFIG_SITE' environment variable to the location of the site script. 293 | A warning: not all 'configure' scripts look for a site script. 294 | 295 | Defining Variables 296 | ================== 297 | 298 | Variables not defined in a site shell script can be set in the 299 | environment passed to 'configure'. However, some packages may run 300 | configure again during the build, and the customized values of these 301 | variables may be lost. In order to avoid this problem, you should set 302 | them in the 'configure' command line, using 'VAR=value'. For example: 303 | 304 | ./configure CC=/usr/local2/bin/gcc 305 | 306 | causes the specified 'gcc' to be used as the C compiler (unless it is 307 | overridden in the site shell script). 308 | 309 | Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an 310 | Autoconf limitation. Until the limitation is lifted, you can use this 311 | workaround: 312 | 313 | CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash 314 | 315 | 'configure' Invocation 316 | ====================== 317 | 318 | 'configure' recognizes the following options to control how it 319 | operates. 320 | 321 | '--help' 322 | '-h' 323 | Print a summary of all of the options to 'configure', and exit. 324 | 325 | '--help=short' 326 | '--help=recursive' 327 | Print a summary of the options unique to this package's 328 | 'configure', and exit. The 'short' variant lists options used only 329 | in the top level, while the 'recursive' variant lists options also 330 | present in any nested packages. 331 | 332 | '--version' 333 | '-V' 334 | Print the version of Autoconf used to generate the 'configure' 335 | script, and exit. 336 | 337 | '--cache-file=FILE' 338 | Enable the cache: use and save the results of the tests in FILE, 339 | traditionally 'config.cache'. FILE defaults to '/dev/null' to 340 | disable caching. 341 | 342 | '--config-cache' 343 | '-C' 344 | Alias for '--cache-file=config.cache'. 345 | 346 | '--quiet' 347 | '--silent' 348 | '-q' 349 | Do not print messages saying which checks are being made. To 350 | suppress all normal output, redirect it to '/dev/null' (any error 351 | messages will still be shown). 352 | 353 | '--srcdir=DIR' 354 | Look for the package's source code in directory DIR. Usually 355 | 'configure' can determine that directory automatically. 356 | 357 | '--prefix=DIR' 358 | Use DIR as the installation prefix. *note Installation Names:: for 359 | more details, including other options available for fine-tuning the 360 | installation locations. 361 | 362 | '--no-create' 363 | '-n' 364 | Run the configure checks, but stop before creating any output 365 | files. 366 | 367 | 'configure' also accepts some other, not widely useful, options. Run 368 | 'configure --help' for more details. 369 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Config file for GNU Automake. 2 | ## 3 | ## Copyright (C) 2020 Artyom V. Poptsov 4 | ## 5 | ## This file is part of Metabash. 6 | ## 7 | ## Metabash is free software: you can redistribute it and/or modify it under the 8 | ## terms of the GNU General Public License as published by the Free Software 9 | ## Foundation, either version 3 of the License, or (at your option) any later 10 | ## version. 11 | ## 12 | ## Metabash is distributed in the hope that it will be useful, but WITHOUT ANY 13 | ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 14 | ## A PARTICULAR PURPOSE. See the GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License along with 17 | ## Metabash. If not, see . 18 | 19 | ACLOCAL_AMFLAGS = -I build-aux 20 | 21 | SUBDIRS = am build-aux m4 modules/metabash doc 22 | 23 | gen-ChangeLog: 24 | if test -d .git; then \ 25 | $(top_srcdir)/build-aux/gitlog-to-changelog \ 26 | 2bea8c70..HEAD > $(distdir)/cl-t; \ 27 | rm -f $(distdir)/ChangeLog; \ 28 | mv $(distdir)/cl-t $(distdir)/ChangeLog; \ 29 | fi 30 | 31 | dist-hook: gen-ChangeLog 32 | .PHONY: gen-ChangeLog 33 | 34 | clean-go: 35 | -$(RM) $(GOBJECTS) 36 | .PHONY: clean-go 37 | 38 | CLEANFILES = \ 39 | $(GOBJECTS) 40 | 41 | # Makefile.am ends here 42 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | #+TITLE: Metabash News -- history of user-visible changes. 2 | #+STARTUP: content hidestars 3 | 4 | Copyright (C) Artyom V. Poptsov 5 | 6 | Copying and distribution of this file, with or without modification, 7 | are permitted in any medium without royalty provided the copyright 8 | notice and this notice are preserved. 9 | 10 | * Changes in version 0.0.0 (2020-08-06) 11 | ** Release of the alpha version of Metabash 12 | 13 | Local Variables: 14 | mode: org 15 | End: 16 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.org -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | [[./doc/logo.png]] 2 | 3 | * Metabash 4 | *Metabash* (or *M#!* for short) is a GNU Guile module that provides domain 5 | specific language (DSL) for running distributed shell pipelines. "What are 6 | distributed shell pipelines?" you may ask. Well, the idea is that we can 7 | implement some sort of Unix pipeline that is spanned across multiple hosts over 8 | a network. 9 | 10 | Using such pipeline you can run a command on one host and then pass the output 11 | to a command that is run on another. 12 | 13 | Metabash is a research project of mine that was born as a [[https://github.com/artyom-poptsov/guile-ssh][Guile-SSH]] spinoff. 14 | 15 | ** License 16 | Metabash is free software: you can redistribute it and/or modify it under the 17 | terms of the GNU General Public License as published by the Free Software 18 | Foundation, either version 3 of the License, or (at your option) any later 19 | version. Please see =COPYING= file for the terms of GNU General Public 20 | License. 21 | 22 | The logo (=doc/logo.svg= and rasterised versions) is distributed 23 | under terms of [[https://creativecommons.org/licenses/by-sa/4.0/][Creative Commons Attribution-ShareAlike 4.0 24 | International]] license. 25 | 26 | ** Requirements 27 | - GNU Guile 2.2+ 28 | - Guile-SSH 0.13.0+ 29 | 30 | ** Installation 31 | #+BEGIN_EXAMPLE shell 32 | $ autoreconf -vif 33 | $ ./configure 34 | $ make install 35 | #+END_EXAMPLE 36 | 37 | ** Main concepts 38 | 39 | *** Process 40 | Running local or remote process. Each process runs a specified command and 41 | has an input and an output port. 42 | 43 | A process is described by == class from the =(metabash core process)= 44 | module. 45 | 46 | *** Pipe 47 | Pipe connects two running processes by means of connecting output port 48 | (=stdout=) of the first process with the input port (=stdin=) of the second. 49 | 50 | For the clarity sake we will assume that the process that produces the data 51 | is always placed on the "left" side of the pipe and all the processes that 52 | read the data is always placed on the "right" side of the pipe. With that 53 | assumption in mind we can talk about "left" and "right" processes in 54 | relation to a pipe. 55 | 56 | A pipe is described by == class from the =(metabash core plumbing pipe)= module. 57 | 58 | *** Plumber 59 | Plumber builds a pipeline upon the processes and pipes that are described 60 | above. It implemented as =plumb= command and =M#!= macro. 61 | 62 | When a plumber is called it spawns a process for each specified command and 63 | connects the spawned processes with pipes. The output of the plumber is a 64 | pipeline. 65 | 66 | *** Pipeline 67 | Pipeline describes a sequence of running processes connected by pipes. Each 68 | pipeline has an input port and output port. 69 | 70 | A pipeline is described by == class from the =(metabash core 71 | pipeline)= module. 72 | 73 | ** Examples 74 | #+BEGIN_EXAMPLE lisp 75 | (use-modules (ssh session) 76 | (ssh auth) 77 | (oop goops) 78 | (metabash core plumbing pipe) 79 | (metabash core pipeline) 80 | (metabash core process) 81 | (metabash plumber)) 82 | 83 | ;; Create a Guile-SSH session: 84 | (define session (make-session #:host "example.org")) 85 | 86 | ;; Connect to the remote host: 87 | (connect! session) 88 | 89 | ;; Authenticate with the host using the SSH Agent: 90 | (userauth-agent! session) 91 | 92 | (let* ((pipeline (plumb 93 | ;; This commands runs on a remote host 94 | `(remote ,session "cat /etc/passwd") 95 | ;; This commands runs on the local host 96 | `(local "sort") 97 | ;; This command runs on the local host as well, 98 | ;; but this time it's a Guile process 99 | `(guile #f 100 | (begin 101 | (use-modules (ice-9 rdelim)) 102 | (let loop ((line (read-line))) 103 | (if (eof-object? line) 104 | (exit) 105 | (begin 106 | (write-line (string-join (string-split line #\:) ",")) 107 | (loop (read-line))))))))) 108 | ;; Plumber will connect output of the 1st (remote) command 109 | ;; with the input of the 2nd (local) command with a pipe. 110 | ;; The list of commands passed to the plumber can be arbitrary 111 | ;; long. 112 | ;; 113 | ;; To read data from the pipeline, we connect the pipeline output 114 | ;; with the current output port: 115 | (pipe (make 116 | #:input-port (pipeline-output-port pipeline) 117 | #:output-port (current-output-port)))) 118 | (while #t 119 | (sleep 1))) 120 | #+END_EXAMPLE 121 | 122 | The plumbing can be done with =M#!= macro which adds some syntactic sugar upon 123 | the =plumb= command: 124 | 125 | #+BEGIN_EXAMPLE lisp 126 | (use-modules (oop goops) 127 | (ssh session) 128 | (ssh auth) 129 | (metabash core plumbing pipe) 130 | (metabash core pipeline) 131 | (metabash plumber)) 132 | 133 | (define (main args) 134 | (define session (make-session #:host "example.org")) 135 | (connect! session) 136 | (userauth-agent! session) 137 | (let ((pipeline (M#! remote session "cat /etc/passwd" 138 | => local "sort" 139 | => local "grep avp"))) 140 | 141 | (let ((pipe (make 142 | #:input-port (pipeline-output-port pipeline) 143 | #:output-port (current-output-port) 144 | #:on-disconnect (lambda (pipe) 145 | (pipe-close! pipe) 146 | (disconnect! session))))) 147 | (pipe-connect! pipe) 148 | (while (pipe-connected? pipe) 149 | (sleep 1))))) 150 | #+END_EXAMPLE 151 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Metabash has originally been written by Artyom V. Poptsov. 2 | -------------------------------------------------------------------------------- /am/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Config file for GNU Automake. 2 | ## 3 | ## Copyright (C) 2014 Artyom V. Poptsov 4 | ## 5 | ## This file is part of Metabash. 6 | ## 7 | ## Metabash is free software: you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License as 9 | ## published by the Free Software Foundation, either version 3 of the 10 | ## License, or (at your option) any later version. 11 | ## 12 | ## Metabash is distributed in the hope that it will be useful, but 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | ## General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with Metabash. If not, see . 19 | 20 | AUTOMAKE_OPTIONS = gnu 21 | 22 | am_frags = guilec 23 | 24 | EXTRA_DIST = $(am_frags) 25 | 26 | ## Makefile.am ends here 27 | -------------------------------------------------------------------------------- /am/guilec: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | GUILEC = $(GUILD) compile 4 | 5 | AM_V_GUILEC = $(AM_V_GUILEC_$(V)) 6 | AM_V_GUILEC_ = $(AM_V_GUILEC_$(AM_DEFAULT_VERBOSITY)) 7 | AM_V_GUILEC_0 = @echo " GUILEC " $@; 8 | -------------------------------------------------------------------------------- /build-aux/.gitignore: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | 3 | config.guess 4 | config.sub 5 | depcomp 6 | install-sh 7 | ltmain.sh 8 | mdate-sh 9 | missing 10 | test-driver 11 | texinfo.tex -------------------------------------------------------------------------------- /build-aux/Makefile.am: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /build-aux/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand '-c -o'. 3 | 4 | scriptversion=2012-10-14.11; # UTC 5 | 6 | # Copyright (C) 1999-2013 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # This file is maintained in Automake, please report 28 | # bugs to or send patches to 29 | # . 30 | 31 | nl=' 32 | ' 33 | 34 | # We need space, tab and new line, in precisely that order. Quoting is 35 | # there to prevent tools from complaining about whitespace usage. 36 | IFS=" "" $nl" 37 | 38 | file_conv= 39 | 40 | # func_file_conv build_file lazy 41 | # Convert a $build file to $host form and store it in $file 42 | # Currently only supports Windows hosts. If the determined conversion 43 | # type is listed in (the comma separated) LAZY, no conversion will 44 | # take place. 45 | func_file_conv () 46 | { 47 | file=$1 48 | case $file in 49 | / | /[!/]*) # absolute file, and not a UNC file 50 | if test -z "$file_conv"; then 51 | # lazily determine how to convert abs files 52 | case `uname -s` in 53 | MINGW*) 54 | file_conv=mingw 55 | ;; 56 | CYGWIN*) 57 | file_conv=cygwin 58 | ;; 59 | *) 60 | file_conv=wine 61 | ;; 62 | esac 63 | fi 64 | case $file_conv/,$2, in 65 | *,$file_conv,*) 66 | ;; 67 | mingw/*) 68 | file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` 69 | ;; 70 | cygwin/*) 71 | file=`cygpath -m "$file" || echo "$file"` 72 | ;; 73 | wine/*) 74 | file=`winepath -w "$file" || echo "$file"` 75 | ;; 76 | esac 77 | ;; 78 | esac 79 | } 80 | 81 | # func_cl_dashL linkdir 82 | # Make cl look for libraries in LINKDIR 83 | func_cl_dashL () 84 | { 85 | func_file_conv "$1" 86 | if test -z "$lib_path"; then 87 | lib_path=$file 88 | else 89 | lib_path="$lib_path;$file" 90 | fi 91 | linker_opts="$linker_opts -LIBPATH:$file" 92 | } 93 | 94 | # func_cl_dashl library 95 | # Do a library search-path lookup for cl 96 | func_cl_dashl () 97 | { 98 | lib=$1 99 | found=no 100 | save_IFS=$IFS 101 | IFS=';' 102 | for dir in $lib_path $LIB 103 | do 104 | IFS=$save_IFS 105 | if $shared && test -f "$dir/$lib.dll.lib"; then 106 | found=yes 107 | lib=$dir/$lib.dll.lib 108 | break 109 | fi 110 | if test -f "$dir/$lib.lib"; then 111 | found=yes 112 | lib=$dir/$lib.lib 113 | break 114 | fi 115 | if test -f "$dir/lib$lib.a"; then 116 | found=yes 117 | lib=$dir/lib$lib.a 118 | break 119 | fi 120 | done 121 | IFS=$save_IFS 122 | 123 | if test "$found" != yes; then 124 | lib=$lib.lib 125 | fi 126 | } 127 | 128 | # func_cl_wrapper cl arg... 129 | # Adjust compile command to suit cl 130 | func_cl_wrapper () 131 | { 132 | # Assume a capable shell 133 | lib_path= 134 | shared=: 135 | linker_opts= 136 | for arg 137 | do 138 | if test -n "$eat"; then 139 | eat= 140 | else 141 | case $1 in 142 | -o) 143 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 144 | eat=1 145 | case $2 in 146 | *.o | *.[oO][bB][jJ]) 147 | func_file_conv "$2" 148 | set x "$@" -Fo"$file" 149 | shift 150 | ;; 151 | *) 152 | func_file_conv "$2" 153 | set x "$@" -Fe"$file" 154 | shift 155 | ;; 156 | esac 157 | ;; 158 | -I) 159 | eat=1 160 | func_file_conv "$2" mingw 161 | set x "$@" -I"$file" 162 | shift 163 | ;; 164 | -I*) 165 | func_file_conv "${1#-I}" mingw 166 | set x "$@" -I"$file" 167 | shift 168 | ;; 169 | -l) 170 | eat=1 171 | func_cl_dashl "$2" 172 | set x "$@" "$lib" 173 | shift 174 | ;; 175 | -l*) 176 | func_cl_dashl "${1#-l}" 177 | set x "$@" "$lib" 178 | shift 179 | ;; 180 | -L) 181 | eat=1 182 | func_cl_dashL "$2" 183 | ;; 184 | -L*) 185 | func_cl_dashL "${1#-L}" 186 | ;; 187 | -static) 188 | shared=false 189 | ;; 190 | -Wl,*) 191 | arg=${1#-Wl,} 192 | save_ifs="$IFS"; IFS=',' 193 | for flag in $arg; do 194 | IFS="$save_ifs" 195 | linker_opts="$linker_opts $flag" 196 | done 197 | IFS="$save_ifs" 198 | ;; 199 | -Xlinker) 200 | eat=1 201 | linker_opts="$linker_opts $2" 202 | ;; 203 | -*) 204 | set x "$@" "$1" 205 | shift 206 | ;; 207 | *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) 208 | func_file_conv "$1" 209 | set x "$@" -Tp"$file" 210 | shift 211 | ;; 212 | *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) 213 | func_file_conv "$1" mingw 214 | set x "$@" "$file" 215 | shift 216 | ;; 217 | *) 218 | set x "$@" "$1" 219 | shift 220 | ;; 221 | esac 222 | fi 223 | shift 224 | done 225 | if test -n "$linker_opts"; then 226 | linker_opts="-link$linker_opts" 227 | fi 228 | exec "$@" $linker_opts 229 | exit 1 230 | } 231 | 232 | eat= 233 | 234 | case $1 in 235 | '') 236 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 237 | exit 1; 238 | ;; 239 | -h | --h*) 240 | cat <<\EOF 241 | Usage: compile [--help] [--version] PROGRAM [ARGS] 242 | 243 | Wrapper for compilers which do not understand '-c -o'. 244 | Remove '-o dest.o' from ARGS, run PROGRAM with the remaining 245 | arguments, and rename the output as expected. 246 | 247 | If you are trying to build a whole package this is not the 248 | right script to run: please start by reading the file 'INSTALL'. 249 | 250 | Report bugs to . 251 | EOF 252 | exit $? 253 | ;; 254 | -v | --v*) 255 | echo "compile $scriptversion" 256 | exit $? 257 | ;; 258 | cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) 259 | func_cl_wrapper "$@" # Doesn't return... 260 | ;; 261 | esac 262 | 263 | ofile= 264 | cfile= 265 | 266 | for arg 267 | do 268 | if test -n "$eat"; then 269 | eat= 270 | else 271 | case $1 in 272 | -o) 273 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 274 | # So we strip '-o arg' only if arg is an object. 275 | eat=1 276 | case $2 in 277 | *.o | *.obj) 278 | ofile=$2 279 | ;; 280 | *) 281 | set x "$@" -o "$2" 282 | shift 283 | ;; 284 | esac 285 | ;; 286 | *.c) 287 | cfile=$1 288 | set x "$@" "$1" 289 | shift 290 | ;; 291 | *) 292 | set x "$@" "$1" 293 | shift 294 | ;; 295 | esac 296 | fi 297 | shift 298 | done 299 | 300 | if test -z "$ofile" || test -z "$cfile"; then 301 | # If no '-o' option was seen then we might have been invoked from a 302 | # pattern rule where we don't need one. That is ok -- this is a 303 | # normal compilation that the losing compiler can handle. If no 304 | # '.c' file was seen then we are probably linking. That is also 305 | # ok. 306 | exec "$@" 307 | fi 308 | 309 | # Name of file we expect compiler to create. 310 | cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 311 | 312 | # Create the lock directory. 313 | # Note: use '[/\\:.-]' here to ensure that we don't use the same name 314 | # that we are using for the .o file. Also, base the name on the expected 315 | # object file name, since that is what matters with a parallel build. 316 | lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 317 | while true; do 318 | if mkdir "$lockdir" >/dev/null 2>&1; then 319 | break 320 | fi 321 | sleep 1 322 | done 323 | # FIXME: race condition here if user kills between mkdir and trap. 324 | trap "rmdir '$lockdir'; exit 1" 1 2 15 325 | 326 | # Run the compile. 327 | "$@" 328 | ret=$? 329 | 330 | if test -f "$cofile"; then 331 | test "$cofile" = "$ofile" || mv "$cofile" "$ofile" 332 | elif test -f "${cofile}bj"; then 333 | test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" 334 | fi 335 | 336 | rmdir "$lockdir" 337 | exit $ret 338 | 339 | # Local Variables: 340 | # mode: shell-script 341 | # sh-indentation: 2 342 | # eval: (add-hook 'write-file-hooks 'time-stamp) 343 | # time-stamp-start: "scriptversion=" 344 | # time-stamp-format: "%:y-%02m-%02d.%02H" 345 | # time-stamp-time-zone: "UTC" 346 | # time-stamp-end: "; # UTC" 347 | # End: 348 | -------------------------------------------------------------------------------- /build-aux/config.rpath: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artyom-poptsov/metabash/8a0979ca1a1d411f0d15916e0affca8989094679/build-aux/config.rpath -------------------------------------------------------------------------------- /build-aux/gitlog-to-changelog: -------------------------------------------------------------------------------- 1 | eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' 2 | & eval 'exec perl -wS "$0" $argv:q' 3 | if 0; 4 | # Convert git log output to ChangeLog format. 5 | 6 | my $VERSION = '2012-07-29 06:11'; # UTC 7 | # The definition above must lie within the first 8 lines in order 8 | # for the Emacs time-stamp write hook (at end) to update it. 9 | # If you change this file with Emacs, please let the write hook 10 | # do its job. Otherwise, update this string manually. 11 | 12 | # Copyright (C) 2008-2013 Free Software Foundation, Inc. 13 | 14 | # This program is free software: you can redistribute it and/or modify 15 | # it under the terms of the GNU General Public License as published by 16 | # the Free Software Foundation, either version 3 of the License, or 17 | # (at your option) any later version. 18 | 19 | # This program is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | # GNU General Public License for more details. 23 | 24 | # You should have received a copy of the GNU General Public License 25 | # along with this program. If not, see . 26 | 27 | # Written by Jim Meyering 28 | 29 | use strict; 30 | use warnings; 31 | use Getopt::Long; 32 | use POSIX qw(strftime); 33 | 34 | (my $ME = $0) =~ s|.*/||; 35 | 36 | # use File::Coda; # http://meyering.net/code/Coda/ 37 | END { 38 | defined fileno STDOUT or return; 39 | close STDOUT and return; 40 | warn "$ME: failed to close standard output: $!\n"; 41 | $? ||= 1; 42 | } 43 | 44 | sub usage ($) 45 | { 46 | my ($exit_code) = @_; 47 | my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); 48 | if ($exit_code != 0) 49 | { 50 | print $STREAM "Try '$ME --help' for more information.\n"; 51 | } 52 | else 53 | { 54 | print $STREAM < ChangeLog 88 | $ME -- -n 5 foo > last-5-commits-to-branch-foo 89 | 90 | SPECIAL SYNTAX: 91 | 92 | The following types of strings are interpreted specially when they appear 93 | at the beginning of a log message line. They are not copied to the output. 94 | 95 | Copyright-paperwork-exempt: Yes 96 | Append the "(tiny change)" notation to the usual "date name email" 97 | ChangeLog header to mark a change that does not require a copyright 98 | assignment. 99 | Co-authored-by: Joe User 100 | List the specified name and email address on a second 101 | ChangeLog header, denoting a co-author. 102 | Signed-off-by: Joe User 103 | These lines are simply elided. 104 | 105 | In a FILE specified via --amend, comment lines (starting with "#") are ignored. 106 | FILE must consist of pairs where SHA is a 40-byte SHA1 (alone on 107 | a line) referring to a commit in the current project, and CODE refers to one 108 | or more consecutive lines of Perl code. Pairs must be separated by one or 109 | more blank line. 110 | 111 | Here is sample input for use with --amend=FILE, from coreutils: 112 | 113 | 3a169f4c5d9159283548178668d2fae6fced3030 114 | # fix typo in title: 115 | s/all tile types/all file types/ 116 | 117 | 1379ed974f1fa39b12e2ffab18b3f7a607082202 118 | # Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself. 119 | # Change the author to be Paul. Note the escaped "@": 120 | s,Jim .*>,Paul Eggert , 121 | 122 | EOF 123 | } 124 | exit $exit_code; 125 | } 126 | 127 | # If the string $S is a well-behaved file name, simply return it. 128 | # If it contains white space, quotes, etc., quote it, and return the new string. 129 | sub shell_quote($) 130 | { 131 | my ($s) = @_; 132 | if ($s =~ m![^\w+/.,-]!) 133 | { 134 | # Convert each single quote to '\'' 135 | $s =~ s/\'/\'\\\'\'/g; 136 | # Then single quote the string. 137 | $s = "'$s'"; 138 | } 139 | return $s; 140 | } 141 | 142 | sub quoted_cmd(@) 143 | { 144 | return join (' ', map {shell_quote $_} @_); 145 | } 146 | 147 | # Parse file F. 148 | # Comment lines (starting with "#") are ignored. 149 | # F must consist of pairs where SHA is a 40-byte SHA1 150 | # (alone on a line) referring to a commit in the current project, and 151 | # CODE refers to one or more consecutive lines of Perl code. 152 | # Pairs must be separated by one or more blank line. 153 | sub parse_amend_file($) 154 | { 155 | my ($f) = @_; 156 | 157 | open F, '<', $f 158 | or die "$ME: $f: failed to open for reading: $!\n"; 159 | 160 | my $fail; 161 | my $h = {}; 162 | my $in_code = 0; 163 | my $sha; 164 | while (defined (my $line = )) 165 | { 166 | $line =~ /^\#/ 167 | and next; 168 | chomp $line; 169 | $line eq '' 170 | and $in_code = 0, next; 171 | 172 | if (!$in_code) 173 | { 174 | $line =~ /^([0-9a-fA-F]{40})$/ 175 | or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"), 176 | $fail = 1, next; 177 | $sha = lc $1; 178 | $in_code = 1; 179 | exists $h->{$sha} 180 | and (warn "$ME: $f:$.: duplicate SHA1\n"), 181 | $fail = 1, next; 182 | } 183 | else 184 | { 185 | $h->{$sha} ||= ''; 186 | $h->{$sha} .= "$line\n"; 187 | } 188 | } 189 | close F; 190 | 191 | $fail 192 | and exit 1; 193 | 194 | return $h; 195 | } 196 | 197 | # git_dir_option $SRCDIR 198 | # 199 | # From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR 200 | # is undef). Return as a list (0 or 1 element). 201 | sub git_dir_option($) 202 | { 203 | my ($srcdir) = @_; 204 | my @res = (); 205 | if (defined $srcdir) 206 | { 207 | my $qdir = shell_quote $srcdir; 208 | my $cmd = "cd $qdir && git rev-parse --show-toplevel"; 209 | my $qcmd = shell_quote $cmd; 210 | my $git_dir = qx($cmd); 211 | defined $git_dir 212 | or die "$ME: cannot run $qcmd: $!\n"; 213 | $? == 0 214 | or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"; 215 | chomp $git_dir; 216 | push @res, "--git-dir=$git_dir/.git"; 217 | } 218 | @res; 219 | } 220 | 221 | { 222 | my $since_date; 223 | my $format_string = '%s%n%b%n'; 224 | my $amend_file; 225 | my $append_dot = 0; 226 | my $cluster = 1; 227 | my $strip_tab = 0; 228 | my $strip_cherry_pick = 0; 229 | my $srcdir; 230 | GetOptions 231 | ( 232 | help => sub { usage 0 }, 233 | version => sub { print "$ME version $VERSION\n"; exit }, 234 | 'since=s' => \$since_date, 235 | 'format=s' => \$format_string, 236 | 'amend=s' => \$amend_file, 237 | 'append-dot' => \$append_dot, 238 | 'cluster!' => \$cluster, 239 | 'strip-tab' => \$strip_tab, 240 | 'strip-cherry-pick' => \$strip_cherry_pick, 241 | 'srcdir=s' => \$srcdir, 242 | ) or usage 1; 243 | 244 | defined $since_date 245 | and unshift @ARGV, "--since=$since_date"; 246 | 247 | # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/) 248 | # that makes a correction in the log or attribution of that commit. 249 | my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {}; 250 | 251 | my @cmd = ('git', 252 | git_dir_option $srcdir, 253 | qw(log --log-size), 254 | '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV); 255 | open PIPE, '-|', @cmd 256 | or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n" 257 | . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); 258 | 259 | my $prev_multi_paragraph; 260 | my $prev_date_line = ''; 261 | my @prev_coauthors = (); 262 | while (1) 263 | { 264 | defined (my $in = ) 265 | or last; 266 | $in =~ /^log size (\d+)$/ 267 | or die "$ME:$.: Invalid line (expected log size):\n$in"; 268 | my $log_nbytes = $1; 269 | 270 | my $log; 271 | my $n_read = read PIPE, $log, $log_nbytes; 272 | $n_read == $log_nbytes 273 | or die "$ME:$.: unexpected EOF\n"; 274 | 275 | # Extract leading hash. 276 | my ($sha, $rest) = split ':', $log, 2; 277 | defined $sha 278 | or die "$ME:$.: malformed log entry\n"; 279 | $sha =~ /^[0-9a-fA-F]{40}$/ 280 | or die "$ME:$.: invalid SHA1: $sha\n"; 281 | 282 | # If this commit's log requires any transformation, do it now. 283 | my $code = $amend_code->{$sha}; 284 | if (defined $code) 285 | { 286 | eval 'use Safe'; 287 | my $s = new Safe; 288 | # Put the unpreprocessed entry into "$_". 289 | $_ = $rest; 290 | 291 | # Let $code operate on it, safely. 292 | my $r = $s->reval("$code") 293 | or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n"; 294 | 295 | # Note that we've used this entry. 296 | delete $amend_code->{$sha}; 297 | 298 | # Update $rest upon success. 299 | $rest = $_; 300 | } 301 | 302 | # Remove lines inserted by "git cherry-pick". 303 | if ($strip_cherry_pick) 304 | { 305 | $rest =~ s/^\s*Conflicts:\n.*//sm; 306 | $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m; 307 | } 308 | 309 | my @line = split "\n", $rest; 310 | my $author_line = shift @line; 311 | defined $author_line 312 | or die "$ME:$.: unexpected EOF\n"; 313 | $author_line =~ /^(\d+) (.*>)$/ 314 | or die "$ME:$.: Invalid line " 315 | . "(expected date/author/email):\n$author_line\n"; 316 | 317 | # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog 318 | # `(tiny change)' annotation. 319 | my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line) 320 | ? ' (tiny change)' : ''); 321 | 322 | my $date_line = sprintf "%s %s$tiny\n", 323 | strftime ("%F", localtime ($1)), $2; 324 | 325 | my @coauthors = grep /^Co-authored-by:.*$/, @line; 326 | # Omit meta-data lines we've already interpreted. 327 | @line = grep !/^(?:Signed-off-by:[ ].*>$ 328 | |Co-authored-by:[ ] 329 | |Copyright-paperwork-exempt:[ ] 330 | )/x, @line; 331 | 332 | # Remove leading and trailing blank lines. 333 | if (@line) 334 | { 335 | while ($line[0] =~ /^\s*$/) { shift @line; } 336 | while ($line[$#line] =~ /^\s*$/) { pop @line; } 337 | } 338 | 339 | # Record whether there are two or more paragraphs. 340 | my $multi_paragraph = grep /^\s*$/, @line; 341 | 342 | # Format 'Co-authored-by: A U Thor ' lines in 343 | # standard multi-author ChangeLog format. 344 | for (@coauthors) 345 | { 346 | s/^Co-authored-by:\s*/\t /; 347 | s/\s*/ 350 | or warn "$ME: warning: missing email address for " 351 | . substr ($_, 5) . "\n"; 352 | } 353 | 354 | # If clustering of commit messages has been disabled, if this header 355 | # would be different from the previous date/name/email/coauthors header, 356 | # or if this or the previous entry consists of two or more paragraphs, 357 | # then print the header. 358 | if ( ! $cluster 359 | || $date_line ne $prev_date_line 360 | || "@coauthors" ne "@prev_coauthors" 361 | || $multi_paragraph 362 | || $prev_multi_paragraph) 363 | { 364 | $prev_date_line eq '' 365 | or print "\n"; 366 | print $date_line; 367 | @coauthors 368 | and print join ("\n", @coauthors), "\n"; 369 | } 370 | $prev_date_line = $date_line; 371 | @prev_coauthors = @coauthors; 372 | $prev_multi_paragraph = $multi_paragraph; 373 | 374 | # If there were any lines 375 | if (@line == 0) 376 | { 377 | warn "$ME: warning: empty commit message:\n $date_line\n"; 378 | } 379 | else 380 | { 381 | if ($append_dot) 382 | { 383 | # If the first line of the message has enough room, then 384 | if (length $line[0] < 72) 385 | { 386 | # append a dot if there is no other punctuation or blank 387 | # at the end. 388 | $line[0] =~ /[[:punct:]\s]$/ 389 | or $line[0] .= '.'; 390 | } 391 | } 392 | 393 | # Remove one additional leading TAB from each line. 394 | $strip_tab 395 | and map { s/^\t// } @line; 396 | 397 | # Prefix each non-empty line with a TAB. 398 | @line = map { length $_ ? "\t$_" : '' } @line; 399 | 400 | print "\n", join ("\n", @line), "\n"; 401 | } 402 | 403 | defined ($in = ) 404 | or last; 405 | $in ne "\n" 406 | and die "$ME:$.: unexpected line:\n$in"; 407 | } 408 | 409 | close PIPE 410 | or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; 411 | # FIXME-someday: include $PROCESS_STATUS in the diagnostic 412 | 413 | # Complain about any unused entry in the --amend=F specified file. 414 | my $fail = 0; 415 | foreach my $sha (keys %$amend_code) 416 | { 417 | warn "$ME:$amend_file: unused entry: $sha\n"; 418 | $fail = 1; 419 | } 420 | 421 | exit $fail; 422 | } 423 | 424 | # Local Variables: 425 | # mode: perl 426 | # indent-tabs-mode: nil 427 | # eval: (add-hook 'write-file-hooks 'time-stamp) 428 | # time-stamp-start: "my $VERSION = '" 429 | # time-stamp-format: "%:y-%02m-%02d %02H:%02M" 430 | # time-stamp-time-zone: "UTC" 431 | # time-stamp-end: "'; # UTC" 432 | # End: 433 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl configuration script for Metabash 2 | dnl Process this file with autoconf to produce configure. 3 | dnl 4 | 5 | define(METABASH_CONFIGURE_COPYRIGHT, [[ 6 | Copyright (C) 2020 Artyom V. Poptsov 7 | 8 | This file is part of Metabash. 9 | 10 | Metabash is free software: you can redistribute it and/or modify it under the 11 | terms of the GNU General Public License as published by the Free Software 12 | Foundation, either version 3 of the License, or (at your option) any later 13 | version. 14 | 15 | Metabash is distributed in the hope that it will be useful, but WITHOUT ANY 16 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 17 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along with 20 | Metabash. If not, see . 21 | ]]) 22 | 23 | AC_INIT([Metabash], [0.0.0], [poptsov.artyom@gmail.com], 24 | [metabash], 25 | [https://github.com/artyom-poptsov/metabash]) 26 | 27 | AC_COPYRIGHT(METABASH_CONFIGURE_COPYRIGHT) 28 | AC_CONFIG_AUX_DIR([build-aux]) 29 | AC_CONFIG_MACRO_DIR([m4]) 30 | 31 | AM_INIT_AUTOMAKE([gnu silent-rules -Wall -Wno-portability 32 | color-tests]) 33 | 34 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],1)]) 35 | 36 | AC_ARG_WITH([guilesitedir], 37 | [AS_HELP_STRING([--with-guilesitedir], 38 | [use the specified installation path for Guile modules])], 39 | [case "x$withval" in 40 | xyes|xno) guilesitedir="";; 41 | *) guilesitedir="$withval";; 42 | esac], 43 | [guilesitedir=""]) 44 | 45 | GUILE_PKG([3.0 2.0 2.2]) 46 | GUILE_PROGS 47 | GUILE_SITE_DIR 48 | 49 | GUILE_MODULE_REQUIRED([ssh session]) 50 | 51 | if test "x$guilesitedir" = "x"; then 52 | guilesitedir="$datadir/guile/site/$GUILE_EFFECTIVE_VERSION" 53 | fi 54 | AC_SUBST([guilesitedir]) 55 | 56 | AC_CONFIG_FILES([Makefile am/Makefile]) 57 | AC_CONFIG_FILES([build-aux/Makefile m4/Makefile]) 58 | AC_CONFIG_FILES([modules/metabash/Makefile]) 59 | AC_CONFIG_FILES([modules/metabash/core/Makefile]) 60 | AC_CONFIG_FILES([modules/metabash/core/plumbing/Makefile]) 61 | AC_CONFIG_FILES([doc/Makefile]) 62 | 63 | dnl texinfo package required to make the documentation in Texinfo format. 64 | AC_CHECK_PROG(MAKEINFO_CHECK, makeinfo, yes) 65 | AS_IF([test x"$MAKEINFO_CHECK" != x"yes"], 66 | [ AC_MSG_ERROR([Please install texinfo before configuring])]) 67 | 68 | # Generate a Makefile, based on the results. 69 | AC_OUTPUT 70 | 71 | if test "$guilesitedir" != "$GUILE_SITE"; then 72 | # Guile has a different prefix than this module 73 | AC_MSG_WARN([] 74 | [The Guile modules will be installed in ${guilesitedir}.] 75 | [You should probably re-run `configure' with] 76 | [`--with-guilesitedir=$GUILE_SITE'] 77 | [Otherwise, you will have to adjust the `GUILE_LOAD_PATH' environment] 78 | [variable.]) 79 | fi 80 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | 3 | # Generated files 4 | metabash.info 5 | 6 | stamp-vti 7 | version.texi 8 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Config file for GNU Automake. 2 | ## 3 | ## Copyright (C) 2020 Artyom V. Poptsov 4 | ## 5 | ## This file is part of Metabash. 6 | ## 7 | ## Metabash is free software: you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License as 9 | ## published by the Free Software Foundation, either version 3 of the 10 | ## License, or (at your option) any later version. 11 | ## 12 | ## Metabash is distributed in the hope that it will be useful, but 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | ## General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with Metabash. If not, see . 19 | 20 | info_TEXINFOS = metabash.texi 21 | 22 | guile_dsv_TEXINFOS = \ 23 | metabash.texi \ 24 | fdl.texi 25 | 26 | ## Makefile.am ends here 27 | -------------------------------------------------------------------------------- /doc/fdl.texi: -------------------------------------------------------------------------------- 1 | @c The GNU Free Documentation License. 2 | @center Version 1.3, 3 November 2008 3 | 4 | @c This file is intended to be included within another document, 5 | @c hence no sectioning command or @node. 6 | 7 | @display 8 | Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 9 | @uref{http://fsf.org/} 10 | 11 | Everyone is permitted to copy and distribute verbatim copies 12 | of this license document, but changing it is not allowed. 13 | @end display 14 | 15 | @enumerate 0 16 | @item 17 | PREAMBLE 18 | 19 | The purpose of this License is to make a manual, textbook, or other 20 | functional and useful document @dfn{free} in the sense of freedom: to 21 | assure everyone the effective freedom to copy and redistribute it, 22 | with or without modifying it, either commercially or noncommercially. 23 | Secondarily, this License preserves for the author and publisher a way 24 | to get credit for their work, while not being considered responsible 25 | for modifications made by others. 26 | 27 | This License is a kind of ``copyleft'', which means that derivative 28 | works of the document must themselves be free in the same sense. It 29 | complements the GNU General Public License, which is a copyleft 30 | license designed for free software. 31 | 32 | We have designed this License in order to use it for manuals for free 33 | software, because free software needs free documentation: a free 34 | program should come with manuals providing the same freedoms that the 35 | software does. But this License is not limited to software manuals; 36 | it can be used for any textual work, regardless of subject matter or 37 | whether it is published as a printed book. We recommend this License 38 | principally for works whose purpose is instruction or reference. 39 | 40 | @item 41 | APPLICABILITY AND DEFINITIONS 42 | 43 | This License applies to any manual or other work, in any medium, that 44 | contains a notice placed by the copyright holder saying it can be 45 | distributed under the terms of this License. Such a notice grants a 46 | world-wide, royalty-free license, unlimited in duration, to use that 47 | work under the conditions stated herein. The ``Document'', below, 48 | refers to any such manual or work. Any member of the public is a 49 | licensee, and is addressed as ``you''. You accept the license if you 50 | copy, modify or distribute the work in a way requiring permission 51 | under copyright law. 52 | 53 | A ``Modified Version'' of the Document means any work containing the 54 | Document or a portion of it, either copied verbatim, or with 55 | modifications and/or translated into another language. 56 | 57 | A ``Secondary Section'' is a named appendix or a front-matter section 58 | of the Document that deals exclusively with the relationship of the 59 | publishers or authors of the Document to the Document's overall 60 | subject (or to related matters) and contains nothing that could fall 61 | directly within that overall subject. (Thus, if the Document is in 62 | part a textbook of mathematics, a Secondary Section may not explain 63 | any mathematics.) The relationship could be a matter of historical 64 | connection with the subject or with related matters, or of legal, 65 | commercial, philosophical, ethical or political position regarding 66 | them. 67 | 68 | The ``Invariant Sections'' are certain Secondary Sections whose titles 69 | are designated, as being those of Invariant Sections, in the notice 70 | that says that the Document is released under this License. If a 71 | section does not fit the above definition of Secondary then it is not 72 | allowed to be designated as Invariant. The Document may contain zero 73 | Invariant Sections. If the Document does not identify any Invariant 74 | Sections then there are none. 75 | 76 | The ``Cover Texts'' are certain short passages of text that are listed, 77 | as Front-Cover Texts or Back-Cover Texts, in the notice that says that 78 | the Document is released under this License. A Front-Cover Text may 79 | be at most 5 words, and a Back-Cover Text may be at most 25 words. 80 | 81 | A ``Transparent'' copy of the Document means a machine-readable copy, 82 | represented in a format whose specification is available to the 83 | general public, that is suitable for revising the document 84 | straightforwardly with generic text editors or (for images composed of 85 | pixels) generic paint programs or (for drawings) some widely available 86 | drawing editor, and that is suitable for input to text formatters or 87 | for automatic translation to a variety of formats suitable for input 88 | to text formatters. A copy made in an otherwise Transparent file 89 | format whose markup, or absence of markup, has been arranged to thwart 90 | or discourage subsequent modification by readers is not Transparent. 91 | An image format is not Transparent if used for any substantial amount 92 | of text. A copy that is not ``Transparent'' is called ``Opaque''. 93 | 94 | Examples of suitable formats for Transparent copies include plain 95 | @sc{ascii} without markup, Texinfo input format, La@TeX{} input 96 | format, @acronym{SGML} or @acronym{XML} using a publicly available 97 | @acronym{DTD}, and standard-conforming simple @acronym{HTML}, 98 | PostScript or @acronym{PDF} designed for human modification. Examples 99 | of transparent image formats include @acronym{PNG}, @acronym{XCF} and 100 | @acronym{JPG}. Opaque formats include proprietary formats that can be 101 | read and edited only by proprietary word processors, @acronym{SGML} or 102 | @acronym{XML} for which the @acronym{DTD} and/or processing tools are 103 | not generally available, and the machine-generated @acronym{HTML}, 104 | PostScript or @acronym{PDF} produced by some word processors for 105 | output purposes only. 106 | 107 | The ``Title Page'' means, for a printed book, the title page itself, 108 | plus such following pages as are needed to hold, legibly, the material 109 | this License requires to appear in the title page. For works in 110 | formats which do not have any title page as such, ``Title Page'' means 111 | the text near the most prominent appearance of the work's title, 112 | preceding the beginning of the body of the text. 113 | 114 | The ``publisher'' means any person or entity that distributes copies 115 | of the Document to the public. 116 | 117 | A section ``Entitled XYZ'' means a named subunit of the Document whose 118 | title either is precisely XYZ or contains XYZ in parentheses following 119 | text that translates XYZ in another language. (Here XYZ stands for a 120 | specific section name mentioned below, such as ``Acknowledgements'', 121 | ``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' 122 | of such a section when you modify the Document means that it remains a 123 | section ``Entitled XYZ'' according to this definition. 124 | 125 | The Document may include Warranty Disclaimers next to the notice which 126 | states that this License applies to the Document. These Warranty 127 | Disclaimers are considered to be included by reference in this 128 | License, but only as regards disclaiming warranties: any other 129 | implication that these Warranty Disclaimers may have is void and has 130 | no effect on the meaning of this License. 131 | 132 | @item 133 | VERBATIM COPYING 134 | 135 | You may copy and distribute the Document in any medium, either 136 | commercially or noncommercially, provided that this License, the 137 | copyright notices, and the license notice saying this License applies 138 | to the Document are reproduced in all copies, and that you add no other 139 | conditions whatsoever to those of this License. You may not use 140 | technical measures to obstruct or control the reading or further 141 | copying of the copies you make or distribute. However, you may accept 142 | compensation in exchange for copies. If you distribute a large enough 143 | number of copies you must also follow the conditions in section 3. 144 | 145 | You may also lend copies, under the same conditions stated above, and 146 | you may publicly display copies. 147 | 148 | @item 149 | COPYING IN QUANTITY 150 | 151 | If you publish printed copies (or copies in media that commonly have 152 | printed covers) of the Document, numbering more than 100, and the 153 | Document's license notice requires Cover Texts, you must enclose the 154 | copies in covers that carry, clearly and legibly, all these Cover 155 | Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on 156 | the back cover. Both covers must also clearly and legibly identify 157 | you as the publisher of these copies. The front cover must present 158 | the full title with all words of the title equally prominent and 159 | visible. You may add other material on the covers in addition. 160 | Copying with changes limited to the covers, as long as they preserve 161 | the title of the Document and satisfy these conditions, can be treated 162 | as verbatim copying in other respects. 163 | 164 | If the required texts for either cover are too voluminous to fit 165 | legibly, you should put the first ones listed (as many as fit 166 | reasonably) on the actual cover, and continue the rest onto adjacent 167 | pages. 168 | 169 | If you publish or distribute Opaque copies of the Document numbering 170 | more than 100, you must either include a machine-readable Transparent 171 | copy along with each Opaque copy, or state in or with each Opaque copy 172 | a computer-network location from which the general network-using 173 | public has access to download using public-standard network protocols 174 | a complete Transparent copy of the Document, free of added material. 175 | If you use the latter option, you must take reasonably prudent steps, 176 | when you begin distribution of Opaque copies in quantity, to ensure 177 | that this Transparent copy will remain thus accessible at the stated 178 | location until at least one year after the last time you distribute an 179 | Opaque copy (directly or through your agents or retailers) of that 180 | edition to the public. 181 | 182 | It is requested, but not required, that you contact the authors of the 183 | Document well before redistributing any large number of copies, to give 184 | them a chance to provide you with an updated version of the Document. 185 | 186 | @item 187 | MODIFICATIONS 188 | 189 | You may copy and distribute a Modified Version of the Document under 190 | the conditions of sections 2 and 3 above, provided that you release 191 | the Modified Version under precisely this License, with the Modified 192 | Version filling the role of the Document, thus licensing distribution 193 | and modification of the Modified Version to whoever possesses a copy 194 | of it. In addition, you must do these things in the Modified Version: 195 | 196 | @enumerate A 197 | @item 198 | Use in the Title Page (and on the covers, if any) a title distinct 199 | from that of the Document, and from those of previous versions 200 | (which should, if there were any, be listed in the History section 201 | of the Document). You may use the same title as a previous version 202 | if the original publisher of that version gives permission. 203 | 204 | @item 205 | List on the Title Page, as authors, one or more persons or entities 206 | responsible for authorship of the modifications in the Modified 207 | Version, together with at least five of the principal authors of the 208 | Document (all of its principal authors, if it has fewer than five), 209 | unless they release you from this requirement. 210 | 211 | @item 212 | State on the Title page the name of the publisher of the 213 | Modified Version, as the publisher. 214 | 215 | @item 216 | Preserve all the copyright notices of the Document. 217 | 218 | @item 219 | Add an appropriate copyright notice for your modifications 220 | adjacent to the other copyright notices. 221 | 222 | @item 223 | Include, immediately after the copyright notices, a license notice 224 | giving the public permission to use the Modified Version under the 225 | terms of this License, in the form shown in the Addendum below. 226 | 227 | @item 228 | Preserve in that license notice the full lists of Invariant Sections 229 | and required Cover Texts given in the Document's license notice. 230 | 231 | @item 232 | Include an unaltered copy of this License. 233 | 234 | @item 235 | Preserve the section Entitled ``History'', Preserve its Title, and add 236 | to it an item stating at least the title, year, new authors, and 237 | publisher of the Modified Version as given on the Title Page. If 238 | there is no section Entitled ``History'' in the Document, create one 239 | stating the title, year, authors, and publisher of the Document as 240 | given on its Title Page, then add an item describing the Modified 241 | Version as stated in the previous sentence. 242 | 243 | @item 244 | Preserve the network location, if any, given in the Document for 245 | public access to a Transparent copy of the Document, and likewise 246 | the network locations given in the Document for previous versions 247 | it was based on. These may be placed in the ``History'' section. 248 | You may omit a network location for a work that was published at 249 | least four years before the Document itself, or if the original 250 | publisher of the version it refers to gives permission. 251 | 252 | @item 253 | For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve 254 | the Title of the section, and preserve in the section all the 255 | substance and tone of each of the contributor acknowledgements and/or 256 | dedications given therein. 257 | 258 | @item 259 | Preserve all the Invariant Sections of the Document, 260 | unaltered in their text and in their titles. Section numbers 261 | or the equivalent are not considered part of the section titles. 262 | 263 | @item 264 | Delete any section Entitled ``Endorsements''. Such a section 265 | may not be included in the Modified Version. 266 | 267 | @item 268 | Do not retitle any existing section to be Entitled ``Endorsements'' or 269 | to conflict in title with any Invariant Section. 270 | 271 | @item 272 | Preserve any Warranty Disclaimers. 273 | @end enumerate 274 | 275 | If the Modified Version includes new front-matter sections or 276 | appendices that qualify as Secondary Sections and contain no material 277 | copied from the Document, you may at your option designate some or all 278 | of these sections as invariant. To do this, add their titles to the 279 | list of Invariant Sections in the Modified Version's license notice. 280 | These titles must be distinct from any other section titles. 281 | 282 | You may add a section Entitled ``Endorsements'', provided it contains 283 | nothing but endorsements of your Modified Version by various 284 | parties---for example, statements of peer review or that the text has 285 | been approved by an organization as the authoritative definition of a 286 | standard. 287 | 288 | You may add a passage of up to five words as a Front-Cover Text, and a 289 | passage of up to 25 words as a Back-Cover Text, to the end of the list 290 | of Cover Texts in the Modified Version. Only one passage of 291 | Front-Cover Text and one of Back-Cover Text may be added by (or 292 | through arrangements made by) any one entity. If the Document already 293 | includes a cover text for the same cover, previously added by you or 294 | by arrangement made by the same entity you are acting on behalf of, 295 | you may not add another; but you may replace the old one, on explicit 296 | permission from the previous publisher that added the old one. 297 | 298 | The author(s) and publisher(s) of the Document do not by this License 299 | give permission to use their names for publicity for or to assert or 300 | imply endorsement of any Modified Version. 301 | 302 | @item 303 | COMBINING DOCUMENTS 304 | 305 | You may combine the Document with other documents released under this 306 | License, under the terms defined in section 4 above for modified 307 | versions, provided that you include in the combination all of the 308 | Invariant Sections of all of the original documents, unmodified, and 309 | list them all as Invariant Sections of your combined work in its 310 | license notice, and that you preserve all their Warranty Disclaimers. 311 | 312 | The combined work need only contain one copy of this License, and 313 | multiple identical Invariant Sections may be replaced with a single 314 | copy. If there are multiple Invariant Sections with the same name but 315 | different contents, make the title of each such section unique by 316 | adding at the end of it, in parentheses, the name of the original 317 | author or publisher of that section if known, or else a unique number. 318 | Make the same adjustment to the section titles in the list of 319 | Invariant Sections in the license notice of the combined work. 320 | 321 | In the combination, you must combine any sections Entitled ``History'' 322 | in the various original documents, forming one section Entitled 323 | ``History''; likewise combine any sections Entitled ``Acknowledgements'', 324 | and any sections Entitled ``Dedications''. You must delete all 325 | sections Entitled ``Endorsements.'' 326 | 327 | @item 328 | COLLECTIONS OF DOCUMENTS 329 | 330 | You may make a collection consisting of the Document and other documents 331 | released under this License, and replace the individual copies of this 332 | License in the various documents with a single copy that is included in 333 | the collection, provided that you follow the rules of this License for 334 | verbatim copying of each of the documents in all other respects. 335 | 336 | You may extract a single document from such a collection, and distribute 337 | it individually under this License, provided you insert a copy of this 338 | License into the extracted document, and follow this License in all 339 | other respects regarding verbatim copying of that document. 340 | 341 | @item 342 | AGGREGATION WITH INDEPENDENT WORKS 343 | 344 | A compilation of the Document or its derivatives with other separate 345 | and independent documents or works, in or on a volume of a storage or 346 | distribution medium, is called an ``aggregate'' if the copyright 347 | resulting from the compilation is not used to limit the legal rights 348 | of the compilation's users beyond what the individual works permit. 349 | When the Document is included in an aggregate, this License does not 350 | apply to the other works in the aggregate which are not themselves 351 | derivative works of the Document. 352 | 353 | If the Cover Text requirement of section 3 is applicable to these 354 | copies of the Document, then if the Document is less than one half of 355 | the entire aggregate, the Document's Cover Texts may be placed on 356 | covers that bracket the Document within the aggregate, or the 357 | electronic equivalent of covers if the Document is in electronic form. 358 | Otherwise they must appear on printed covers that bracket the whole 359 | aggregate. 360 | 361 | @item 362 | TRANSLATION 363 | 364 | Translation is considered a kind of modification, so you may 365 | distribute translations of the Document under the terms of section 4. 366 | Replacing Invariant Sections with translations requires special 367 | permission from their copyright holders, but you may include 368 | translations of some or all Invariant Sections in addition to the 369 | original versions of these Invariant Sections. You may include a 370 | translation of this License, and all the license notices in the 371 | Document, and any Warranty Disclaimers, provided that you also include 372 | the original English version of this License and the original versions 373 | of those notices and disclaimers. In case of a disagreement between 374 | the translation and the original version of this License or a notice 375 | or disclaimer, the original version will prevail. 376 | 377 | If a section in the Document is Entitled ``Acknowledgements'', 378 | ``Dedications'', or ``History'', the requirement (section 4) to Preserve 379 | its Title (section 1) will typically require changing the actual 380 | title. 381 | 382 | @item 383 | TERMINATION 384 | 385 | You may not copy, modify, sublicense, or distribute the Document 386 | except as expressly provided under this License. Any attempt 387 | otherwise to copy, modify, sublicense, or distribute it is void, and 388 | will automatically terminate your rights under this License. 389 | 390 | However, if you cease all violation of this License, then your license 391 | from a particular copyright holder is reinstated (a) provisionally, 392 | unless and until the copyright holder explicitly and finally 393 | terminates your license, and (b) permanently, if the copyright holder 394 | fails to notify you of the violation by some reasonable means prior to 395 | 60 days after the cessation. 396 | 397 | Moreover, your license from a particular copyright holder is 398 | reinstated permanently if the copyright holder notifies you of the 399 | violation by some reasonable means, this is the first time you have 400 | received notice of violation of this License (for any work) from that 401 | copyright holder, and you cure the violation prior to 30 days after 402 | your receipt of the notice. 403 | 404 | Termination of your rights under this section does not terminate the 405 | licenses of parties who have received copies or rights from you under 406 | this License. If your rights have been terminated and not permanently 407 | reinstated, receipt of a copy of some or all of the same material does 408 | not give you any rights to use it. 409 | 410 | @item 411 | FUTURE REVISIONS OF THIS LICENSE 412 | 413 | The Free Software Foundation may publish new, revised versions 414 | of the GNU Free Documentation License from time to time. Such new 415 | versions will be similar in spirit to the present version, but may 416 | differ in detail to address new problems or concerns. See 417 | @uref{http://www.gnu.org/copyleft/}. 418 | 419 | Each version of the License is given a distinguishing version number. 420 | If the Document specifies that a particular numbered version of this 421 | License ``or any later version'' applies to it, you have the option of 422 | following the terms and conditions either of that specified version or 423 | of any later version that has been published (not as a draft) by the 424 | Free Software Foundation. If the Document does not specify a version 425 | number of this License, you may choose any version ever published (not 426 | as a draft) by the Free Software Foundation. If the Document 427 | specifies that a proxy can decide which future versions of this 428 | License can be used, that proxy's public statement of acceptance of a 429 | version permanently authorizes you to choose that version for the 430 | Document. 431 | 432 | @item 433 | RELICENSING 434 | 435 | ``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any 436 | World Wide Web server that publishes copyrightable works and also 437 | provides prominent facilities for anybody to edit those works. A 438 | public wiki that anybody can edit is an example of such a server. A 439 | ``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the 440 | site means any set of copyrightable works thus published on the MMC 441 | site. 442 | 443 | ``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 444 | license published by Creative Commons Corporation, a not-for-profit 445 | corporation with a principal place of business in San Francisco, 446 | California, as well as future copyleft versions of that license 447 | published by that same organization. 448 | 449 | ``Incorporate'' means to publish or republish a Document, in whole or 450 | in part, as part of another Document. 451 | 452 | An MMC is ``eligible for relicensing'' if it is licensed under this 453 | License, and if all works that were first published under this License 454 | somewhere other than this MMC, and subsequently incorporated in whole 455 | or in part into the MMC, (1) had no cover texts or invariant sections, 456 | and (2) were thus incorporated prior to November 1, 2008. 457 | 458 | The operator of an MMC Site may republish an MMC contained in the site 459 | under CC-BY-SA on the same site at any time before August 1, 2009, 460 | provided the MMC is eligible for relicensing. 461 | 462 | @end enumerate 463 | 464 | @page 465 | @heading ADDENDUM: How to use this License for your documents 466 | 467 | To use this License in a document you have written, include a copy of 468 | the License in the document and put the following copyright and 469 | license notices just after the title page: 470 | 471 | @smallexample 472 | @group 473 | Copyright (C) @var{year} @var{your name}. 474 | Permission is granted to copy, distribute and/or modify this document 475 | under the terms of the GNU Free Documentation License, Version 1.3 476 | or any later version published by the Free Software Foundation; 477 | with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 478 | Texts. A copy of the license is included in the section entitled ``GNU 479 | Free Documentation License''. 480 | @end group 481 | @end smallexample 482 | 483 | If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, 484 | replace the ``with@dots{}Texts.'' line with this: 485 | 486 | @smallexample 487 | @group 488 | with the Invariant Sections being @var{list their titles}, with 489 | the Front-Cover Texts being @var{list}, and with the Back-Cover Texts 490 | being @var{list}. 491 | @end group 492 | @end smallexample 493 | 494 | If you have Invariant Sections without Cover Texts, or some other 495 | combination of the three, merge those two alternatives to suit the 496 | situation. 497 | 498 | If your document contains nontrivial examples of program code, we 499 | recommend releasing these examples in parallel under your choice of 500 | free software license, such as the GNU General Public License, 501 | to permit their use in free software. 502 | 503 | @c Local Variables: 504 | @c ispell-local-pdict: "ispell-dict" 505 | @c End: 506 | 507 | -------------------------------------------------------------------------------- /doc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artyom-poptsov/metabash/8a0979ca1a1d411f0d15916e0affca8989094679/doc/logo.png -------------------------------------------------------------------------------- /doc/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | Metabash logo. 21 | 23 | 47 | 52 | 57 | 62 | 67 | 72 | 77 | 82 | 87 | 92 | 97 | 98 | 100 | 101 | 103 | image/svg+xml 104 | 106 | Metabash logo. 107 | 108 | 109 | Artyom V. Poptsov <poptsov.artyom@gmail.com> 110 | 111 | 112 | 114 | 115 | 117 | 119 | 121 | 123 | 125 | 127 | 129 | 130 | 131 | 132 | 137 | 142 | 149 | M#! 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /doc/metabash.texi: -------------------------------------------------------------------------------- 1 | \input texinfo 2 | @c -*-texinfo-*- 3 | @c %**start of header 4 | @setfilename metabash.info 5 | @documentencoding UTF-8 6 | @settitle Metabash Reference Manual 7 | @c %**end of header 8 | @include version.texi 9 | 10 | @copying 11 | This manual documents Metabash version @value{VERSION}. 12 | 13 | Copyright (C) 2020 Artyom V. Poptsov 14 | 15 | Permission is granted to copy, distribute and/or modify this document 16 | under the terms of the GNU Free Documentation License, Version 1.3 or 17 | any later version published by the Free Software Foundation; with no 18 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A 19 | copy of the license is included in the section entitled ``GNU Free 20 | Documentation License.'' 21 | @end copying 22 | 23 | @dircategory The Algorithmic Language Scheme 24 | 25 | @direntry 26 | * Metabash: (metabash). Guile module for working with distributed pipelines. 27 | @end direntry 28 | 29 | @setchapternewpage odd 30 | 31 | @titlepage 32 | @sp 10 33 | 34 | @title Metabash Reference Manual 35 | @subtitle For Metabash @value{VERSION} 36 | 37 | @author Artyom V. Poptsov 38 | 39 | @page 40 | @vskip 0pt plus 1filll 41 | @vskip 0pt plus 1filll 42 | @insertcopying 43 | @end titlepage 44 | 45 | @finalout 46 | @headings double 47 | 48 | @ifnottex 49 | @node Top, Introduction, (dir), (dir) 50 | @top The Guile-DSV Reference Manual 51 | 52 | @insertcopying 53 | @sp 1 54 | @end ifnottex 55 | 56 | @menu 57 | * Introduction:: 58 | 59 | Appendices 60 | 61 | * GNU Free Documentation License:: The license of this manual. 62 | 63 | @end menu 64 | 65 | @contents 66 | 67 | @node Introduction 68 | @chapter Introduction 69 | 70 | Metabash (or ``M#!'' for short) GNU Guile module for running 71 | distributed shell pipelines. ``what are distributed shell pipelines?'' 72 | you may ask. Well the idea is that we can implement some sort of Unix 73 | pipeline that is spanned across multiple hosts over a network. 74 | 75 | Using such pipeline you can run a command on one host and then pass 76 | the output to a command that is run on another. 77 | 78 | Metabash is a research project of mine that was born as a 79 | @url{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} spinoff. 80 | 81 | @node GNU Free Documentation License 82 | @appendix GNU Free Documentation License 83 | 84 | @include fdl.texi 85 | 86 | @bye 87 | -------------------------------------------------------------------------------- /examples/group-grep.scm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/guile \ 2 | -L modules --no-auto-compile -e main -s 3 | !# 4 | 5 | ;;; group-grep.scm -- A program to grep '/etc/group' on a remote host. 6 | 7 | (use-modules (oop goops) 8 | (ssh session) 9 | (ssh auth) 10 | (metabash core plumbing pipe) 11 | (metabash core pipeline) 12 | (metabash plumber)) 13 | 14 | (define (print-help-and-exit prog) 15 | (format #t "Usage: ~a ~%" prog) 16 | (exit 0)) 17 | 18 | (define (main args) 19 | 20 | (when (< (length args) 3) 21 | (print-help-and-exit (car args))) 22 | 23 | (let ((session (make-session #:host (cadr args))) 24 | (user (caddr args))) 25 | (connect! session) 26 | (userauth-agent! session) 27 | (let ((pipeline (M#! remote session "cat /etc/group" 28 | => local "sort" 29 | => local (format #f "grep '~a'" user)))) 30 | 31 | (pipeline-pretty-print pipeline) 32 | 33 | (let ((pipe (make 34 | #:input-port (pipeline-output-port pipeline) 35 | #:output-port (current-output-port) 36 | #:on-disconnect (lambda (pipe) 37 | ;; (format (current-error-port) 38 | ;; "Closing pipe: ~a ...~%" 39 | ;; pipe) 40 | (pipe-close! pipe) 41 | (disconnect! session))))) 42 | (pipe-connect! pipe) 43 | (while (pipe-connected? pipe) 44 | (sleep 1)))))) 45 | -------------------------------------------------------------------------------- /examples/kernel-release-diff.scm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/guile \ 2 | -L modules -e main -s 3 | !# 4 | 5 | ;;; kernel-release-diff.scm -- Compare kernel versions of two machines 6 | 7 | (use-modules (ssh session) 8 | (ssh auth) 9 | (metabash core pipeline) 10 | (metabash plumber) 11 | (metabash diff)) 12 | 13 | 14 | 15 | (define (print-help-and-exit prog) 16 | (format (current-error-port) 17 | "Usage: ~a ~%" 18 | prog) 19 | (exit 0)) 20 | 21 | 22 | (define (main args) 23 | 24 | (when (< (length args) 3) 25 | (print-help-and-exit (car args))) 26 | 27 | (let ((session-1 (make-session #:host (cadr args))) 28 | (session-2 (make-session #:host (caddr args)))) 29 | 30 | (connect! session-1) 31 | (connect! session-2) 32 | 33 | (userauth-agent! session-1) 34 | (userauth-agent! session-2) 35 | 36 | (let ((pipeline-1 (M#! remote session-1 "uname -r")) 37 | (pipeline-2 (M#! remote session-2 "uname -r"))) 38 | 39 | (diff pipeline-1 pipeline-2 (current-output-port)) 40 | 41 | (while (or (not (port-closed? (pipeline-output-port pipeline-1))) 42 | (not (port-closed? (pipeline-output-port pipeline-2)))) 43 | (sleep 1))))) 44 | -------------------------------------------------------------------------------- /m4/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Config file for GNU Automake. 2 | ## 3 | ## Copyright (C) 2014 Artyom V. Poptsov 4 | ## 5 | ## This file is part of Metabash. 6 | ## 7 | ## Metabash is free software: you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License as 9 | ## published by the Free Software Foundation, either version 3 of the 10 | ## License, or (at your option) any later version. 11 | ## 12 | ## Metabash is distributed in the hope that it will be useful, but 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | ## General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with Metabash. If not, see . 19 | 20 | EXTRA_DIST = \ 21 | guile-2.0.m4 \ 22 | pkg.m4 23 | 24 | ## Makefile.am ends here 25 | 26 | -------------------------------------------------------------------------------- /m4/guile-2.0.m4: -------------------------------------------------------------------------------- 1 | ## Autoconf macros for working with Guile. 2 | ## 3 | ## Copyright (C) 1998,2001, 2006, 2010, 2012 Free Software Foundation, Inc. 4 | ## 5 | ## This library is free software; you can redistribute it and/or 6 | ## modify it under the terms of the GNU Lesser General Public License 7 | ## as published by the Free Software Foundation; either version 3 of 8 | ## the License, or (at your option) any later version. 9 | ## 10 | ## This library is distributed in the hope that it will be useful, 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | ## Lesser General Public License for more details. 14 | ## 15 | ## You should have received a copy of the GNU Lesser General Public 16 | ## License along with this library; if not, write to the Free Software 17 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 | ## 02110-1301 USA 19 | 20 | # serial 10 21 | 22 | ## Index 23 | ## ----- 24 | ## 25 | ## GUILE_PKG -- find Guile development files 26 | ## GUILE_PROGS -- set paths to Guile interpreter, config and tool programs 27 | ## GUILE_FLAGS -- set flags for compiling and linking with Guile 28 | ## GUILE_SITE_DIR -- find path to Guile "site" directory 29 | ## GUILE_CHECK -- evaluate Guile Scheme code and capture the return value 30 | ## GUILE_MODULE_CHECK -- check feature of a Guile Scheme module 31 | ## GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module 32 | ## GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable 33 | ## GUILE_MODULE_EXPORTS -- check if a module exports a variable 34 | ## GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable 35 | 36 | ## Code 37 | ## ---- 38 | 39 | ## NOTE: Comments preceding an AC_DEFUN (starting from "Usage:") are massaged 40 | ## into doc/ref/autoconf-macros.texi (see Makefile.am in that directory). 41 | 42 | # GUILE_PKG -- find Guile development files 43 | # 44 | # Usage: GUILE_PKG([VERSIONS]) 45 | # 46 | # This macro runs the @code{pkg-config} tool to find development files 47 | # for an available version of Guile. 48 | # 49 | # By default, this macro will search for the latest stable version of 50 | # Guile (e.g. 2.0), falling back to the previous stable version 51 | # (e.g. 1.8) if it is available. If no guile-@var{VERSION}.pc file is 52 | # found, an error is signalled. The found version is stored in 53 | # @var{GUILE_EFFECTIVE_VERSION}. 54 | # 55 | # If @code{GUILE_PROGS} was already invoked, this macro ensures that the 56 | # development files have the same effective version as the Guile 57 | # program. 58 | # 59 | # @var{GUILE_EFFECTIVE_VERSION} is marked for substitution, as by 60 | # @code{AC_SUBST}. 61 | # 62 | AC_DEFUN([GUILE_PKG], 63 | [PKG_PROG_PKG_CONFIG 64 | _guile_versions_to_search="m4_default([$1], [2.0 1.8])" 65 | if test -n "$GUILE_EFFECTIVE_VERSION"; then 66 | _guile_tmp="" 67 | for v in $_guile_versions_to_search; do 68 | if test "$v" = "$GUILE_EFFECTIVE_VERSION"; then 69 | _guile_tmp=$v 70 | fi 71 | done 72 | if test -z "$_guile_tmp"; then 73 | AC_MSG_FAILURE([searching for guile development files for versions $_guile_versions_to_search, but previously found $GUILE version $GUILE_EFFECTIVE_VERSION]) 74 | fi 75 | _guile_versions_to_search=$GUILE_EFFECTIVE_VERSION 76 | fi 77 | GUILE_EFFECTIVE_VERSION="" 78 | _guile_errors="" 79 | for v in $_guile_versions_to_search; do 80 | AC_MSG_NOTICE([checking for guile $v]) 81 | if test -z "$GUILE_EFFECTIVE_VERSION"; then 82 | PKG_CHECK_EXISTS([guile-$v], [GUILE_EFFECTIVE_VERSION=$v], []) 83 | fi 84 | done 85 | 86 | if test -z "$GUILE_EFFECTIVE_VERSION"; then 87 | AC_MSG_ERROR([ 88 | No Guile development packages were found. 89 | 90 | Please verify that you have Guile installed. If you installed Guile 91 | from a binary distribution, please verify that you have also installed 92 | the development packages. If you installed it yourself, you might need 93 | to adjust your PKG_CONFIG_PATH; see the pkg-config man page for more. 94 | ]) 95 | fi 96 | AC_MSG_NOTICE([found guile $v]) 97 | AC_SUBST([GUILE_EFFECTIVE_VERSION]) 98 | ]) 99 | 100 | # GUILE_FLAGS -- set flags for compiling and linking with Guile 101 | # 102 | # Usage: GUILE_FLAGS 103 | # 104 | # This macro runs the @code{pkg-config} tool to find out how to compile 105 | # and link programs against Guile. It sets four variables: 106 | # @var{GUILE_CFLAGS}, @var{GUILE_LDFLAGS}, @var{GUILE_LIBS}, and 107 | # @var{GUILE_LTLIBS}. 108 | # 109 | # @var{GUILE_CFLAGS}: flags to pass to a C or C++ compiler to build code that 110 | # uses Guile header files. This is almost always just one or more @code{-I} 111 | # flags. 112 | # 113 | # @var{GUILE_LDFLAGS}: flags to pass to the compiler to link a program 114 | # against Guile. This includes @code{-lguile-@var{VERSION}} for the 115 | # Guile library itself, and may also include one or more @code{-L} flag 116 | # to tell the compiler where to find the libraries. But it does not 117 | # include flags that influence the program's runtime search path for 118 | # libraries, and will therefore lead to a program that fails to start, 119 | # unless all necessary libraries are installed in a standard location 120 | # such as @file{/usr/lib}. 121 | # 122 | # @var{GUILE_LIBS} and @var{GUILE_LTLIBS}: flags to pass to the compiler or to 123 | # libtool, respectively, to link a program against Guile. It includes flags 124 | # that augment the program's runtime search path for libraries, so that shared 125 | # libraries will be found at the location where they were during linking, even 126 | # in non-standard locations. @var{GUILE_LIBS} is to be used when linking the 127 | # program directly with the compiler, whereas @var{GUILE_LTLIBS} is to be used 128 | # when linking the program is done through libtool. 129 | # 130 | # The variables are marked for substitution, as by @code{AC_SUBST}. 131 | # 132 | AC_DEFUN([GUILE_FLAGS], 133 | [AC_REQUIRE([GUILE_PKG]) 134 | PKG_CHECK_MODULES(GUILE, [guile-$GUILE_EFFECTIVE_VERSION]) 135 | 136 | dnl GUILE_CFLAGS and GUILE_LIBS are already defined and AC_SUBST'd by 137 | dnl PKG_CHECK_MODULES. But GUILE_LIBS to pkg-config is GUILE_LDFLAGS 138 | dnl to us. 139 | 140 | GUILE_LDFLAGS=$GUILE_LIBS 141 | 142 | dnl Determine the platform dependent parameters needed to use rpath. 143 | dnl AC_LIB_LINKFLAGS_FROM_LIBS is defined in gnulib/m4/lib-link.m4 and needs 144 | dnl the file gnulib/build-aux/config.rpath. 145 | AC_LIB_LINKFLAGS_FROM_LIBS([GUILE_LIBS], [$GUILE_LDFLAGS], []) 146 | GUILE_LIBS="$GUILE_LDFLAGS $GUILE_LIBS" 147 | AC_LIB_LINKFLAGS_FROM_LIBS([GUILE_LTLIBS], [$GUILE_LDFLAGS], [yes]) 148 | GUILE_LTLIBS="$GUILE_LDFLAGS $GUILE_LTLIBS" 149 | 150 | AC_SUBST([GUILE_EFFECTIVE_VERSION]) 151 | AC_SUBST([GUILE_CFLAGS]) 152 | AC_SUBST([GUILE_LDFLAGS]) 153 | AC_SUBST([GUILE_LIBS]) 154 | AC_SUBST([GUILE_LTLIBS]) 155 | ]) 156 | 157 | # GUILE_SITE_DIR -- find path to Guile "site" directory 158 | # 159 | # Usage: GUILE_SITE_DIR 160 | # 161 | # This looks for Guile's "site" directory, usually something like 162 | # PREFIX/share/guile/site, and sets var @var{GUILE_SITE} to the path. 163 | # Note that the var name is different from the macro name. 164 | # 165 | # The variable is marked for substitution, as by @code{AC_SUBST}. 166 | # 167 | AC_DEFUN([GUILE_SITE_DIR], 168 | [AC_REQUIRE([GUILE_PKG]) 169 | AC_MSG_CHECKING(for Guile site directory) 170 | GUILE_SITE=`$PKG_CONFIG --print-errors --variable=sitedir guile-$GUILE_EFFECTIVE_VERSION` 171 | AC_MSG_RESULT($GUILE_SITE) 172 | if test "$GUILE_SITE" = ""; then 173 | AC_MSG_FAILURE(sitedir not found) 174 | fi 175 | AC_SUBST(GUILE_SITE) 176 | ]) 177 | 178 | # GUILE_PROGS -- set paths to Guile interpreter, config and tool programs 179 | # 180 | # Usage: GUILE_PROGS 181 | # 182 | # This macro looks for programs @code{guile} and @code{guild}, setting 183 | # variables @var{GUILE} and @var{GUILD} to their paths, respectively. 184 | # If @code{guile} is not found, signal an error. 185 | # 186 | # The effective version of the found @code{guile} is set to 187 | # @var{GUILE_EFFECTIVE_VERSION}. This macro ensures that the effective 188 | # version is compatible with the result of a previous invocation of 189 | # @code{GUILE_FLAGS}, if any. 190 | # 191 | # As a legacy interface, it also looks for @code{guile-config} and 192 | # @code{guile-tools}, setting @var{GUILE_CONFIG} and @var{GUILE_TOOLS}. 193 | # 194 | # The variables are marked for substitution, as by @code{AC_SUBST}. 195 | # 196 | AC_DEFUN([GUILE_PROGS], 197 | [AC_PATH_PROG(GUILE,guile) 198 | if test "$GUILE" = "" ; then 199 | AC_MSG_ERROR([guile required but not found]) 200 | fi 201 | AC_SUBST(GUILE) 202 | 203 | _guile_prog_version=`$GUILE -c "(display (effective-version))"` 204 | if test -z "$GUILE_EFFECTIVE_VERSION"; then 205 | GUILE_EFFECTIVE_VERSION=$_guile_prog_version 206 | elif test "$GUILE_EFFECTIVE_VERSION" != "$_guile_prog_version"; then 207 | AC_MSG_ERROR([found development files for Guile $GUILE_EFFECTIVE_VERSION, but $GUILE has effective version $_guile_prog_version]) 208 | fi 209 | 210 | AC_PATH_PROG(GUILD,guild) 211 | AC_SUBST(GUILD) 212 | 213 | AC_PATH_PROG(GUILE_CONFIG,guile-config) 214 | AC_SUBST(GUILE_CONFIG) 215 | if test -n "$GUILD"; then 216 | GUILE_TOOLS=$GUILD 217 | else 218 | AC_PATH_PROG(GUILE_TOOLS,guile-tools) 219 | fi 220 | AC_SUBST(GUILE_TOOLS) 221 | ]) 222 | 223 | # GUILE_CHECK -- evaluate Guile Scheme code and capture the return value 224 | # 225 | # Usage: GUILE_CHECK_RETVAL(var,check) 226 | # 227 | # @var{var} is a shell variable name to be set to the return value. 228 | # @var{check} is a Guile Scheme expression, evaluated with "$GUILE -c", and 229 | # returning either 0 or non-#f to indicate the check passed. 230 | # Non-0 number or #f indicates failure. 231 | # Avoid using the character "#" since that confuses autoconf. 232 | # 233 | AC_DEFUN([GUILE_CHECK], 234 | [AC_REQUIRE([GUILE_PROGS]) 235 | $GUILE -c "$2" > /dev/null 2>&1 236 | $1=$? 237 | ]) 238 | 239 | # GUILE_MODULE_CHECK -- check feature of a Guile Scheme module 240 | # 241 | # Usage: GUILE_MODULE_CHECK(var,module,featuretest,description) 242 | # 243 | # @var{var} is a shell variable name to be set to "yes" or "no". 244 | # @var{module} is a list of symbols, like: (ice-9 common-list). 245 | # @var{featuretest} is an expression acceptable to GUILE_CHECK, q.v. 246 | # @var{description} is a present-tense verb phrase (passed to AC_MSG_CHECKING). 247 | # 248 | AC_DEFUN([GUILE_MODULE_CHECK], 249 | [AC_MSG_CHECKING([if $2 $4]) 250 | GUILE_CHECK($1,(use-modules $2) (exit ((lambda () $3)))) 251 | if test "$$1" = "0" ; then $1=yes ; else $1=no ; fi 252 | AC_MSG_RESULT($$1) 253 | ]) 254 | 255 | # GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module 256 | # 257 | # Usage: GUILE_MODULE_AVAILABLE(var,module) 258 | # 259 | # @var{var} is a shell variable name to be set to "yes" or "no". 260 | # @var{module} is a list of symbols, like: (ice-9 common-list). 261 | # 262 | AC_DEFUN([GUILE_MODULE_AVAILABLE], 263 | [GUILE_MODULE_CHECK($1,$2,0,is available) 264 | ]) 265 | 266 | # GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable 267 | # 268 | # Usage: GUILE_MODULE_REQUIRED(symlist) 269 | # 270 | # @var{symlist} is a list of symbols, WITHOUT surrounding parens, 271 | # like: ice-9 common-list. 272 | # 273 | AC_DEFUN([GUILE_MODULE_REQUIRED], 274 | [GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1)) 275 | if test "$ac_guile_module_required" = "no" ; then 276 | AC_MSG_ERROR([required guile module not found: ($1)]) 277 | fi 278 | ]) 279 | 280 | # GUILE_MODULE_EXPORTS -- check if a module exports a variable 281 | # 282 | # Usage: GUILE_MODULE_EXPORTS(var,module,modvar) 283 | # 284 | # @var{var} is a shell variable to be set to "yes" or "no". 285 | # @var{module} is a list of symbols, like: (ice-9 common-list). 286 | # @var{modvar} is the Guile Scheme variable to check. 287 | # 288 | AC_DEFUN([GUILE_MODULE_EXPORTS], 289 | [GUILE_MODULE_CHECK($1,$2,$3,exports `$3') 290 | ]) 291 | 292 | # GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable 293 | # 294 | # Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar) 295 | # 296 | # @var{module} is a list of symbols, like: (ice-9 common-list). 297 | # @var{modvar} is the Guile Scheme variable to check. 298 | # 299 | AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT], 300 | [GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2) 301 | if test "$guile_module_required_export" = "no" ; then 302 | AC_MSG_ERROR([module $1 does not export $2; required]) 303 | fi 304 | ]) 305 | 306 | ## guile.m4 ends here 307 | -------------------------------------------------------------------------------- /m4/pkg.m4: -------------------------------------------------------------------------------- 1 | # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 2 | # serial 1 (pkg-config-0.24) 3 | # 4 | # Copyright © 2004 Scott James Remnant . 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, but 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | # 20 | # As a special exception to the GNU General Public License, if you 21 | # distribute this file as part of a program that contains a 22 | # configuration script generated by Autoconf, you may include it under 23 | # the same distribution terms that you use for the rest of that program. 24 | 25 | # PKG_PROG_PKG_CONFIG([MIN-VERSION]) 26 | # ---------------------------------- 27 | AC_DEFUN([PKG_PROG_PKG_CONFIG], 28 | [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) 29 | m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) 30 | m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) 31 | AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) 32 | AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) 33 | AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) 34 | 35 | if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then 36 | AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) 37 | fi 38 | if test -n "$PKG_CONFIG"; then 39 | _pkg_min_version=m4_default([$1], [0.9.0]) 40 | AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) 41 | if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then 42 | AC_MSG_RESULT([yes]) 43 | else 44 | AC_MSG_RESULT([no]) 45 | PKG_CONFIG="" 46 | fi 47 | fi[]dnl 48 | ])# PKG_PROG_PKG_CONFIG 49 | 50 | # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 51 | # 52 | # Check to see whether a particular set of modules exists. Similar 53 | # to PKG_CHECK_MODULES(), but does not set variables or print errors. 54 | # 55 | # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 56 | # only at the first occurence in configure.ac, so if the first place 57 | # it's called might be skipped (such as if it is within an "if", you 58 | # have to call PKG_CHECK_EXISTS manually 59 | # -------------------------------------------------------------- 60 | AC_DEFUN([PKG_CHECK_EXISTS], 61 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 62 | if test -n "$PKG_CONFIG" && \ 63 | AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then 64 | m4_default([$2], [:]) 65 | m4_ifvaln([$3], [else 66 | $3])dnl 67 | fi]) 68 | 69 | # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 70 | # --------------------------------------------- 71 | m4_define([_PKG_CONFIG], 72 | [if test -n "$$1"; then 73 | pkg_cv_[]$1="$$1" 74 | elif test -n "$PKG_CONFIG"; then 75 | PKG_CHECK_EXISTS([$3], 76 | [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` 77 | test "x$?" != "x0" && pkg_failed=yes ], 78 | [pkg_failed=yes]) 79 | else 80 | pkg_failed=untried 81 | fi[]dnl 82 | ])# _PKG_CONFIG 83 | 84 | # _PKG_SHORT_ERRORS_SUPPORTED 85 | # ----------------------------- 86 | AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], 87 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 88 | if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 89 | _pkg_short_errors_supported=yes 90 | else 91 | _pkg_short_errors_supported=no 92 | fi[]dnl 93 | ])# _PKG_SHORT_ERRORS_SUPPORTED 94 | 95 | 96 | # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 97 | # [ACTION-IF-NOT-FOUND]) 98 | # 99 | # 100 | # Note that if there is a possibility the first call to 101 | # PKG_CHECK_MODULES might not happen, you should be sure to include an 102 | # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac 103 | # 104 | # 105 | # -------------------------------------------------------------- 106 | AC_DEFUN([PKG_CHECK_MODULES], 107 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 108 | AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 109 | AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl 110 | 111 | pkg_failed=no 112 | AC_MSG_CHECKING([for $1]) 113 | 114 | _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) 115 | _PKG_CONFIG([$1][_LIBS], [libs], [$2]) 116 | 117 | m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS 118 | and $1[]_LIBS to avoid the need to call pkg-config. 119 | See the pkg-config man page for more details.]) 120 | 121 | if test $pkg_failed = yes; then 122 | AC_MSG_RESULT([no]) 123 | _PKG_SHORT_ERRORS_SUPPORTED 124 | if test $_pkg_short_errors_supported = yes; then 125 | $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` 126 | else 127 | $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` 128 | fi 129 | # Put the nasty error message in config.log where it belongs 130 | echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 131 | 132 | m4_default([$4], [AC_MSG_ERROR( 133 | [Package requirements ($2) were not met: 134 | 135 | $$1_PKG_ERRORS 136 | 137 | Consider adjusting the PKG_CONFIG_PATH environment variable if you 138 | installed software in a non-standard prefix. 139 | 140 | _PKG_TEXT])[]dnl 141 | ]) 142 | elif test $pkg_failed = untried; then 143 | AC_MSG_RESULT([no]) 144 | m4_default([$4], [AC_MSG_FAILURE( 145 | [The pkg-config script could not be found or is too old. Make sure it 146 | is in your PATH or set the PKG_CONFIG environment variable to the full 147 | path to pkg-config. 148 | 149 | _PKG_TEXT 150 | 151 | To get pkg-config, see .])[]dnl 152 | ]) 153 | else 154 | $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 155 | $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 156 | AC_MSG_RESULT([yes]) 157 | $3 158 | fi[]dnl 159 | ])# PKG_CHECK_MODULES 160 | 161 | 162 | # PKG_INSTALLDIR(DIRECTORY) 163 | # ------------------------- 164 | # Substitutes the variable pkgconfigdir as the location where a module 165 | # should install pkg-config .pc files. By default the directory is 166 | # $libdir/pkgconfig, but the default can be changed by passing 167 | # DIRECTORY. The user can override through the --with-pkgconfigdir 168 | # parameter. 169 | AC_DEFUN([PKG_INSTALLDIR], 170 | [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) 171 | m4_pushdef([pkg_description], 172 | [pkg-config installation directory @<:@]pkg_default[@:>@]) 173 | AC_ARG_WITH([pkgconfigdir], 174 | [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, 175 | [with_pkgconfigdir=]pkg_default) 176 | AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) 177 | m4_popdef([pkg_default]) 178 | m4_popdef([pkg_description]) 179 | ]) dnl PKG_INSTALLDIR 180 | 181 | 182 | # PKG_NOARCH_INSTALLDIR(DIRECTORY) 183 | # ------------------------- 184 | # Substitutes the variable noarch_pkgconfigdir as the location where a 185 | # module should install arch-independent pkg-config .pc files. By 186 | # default the directory is $datadir/pkgconfig, but the default can be 187 | # changed by passing DIRECTORY. The user can override through the 188 | # --with-noarch-pkgconfigdir parameter. 189 | AC_DEFUN([PKG_NOARCH_INSTALLDIR], 190 | [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) 191 | m4_pushdef([pkg_description], 192 | [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) 193 | AC_ARG_WITH([noarch-pkgconfigdir], 194 | [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, 195 | [with_noarch_pkgconfigdir=]pkg_default) 196 | AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) 197 | m4_popdef([pkg_default]) 198 | m4_popdef([pkg_description]) 199 | ]) dnl PKG_NOARCH_INSTALLDIR 200 | 201 | 202 | # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, 203 | # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 204 | # ------------------------------------------- 205 | # Retrieves the value of the pkg-config variable for the given module. 206 | AC_DEFUN([PKG_CHECK_VAR], 207 | [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 208 | AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl 209 | 210 | _PKG_CONFIG([$1], [variable="][$3]["], [$2]) 211 | AS_VAR_COPY([$1], [pkg_cv_][$1]) 212 | 213 | AS_VAR_IF([$1], [""], [$5], [$4])dnl 214 | ])# PKG_CHECK_VAR 215 | -------------------------------------------------------------------------------- /modules/metabash/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Config file for GNU Automake. 2 | ## 3 | ## Copyright (C) 2015 Artyom V. Poptsov 4 | ## 5 | ## This file is part of Metabash. 6 | ## 7 | ## Metabash is free software: you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License as 9 | ## published by the Free Software Foundation, either version 3 of the 10 | ## License, or (at your option) any later version. 11 | ## 12 | ## Metabash is distributed in the hope that it will be useful, but 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | ## General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with Metabash. If not, see . 19 | 20 | include $(top_srcdir)/am/guilec 21 | 22 | SUBDIRS = core 23 | 24 | SOURCES = \ 25 | plumber.scm \ 26 | diff.scm 27 | 28 | GOBJECTS = $(SOURCES:%.scm=%.go) 29 | moddir=$(guilesitedir)/metabash 30 | nobase_dist_mod_DATA = $(SOURCES) 31 | 32 | ccachedir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache/metabash 33 | nobase_nodist_ccache_DATA = $(GOBJECTS) 34 | 35 | # Make sure source files are installed first, so that the mtime of 36 | # installed compiled files is greater than that of installed source 37 | # files. See 38 | # 39 | # for details. 40 | guile_dsv_install_go_files = install-nobase_dist_ccacheDATA 41 | $(guile_dsv_install_go_files): install-nobase_dist_modDATA 42 | 43 | GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat 44 | SUFFIXES = .scm .go 45 | 46 | guilec_opts = --load-path=$(abs_top_srcdir)/modules/ 47 | .scm.go: 48 | $(AM_V_GUILEC)$(guilec_env) $(GUILEC) $(guilec_opts) \ 49 | --output=$@ $< 50 | 51 | clean-go: 52 | -$(RM) $(GOBJECTS) 53 | .PHONY: clean-go 54 | 55 | CLEANFILES = \ 56 | $(GOBJECTS) 57 | 58 | # Makefile.am ends here 59 | -------------------------------------------------------------------------------- /modules/metabash/core/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Config file for GNU Automake. 2 | ## 3 | ## Copyright (C) 2020 Artyom V. Poptsov 4 | ## 5 | ## This file is part of Metabash. 6 | ## 7 | ## Metabash is free software: you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License as 9 | ## published by the Free Software Foundation, either version 3 of the 10 | ## License, or (at your option) any later version. 11 | ## 12 | ## Metabash is distributed in the hope that it will be useful, but 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | ## General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with Metabash. If not, see . 19 | 20 | include $(top_srcdir)/am/guilec 21 | 22 | SUBDIRS = plumbing 23 | 24 | SOURCES = \ 25 | process.scm \ 26 | pipeline.scm \ 27 | redirection.scm 28 | 29 | GOBJECTS = $(SOURCES:%.scm=%.go) 30 | moddir=$(guilesitedir)/metabash/core/ 31 | nobase_dist_mod_DATA = $(SOURCES) 32 | 33 | ccachedir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache/metabash/core/ 34 | nobase_nodist_ccache_DATA = $(GOBJECTS) 35 | 36 | # Make sure source files are installed first, so that the mtime of 37 | # installed compiled files is greater than that of installed source 38 | # files. See 39 | # 40 | # for details. 41 | guile_dsv_install_go_files = install-nobase_dist_ccacheDATA 42 | $(guile_dsv_install_go_files): install-nobase_dist_modDATA 43 | 44 | GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat 45 | SUFFIXES = .scm .go 46 | 47 | guilec_opts = --load-path=$(abs_top_srcdir)/modules/ 48 | .scm.go: 49 | $(AM_V_GUILEC)$(guilec_env) $(GUILEC) $(guilec_opts) \ 50 | --output=$@ $< 51 | 52 | clean-go: 53 | -$(RM) $(GOBJECTS) 54 | .PHONY: clean-go 55 | 56 | CLEANFILES = \ 57 | $(GOBJECTS) 58 | 59 | # Makefile.am ends here 60 | -------------------------------------------------------------------------------- /modules/metabash/core/pipeline.scm: -------------------------------------------------------------------------------- 1 | ;;; plumber.scm -- Metabash plumbering procedures. 2 | 3 | ;; Copyright (C) 2020 Artyom V. Poptsov 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; The program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with the program. If not, see . 17 | 18 | 19 | ;;; Commentary: 20 | 21 | ;; This file contains procedures description of the pipeline. 22 | 23 | 24 | ;;; Code: 25 | 26 | (define-module (metabash core pipeline) 27 | #:use-module (metabash core plumbing pipe) 28 | #:use-module (metabash core process) 29 | #:use-module (oop goops) 30 | #:use-module (ssh dist node) 31 | #:use-module (srfi srfi-9 gnu) 32 | #:use-module (srfi srfi-11) 33 | #:use-module (ice-9 rdelim) 34 | #:use-module (ice-9 binary-ports) 35 | #:use-module (ice-9 textual-ports) 36 | #:export ( 37 | pipeline? 38 | pipeline-pipes 39 | pipeline-processes 40 | pipeline-output-port 41 | pipeline-input-port 42 | pipeline-pretty-print 43 | last)) 44 | 45 | 46 | 47 | (define (last lst) 48 | "Get the last element of a list LST." 49 | (and (not (null? lst)) 50 | (car (last-pair lst)))) 51 | 52 | 53 | 54 | (define-class () 55 | (pipes #:accessor pipeline-pipes 56 | #:init-value '() 57 | #:init-keyword #:pipes) 58 | (processes #:accessor pipeline-processes 59 | #:init-value '() 60 | #:init-keyword #:processes)) 61 | 62 | (define (pipeline? x) 63 | (is-a? x )) 64 | 65 | (define-method (display (pipeline ) (port )) 66 | (format port "#" 67 | (length (pipeline-processes pipeline)) 68 | (length (pipeline-pipes pipeline)) 69 | (number->string (object-address pipe) 16))) 70 | 71 | (define-method (write (pipeline ) (port )) 72 | (display pipeline port)) 73 | 74 | (define-method (display (pipeline )) 75 | (next-method) 76 | (display pipeline (current-output-port))) 77 | 78 | (define-method (write (pipeline )) 79 | (next-method) 80 | (display pipeline (current-output-port))) 81 | 82 | (define-method (pipeline-input-port (pipeline )) 83 | (process-input-port (car (pipeline-processes pipeline)))) 84 | 85 | (define-method (pipeline-output-port (pipeline )) 86 | (process-output-port (last (pipeline-processes pipeline)))) 87 | 88 | 89 | (define-generic pipeline-pretty-print) 90 | 91 | ;; Pretty-print the given PIPELINE to the given PORT. 92 | (define-method (pipeline-pretty-print (pipeline ) (port )) 93 | (format port ";;; ~a~%" pipeline) 94 | (let loop ((processes (pipeline-processes pipeline)) 95 | (pipes (pipeline-pipes pipeline))) 96 | (format port ";;; ~a~%" (car processes)) 97 | (unless (null? pipes) 98 | (format port ";;; ~a~%" (car pipes))) 99 | (when (> (length processes) 1) 100 | (loop (cdr processes) 101 | (if (null? pipes) pipes (cdr pipes)))))) 102 | 103 | ;; Pretty-print the given PIPELINE to the current output port. 104 | (define-method (pipeline-pretty-print (pipeline )) 105 | (pipeline-pretty-print pipeline (current-output-port))) 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /modules/metabash/core/plumbing/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Makefile.am -- Config file for GNU Automake. 2 | ## 3 | ## Copyright (C) 2020 Artyom V. Poptsov 4 | ## 5 | ## This file is part of Metabash. 6 | ## 7 | ## Metabash is free software: you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License as 9 | ## published by the Free Software Foundation, either version 3 of the 10 | ## License, or (at your option) any later version. 11 | ## 12 | ## Metabash is distributed in the hope that it will be useful, but 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | ## General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with Metabash. If not, see . 19 | 20 | include $(top_srcdir)/am/guilec 21 | 22 | SOURCES = \ 23 | pipe.scm \ 24 | tee.scm 25 | 26 | GOBJECTS = $(SOURCES:%.scm=%.go) 27 | moddir=$(guilesitedir)/metabash/core/plumbing/ 28 | nobase_dist_mod_DATA = $(SOURCES) 29 | 30 | ccachedir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache/metabash/core/plumbing/ 31 | nobase_nodist_ccache_DATA = $(GOBJECTS) 32 | 33 | # Make sure source files are installed first, so that the mtime of 34 | # installed compiled files is greater than that of installed source 35 | # files. See 36 | # 37 | # for details. 38 | guile_dsv_install_go_files = install-nobase_dist_ccacheDATA 39 | $(guile_dsv_install_go_files): install-nobase_dist_modDATA 40 | 41 | GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat 42 | SUFFIXES = .scm .go 43 | 44 | guilec_opts = --load-path=$(abs_top_srcdir)/modules/ 45 | .scm.go: 46 | $(AM_V_GUILEC)$(guilec_env) $(GUILEC) $(guilec_opts) \ 47 | --output=$@ $< 48 | 49 | clean-go: 50 | -$(RM) $(GOBJECTS) 51 | .PHONY: clean-go 52 | 53 | CLEANFILES = \ 54 | $(GOBJECTS) 55 | 56 | # Makefile.am ends here 57 | -------------------------------------------------------------------------------- /modules/metabash/core/plumbing/pipe.scm: -------------------------------------------------------------------------------- 1 | ;;; pipe.scm -- Pipe implementation for Metabash. 2 | 3 | ;; Copyright (C) 2020 Artyom V. Poptsov 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; The program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with the program. If not, see . 17 | 18 | 19 | ;;; Commentary: 20 | 21 | ;; This file contains implementation of pipes that can connect two ports 22 | ;; together akin to Unix pipes. 23 | 24 | 25 | ;;; Code: 26 | 27 | (define-module (metabash core plumbing pipe) 28 | #:use-module (oop goops) 29 | #:use-module (ice-9 threads) 30 | #:use-module (ice-9 binary-ports) 31 | #:use-module (rnrs bytevectors) 32 | #:export ( 33 | pipe? 34 | pipe-thread 35 | pipe-input-port 36 | pipe-output-port 37 | pipe-on-disconnect-callback 38 | pipe-connect! 39 | pipe-connected? 40 | pipe-disconnect! 41 | pipe-close! 42 | pipe-closed? 43 | ;; tee 44 | 45 | tee-side-branch-port)) 46 | 47 | 48 | 49 | (define (object->naked-string object) 50 | "Convert an OBJECT to a 'naked' string, that is, without '#<' and '>'." 51 | (let ((str (object->string object))) 52 | (substring str 2 (- (string-length str) 1)))) 53 | 54 | 55 | ;;; Default callbacks. 56 | 57 | (define (%default-on-data-callback! pipe data) 58 | "Default callback to be called with new DATA is available from a PIPE input 59 | port." 60 | (slot-set! pipe 'tx (+ (pipe-tx pipe) (bytevector-length data)))) 61 | 62 | (define (%default-on-disconnect-callback! pipe) 63 | "Default callback to be called when a PIPE is closed." 64 | (close (pipe-input-port pipe)) 65 | (close (pipe-output-port pipe))) 66 | 67 | 68 | ;; This class describes a pipe (akin to Unix pipe) that can connect two ports 69 | ;; together by forwarding data from an INPUT-PORT to an OUTPUT-PORT in a 70 | ;; separate thread. 71 | (define-class () 72 | ;; 73 | ;; 74 | ;; The pipe thread. 75 | (thread #:accessor pipe-thread 76 | #:init-value #f) 77 | 78 | ;; 79 | ;; 80 | ;; The port from which the data will be read. 81 | (input-port #:accessor pipe-input-port 82 | #:init-value #f 83 | #:init-keyword #:input-port) 84 | 85 | ;; 86 | ;; 87 | ;; The port the data will be written to. 88 | (output-port #:accessor pipe-output-port 89 | #:init-value #f 90 | #:init-keyword #:output-port) 91 | 92 | ;; 93 | ;; 94 | ;; The total number of transmitted bytes. 95 | (tx #:accessor pipe-tx 96 | #:init-value 0) 97 | 98 | ;; 99 | ;; 100 | ;; This callback is called with the pipe instance and the data as an argument. 101 | ;; The default callback counts the transmitted data. 102 | (on-data-callback #:accessor pipe-on-data-callback 103 | #:init-value %default-on-data-callback! 104 | #:init-keyword #:on-data) 105 | 106 | ;; 107 | ;; 108 | ;; This callback is called with the pipe instance as an argument. The default 109 | ;; callback closes both input and output ports. 110 | (on-disconnect-callback #:accessor pipe-on-disconnect-callback 111 | #:init-value %default-on-disconnect-callback! 112 | #:init-keyword #:on-disconnect)) 113 | (define (pipe? x) 114 | "Check if X is a instance." 115 | (is-a? x )) 116 | 117 | 118 | ;; Overloaded methods to display a instance. 119 | 120 | (define-method (display (pipe ) (port )) 121 | (format port "# [~a] tx: ~a ~a>" 122 | (object->naked-string (pipe-input-port pipe)) 123 | (if (pipe-connected? pipe) 124 | "=" 125 | "x") 126 | (object->naked-string (pipe-output-port pipe)) 127 | (pipe-tx pipe) 128 | (number->string (object-address pipe) 16))) 129 | 130 | (define-method (write (pipe ) (port )) 131 | (display pipe port)) 132 | 133 | (define-method (display (pipe )) 134 | (next-method) 135 | (display pipe (current-output-port))) 136 | 137 | (define-method (write (pipe )) 138 | (next-method) 139 | (display pipe (current-output-port))) 140 | 141 | 142 | 143 | (define-generic pipe-connect!) 144 | 145 | ;; Make a new pipe that connects INPUT-PORT and OUTPUT-PORT. 146 | (define-method (pipe-connect! (pipe )) 147 | (let ((input-port (pipe-input-port pipe)) 148 | (output-port (pipe-output-port pipe))) 149 | (when (pipe-closed? pipe) 150 | (error "One of the ports is closed." input-port output-port)) 151 | (slot-set! pipe 'thread 152 | (begin-thread 153 | (let loop ((data (get-bytevector-some input-port))) 154 | (unless (or (port-closed? input-port) 155 | (port-closed? output-port)) 156 | (if (eof-object? data) 157 | ((pipe-on-disconnect-callback pipe) pipe) 158 | (begin 159 | ((pipe-on-data-callback pipe) pipe data) 160 | (put-bytevector output-port data) 161 | (loop (get-bytevector-some input-port)))))))))) 162 | 163 | ;; Predicate. Check if a PIPE is connected (that is, the pipe thread is 164 | ;; running.) 165 | (define-method (pipe-connected? (pipe )) 166 | (and (not (equal? (pipe-thread pipe) #f)) 167 | (not (thread-exited? (pipe-thread pipe))))) 168 | 169 | 170 | 171 | (define-generic pipe-disconnect!) 172 | 173 | ;; Disconnect a PIPE by stopping the pipe thread. Note that the ports will not 174 | ;; be closed. 175 | (define-method (pipe-disconnect! (pipe )) 176 | (cancel-thread (pipe-thread pipe)) 177 | (join-thread (pipe-thread pipe)) 178 | (slot-set! pipe 'thread #f)) 179 | 180 | 181 | 182 | (define-generic pipe-close!) 183 | 184 | ;; Close a specified PIPE. 185 | (define-method (pipe-close! (pipe )) 186 | (pipe-disconnect! pipe) 187 | (close (pipe-input-port pipe)) 188 | (close (pipe-output-port pipe))) 189 | 190 | 191 | (define-generic pipe-closed?) 192 | 193 | ;; Predicate. Check if a PIPE is closed. The PIPE considered as closed if one 194 | ;; of the pipe ports is closed. 195 | (define-method (pipe-closed? (pipe )) 196 | (or (port-closed? (pipe-input-port pipe)) 197 | (port-closed? (pipe-output-port pipe)))) 198 | 199 | ;;; pipe.scm ends here. 200 | -------------------------------------------------------------------------------- /modules/metabash/core/plumbing/tee.scm: -------------------------------------------------------------------------------- 1 | ;;; tee.scm -- Tee implementation for Metabash. 2 | 3 | ;; Copyright (C) 2020 Artyom V. Poptsov 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; The program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with the program. If not, see . 17 | 18 | 19 | ;;; Commentary: 20 | 21 | ;; This file contains implementation of a tee that can connect an input port to 22 | ;; two output ports effectively copying the output to two ports simultaneously , 23 | ;; akin to the Unix 'tee' command. 24 | 25 | 26 | ;;; Code: 27 | 28 | (define-module (metabash core plumbing tee) 29 | #:use-module (oop goops) 30 | #:use-module (metabash core plumbing pipe) 31 | #:export ( 32 | tee-side-branch-port)) 33 | 34 | 35 | 36 | ;;; Tee implementation. 37 | 38 | ;; This class describes a tee that can send a data from an INPUT-PORT to both an 39 | ;; OUTPUT-PORT and a SIDE-BRANCH-PORT. 40 | (define-class () 41 | (side-branch-port #:accessor tee-side-branch-port 42 | #:init-value #f 43 | #:init-keyword #:side-branch-port)) 44 | 45 | 46 | ;;; Default tee callbacks. 47 | 48 | (define (%default-tee-on-disconnect-callback! tee) 49 | "Default callback to be called when a PIPE is closed." 50 | (close (pipe-input-port tee)) 51 | (close (pipe-output-port tee)) 52 | (close (tee-side-branch-port tee))) 53 | 54 | 55 | ;;; The constructor. 56 | 57 | (define-method (initialize (tee ) initargs) 58 | (next-method) 59 | (unless (memq #:on-disconnect initargs) 60 | (slot-set! tee 'on-disconnect-callback 61 | %default-tee-on-disconnect-callback!))) 62 | 63 | 64 | ;; Overloaded methods to display a instance. 65 | 66 | ;; TODO: Make the format less cumbersome. 67 | (define-method (display (tee ) (port )) 68 | (format port "# [~a], [~a] tx: ~a ~a>" 69 | (object->naked-string (pipe-input-port tee)) 70 | (if (pipe-thread tee) 71 | "=" 72 | "x") 73 | (object->naked-string (tee-side-branch-port tee)) 74 | (object->naked-string (pipe-output-port tee)) 75 | (pipe-tx tee) 76 | (number->string (object-address tee) 16))) 77 | 78 | (define-method (write (tee ) (port )) 79 | (display tee port)) 80 | 81 | (define-method (display (tee )) 82 | (next-method) 83 | (display tee (current-output-port))) 84 | 85 | (define-method (write (tee )) 86 | (next-method) 87 | (display tee (current-output-port))) 88 | 89 | 90 | 91 | ;; Redirect data from INPUT-PORT to OUTPUT-PORT and BRANCH-OUTPUT-PORT. 92 | (define-method (pipe-connect! (tee )) 93 | (let ((input-port (pipe-input-port tee)) 94 | (output-port (pipe-output-port tee)) 95 | (branch-port (tee-side-branch-port tee))) 96 | (when (pipe-closed? tee) 97 | (error "One of the ports is closed." 98 | input-port output-port branch-port)) 99 | (slot-set! tee 'thread 100 | (begin-thread 101 | (let loop ((data (get-bytevector-some input-port))) 102 | (unless (eof-object? data) 103 | (slot-set! tee 'tx (+ (pipe-tx tee) (bytevector-length data))) 104 | (put-bytevector branch-port data) 105 | (put-bytevector output-port data) 106 | (loop (get-bytevector-some input-port)))))))) 107 | 108 | 109 | 110 | ;; Close a specified TEE by stopping the thread and closing the ports. 111 | (define-method (pipe-close! (tee )) 112 | (pipe-disconnect! tee) 113 | (close (pipe-input-port tee)) 114 | (close (tee-side-branch-port tee)) 115 | (close (pipe-output-port tee))) 116 | 117 | ;; Check if a TEE is closed. The tee is considered as closed if any of its 118 | ;; ports is closed. 119 | (define-method (pipe-closed? (tee )) 120 | (or (port-closed? (pipe-input-port tee)) 121 | (port-closed? (pipe-output-port tee)) 122 | (port-closed? (tee-side-branch-port tee)))) 123 | 124 | ;;; tee.scm ends here. 125 | 126 | -------------------------------------------------------------------------------- /modules/metabash/core/process.scm: -------------------------------------------------------------------------------- 1 | ;;; process.scm -- Metabash process implementation. 2 | 3 | ;; Copyright (C) 2020 Artyom V. Poptsov 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; The program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with the program. If not, see . 17 | 18 | 19 | ;;; Commentary: 20 | 21 | ;; This file contains implementation of Metabash processes. 22 | 23 | 24 | ;;; Code: 25 | 26 | (define-module (metabash core process) 27 | #:use-module (oop goops) 28 | #:use-module (ice-9 popen) 29 | #:use-module (ice-9 rdelim) 30 | #:use-module (ssh popen) 31 | #:use-module (ssh session) 32 | #:use-module (ssh dist) 33 | #:export ( 34 | process? 35 | process-input-port 36 | process-output-port 37 | process-state 38 | process-host 39 | process-command 40 | process-fifo-name 41 | process-start! 42 | process-started? 43 | process-stop! 44 | process-stopped? 45 | make-remote-fifo)) 46 | 47 | (define-class () 48 | ;; 49 | ;; 50 | ;; Process state. Available states: 51 | ;; stopped, started 52 | (state #:accessor process-state 53 | #:setter process-state-set! 54 | #:init-value 'stopped) 55 | 56 | ;; | #f 57 | (host #:accessor process-host 58 | #:init-value #f 59 | #:init-keyword #:host) 60 | ;; 61 | (command #:accessor process-command 62 | #:init-value "/bin/true" 63 | #:init-keyword #:command) 64 | ;; 65 | (fifo-name #:accessor process-fifo-name 66 | #:init-value #f) 67 | ;; 68 | (input-port #:accessor process-input-port 69 | #:init-value #f) 70 | ;; 71 | (output-port #:accessor process-output-port 72 | #:init-value #f)) 73 | 74 | (define (process? x) 75 | (is-a? x )) 76 | 77 | 78 | 79 | (define-method (process-stopped? (proc )) 80 | (equal? (process-state proc) 'stopped)) 81 | 82 | (define-method (process-started? (proc )) 83 | (equal? (process-state proc) 'started)) 84 | 85 | 86 | 87 | (define-method (display (proc ) (port )) 88 | (format port "#" 89 | (if (or (process-stopped? proc) 90 | (port-closed? (process-input-port proc))) 91 | "x" 92 | "=") 93 | (if (process-started? proc) 94 | "=" 95 | "x") 96 | (if (or (process-stopped? proc) 97 | (port-closed? (process-output-port proc))) 98 | "x" 99 | "=") 100 | 101 | (let ((host (process-host proc))) 102 | (cond 103 | ((string? host) 104 | (string-append host ": ")) 105 | ((session? host) 106 | (string-append (session-get host 'host) ": ")) 107 | (else 108 | ""))) 109 | 110 | (car (string-split (process-command proc) #\space)) 111 | 112 | (number->string (object-address pipe) 16))) 113 | 114 | (define-method (write (proc ) (port )) 115 | (display proc port)) 116 | 117 | (define-method (display (proc )) 118 | (next-method) 119 | (display proc (current-output-port))) 120 | 121 | (define-method (write (proc )) 122 | (next-method) 123 | (display proc (current-output-port))) 124 | 125 | 126 | 127 | (define (make-remote-fifo session) 128 | "Make a remote FIFO using a SSH session. Return the FIFO name." 129 | (read-line 130 | (open-remote-input-pipe 131 | session 132 | "export NAME=$(mktemp --dry-run) && mkfifo ${NAME} && echo ${NAME}"))) 133 | 134 | 135 | 136 | (define-method (process-start! (proc )) 137 | (when (process-started? proc) 138 | (error "The process is already started" proc)) 139 | (let ((host (process-host proc)) 140 | (fifo-name (process-fifo-name proc)) 141 | (command (process-command proc))) 142 | (cond 143 | ((not host) 144 | (let ((fifo-name (tmpnam))) 145 | (system (string-append "mkfifo " fifo-name)) 146 | (let ((input-port (open-output-pipe 147 | (string-append command " > " fifo-name))) 148 | (output-port (open-input-pipe 149 | (string-append "cat " fifo-name)))) 150 | (slot-set! proc 'input-port input-port) 151 | (slot-set! proc 'output-port output-port) 152 | (slot-set! proc 'fifo-name fifo-name)))) 153 | ((session? host) 154 | (let* ((fifo-name (make-remote-fifo host)) 155 | (input-port (open-remote-output-pipe 156 | host 157 | (string-append command " > " fifo-name))) 158 | (output-port (open-remote-input-pipe 159 | host 160 | (string-append "cat " fifo-name)))) 161 | (slot-set! proc 'input-port input-port) 162 | (slot-set! proc 'output-port output-port) 163 | (slot-set! proc 'fifo-name fifo-name))) 164 | (else 165 | (error "Wrong argument type: " host)))) 166 | (process-state-set! proc 'started)) 167 | 168 | (define-method (process-stop! (proc )) 169 | (when (process-stopped? proc) 170 | (error "The process is already stopped" proc)) 171 | (close (process-input-port proc)) 172 | (close (process-output-port proc)) 173 | (slot-set! proc 'fifo-name #f) 174 | (let ((host (process-host proc))) 175 | (cond 176 | ((not host) 177 | (when (process-fifo-name proc) 178 | (delete-file (process-fifo-name proc)))) 179 | ((session? (process-host proc)) 180 | (with-ssh (make-node host) 181 | (delete-file (process-fifo-name proc)))))) 182 | (process-state-set! proc 'stopped)) 183 | 184 | ;;; process.scm ends here. 185 | -------------------------------------------------------------------------------- /modules/metabash/core/redirection.scm: -------------------------------------------------------------------------------- 1 | ;;; redirection.scm -- Output redirection procedures. 2 | 3 | ;; Copyright (C) 2020 Artyom V. Poptsov 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; The program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with the program. If not, see . 17 | 18 | 19 | ;;; Commentary: 20 | 21 | ;; This file contains implementation redirection procedures. 22 | 23 | 24 | ;;; Code: 25 | 26 | (define-module (metabash core redirection) 27 | #:use-module (oop goops) 28 | #:use-module (metabash core plumbing pipe) 29 | #:use-module (metabash core process) 30 | #:use-module (metabash core pipeline) 31 | #:export (M> M>>)) 32 | 33 | ;;; Redirections. 34 | 35 | (define-generic M>) 36 | 37 | (define-method (%redirect (input-port ) (file-name ) (mode )) 38 | (let* ((file-port (open-file file-name mode)) 39 | (pipe (make 40 | #:input-port input-port 41 | #:output-port file-port))) 42 | (pipe-connect! pipe) 43 | pipe)) 44 | 45 | ;; Redirect output from an INPUT-PORT to a FILE-NAME. The contents of the file 46 | ;; will be overwritten. 47 | (define-method (M> (input-port ) (file-name )) 48 | (%redirect input-port file-name "wb")) 49 | 50 | (define-method (M> (process ) (file-name )) 51 | (M> (process-output-port process) file-name)) 52 | 53 | (define-method (M> (pipeline ) (file-name )) 54 | (M> (pipeline-output-port pipeline) file-name)) 55 | 56 | 57 | 58 | (define-generic M>>) 59 | 60 | ;; Redirect output from an INPUT-PORT to a FILE-NAME. The data will be appended 61 | ;; to the end of the file. 62 | (define-method (M>> (input-port ) (file-name )) 63 | (%redirect input-port file-name "ab")) 64 | 65 | (define-method (M>> (process ) (file-name )) 66 | (M>> (process-output-port process) file-name)) 67 | 68 | (define-method (M>> (pipeline ) (file-name )) 69 | (M>> (pipeline-output-port pipeline) file-name)) 70 | -------------------------------------------------------------------------------- /modules/metabash/diff.scm: -------------------------------------------------------------------------------- 1 | ;;; diff.scm -- Metabash diffutils. 2 | 3 | ;; Copyright (C) 2020 Artyom V. Poptsov 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; The program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with the program. If not, see . 17 | 18 | 19 | ;;; Commentary: 20 | 21 | ;; This file contains procedures that allow to check differences between 22 | ;; outputs. 23 | 24 | 25 | ;;; Code: 26 | 27 | (define-module (metabash diff) 28 | #:use-module (oop goops) 29 | #:use-module (ice-9 rdelim) 30 | #:use-module (ice-9 popen) 31 | #:use-module (metabash core plumbing pipe) 32 | #:use-module (metabash core process) 33 | #:use-module (metabash core pipeline) 34 | #:use-module (metabash core redirection) 35 | #:export (diff)) 36 | 37 | (define (mktempdir template) 38 | "Make a temporary directory with the name as specified by a TEMPLATE." 39 | (read-line (open-input-pipe (string-append "mktemp -d '" template "'")))) 40 | 41 | (define (make-diff-command f1 f2) 42 | (format #f "diff '~a' '~a'" f1 f2)) 43 | 44 | 45 | (define-generic diff) 46 | 47 | ;; Read and compare an input from an INPUT-PORT-1 with an input from 48 | ;; INPUT-PORT-2, print differences in Unix diff format to an OUTPUT-PORT. 49 | (define-method (diff (input-port-1 ) (input-port-2 ) (output-port )) 50 | (let* ((template "/tmp/metabash-XXXXXX") 51 | (directory (mktempdir template)) 52 | (file1 (string-append directory "/input-1")) 53 | (file2 (string-append directory "/input-2")) 54 | (pipe1 (M> input-port-1 file1)) 55 | (pipe2 (M> input-port-2 file2))) 56 | 57 | (while (or (not (port-closed? input-port-1)) 58 | (not (port-closed? input-port-2))) 59 | (sleep 1)) 60 | 61 | (pipe-close! pipe1) 62 | (pipe-close! pipe2) 63 | 64 | (let ((process (make #:command (make-diff-command file1 file2)))) 65 | 66 | (process-start! process) 67 | 68 | (let ((output-pipe (make 69 | #:input-port (process-output-port process) 70 | #:output-port output-port))) 71 | (pipe-connect! output-pipe) 72 | 73 | (while (pipe-connected? output-pipe) 74 | (sleep 1)) 75 | 76 | (delete-file file1) 77 | (delete-file file2) 78 | (rmdir directory) 79 | 80 | (pipe-close! output-pipe))))) 81 | 82 | ;; Read and compare an input from a PIPELINE-1 with an input from a PIPELINE-2, 83 | ;; print differences in Unix diff format to an OUTPUT-PORT. 84 | (define-method (diff (pipeline-1 ) (pipeline-2 ) (output-port )) 85 | (diff (pipeline-output-port pipeline-1) 86 | (pipeline-output-port pipeline-2) 87 | output-port)) 88 | 89 | ;;; diff.scm ends here. 90 | -------------------------------------------------------------------------------- /modules/metabash/plumber.scm: -------------------------------------------------------------------------------- 1 | ;;; plumber.scm -- Metabash plumbering procedures. 2 | 3 | ;; Copyright (C) 2020 Artyom V. Poptsov 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; The program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with the program. If not, see . 17 | 18 | 19 | ;;; Commentary: 20 | 21 | ;; This file contains procedures for connecting processes in a pipeline, namely 22 | ;; the 'plumb' procedure. 23 | 24 | 25 | ;;; Code: 26 | 27 | (define-module (metabash plumber) 28 | #:use-module (metabash core plumbing pipe) 29 | #:use-module (metabash core process) 30 | #:use-module (metabash core pipeline) 31 | #:use-module (oop goops) 32 | #:use-module (ssh dist node) 33 | #:use-module (srfi srfi-9 gnu) 34 | #:use-module (srfi srfi-11) 35 | #:use-module (ice-9 rdelim) 36 | #:use-module (ice-9 binary-ports) 37 | #:use-module (ice-9 textual-ports) 38 | #:export (plumb 39 | M#!)) 40 | 41 | 42 | ;;; Helper procedures. 43 | 44 | (define (append-1 lst elem) 45 | (append lst (list elem))) 46 | 47 | 48 | 49 | (define-method (run-local (command )) 50 | "Run local COMMAND." 51 | (let ((proc (make #:command (cadr command)))) 52 | (process-start! proc) 53 | proc)) 54 | 55 | (define-method (run-remote (command )) 56 | "Run a remote command using Guile-SSH." 57 | (let* ((host (cadr command)) 58 | (cmd (caddr command)) 59 | (proc (make #:host host #:command cmd))) 60 | (process-start! proc) 61 | proc)) 62 | 63 | (define-method (run-guile (command )) 64 | "Run a GNU Guile command in a local or a remote process." 65 | (let* ((host (cadr command)) 66 | (proc (make #:host host #:command "sh -c guile -q --"))) 67 | (process-start! proc) 68 | (write-line ",option prompt \"\"" (process-input-port proc)) 69 | (rrepl-skip-to-prompt (process-output-port proc)) 70 | (write (caddr command) (process-input-port proc)) 71 | (newline (process-input-port proc)) 72 | (force-output (process-input-port proc)) 73 | proc)) 74 | 75 | (define-method (append-process (process-list ) (pipe-list ) process) 76 | "Append a new PROCESS to the PROCESS-LIST. If the PROCESS-LIST is not empty, 77 | connect the last process from the list with the new PROCESS. 78 | 79 | Return two values: updated PROCESS-LIST with the new PROCESS and updated 80 | PIPE-LIST." 81 | (let ((last-proc (last process-list))) 82 | (if last-proc 83 | (let ((pipe (make 84 | #:input-port (process-output-port last-proc) 85 | #:output-port (process-input-port process)))) 86 | (pipe-connect! pipe) 87 | (values (append-1 process-list process) 88 | (append-1 pipe-list pipe))) 89 | (values (append-1 process-list process) 90 | pipe-list)))) 91 | 92 | (define (plumb . spec) 93 | "Make a pipeline using the SPEC." 94 | (let loop ((sp spec) 95 | (processes '()) 96 | (pipes '())) 97 | (if (not (null? sp)) 98 | (let* ((command (car sp)) 99 | (type (car command))) 100 | (case type 101 | ((local) 102 | (let-values (((process-list pipe-list) 103 | (append-process processes pipes (run-local command)))) 104 | (loop (cdr sp) process-list pipe-list))) 105 | ((remote) 106 | (let-values (((process-list pipe-list) 107 | (append-process processes pipes (run-remote command)))) 108 | (loop (cdr sp) process-list pipe-list))) 109 | ((guile) 110 | (let-values (((process-list pipe-list) 111 | (append-process processes pipes (run-guile command)))) 112 | (loop (cdr sp) process-list pipe-list))))) 113 | (make #:pipes pipes #:processes processes)))) 114 | 115 | 116 | 117 | ;; Convenient macro that do the plumbing. 118 | (define-syntax M#! 119 | (lambda (x) 120 | 121 | (define (-> commands) 122 | (syntax-case commands (=>) 123 | ((type command) 124 | #`((list (quote type) command))) 125 | ((type command => rest ...) 126 | (with-syntax (((r ...) (-> #'(rest ...)))) 127 | #'((list (quote type) command) r ...))) 128 | ((type host command) 129 | #`((list (quote type) host command))) 130 | ((type host command => rest ...) 131 | (with-syntax (((r ...) (-> #'(rest ...)))) 132 | #'((list (quote type) host command) r ...))))) 133 | 134 | (syntax-case x (=>) 135 | ((_ type command) #'(plumb (list (quote type) command))) 136 | ((_ type host command) #'(plumb (list (quote type) host command))) 137 | ((_ type command => rest ...) 138 | (with-syntax (((wrapper ...) (-> #'(rest ...)))) 139 | #`(apply plumb (list (list (quote type) command) wrapper ...)))) 140 | ((_ type host command => rest ...) 141 | (with-syntax (((wrapper ...) (-> #'(rest ...)))) 142 | #`(apply plumb (list (list (quote type) host command) wrapper ...))))))) 143 | 144 | ;;; plumber.scm ends here. 145 | -------------------------------------------------------------------------------- /utils/README.org: -------------------------------------------------------------------------------- 1 | * Supervisor configuration file 2 | Configuration should be placed in =config.scm= file. 3 | 4 | Configuration example: 5 | 6 | #+BEGIN_EXAMPLE scheme 7 | '((host . "example.org") 8 | (user . "avp") 9 | (port . "2222") 10 | (identity-file . "~/.ssh/id_rsa") 11 | (application-url . "https://my-site.example.com/index.html") 12 | (fixup-command . "echo") 13 | (fixup-command-args . "$(date): Service is down :-/ >> /tmp/log.txt")) 14 | #+END_EXAMPLE 15 | -------------------------------------------------------------------------------- /utils/supervisor: -------------------------------------------------------------------------------- 1 | #!/usr/bin/guile \ 2 | -e main 3 | !# 4 | 5 | ;; Copyright (C) 2017 Artyom V. Poptsov 6 | ;; 7 | ;; This program is free software: you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation, either version 3 of the License, or 10 | ;; (at your option) any later version. 11 | ;; 12 | ;; The program is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | ;; 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with the program. If not, see . 19 | 20 | (add-to-load-path ".") 21 | 22 | (use-modules (ice-9 getopt-long) 23 | (ice-9 popen) 24 | (ice-9 rdelim) 25 | (ssh session) 26 | (ssh popen) 27 | (metabash) 28 | (common)) 29 | 30 | 31 | ;;; 32 | 33 | (define* (supervise session 34 | #:key 35 | application-url 36 | fixup-command 37 | fixup-command-args) 38 | "Check the your service by accessing it by executing a COMMAND from 39 | a remote host described by a SESSION." 40 | (format-debug "reverse-check: fixup command: ~a ~a" 41 | fixup-command 42 | fixup-command-args) 43 | 44 | (unless (local-command-available? fixup-command) 45 | (error "Command is not avaiable on the local host" 46 | fixup-command)) 47 | 48 | (if (not (application-available? session application-url)) 49 | (let ((fixup-command (string-append fixup-command 50 | " " 51 | fixup-command-args))) 52 | (write-line (read-line (open-input-pipe fixup-command)))))) 53 | 54 | ;;; 55 | 56 | (define (read-config file) 57 | (let ((p (open-input-file file))) 58 | (read p))) 59 | 60 | 61 | ;;; 62 | 63 | (define %option-spec 64 | '((host (value #t) (required? #f)) 65 | (port (value #t) (required? #f)) 66 | (user (value #t) (required? #f)) 67 | (identity-file (value #t) (required? #f)) 68 | (help (value #f)))) 69 | 70 | 71 | ;;; Entry point. 72 | 73 | (define (main args) 74 | "Entry point." 75 | (let ((config (cadr (read-config "config.scm")))) 76 | (let* ((options (getopt-long args %option-spec)) 77 | (host (option-ref options 'host 78 | (assoc-ref config 'host))) 79 | (port (option-ref options 'port 80 | (assoc-ref config 'port))) 81 | (user (option-ref options 'user 82 | (assoc-ref config 'user))) 83 | (identity-file (option-ref options 'identity-file 84 | (assoc-ref config 'identity-file))) 85 | (session (make-session #:host host 86 | #:user user 87 | #:port (string->number port) 88 | #:identity identity-file))) 89 | (format-debug "identity-file: ~a" identity-file) 90 | (if (host-accessible? host) 91 | (begin 92 | (establish-session! session) 93 | (supervise session 94 | #:application-url 95 | (assoc-ref config 'application-url) 96 | #:fixup-command 97 | (assoc-ref config 'fixup-command) 98 | #:fixup-command-args 99 | (assoc-ref config 'fixup-command-args))) 100 | (error "Remote host is not accessible" host))))) 101 | 102 | ;; Local variables: 103 | ;; mode: Scheme 104 | ;; End: 105 | 106 | ;;; whale ends here. 107 | --------------------------------------------------------------------------------