From f548853a31c5ac48fffb7d589199be235ae307e3 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 6 Nov 2015 17:06:40 +0000 Subject: [PATCH] Initial commit Signed-off-by: Ikey Doherty --- .gitignore | 2 + LICENSE | 674 ++++++++++++++++++++++++++++ Makefile | 2 + README.rst | 334 ++++++++++++++ autospec.py | 206 +++++++++ build.py | 865 ++++++++++++++++++++++++++++++++++++ buildpattern.py | 379 ++++++++++++++++ buildreq.py | 374 ++++++++++++++++ config.py | 250 +++++++++++ count.pl | 1040 ++++++++++++++++++++++++++++++++++++++++++++ files.py | 400 +++++++++++++++++ git.py | 66 +++ lang.py | 52 +++ license.py | 275 ++++++++++++ patches.py | 44 ++ specdescription.py | 289 ++++++++++++ tarball.py | 294 +++++++++++++ test.py | 165 +++++++ translate.dic | 52 +++ util.py | 62 +++ 20 files changed, 5825 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.rst create mode 100644 autospec.py create mode 100644 build.py create mode 100644 buildpattern.py create mode 100644 buildreq.py create mode 100644 config.py create mode 100644 count.pl create mode 100644 files.py create mode 100644 git.py create mode 100644 lang.py create mode 100644 license.py create mode 100644 patches.py create mode 100644 specdescription.py create mode 100644 tarball.py create mode 100644 test.py create mode 100644 translate.dic create mode 100644 util.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d35cb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +*.pyc diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ba66447 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +check: *.py + @python3 /usr/bin/flake8 --max-line-length=199 --ignore=E402 $^ diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..d4d8ba6 --- /dev/null +++ b/README.rst @@ -0,0 +1,334 @@ +======== +Autospec +======== + +autospec is a tool to assist in the automated creation and maintainence +of RPM packaging. It will continuously run updated builds based on new +information discovered from build failures, until it has a complete and +valid .spec file. The tool makes use of mock to achieve this. + +License +======= +autospec is available under the terms of the GPL, version 3.0 + +Copyright (C) 2015 Intel Corporation + + +Configuration of autospec +========================= +autospec is configured by means of a simple INI-style configuration file. +The default location of this file is assumed to be ``common/autospec.conf``, +relative to the directory in which autospec is executed. + +Example ``autospec.conf`` file:: + + [autospec] + git = git@someurl.com/%(NAME)s + license_fetch = http://yourhost/hash.php + license_show = http://yourhost/showone.php?hash=%(HASH)s + upstream = http://yourhost/tarballs/%(HASH)s/%(NAME)s + + +**git** + The upstream git repository URL base + +**license_fetch** + Optional URL to use for scanning license files + +**license_show** + Optional URL to interact with online license checker + +**upstream** + Base URL for stored upstream tarballs + +Synopsis +======== + +Usage: ``python3 autospec.py [options] URL`` + + +-h, --help show help message and exit +-g, --skip-git Don't commit result to git +-n NAME, --name NAME Override the package name +-a ARCHIVES, --archives ARCHIVES + tarball URLs for additional source archives and a + location for the sources to be extacted to (e.g. + http://example.com/downloads/dependency.tar.gz + /directory/relative/to/extract/root ) +-l, --license-only Only scan for license files +-b, --skip-bump Don't bump release number +-c CONFIG, --config CONFIG Set configuration file to use + + +Requirements +============= + +In order to run correctly, ``autospec`` requires the following components: + + * python3 + * correctly configured mock + +If ``autospec`` is not configured to use a license server, then you will +need a ``common/licenses`` file - which should be an up to date list of +licenses to facilitate automatic license detection during the scan of a +tarball. For correctness, license names should be in the SPDX identifier +format. Each line in the file constitutes a license definition, for example:: + + 750b9d9cc986bfc80b47c9672c48ca615cac0c87 | BSD-3-Clause + 175e59be229a5bedc6be93e958a970385bb04a62 | Apache-2.0 + 794a893e510ca5c15c9c97a609ce47b0df74fc1a | BSD-2-Clause + + +Control files +============== + +It is possible to influence precisely how autospec will behave in order to +gain fine control over the build itself. These files may be used to alter +the default behaviour of the configure routine, to blacklist build dependencies +from being automatically added, and such. + +These files are expected to live in same directory that the resulting ``.spec`` +will live. + +Common files +------------ + +**release** + + This file contains the current release number that will be used in the + ``.spec``. This is also bumped and generated on existing and new packages, + respectively. This results in less manual work via automatic management. + +**$package.license** + + In certain cases, the package license may not be automatically discovered. + In this instance, ``autospec`` will exit with an error. Update this file + to contain the valid SPDX identifier for any license(s) for the package, + replacing ``$package`` in the filename with the actual package name. + +Controlling dependencies +------------------------- + +**buildreq_add** + + Each line in the file provides the name of a package to add + as a build dependency to the ``.spec``. + +**pkgconfig_add** + + Each line in the file is assumed to be a pkgconfig() build dependency. + Add the pkg-config names here, as ``autospec`` will automatically transform + the names into their ``pkgconfig($name)`` style when generating the ``.spec``. + +**buildreq_ban** + + Each line in the file is a build dependency that under no circumstance + should be automatically added to the build dependencies. This is useful + to block automatic configuration routines adding undesired functionality, + or to omit any automatically discovered dependencies during tarball scanning. + +**pkgconfig_ban** + + Each line in this file is a pkgconfig() build dependency that should not + be added automatically to the build, much the same as ``buildreq_ban``. + As with ``pkgconfig_add``, these names are automatically transformed by + ``autospec`` into their correct ``pkgconfig($name))`` style. + + +Controlling the build process +------------------------------ + +**configure** + + This file contains configuration flags to pass to the ``%configure`` + macro for autotools based tarballs. As an example, adding ``--disable-static`` + to ``./configure`` for an autootools based tarball would result in + ``%configure --disable-static`` being emitted in the ``.spec``. + +**cmake_args** + + This file contains arguments that should be passed to the ``%cmake`` + macro for CMake based tarballs. As an example, adding ``-DUSE_LIB64=ON`` to + ``./cmake_args`` would result in ``%cmake -DUSE_LIB64=ON`` being emitted + in the ``.spec``. + +**broken_parallel_build** + + If this file exists, then parallelisation will be disabled in the build. + This usually means that ``%{?_smp_mflags}`` will not be passed to ``make`` + +**make_args** + + The contents of this file are appended to the ``make`` invocation. This + may be useful for passing arguments to ``make``, i.e. ``make TOOLDIR=/usr`` + +**make_install_args** + + Much like ``make_args``, this will pass arguments to the ``make install`` + macro in the ``.spec`` + +**install_macro** + + The contents of this file be used instead of the automatically detected + ``install`` routine, i.e. use this if ``%make_install`` is insufficient. + +**subdir** + + Not all packages have their ``Makefile``'s available in the root of the tarball. + An example of this may be cross-platform projects that split Makefile's into + the ``unix`` subdirectory. Set the name in this file and the ``.spec`` will + emit the correct ``pushd`` and ``popd`` lines to utilise these directories + for each step in the build. + +**build_pattern** + + In certain situations, the automatically detected build pattern may not + work for the given package. This one line file allows you to override the + build pattern that ``autospec`` will use. The supported build_pattern types are: + + - configure: Traditional ``%configure`` autotools route + - configure_ac: Like ``configure, but performs ``%reconfigure`` to regenerate ``./configure`` + - autogen: Similar to ``configure_ac`` but uses the existing ``./autogen.sh`` instead of ``%reconfigure`` + - distutils: Only build the Pythonic package with Python 2 + - distutils23: Build the Pythonic package using both Python 2 and Python 3 + +**series** + + This file contains a list of patches to apply during the build, using the ``%patch`` + macro. As such it is affected by ``-p1`` style modifiers. + +Controlling files and subpackages +--------------------------------- + +**excludes** + + This file is used to generate ``%exclude`` lines in the ``.spec``. This + is useful for omitting files from being included in the resulting package. + Each line in the file should be a full path name. + +**keepstatic** + + If this file exists, then ``%define keepstatic 1`` is emitted in the ``.spec``. + As a result, any static archive (``.a``) files will not be removed by rpmbuild. + +**extras** + + Each line in the file should be a full path within the resulting package, + that you wish to be placed into an automatic ``-extras`` subpackage. This + allows one to keep the main package slim and split out optional functionality + or files. + +**setuid** + + Each line in this file should contain the full path to a binary in the resulting + build that should have the ``setuid`` attribute set with the ``%attr`` macro. + +**attrs** + + Each line in this file should be a full ``%attr`` macro line that will be included + in the ``.spec`` to have fine-grained control over the permissions and ownership + of files in the package. + + +Controlling test suites +----------------------- + +By default, ``autospec`` will attempt to detect potential test suites that +can be run in the ``%check`` portion of the ``.spec``. + +**skip_test_suite** + + If this file exists, ``autospec`` will not emit any ``%check`` functionality. + +**unit_tests_must_pass** + + This file is automatically created upon successful completion of a package build. + This allows one to identify regressions in test failures when updating or + altering a package. + ``autospec`` will fail a package that does not pass it's test suite if this file + exists. + +**make_check_command** + + Override or set the command to use in the ``%check`` portion of the ``.spec``. + This may be useful when a package uses a custom test suite, or requires + additional work/parameters, to work correctly. + +**allow_test_failures** + + The existence of this file will allow test failures, and will still emit + the ``%check`` code in a way that allows the build to continue. + + +Controlling flags and optimisation +----------------------------------- + +**asneeded** + + If this file exists, the ``.spec`` will disable the LD_AS_NEEDED variable. + Supporting binutils (such as found in Clear Linux Project for Intel Architecture) + will then revert to their normal behaviour, instead of enforcing ``-Wl,-as-needed`` + in the most correct sense. + +**optimize_size** + + If this file exists, the ``CFLAGS/LDFLAGS`` will be extended to build + the package optimised for *size*, and not for *speed*. Use this when + size is more critical than performance. + +**funroll-loops** + + If this file exists, the ``CFLAGS/LDFLAGS`` will be extended to build + the package optimised for *speed*. In short this where speed is of + paramount importance, and will use ``-03`` by default. + +**insecure_build** + + If this file exists, the ``CFLAGS/LDFLAGS`` will be **replaced**, using + the smallest ``-02`` based generic flags possible. This is useful for + operating systems employing heavy optimisations or full RELRO by default. + + +Name and version resolution +=========================== + +``autospec`` will attempt to use a number of patterns to determine the name +and version of the package by examining the URL. For most tarballs this is +simple, if they are of the format ``$name-$version.tar.$compression``. + +For websites such as ``bitbucket`` or ``GitHub``, using ``get$`` and ``v$.tar.*`` +style links, the project name itself is used from the URL and the version is +determined by stripping down the tag. + +CPAN Perl packages, R packages, and rubygems.org rubygems are automatically +prefixed with their language name: ``perl-``, ``R-`` and ``rubygem-`` respectively. + +When these automated detections are not desirable, it is possible to override +these with the ``--name`` flag when invoking ``autospec`` + + +Automatic license server support +================================ +``autospec`` can optionally talk to a license server instead of checking +local hashsum files, which enables greater coverage for license detection. +The URL set in ``license_fetch`` is expected to be a simple script that +talks HTTP. + +This URL should accept ``POST`` requests with the following keys: + +**hash** + Contains the SHA-1 hash of the potential license file being checked. + +**package** + The name of the package being examined + +**text** + The contents of the potential license file + +Implementations return a *plain text* response with the SPDX identifier +of the license, if known. An empty response is assumed to mean that this +license is unknown, in which case ``autospec`` will emit the ``license_show`` +URL. The implementation should show the now-stored license file via a +web page, and enable a human to make a decision on the license. This is +then stored internally, allowing future requests to automatically know +the license type when this hash is encounted again. diff --git a/autospec.py b/autospec.py new file mode 100644 index 0000000..e32301c --- /dev/null +++ b/autospec.py @@ -0,0 +1,206 @@ +#!/usr/bin/python3 +# +# autospec.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import argparse +import build +import buildpattern +import buildreq +import config +import files +import git +import lang +import license +import os +import patches +import re +import specdescription +import sys +import tarball +import test +import types +from tarball import name +from util import _file_write + +sys.path.append(os.path.dirname(__file__)) + + +def write_sources(file): + """Append additonal source files. + systemd unit files, gcov and additional source tarballs + are the currently supported additonal source file types.""" + source_count = 1 + for source in sorted(buildpattern.sources["unit"] + + buildpattern.sources["archive"] + + buildpattern.sources["tmpfile"] + + buildpattern.sources["gcov"]): + buildpattern.source_index[source] = source_count + file.write("Source{0} : {1}\n".format(source_count, source)) + source_count += 1 + + +def write_spec(filename): + file = open(filename, "w", encoding="utf-8") + file.write_strip = types.MethodType(_file_write, file) + file.write("#\n") + file.write("# This file is auto-generated. DO NOT EDIT\n") + file.write("# Generated by: autospec.py\n") + file.write("#\n") + + if config.keepstatic == 1: + file.write("%define keepstatic 1\n") + + # first, write the general package header + tarball.write_nvr(file) + write_sources(file) + specdescription.write_summary(file) + license.write_license(file) + + files.write_main_subpackage_requires(file) + buildreq.write_buildreq(file) + patches.write_patch_header(file) + + # then write the main package extra content + specdescription.write_description(file) + files.write_files_header(file) + + # then write the build instructions + buildpattern.write_buildpattern(file) + + # then write the scriplets + files.write_scriplets(file) + + # then write the %files + files.write_files(file) + lang.write_lang_files(file) + + file.close() + + +def add_sources(download_path, archives): + for file in os.listdir(download_path): + if re.search(".*\.(mount|service|socket|target)$", file): + buildpattern.sources["unit"].append(file) + buildpattern.sources["unit"].sort() + # + # systemd-tmpfiles uses the configuration files from + # /usr/lib/tmpfiles.d/ directories to describe the creation, + # cleaning and removal of volatile and temporary files and + # directories which usually reside in directories such as + # /run or /tmp. + # + if os.path.exists(os.path.normpath(build.download_path + + "/{0}.tmpfiles".format(tarball.name))): + buildpattern.sources["tmpfile"].append( + "{}.tmpfiles".format(tarball.name)) + if tarball.gcov_file: + buildpattern.sources["gcov"].append(tarball.gcov_file) + for archive, destination in zip(archives[::2], archives[1::2]): + buildpattern.sources["archive"].append(archive) + buildpattern.archive_details[archive + "destination"] = destination + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-g", "--skip-git", + action="store_false", dest="git", default=True, + help="Don't commit result to git") + parser.add_argument("-n", "--name", nargs=1, + action="store", dest="name", default="", + help="Override the package name") + parser.add_argument("url", + help="tarball URL (e.g." + " http://example.com/downloads/mytar.tar.gz)") + parser.add_argument('-a', "--archives", action="store", + dest="archives", default=[], nargs='*', + help="tarball URLs for additional source archives and" + " a location for the sources to be extacted to (e.g." + " http://example.com/downloads/dependency.tar.gz" + " /directory/relative/to/extract/root )") + parser.add_argument("-l", "--license-only", + action="store_true", dest="license_only", + default=False, help="Only scan for license files") + parser.add_argument("-b", "--skip-bump", dest="bump", + action="store_false", default=True, + help="Don't bump release number") + parser.add_argument("-c", "--config", nargs=1, dest="config", + action="store", default="common/autospec.conf", + help="Set configuration file to use") + + args = parser.parse_args() + if len(args.archives) % 2 != 0: + parser.error(argparse.ArgumentTypeError( + "-a/--archives requires an even number of arguments")) + # + # First, download the tarball, extract it and then do a set + # of static analysis on the content of the tarball. + # + build.setup_patterns() + + tarball.download_tarball(args.url, args.name, args.archives) + dir = tarball.path + if args.license_only: + try: + with open(os.path.join(build.download_path, + tarball.name + ".license"), "r") as dotlic: + for word in dotlic.read().split(): + if word.find(":") < 0: + license.add_license(word) + except: + pass + license.scan_for_licenses(name, dir) + exit(0) + + config.config_file = args.config + config.parse_config_files(build.download_path, args.bump) + + buildreq.scan_for_configure(name, dir, build.download_path) + specdescription.scan_for_description(name, dir) + license.scan_for_licenses(name, dir) + add_sources(build.download_path, args.archives) + test.scan_for_tests(dir) + + # + # Now, we have enough to write out a specfile, and try to build it. + # We will then analyze the build result and learn information until the + # package builds + # + write_spec(build.download_path + "/" + tarball.name + ".spec") + + print("\n") + while 1: + build.package() + write_spec(build.download_path + "/" + tarball.name + ".spec") + files.newfiles_printed = 0 + if build.round > 20 or build.must_restart == 0: + break + + test.check_regression(build.download_path) + + if build.success == 0: + print("Build failed") + return + + with open(build.download_path + "/release", "w") as fp: + fp.write(tarball.release + "\n") + + if args.git: + git.commit_to_git(build.download_path) + + +if __name__ == '__main__': + main() diff --git a/build.py b/build.py new file mode 100644 index 0000000..6b1a00d --- /dev/null +++ b/build.py @@ -0,0 +1,865 @@ +#!/bin/true +# +# build.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Actually build the package +# + +import buildreq +import files +import getpass +import re +import tarball + +import util +import filecmp + +success = 0 +round = 0 +must_restart = 0 +failed_commands = dict() +base_path = "/tmp/" + getpass.getuser() + "/" +output_path = base_path + "output" +download_path = output_path +mock_cmd = '/usr/bin/mock' + + +def setup_patterns(): + global failed_commands + failed_commands["doxygen"] = "doxygen" + failed_commands["scrollkeeper-config"] = "rarian" + failed_commands["dot"] = "graphviz" + failed_commands["nroff"] = "groff" + failed_commands["flex"] = "flex" + failed_commands["Berkeley DB"] = "db" + failed_commands["libdb"] = "db" + failed_commands["lex"] = "flex" + failed_commands["rake"] = "rubygem-rake" + failed_commands["py.test"] = "pytest" + failed_commands["freetype-config"] = "freetype-dev" + failed_commands["Freetype"] = "freetype-dev" + failed_commands["makeinfo"] = "texinfo" + failed_commands["install-info"] = "texinfo" + failed_commands["desktop-file-install"] = "desktop-file-utils" + failed_commands["deflateBound in -lz"] = "zlib-dev" + failed_commands["-lgnutls-openssl"] = "gnutls-dev" + failed_commands["gnutls/openssl.h"] = "gnutls-dev" + failed_commands["zlib.h"] = "pkgconfig(zlib)" + failed_commands["inflate in -lz"] = "zlib-dev" + failed_commands["udev_new in -ludev"] = "systemd-dev" + failed_commands["libudev.h"] = "systemd-dev" + failed_commands["jpeglib.h"] = "libjpeg-turbo-dev" + failed_commands["JPEG"] = "libjpeg-turbo-dev" + failed_commands["expat.h"] = "expat-dev" + failed_commands["Expat"] = "expat-dev" + failed_commands["bison"] = "bison" + failed_commands["numa.h"] = "numactl-dev" + failed_commands["cmdtest"] = "cmdtest" + failed_commands["runtest"] = "dejagnu" + failed_commands["msgfmt"] = "gettext" + failed_commands["gmsgfmt"] = "gettext" + failed_commands["msgmerge"] = "gettext" + failed_commands["xgettext"] = "gettext" + failed_commands["xkbcomp"] = "xkbcomp-bin" + failed_commands["CHECK"] = "check" + failed_commands["curl-config"] = "curl-dev" + failed_commands["curl"] = "curl-dev" + failed_commands["gnome-session"] = "gnome-session" + failed_commands["mkfontdir"] = "mkfontdir-bin" + failed_commands["mkfontscale"] = "mkfontscale-bin" + failed_commands["doxygen"] = "doxygen" + failed_commands["krb5/krb.h"] = "krb5-dev" + failed_commands["krb/krb5.h"] = "krb5-dev" + failed_commands["krb5-config"] = "krb5-dev" + failed_commands["X"] = "pkgconfig(x11)" + failed_commands["valgrind"] = "valgrind" + failed_commands["nasm"] = "nasm-bin" + failed_commands["XML::Parser"] = "perl(XML::Parser)" + failed_commands["XML::Simple"] = "perl(XML::Simple)" + failed_commands["ExtUtils::Depends"] = "perl(ExtUtils::Depends)" + failed_commands["ExtUtils::PkgConfig"] = "perl(ExtUtils::PkgConfig)" + failed_commands["LIBRSVG"] = "librsvg-dev" + failed_commands["openssl/opensslconf.h"] = "openssl-dev" + failed_commands["openssl/evp.h"] = "openssl-dev" + failed_commands["openssl"] = "openssl-dev" + failed_commands["openssl/hmac.h"] = "openssl-dev" + failed_commands["libgnutls"] = "gnutls-dev" + failed_commands["attr/libattr.h"] = "attr-dev" + failed_commands["acl/libacl.h"] = "acl-dev" + failed_commands["openssl/ssl.h"] = "openssl-dev" + failed_commands["Ogg"] = "libogg-dev" + failed_commands["X"] = "pkgconfig(x11)" + failed_commands["X11/Intrinsic.h"] = "pkgconfig(xt)" + failed_commands["X11/Xmu/Atoms.h"] = "pkgconfig(xmu)" + failed_commands["tiffio.h"] = "tiff-dev" + failed_commands["TIFF"] = "tiff-dev" + failed_commands["tiff.h"] = "tiff-dev" + failed_commands["readline/history.h"] = "readline-dev" + failed_commands["readline.h"] = "readline-dev" + failed_commands["readline in -lreadline"] = "readline-dev" + failed_commands["readline"] = "readline-dev" + failed_commands["libgcrypt-config"] = "libgcrypt-dev" + failed_commands["gpg-error.h"] = "libgpg-error-dev" + failed_commands["Xapian"] = "xapian-core-dev" + failed_commands["raptor"] = "raptor2-dev" + failed_commands["rasqal"] = "rasqal-dev" + failed_commands["DBUS"] = "dbus-dev" + failed_commands["less"] = "less" + failed_commands["pam_authenticate"] = "Linux-PAM-dev" + failed_commands["vim"] = "vim" + failed_commands["valac"] = "vala-dev" + failed_commands["vapigen"] = "vala-dev" + failed_commands["CLUTTER"] = "clutter-dev" + failed_commands["asciidoc"] = "asciidoc" + failed_commands["webp/decode.h"] = "libwebp-dev" + failed_commands["inkscape"] = "inkscape" + failed_commands["desktop-file-validate"] = "desktop-file-utils" + failed_commands["openssl/opensslv.h"] = "openssl-dev" + failed_commands["/usr/lib64/libsoprano.so"] = "soprano-dev" + failed_commands["PulseAudio"] = "pulseaudio-dev" + failed_commands["FindKDEGames"] = "libkdegames-dev" + failed_commands["FindStrigi"] = "strigi-dev" + failed_commands["akonadi/private/imapparser_p.h"] = "akonadi-dev" + failed_commands["LIBLZMA"] = "xz-dev" + failed_commands["LibAttica"] = "attica-dev" + failed_commands["FindAnalitza"] = "analitza-dev" + failed_commands["R"] = "R" + failed_commands["gfortran"] = "gfortran" + failed_commands["EXIV2"] = "exiv2-dev" + failed_commands["Exiv2"] = "exiv2-dev" + failed_commands["KDE4Workspace"] = "kde-workspace-dev" + failed_commands["LIBKONQ"] = "kde-baseapps-dev" + failed_commands["Jasper"] = "jasper-dev" + failed_commands["JASPER"] = "jasper-dev" + failed_commands["dot"] = "graphviz" + failed_commands["qjson/parser.h"] = "qjson-dev" + failed_commands["Sasl2"] = "cyrus-sasl-dev" + failed_commands["FindAkonadi"] = "akonadi-dev" + failed_commands["LIBICAL"] = "libical-dev" + failed_commands["Nepomuk"] = "nepomuk-core-dev" + failed_commands["FindNepomukCore"] = "nepomuk-core-dev" + failed_commands["FindNepomukWidgets"] = "nepomuk-widgets-dev" + failed_commands["Analitza"] = "analitza-dev" + failed_commands["DBusMenuQt"] = "libdbusmenu-qt-dev" + failed_commands["FindKActivities"] = "kactivities-dev" + failed_commands["Soprano"] = "soprano-dev" + failed_commands["PopplerQt4"] = "poppler-dev" + failed_commands[ + "SharedDesktopOntologies"] = "shared-desktop-ontologies-dev" + failed_commands["KDE4"] = "kdelibs-dev" + failed_commands["kde4-config"] = "kdelibs-dev" + failed_commands["KdepimLibs"] = "kdepimlibs-dev" + failed_commands["efi.h"] = "gnu-efi" + failed_commands["CAIRO"] = "cairo-dev" + failed_commands["Qt4"] = "qt-everywhere-opensource-src-dev" + failed_commands["FindQt4"] = "qt-everywhere-opensource-src-dev" + failed_commands["Phonon"] = "phonon-dev" + failed_commands["xdg-user-dirs-update"] = "xdg-user-dirs" + failed_commands["gtk-builder-convert"] = "compat-gtk2-dev" + failed_commands["DGA"] = "libXxf86dga-dev" + failed_commands["DMXMODULES"] = "libdmx-dev" + failed_commands["ImathInt64.h"] = "pkgconfig(IlmBase)" + failed_commands["jade"] = "openjade-dev" + failed_commands["JSON"] = "json-dev" + failed_commands["ltdl.h"] = "libtool-dev" + failed_commands["DRI2PROTO"] = "pkgconfig(dri2proto)" + failed_commands["killall"] = "psmisc" + failed_commands["pkill"] = "psmisc" + failed_commands["cairo/cairo-xcb.h"] = "cairo-dev" + failed_commands["XCB"] = "libxcb-dev" + failed_commands["XCB_IMAGE"] = "xcb-util-image-dev" + failed_commands["XCB_RENDERUTIL"] = "xcb-util-renderutil-dev" + failed_commands["pango/pangocairo.h"] = "pkgconfig(pangocairo)" + failed_commands["LIBUSB1"] = "libusb-dev" + failed_commands["libusb-1.0/libusb.h"] = "libusb-dev" + failed_commands["X11/extensions/saver.h"] = "pkgconfig(scrnsaverproto)" + failed_commands["apr_general.h"] = "apr-dev" + failed_commands["apr_md5.h"] = "apr-util-dev" + failed_commands["pkg.m4"] = "pkg-config-dev" + failed_commands["mate-common.m4"] = "mate-common-dev" + failed_commands["intltool.m4"] = "intltool-dev" + failed_commands["glib-gettext.m4"] = "glib-dev" + failed_commands["GLIB2"] = "glib-dev" + failed_commands["-lname-matecorba-server-2"] = "mate-corba-dev" + failed_commands["-lelf"] = "elfutils-dev" + failed_commands["mate-compiler-flags.m4"] = "mate-common-dev" + failed_commands["xmlcatalog"] = "libxml2-dev" + failed_commands["getopt"] = "util-linux" + failed_commands["ps"] = "procps-ng" + failed_commands["Xinerama"] = "libXinerama-dev" + failed_commands["XineramaQueryExtension"] = "libXinerama-dev" + failed_commands["matedialog"] = "mate-dialogs" + failed_commands["-lXinerama"] = "libXinerama-dev" + failed_commands["-lXv"] = "libXv-dev" + failed_commands["XvQueryExtension in -lXv"] = "libXv-dev" + failed_commands["IceConnectionNumber"] = "pkgconfig(ice)" + failed_commands["/etc/xml/catalog"] = "docbook-xml" + failed_commands["/usr/share/sgml/docbook/xsl-stylesheets"] = "docbook-xml" + failed_commands["mate-autogen"] = "mate-common-dev" + failed_commands["itstool"] = "itstool" + failed_commands["X11/extensions/XKBrules.h"] = "libxkbfile-dev" + failed_commands["X11/extensions/XResproto.h"] = "pkgconfig(resourceproto)" + failed_commands["X11/extensions/scrnsaver.h"] = "libXScrnSaver-dev" + failed_commands[ + "XF86MiscSetGrabKeysState in -lXxf86misc"] = "libXxf86misc-dev" + failed_commands["gtk-update-icon-cache"] = "pkgconfig(gtk+-3.0)" + failed_commands["gtk-config"] = "pkgconfig(gtk+-2.0)" + failed_commands["gphoto2-config"] = "libgphoto2-dev" + failed_commands["update-mime-database"] = "shared-mime-info" + failed_commands["SharedMimeInfo"] = "shared-mime-info" + failed_commands["crack.h"] = "cracklib-dev" + failed_commands["XML"] = "libxml2-dev" + failed_commands["LibXml2"] = "libxml2-dev" + failed_commands["EDS"] = "evolution-data-server-dev" + failed_commands["icu-config"] = "icu4c-dev" + failed_commands["ICU"] = "icu4c-dev" + failed_commands["ruby"] = "ruby" + failed_commands["XGetEventData"] = "inputproto" + failed_commands["X11/extensions/XInput.h"] = "libXi-dev" + failed_commands["libgtop"] = "libgtop-dev" + failed_commands["libcanberra-gtk"] = "libcanberra-dev" + failed_commands["update-desktop-database"] = "desktop-file-utils" + failed_commands["Startup notification library"] = "libnotify-dev" + failed_commands["Xcursor"] = "pkgconfig(xcursor)" + failed_commands["-lXrandr"] = "pkgconfig(xrandr)" + failed_commands["xrandr"] = "pkgconfig(xrandr)" + failed_commands["mateconf-sanity-check-2"] = "mate-conf-dev" + failed_commands["DEPENDENT_WITH_GTK"] = "compat-gtk2-dev" + failed_commands["zenity"] = "zenity" + failed_commands["gobject-introspection"] = "gobject-introspection-dev" + failed_commands["XCOMPOSITE extension"] = "libXcomposite-dev" + failed_commands["xauth"] = "xauth" + failed_commands["gconftool-2"] = "GConf-dev" + failed_commands["-lXss"] = "libXScrnSaver-dev" + failed_commands["-lSM"] = "pkgconfig(sm)" + failed_commands["X11/Xmu/Error.h"] = "libXmu-dev" + failed_commands["X11/extensions/Xinerama.h"] = "libXinerama-dev" + failed_commands["PAM"] = "Linux-PAM-dev" + failed_commands["gtk+-2.0"] = "gtk+-dev" + failed_commands["bc"] = "bc" + failed_commands["GL/glx.h"] = "pkgconfig(gl)" + failed_commands["lzma.h"] = "xz-dev" + failed_commands["lzma"] = "xz-dev" + failed_commands["liblzma"] = "xz-dev" + failed_commands["boost/unordered_map.hpp"] = "boost-dev" + failed_commands["Boost"] = "boost-dev" + failed_commands["Eigen/Core"] = "eigen-dev" + failed_commands["GL/glu.h"] = "glu-dev" + failed_commands["opencsg.h"] = "OpenCSG-dev" + failed_commands["GL/glut.h"] = "freeglut-dev" + failed_commands["enlightenment_start"] = "pkgconfig(enlightenment)" + failed_commands["-lcap-ng"] = "libcap-ng-dev" + failed_commands["ALSA"] = "alsa-lib-dev" + failed_commands["alsa/asoundlib.h"] = "alsa-lib-dev" + failed_commands["autoconf"] = "autoconf" + failed_commands["automake-1.12"] = "automake" + failed_commands["automake-1.14"] = "automake" + failed_commands["autoreconf"] = "autoconf" + failed_commands["GSTREAMER"] = "gstreamer-dev" + failed_commands["USB"] = "libusb-dev" + failed_commands["SNDFILE"] = "libsndfile-dev" + failed_commands["sys/capability.h"] = "libcap-dev" + failed_commands["cap_rights_init"] = "libcap-ng-dev" + failed_commands["readline/readline.h"] = "readline-dev" + failed_commands["xorg-launch-helper"] = "xorg-launch-helper" + failed_commands["blkid/blkid.h"] = "util-linux-dev" + failed_commands["-lblkid"] = "util-linux-dev" + failed_commands["-ltirpc"] = "libtirpc-dev" + failed_commands["-lreadline"] = "readline-dev" + failed_commands["-lnfsidmap"] = "libnfsidmap-dev" + failed_commands["pycurl"] = "pycurl" + failed_commands["gpgme.h"] = "gpgme-dev" + failed_commands["gcrypt.h"] = "libgcrypt-dev" + failed_commands["ffi_call"] = "libffi-dev" + failed_commands["boost/concept_check.hpp"] = "boost-dev" + failed_commands["gc/gc.h"] = "gc-dev" + failed_commands["D-Bus .pc file"] = "dbus-dev" + failed_commands["magic.h"] = "file-dev" + failed_commands["libproxy-1.0 pkg-config data"] = "libproxy-dev" + failed_commands["-lproxy"] = "libproxy-dev" + failed_commands["neon-config"] = "neon-dev" + failed_commands["-lbz2"] = "bzip2-dev" + failed_commands["-lbz2"] = "bzip2-dev" + failed_commands["asn1Parser"] = "libtasn1-dev" + failed_commands["gcj"] = "gcj" + failed_commands["pam/pam_modules.h"] = "Linux-PAM-dev" + failed_commands["-lXmu"] = "pkgconfig(xmu)" + failed_commands["convert"] = "ImageMagick" + failed_commands["-lIlmThread"] = "ilmbase-dev" + failed_commands["emacs"] = "emacs" + failed_commands["-lSM"] = "pkgconfig(sm)" + failed_commands["GTK"] = "gtk+-dev" + failed_commands["IDN"] = "libidn-dev" + failed_commands["GIF"] = "giflib-dev" + failed_commands["sqlite3.h"] = "sqlite-autoconf-dev" + failed_commands["Sqlite"] = "sqlite-autoconf-dev" + failed_commands["sqlite3"] = "sqlite-autoconf-dev" + failed_commands["sqlite.h"] = "sqlite-autoconf-dev" + failed_commands["zip"] = "zip" + failed_commands["unzip"] = "unzip" + failed_commands["cups/cups.h"] = "cups-dev" + failed_commands["cups-config"] = "cups-dev" + failed_commands["-lcrack"] = "cracklib-dev" + failed_commands["-lc"] = "glibc-staticdev" + failed_commands["uuid/uuid.h"] = "util-linux-dev" + failed_commands["uuid_generate"] = "util-linux-dev" + failed_commands["-luuid"] = "util-linux-dev" + failed_commands["dbus"] = "dbus-dev" + failed_commands["ltdl.h"] = "libtool-dev" + failed_commands["fontconfig"] = "pkgconfig(fontconfig)" + failed_commands["Fontconfig"] = "pkgconfig(fontconfig)" + failed_commands["FcInit in -lfontconfig"] = "pkgconfig(fontconfig)" + failed_commands["more"] = "util-linux" + failed_commands["OpenGL library"] = "mesa-dev" + failed_commands["OpenGL"] = "mesa-dev" + failed_commands["QImageBlitz"] = "qimageblitz-dev" + failed_commands["GLUT library"] = "freeglut-dev" + failed_commands["gs"] = "ghostscript" + failed_commands["-lgs"] = "ghostscript" + failed_commands["xcursorgen"] = "xcursorgen" + failed_commands["bzlib.h"] = "bzip2-dev" + failed_commands["diff"] = "diffutils" + failed_commands["cmp"] = "diffutils" + failed_commands["X11/Xtrans/Xtrans.h"] = "xtrans-dev" + failed_commands["patch"] = "patch" + failed_commands["GMP"] = "gmp-dev" + failed_commands["FindGMP"] = "gmp-dev" + failed_commands["MPFR"] = "mpfr-dev" + failed_commands["cmake"] = "cmake" + failed_commands["exo-1"] = "pkgconfig(exo-1)" + failed_commands["python2.5"] = "python" + failed_commands["-lpython2.7"] = "python-dev" + failed_commands["python-config"] = "python-dev" + failed_commands["python"] = "python-dev" + failed_commands["ZLIB"] = "zlib-dev" + failed_commands["BZip2"] = "bzip2-dev" + failed_commands["BZ2_bzCompress"] = "bzip2-dev" + failed_commands["gsapi_new_instance"] = "ghostscript" + failed_commands["FreeType 2"] = "freetype-dev" + failed_commands["GNU MP"] = "gmp-dev" + failed_commands["OpenSSL"] = "openssl-dev" + failed_commands["cURL"] = "curl-dev" + failed_commands["DGA"] = "pkgconfig(xf86dgaproto)" + failed_commands["APR"] = "apr-dev" + failed_commands["APR-util"] = "apr-util-dev" + failed_commands["pcre-config"] = "pcre-dev" + failed_commands["nspr.h"] = "nspr-dev" + failed_commands["wpa_supplicant"] = "wpa_supplicant" + failed_commands["pcap-config"] = "libpcap-dev" + failed_commands["Tcl configuration"] = "tcl" + failed_commands["tclsh"] = "tcl" + failed_commands["tgetent"] = "ncurses-dev" + failed_commands["tinfo"] = "ncurses-dev" + failed_commands["term.h"] = "ncurses-dev" + failed_commands["python2.7/Python.h"] = "python-dev" + failed_commands["PythonLibsUnix"] = "python-dev" + failed_commands["llvm-config"] = "llvm-dev" + failed_commands["Python.h"] = "python-dev" + failed_commands["SDL"] = "pkgconfig(sdl)" + failed_commands["CURL"] = "curl-dev" + failed_commands["GLIB"] = "glib-dev" + failed_commands["makedepend"] = "makedepend" + failed_commands["OpenGL X11"] = "mesa-dev" + failed_commands["intltool-update"] = "intltool" + failed_commands["intltool-merge"] = "intltool" + failed_commands["scrollkeeper-preinstall"] = "rarian" + failed_commands["librsvg-2.0"] = "librsvg-dev" + failed_commands["SVG"] = "librsvg-dev" + failed_commands["EET"] = "eet-dev" + failed_commands["gawk"] = "gawk" + failed_commands["xbkcomp"] = "xkbcomp" + failed_commands["Vorbis"] = "libvorbis-dev" + failed_commands["Expat 1.95.x"] = "expat-dev" + failed_commands["libexpat"] = "expat-dev" + failed_commands["pcap.h"] = "libpcap-dev" + failed_commands["nl_handle_alloc"] = "libnl-dev" + failed_commands["svn_client.h"] = "subversion-dev" + failed_commands["bluetooth/bluetooth.h"] = "bluez-dev" + failed_commands["xml2-config path"] = "libxml2-dev" + failed_commands["xmllint"] = "libxml2-dev" + failed_commands["xml2-config"] = "libxml2-dev" + failed_commands["gmp.h"] = "gmp-dev" + failed_commands["gc/gc.h"] = "gc-dev" + failed_commands["Eet.h"] = "eet-dev" + failed_commands["MPFR"] = "mpfr-dev" + failed_commands["-lncurses"] = "ncurses-dev" + failed_commands["ncurses.h"] = "ncurses-dev" + failed_commands["gperf"] = "gperf" + failed_commands["groff"] = "groff" + failed_commands["yacc"] = "bison" + failed_commands["db.h"] = "db-dev" + failed_commands["Berkeley DB4"] = "db" + failed_commands["gdbm.h"] = "gdbm-dev" + failed_commands["GDBM"] = "gdbm-dev" + failed_commands["GD"] = "gd-dev" + failed_commands["ENCHANT"] = "enchant-dev" + failed_commands["libelf.h"] = "elfutils-dev" + failed_commands["libgpg-error"] = "libgpg-error-dev" + failed_commands["gpg-error-config"] = "libgpg-error-dev" + failed_commands["libgcrypt"] = "libgcrypt-dev" + failed_commands["pth-config"] = "pth-dev" + failed_commands["libassuan-config"] = "libassuan-dev" + failed_commands["libassuan"] = "libassuan-dev" + failed_commands["ksba-config"] = "libksba-dev" + failed_commands["libksba"] = "libksba-dev" + failed_commands["which"] = "which" + failed_commands["libnettle"] = "nettle-dev nettle-lib" + failed_commands["nettle/md5.h"] = "nettle-dev nettle-lib" + failed_commands["cap_init"] = "libcap-dev" + failed_commands["lzo/lzoconf.h"] = "lzo-dev" + failed_commands["security/pam_appl.h"] = "Linux-PAM-dev" + failed_commands["popt.h"] = "popt-dev" + failed_commands["-lpopt"] = "popt-dev" + failed_commands["poptStrippedArgv"] = "popt-dev" + failed_commands["sysfs/libsysfs.h"] = "sysfsutils-dev" + failed_commands["curl.h"] = "curl-dev" + failed_commands["libxml2 library"] = "libxml2-dev" + failed_commands["sys/acl.h"] = "acl-dev" + failed_commands["attr/xattr.h"] = "attr-dev" + failed_commands["-lattr"] = "attr-dev" + failed_commands["DBUS_GLIB"] = "glib-dev" + failed_commands["xsltproc"] = "libxslt-bin" + failed_commands["xslt-config"] = "libxslt-dev" + failed_commands["X11/Xaw/SimpleMenu.h"] = "libXaw-dev" + failed_commands["X11/Xcursor/Xcursor.h"] = "libXcursor-dev" + failed_commands["X11/extensions/Xcomposite.h"] = "libXcomposite-dev" + failed_commands["X11/extensions/Xdamage.h"] = "libXdamage-dev" + failed_commands["X11/extensions/Xfixes.h"] = "libXfixes-dev" + failed_commands["X11/extensions/Xrandr.h"] = "libXrandr-dev" + failed_commands["X11/extensions/Xrender.h"] = "libXrender-dev" + failed_commands["GL/gl.h"] = "mesa-dev" + failed_commands["PNG"] = "pkgconfig(libpng)" + failed_commands["png_read_info in -lpng"] = "pkgconfig(libpng)" + failed_commands["libpng-config"] = "pkgconfig(libpng)" + failed_commands["lua"] = "lua" + failed_commands["pcre.h"] = "pcre-dev" + failed_commands["-lSM"] = "pkgconfig(sm)" + failed_commands["X11/xpm.h"] = "pkgconfig(xpm)" + failed_commands["XpmReadFileToXpmImage in -lXpm"] = "pkgconfig(xpm)" + failed_commands["gif_lib.h"] = "giflib-dev" + failed_commands["pixman"] = "pkgconfig(pixman-1)" + failed_commands["libpng"] = "pkgconfig(libpng)" + failed_commands["XOpenDisplay"] = "pkgconfig(xext)" + failed_commands["iceauth"] = "iceauth-bin" + failed_commands["perl module URI::URL"] = "URI" + failed_commands["X11/SM/SMlib.h"] = "pkgconfig(sm)" + failed_commands["-lXfixes"] = "pkgconfig(xfixes)" + failed_commands["-lz"] = "zlib-dev" + failed_commands["-lncursesw"] = "ncurses-dev" + failed_commands["-lncurses"] = "ncurses-dev" + failed_commands["-ltiff"] = "tiff-dev" + failed_commands["-lasound"] = "alsa-lib-dev" + failed_commands["-lgmp"] = "gmp-dev" + failed_commands["Curses"] = "ncurses-dev" + failed_commands["-lexpat"] = "expat-dev" + failed_commands["-lpam"] = "Linux-PAM-dev" + failed_commands["DBI"] = "perl(Bundle::DBI)" + failed_commands["-lcurl"] = "curl-dev" + failed_commands["-lXau"] = "libXau-dev" + failed_commands["-lX11"] = "pkgconfig(x11)" + failed_commands["X11"] = "pkgconfig(x11)" + failed_commands["automoc4"] = "automoc4" + failed_commands["-lXt"] = "pkgconfig(xt)" + failed_commands["-lICE"] = "pkgconfig(ice)" + failed_commands["-lXext"] = "pkgconfig(xext)" + failed_commands["libXext"] = "pkgconfig(xext)" + failed_commands["libz"] = "zlib-dev" + failed_commands["-lXtst"] = "pkgconfig(xtst)" + failed_commands["-lGL"] = "pkgconfig(gl)" + failed_commands["-lGLU"] = "pkgconfig(glu)" + failed_commands["-lXi"] = "pkgconfig(xi)" + failed_commands["-lXmu"] = "pkgconfig(xmu)" + failed_commands["-lXaw"] = "pkgconfig(xaw)" + failed_commands["X11/extensions/randr.h"] = "pkgconfig(xrandr)" + failed_commands["X11/Xlib.h"] = "pkgconfig(x11)" + failed_commands["X11/extensions/XShm.h"] = "pkgconfig(xext)" + failed_commands["X11/extensions/shape.h"] = "pkgconfig(xext)" + failed_commands["ncurses.h"] = "pkgconfig(ncursesw)" + failed_commands["curses.h"] = "pkgconfig(ncurses)" + failed_commands["pci/pci.h"] = "pkgconfig(libpci)" + failed_commands["xf86.h"] = "pkgconfig(xorg-server)" + failed_commands["uuid/uuid.h"] = "pkgconfig(uuid)" + failed_commands[ + "X11/extensions/composite.h"] = "pkgconfig(compositeproto)" + failed_commands["X11/extensions/XIproto.h"] = "pkgconfig(xi)" + failed_commands["xmlto"] = "xmlto" + failed_commands["ffi.h"] = "libffi-dev" + failed_commands["setuptools"] = "setuptools" + failed_commands["testtools"] = "testtools" + failed_commands["unittest2"] = "unittest2" + failed_commands["find_packages"] = "setuptools" + failed_commands["pkg_resources"] = "setuptools" + failed_commands["setup"] = "setuptools" + failed_commands["ez_setup"] = "setuptools" + failed_commands["cffi"] = "cffi" + failed_commands["pbr"] = "pbr" + failed_commands["pip"] = "pip" + failed_commands["six"] = "six" + failed_commands["extras"] = "extras" + failed_commands["testscenarios"] = "testscenarios" + failed_commands["mimeparse"] = "python-mimeparse" + failed_commands["libudev.h"] = "systemd-dev" + failed_commands["pycparser"] = "pycparser" + failed_commands["swig"] = "swig" + failed_commands["SLANG"] = "slang-dev" + failed_commands["libiberty.h"] = "binutils-dev" + failed_commands["Judy"] = "Judy-dev" + failed_commands["systemctl"] = "systemd" + failed_commands["mysql_config"] = "mariadb-dev" + failed_commands["-lssl"] = "openssl-dev" + failed_commands["apxs"] = "httpd-dev" + failed_commands["apr-1-config"] = "apr-dev" + failed_commands["apu-1-config"] = "apr-util-dev" + failed_commands["erl"] = "otp" + failed_commands["nc"] = "netcat" + failed_commands["wx-config"] = "wxGTK-dev" + failed_commands["gem"] = "ruby" + failed_commands["go"] = "go" + + +def simple_pattern_pkgconfig(line, pattern, pkgconfig): + global must_restart + pat = re.compile(pattern) + match = pat.search(line) + if match: + must_restart = must_restart + \ + buildreq.add_pkgconfig_buildreq(pkgconfig) + + +def simple_pattern(line, pattern, req): + global must_restart + pat = re.compile(pattern) + match = pat.search(line) + if match: + must_restart = must_restart + buildreq.add_buildreq(req) + + +def failed_pattern(line, pattern, verbose=0): + global must_restart + global failed_commands + + pat = re.compile(pattern) + match = pat.search(line) + if match: + s = match.group(1) + try: + req = failed_commands[s] + if req: + must_restart = must_restart + buildreq.add_buildreq(req) + except: + if verbose > 0: + print("Unknown pattern match: ", pattern, s) + + +def failed_pattern_pkgconfig(line, pattern, verbose=0): + global must_restart + global failed_commands + + pat = re.compile(pattern) + match = pat.search(line) + if match: + s = match.group(1) + must_restart = must_restart + buildreq.add_pkgconfig_buildreq(s) + + +def failed_pattern_R(line, pattern, verbose=0): + global must_restart + global failed_commands + + pat = re.compile(pattern) + match = pat.search(line) + if match: + s = match.group(1) + try: + if buildreq.add_buildreq("R-" + s) > 0: + must_restart = must_restart + 1 + files.push_main_requires("R-" + s) + except: + if verbose > 0: + print("Unknown pattern match: ", pattern, s) + + +def failed_pattern_perl(line, pattern, verbose=0): + global must_restart + global failed_commands + + pat = re.compile(pattern) + match = pat.search(line) + if match: + s = match.group(1) + try: + must_restart = must_restart + buildreq.add_buildreq('perl(%s)' % s) + except: + if verbose > 0: + print("Unknown pattern match: ", pattern, s) + + +def failed_pattern_pypi(line, pattern, verbose=0): + global must_restart + global failed_commands + + pat = re.compile(pattern) + match = pat.search(line) + if match: + s = util.translate(match.group(1)) + if s == "": + return + try: + must_restart = must_restart + buildreq.add_buildreq(util.translate('%s-python' % s)) + except: + if verbose > 0: + print("Unknown python pattern match: ", pattern, s, line) + + +def failed_pattern_ruby(line, pattern, verbose=0): + global must_restart + global failed_commands + + pat = re.compile(pattern) + match = pat.search(line) + if match: + s = match.group(1) + try: + if s in buildreq.gems: + must_restart = must_restart + buildreq.add_buildreq(buildreq.gems[s]) + else: + must_restart = must_restart + buildreq.add_buildreq('rubygem-%s' % s) + except: + if verbose > 0: + print("Unknown pattern match: ", pattern, s) + + +def failed_pattern_ruby_table(line, pattern, verbose=0): + global must_restart + global failed_commands + + pat = re.compile(pattern) + match = pat.search(line) + if match: + s = match.group(1) + try: + if s in buildreq.gems: + must_restart = must_restart + buildreq.add_buildreq(buildreq.gems[s]) + else: + print("Unknown ruby gem match", s) + except: + if verbose > 0: + print("Unknown pattern match: ", pattern, s) + + +def parse_build_results(filename, returncode): + global must_restart + global success + buildreq.verbose = 1 + must_restart = 0 + infiles = 0 + + # Flush the build-log to disk, before reading it + util.call("sync") + file = open(filename, "r", encoding="latin-1") + for line in file.readlines(): + simple_pattern_pkgconfig(line, r"which: no qmake", "Qt") + simple_pattern_pkgconfig(line, r"XInput2 extension not found", "xi") + simple_pattern_pkgconfig(line, r"checking for UDEV\.\.\. no", "udev") + simple_pattern_pkgconfig( + line, r"checking for UDEV\.\.\. no", "libudev") + simple_pattern_pkgconfig( + line, r"XMLLINT not set and xmllint not found in path", "libxml-2.0") + simple_pattern_pkgconfig( + line, r"error\: xml2-config not found", "libxml-2.0") + simple_pattern_pkgconfig( + line, r"error: must install xorg-macros", "xorg-macros") + simple_pattern( + line, r"Cannot find development files for any supported version of libnl", "libnl-dev") + simple_pattern(line, r"/", "cmake") + simple_pattern(line, r"\-\- Boost libraries:", "boost-dev") + simple_pattern(line, r"XInput2 extension not found", "inputproto") + simple_pattern(line, r"^WARNING: could not find 'runtest'$", "dejagnu") + simple_pattern(line, r"^WARNING: could not find 'runtest'$", "expect") + simple_pattern(line, r"^WARNING: could not find 'runtest'$", "tcl") + simple_pattern(line, r"VignetteBuilder package required for checking but installed:", "R-knitr") + simple_pattern( + line, r"You must have XML::Parser installed", "perl(XML::Parser)") + simple_pattern( + line, r"checking for Apache .* module support", "httpd-dev") + simple_pattern( + line, r"checking for.*in -ljpeg... no", "libjpeg-turbo-dev") + simple_pattern( + line, r"fatal error\: zlib\.h\: No such file or directory", "zlib-dev") + simple_pattern(line, r"\* tclsh failed", "tcl") + simple_pattern( + line, r"\/usr\/include\/python2\.7\/pyconfig.h", "python-dev") + simple_pattern( + line, r"checking \"location of ncurses\.h file\"", "ncurses-dev") + simple_pattern(line, r"Can't exec \"aclocal\"", "automake") + simple_pattern(line, r"Can't exec \"aclocal\"", "libtool") + simple_pattern( + line, r"configure: error: no suitable Python interpreter found", "python-dev") + simple_pattern(line, r"Checking for header Python.h", "python-dev") + simple_pattern( + line, r"configure: error: No curses header-files found", "ncurses-dev") + simple_pattern(line, r" \/usr\/include\/python2\.6$", "python-dev") + simple_pattern(line, r"to compile python extensions", "python-dev") + simple_pattern(line, r"testing autoconf... not found", "autoconf") + simple_pattern(line, r"configure\: error\: could not find Python headers", "python-dev") + simple_pattern(line, r"checking for libxml libraries", "libxml2-dev") + simple_pattern(line, r"configure: error: no suitable Python interpreter found", "python3") + simple_pattern(line, r"configure: error: pcre-config for libpcre not found", "pcre") + simple_pattern(line, r"checking for OpenSSL", "openssl-dev") + simple_pattern(line, r"Package systemd was not found in the pkg-config search path.", "systemd-dev") + simple_pattern(line, r"Unable to find the requested Boost libraries.", "boost-dev") + # simple_pattern(line, r"Can't locate Test/More.pm", "perl-Test-Simple") + + failed_pattern(line, r"checking for library containing (.*)... no") + failed_pattern(line, r"checking for (.*?)\.\.\. not_found") + failed_pattern(line, r"checking for (.*?)\.\.\. not found") + failed_pattern(line, r"checking for (.*?)\.\.\. no") + failed_pattern(line, r"checking for (.*) support\.\.\. no") + failed_pattern(line, r"checking (.*?)\.\.\. no") + failed_pattern(line, r"checking for (.*)... configure: error") + failed_pattern(line, r"checking for (.*) with pkg-config... no") + failed_pattern(line, r"Checking for (.*) development files... No") + failed_pattern(line, r"which\: no ([a-zA-Z\-]*) in \(") + failed_pattern(line, r"checking for (.*) support\.\.\. no") + failed_pattern( + line, r"checking for (.*) in default path\.\.\. not found") + failed_pattern(line, r" ([a-zA-Z0-9\-]*\.m4) not found") + failed_pattern(line, r"configure\: error\: Unable to locate (.*)") + failed_pattern(line, r"No rule to make target `(.*)',") + failed_pattern(line, r"ImportError\: No module named (.*)") + failed_pattern(line, r"/usr/bin/python.*\: No module named (.*)") + failed_pattern(line, r"ImportError\: cannot import name (.*)") + failed_pattern(line, r"ImportError\: ([a-zA-Z]+) module missing") + failed_pattern( + line, r"checking for [a-zA-Z0-9\_\-]+ in (.*?)\.\.\. no") + failed_pattern(line, r"No library found for -l([a-zA-Z\-])") + failed_pattern(line, r"\-\- Could NOT find ([a-zA-Z0-9]+)") + failed_pattern( + line, r"By not providing \"([a-zA-Z0-9]+).cmake\" in CMAKE_MODULE_PATH this project") + failed_pattern( + line, r"CMake Error at cmake\/modules\/([a-zA-Z0-9]+).cmake") + failed_pattern(line, r"Could NOT find ([a-zA-Z0-9]+)") + failed_pattern(line, r" Could not find ([a-zA-Z0-9]+)") + failed_pattern(line, r" Did not find ([a-zA-Z0-9]+)") + failed_pattern( + line, r"([a-zA-Z\-]+) [0-9\.]+ is required to configure this module; please install it or upgrade your CPAN\/CPANPLUS shell.") + failed_pattern(line, r"\/bin\/ld: cannot find (-l[a-zA-Z0-9\_]+)") + failed_pattern(line, r"fatal error\: (.*)\: No such file or directory") + failed_pattern(line, r"([a-zA-Z0-9\-\_\.]*)\: command not found", 1) +# failed_pattern(line, r"\: (.*)\: command not found", 1) + failed_pattern(line, r"-- (.*) not found.", 1) + failed_pattern( + line, r"You need ([a-zA-Z0-9\-\_]*) to build this program.", 1) + failed_pattern(line, r"Cannot find ([a-zA-Z0-9\-_\.]*)", 1) + failed_pattern(line, r" ([a-zA-Z]+\:\:[a-zA-Z]+) not installed", 1) + failed_pattern(line, r"([a-zA-Z\-]*) tool not found or not executable") + failed_pattern(line, r"([a-zA-Z\-]*) validation tool not found or not executable") + failed_pattern(line, r"Could not find suitable distribution for Requirement.parse\('([a-zA-Z\-]*)") + failed_pattern(line, r"unable to execute '([a-zA-Z\-]*)': No such file or directory") + failed_pattern(line, r"Unable to find '(.*)'") + failed_pattern(line, r"Downloading https?://.*\.python\.org/packages/.*/.?/([A-Za-z]*)/.*") + failed_pattern(line, r"configure\: error\: ([a-zA-Z0-9]+) is required to build") + failed_pattern(line, r".* /usr/bin/([a-zA-Z0-9-_]*).*not found") + failed_pattern(line, r"warning: failed to load external entity \"(/usr/share/sgml/docbook/xsl-stylesheets)/.*\"") + failed_pattern(line, r"Warning\: no usable ([a-zA-Z0-9]+) found") + failed_pattern(line, r"/usr/bin/env\: (.*)\: No such file or directory") + failed_pattern(line, r"make: ([a-zA-Z0-9].+): Command not found") + failed_pattern_R(line, r"ERROR: dependencies.*'([a-zA-Z0-9\-]*)' are not available for package '.*'") + failed_pattern_R(line, r"ERROR: dependencies '([a-zA-Z0-9\-]*)'.* are not available for package '.*'") + failed_pattern_R(line, r"ERROR: dependencies '.*', '([a-zA-Z0-9\-]*)',.* are not available for package '.*'") + failed_pattern_R(line, r"ERROR: dependency '([a-zA-Z0-9\-]*)' is not available for package '.*'") + failed_pattern_R(line, r"there is no package called '([a-zA-Z0-9\-]*)'") + failed_pattern_perl(line, r"you may need to install the ([a-zA-Z0-9\-:]*) module") + failed_pattern_perl(line, r" ! ([a-zA-Z:]+) is not installed") + failed_pattern_perl(line, r"Warning: prerequisite ([a-zA-Z:]+) [0-9\.]+ not found.") + failed_pattern_perl(line, r"Can't locate [a-zA-Z\/\.]+ in @INC \(you may need to install the ([a-zA-Z:]+) module\)") + failed_pattern_pypi(line, r"Download error on https://pypi.python.org/simple/([a-zA-Z0-9\-\._:]+)/") + failed_pattern_pypi(line, r"No matching distribution found for ([a-zA-Z0-9\-\._]+)") + failed_pattern_pypi(line, r"ImportError:..*: No module named ([a-zA-Z0-9\-\._]+)") + failed_pattern_pypi(line, r"ImportError: No module named ([a-zA-Z0-9\-\._]+)") + failed_pattern_pypi(line, r"ImportError: No module named '([a-zA-Z0-9\-\._]+)'") + failed_pattern_pkgconfig(line, r"Perhaps you should add the directory containing `([a-zA-Z0-9\-:]*)\.pc'") + failed_pattern_pkgconfig(line, r"No package '([a-zA-Z0-9\-:]*)' found") + failed_pattern_pkgconfig(line, r"Package '([a-zA-Z0-9\-:]*)', required by '.*', not found") + failed_pattern_ruby(line, r"WARNING: [a-zA-Z\-\_]+ dependency on ([a-zA-Z0-9\-\_:]*) \([<>=~]+ ([0-9.]+).*\) .*") + failed_pattern_ruby(line, r"ERROR: Could not find a valid gem '([a-zA-Z0-9\-:]*)' \([>=]+ ([0-9.]+).*\), here is why:") + failed_pattern_ruby(line, r"ERROR: Could not find a valid gem '([a-zA-Z0-9\-\_]*)' \([>=]+ ([0-9.]+).*\) in any repository") + failed_pattern_ruby(line, r"Could not find '([a-zA-Z0-9\-\_]*)' \([~<>=]+ ([0-9.]+).*\) among [0-9]+ total gem") + failed_pattern_ruby(line, r"Could not find gem '([a-zA-Z0-9\-\_]+) \([~<>=0-9\.\, ]+\) ruby'") + failed_pattern_ruby(line, r"Gem::LoadError: Could not find '([a-zA-Z0-9\-\_]*)'") + failed_pattern_ruby(line, r"[a-zA-Z0-9\-:]* is not installed: cannot load such file -- rdoc/([a-zA-Z0-9\-:]*)") + failed_pattern_ruby(line, r"LoadError: cannot load such file -- ([a-zA-Z0-9\-:]+)/.*") + failed_pattern_ruby(line, r":in `require': cannot load such file -- ([a-zA-Z0-9\-\_:]+) ") + failed_pattern_ruby_table(line, r":in `require': cannot load such file -- ([a-zA-Z0-9\-\_:\/]+)") + failed_pattern_ruby_table(line, r"LoadError: cannot load such file -- ([a-zA-Z0-9\-:\/\_]+)") + + if infiles == 1 and line.find("RPM build errors") >= 0: + infiles = 2 + if infiles == 1 and line.find("Childreturncodewas") >= 0: + infiles = 2 + if infiles == 1 and line.find("Child returncode") >= 0: + infiles = 2 + if infiles == 1 and line.startswith("Building"): + infiles = 2 + if infiles == 1 and line.startswith("Child return code was"): + infiles = 2 + if infiles == 1 and line.find("Empty %files file") >= 0: + infiles = 2 + + if line.find("Installed (but unpackaged) file(s) found:") >= 0: + infiles = 1 + else: + if infiles == 1: + files.push_file(line.strip()) + + if line.startswith("Sorry: TabError: inconsistent use of tabs and spaces in indentation"): + print(line) + returncode = 99 + + if "File not found: /builddir/build/BUILDROOT/" in line: + left = "File not found: /builddir/build/BUILDROOT/%s-%s-%s.x86_64/" % (tarball.name, tarball.version, tarball.release) + missing_file = "/" + line.split(left)[1].strip() + files.remove_file(missing_file) + + if line.startswith("Executing(%clean") and returncode == 0: + print("RPM build successful") + success = 1 + + file.close() + + +def set_mock(): + global mock_cmd + if filecmp.cmp('/usr/bin/mock', '/usr/sbin/mock'): + mock_cmd = 'sudo /usr/bin/mock' + + +def package(): + global round + round = round + 1 + set_mock() + print("Building package " + tarball.name + " round", round) + # call(mock_cmd + " -q -r clear --scrub=cache") + # call(mock_cmd + " -q -r clear --scrub=all") + util.call("mkdir -p %s/results" % download_path) + util.call(mock_cmd + " -r clear --buildsrpm --sources=./ --spec={0}.spec --uniqueext={0} --result=results/ --no-cleanup-after".format(tarball.name), + logfile="%s/mock_srpm.log" % download_path, cwd=download_path) + util.call("rm -f results/build.log", cwd=download_path) + srcrpm = "%s/results/%s-%s-%s.src.rpm" % (download_path, tarball.name, tarball.version, tarball.release) + returncode = util.call(mock_cmd + " -r clear --result=results/ %s --enable-plugin=ccache --uniqueext=%s --no-cleanup-after" % (srcrpm, tarball.name), + logfile="%s/mock_build.log" % download_path, check=False, cwd=download_path) + parse_build_results(download_path + "/results/build.log", returncode) diff --git a/buildpattern.py b/buildpattern.py new file mode 100644 index 0000000..7361e29 --- /dev/null +++ b/buildpattern.py @@ -0,0 +1,379 @@ +#!/bin/true +# +# buildpattern.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Deduce and emit the patterns for %build +# + +import config +import files +import lang +import os +import patches +import re +import tarball +import test + +default_pattern = "make" +pattern_strengh = 0 + +disable_static = "--disable-static" + +extra_make = "" +extra_cmake = "" +extra_make_install = "" +install_macro = "%make_install" +make_install_append = [] +subdir = "" +sources = {"unit": [], "gcov": [], "tmpfile": [], "archive": []} +source_index = {} +archive_details = {} + + +def write_prep(file, ruby_pattern=False): + file.write_strip("%prep") + for archive in sources["archive"]: + file.write_strip("tar -xf %{{SOURCE{}}}".format(source_index[archive])) + file.write_strip("cd ..") + if ruby_pattern: + file.write_strip("gem unpack %{SOURCE0}") + file.write_strip("%setup -q -D -T -n " + tarball.tarball_prefix) + file.write_strip("gem spec %{SOURCE0} -l --ruby > " + tarball.name + ".gemspec") + else: + if default_pattern == 'R': + file.write_strip("%setup -q -c -n " + tarball.tarball_prefix) + else: + file.write_strip("%setup -q -n " + tarball.tarball_prefix) + for archive in sources["archive"]: + file.write_strip('mv %{{_topdir}}/BUILD/{0}/* ./{1}' + .format(archive_details[archive + "prefix"], + archive_details[archive + "destination"])) + patches.apply_patches(file) + file.write_strip("\n") + + +def write_variables(file): + flags = [] + if config.optimize_size: + flags.extend(["-Os", "-ffunction-sections"]) + if config.insecure_build: + file.write_strip("export CFLAGS=\"-O2 -g\"\n") + file.write_strip("unset LDFLAGS\n") + if config.optimize_speed: + flags.extend(["-O3", "-flto", "-ffunction-sections", "-fno-semantic-interposition"]) + file.write_strip("export AR=gcc-ar\n") + file.write_strip("export RANLIB=gcc-ranlib\n") + if tarball.gcov_file: + flags = list(filter(("-flto").__ne__, flags)) + flags.extend(["-O3", "-fauto-profile=%{{SOURCE{0}}}".format(source_index[sources["gcov"][0]])]) + if flags: + flags = list(set(flags)) + file.write_strip("export CFLAGS=\"$CFLAGS {0} \"\n".format(" ".join(flags))) + file.write_strip("export CXXFLAGS=\"$CXXFLAGS {0} \"\n".format(" ".join(flags))) + + +def write_check(file): + if test.tests_config: + file.write_strip("%check") + file.write_strip("export http_proxy=http://127.0.0.1:9/") + file.write_strip("export https_proxy=http://127.0.0.1:9/") + file.write_strip("export no_proxy=localhost") + file.write_strip(test.tests_config) + file.write_strip("\n") + + +def write_make_install(file): + file.write_strip("%install") + file.write_strip("rm -rf %{buildroot}") + if subdir: + file.write_strip("pushd %s" % subdir) + file.write_strip("%s %s\n" % (install_macro, extra_make_install)) + if subdir: + file.write_strip("popd") + lang.write_find_lang(file) + + +def write_configure_pattern(file): + if patches.autoreconf: + # Patches affecting configure.* or Makefile.*, reconf instead + write_configure_ac_pattern(file) + return + write_prep(file) + file.write_strip("%build") + if config.asneeded == 0: + file.write_strip("unset LD_AS_NEEDED\n") + write_variables(file) + if subdir: + file.write_strip("pushd %s" % subdir) + file.write_strip("%configure " + disable_static + " " + config.extra_configure) + file.write_strip("make V=1 " + config.parallel_build + extra_make) + if subdir: + file.write_strip("popd") + file.write_strip("\n") + write_check(file) + write_make_install(file) + + +def write_configure_ac_pattern(file): + write_prep(file) + file.write_strip("%build") + if config.asneeded == 0: + file.write_strip("unset LD_AS_NEEDED\n") + write_variables(file) + if subdir: + file.write_strip("pushd %s" % subdir) + file.write_strip("%reconfigure " + disable_static + " " + config.extra_configure) + file.write_strip("make V=1 " + config.parallel_build + extra_make) + if subdir: + file.write_strip("popd") + file.write_strip("\n") + write_check(file) + write_make_install(file) + + +def write_make_pattern(file): + write_prep(file) + file.write_strip("%build") + write_variables(file) + if subdir: + file.write_strip("pushd %s" % subdir) + file.write_strip("make V=1 " + config.parallel_build + extra_make) + file.write_strip("\n") + write_check(file) + write_make_install(file) + + +def write_autogen_pattern(file): + write_prep(file) + file.write_strip("%build") + write_variables(file) + file.write_strip("%autogen " + disable_static + " " + config.extra_configure) + file.write_strip("make V=1 " + config.parallel_build + extra_make) + file.write_strip("\n") + write_check(file) + write_make_install(file) + + +def write_distutils_pattern(file): + write_prep(file) + file.write_strip("%build") + write_variables(file) + file.write_strip("python2 setup.py build -b py2 " + config.extra_configure) + file.write_strip("\n") + if test.tests_config: + file.write_strip("%check") + # Prevent setuptools from hitting the internet + file.write_strip("export http_proxy=http://127.0.0.1:9/") + file.write_strip("export https_proxy=http://127.0.0.1:9/") + file.write_strip("export no_proxy=localhost,127.0.0.1,0.0.0.0") + file.write_strip(test.tests_config) + file.write_strip("%install") + file.write_strip("rm -rf %{buildroot}") + file.write_strip("python2 -tt setup.py build -b py2 install --root=%{buildroot}") + lang.write_find_lang(file) + + +def write_distutils23_pattern(file): + write_prep(file) + file.write_strip("%build") + write_variables(file) + file.write_strip("python2 setup.py build -b py2 " + config.extra_configure) + file.write_strip("python3 setup.py build -b py3 " + config.extra_configure) + file.write_strip("\n") + if test.tests_config: + file.write_strip("%check") + # Prevent setuptools from hitting the internet + file.write_strip("export http_proxy=http://127.0.0.1:9/") + file.write_strip("export https_proxy=http://127.0.0.1:9/") + file.write_strip("export no_proxy=localhost,127.0.0.1,0.0.0.0") + file.write_strip(test.tests_config) + + file.write_strip("%install") + file.write_strip("rm -rf %{buildroot}") + file.write_strip("python2 -tt setup.py build -b py2 install --root=%{buildroot}") + file.write_strip("python3 -tt setup.py build -b py3 install --root=%{buildroot}") + lang.write_find_lang(file) + + +def write_R_pattern(file): + write_prep(file) + file.write_strip("%build") + file.write_strip("\n") + + file.write_strip("%install") + file.write_strip("rm -rf %{buildroot}") + file.write_strip("export LANG=C") + file.write_strip("export CFLAGS=\"$CFLAGS -O3 -flto -ffunction-sections -fno-semantic-interposition \"\n") + file.write_strip("export CXXFLAGS=\"$CXXFLAGS -O3 -flto -ffunction-sections -fno-semantic-interposition \"\n") + file.write_strip("export AR=gcc-ar\n") + file.write_strip("export RANLIB=gcc-ranlib\n") + file.write_strip("export LDFLAGS=\"$LDFLAGS -Wl,-z -Wl,relro\"\n") + + file.write_strip("mkdir -p %{buildroot}/usr/lib64/R/library") + file.write_strip("R CMD INSTALL --install-tests --build -l %{buildroot}/usr/lib64/R/library " + tarball.rawname) + file.write_strip("%{__rm} -rf %{buildroot}%{_datadir}/R/library/R.css") + lang.write_find_lang(file) + write_check(file) + + +def write_ruby_pattern(file): + write_prep(file, ruby_pattern=True) + file.write_strip("%build") + file.write_strip("gem build " + tarball.name + ".gemspec") + file.write_strip("\n") + + file.write_strip("%install") + file.write_strip("%global gem_dir $(ruby -e'puts Gem.default_dir')") + file.write_strip("gem install -V \\") + file.write_strip(" --local \\") + file.write_strip(" --force \\") + file.write_strip(" --install-dir .%{gem_dir} \\") + file.write_strip(" --bindir .%{_bindir} \\") + file.write_strip(" " + tarball.tarball_prefix + ".gem") + file.write_strip("\n") + + file.write_strip("mkdir -p %{buildroot}%{gem_dir}") + file.write_strip("cp -pa .%{gem_dir}/* \\") + file.write_strip(" %{buildroot}%{gem_dir}") + file.write_strip("\n") + + file.write_strip("if [ -d .%{_bindir} ]; then") + file.write_strip(" mkdir -p %{buildroot}%{_bindir}") + file.write_strip(" cp -pa .%{_bindir}/* \\") + file.write_strip(" %{buildroot}%{_bindir}/") + file.write_strip("fi") + file.write_strip("\n") + lang.write_find_lang(file) + write_check(file) + + +def write_cmake_pattern(file): + global subdir + subdir = "clr-build" + write_prep(file) + file.write_strip("%build") + file.write_strip("mkdir clr-build") + file.write_strip("pushd clr-build") + file.write_strip("cmake .. -G \"Unix Makefiles\" -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS:BOOL=ON -DLIB_INSTALL_DIR:PATH=%{_libdir} " + extra_cmake) + file.write_strip("make V=1 " + config.parallel_build + extra_make) + file.write_strip("popd") + file.write_strip("\n") + write_check(file) + write_make_install(file) + + +def write_cpan_pattern(file): + global subdir + write_prep(file) + file.write_strip("%build") + file.write_strip("if test -f Makefile.PL; then") + file.write_strip("%{__perl} Makefile.PL") + file.write_strip("make V=1 " + config.parallel_build + extra_make) + file.write_strip("else") + file.write_strip("%{__perl} Build.PL") + file.write_strip("./Build") + file.write_strip("fi") + file.write_strip("\n") + write_check(file) + file.write_strip("%install") + file.write_strip("rm -rf %{buildroot}") + file.write_strip("if test -f Makefile.PL; then") + file.write_strip("make pure_install PERL_INSTALL_ROOT=%{buildroot}") + file.write_strip("else") + file.write_strip("./Build install --installdirs=site --destdir=%{buildroot}") + file.write_strip("fi") + file.write_strip("find %{buildroot} -type f -name .packlist -exec rm -f {} ';'") + file.write_strip("find %{buildroot} -depth -type d -exec rmdir {} 2>/dev/null ';'") + file.write_strip("find %{buildroot} -type f -name '*.bs' -empty -exec rm -f {} ';'") + file.write_strip("%{_fixperms} %{buildroot}/*") + lang.write_find_lang(file) + + +def write_scons_pattern(file): + write_prep(file) + file.write_strip("%build") + write_variables(file) + file.write_strip("scons" + config.parallel_build + " " + config.extra_configure) + file.write_strip("\n") + file.write_strip("%install") + file.write_strip("scons install " + extra_make_install) + + +def set_build_pattern(pattern, strength): + global default_pattern + global pattern_strengh + if strength <= pattern_strengh: + return 0 + default_pattern = pattern + pattern_strengh = strength + + +def get_systemd_units(): + """get systemd unit files from the files module""" + service_file_section = "config" + systemd_service_pattern = r"^/usr/lib/systemd/system/[^/]*\.(mount|service|socket|target)$" + systemd_units = [] + + if service_file_section not in files.packages: + return systemd_units + + for f in files.packages[service_file_section]: + if re.search(systemd_service_pattern, f) and f not in files.excludes: + systemd_units.append(f) + + return systemd_units + + +def write_sources(file): + """write out installs from SourceX lines""" + if len(sources["unit"]) != 0: + file.write_strip("mkdir -p %{buildroot}/usr/lib/systemd/system") + for unit in sources["unit"]: + file.write_strip("install -m 0644 %{{SOURCE{0}}} %{{buildroot}}/usr/lib/systemd/system/{1}" + .format(source_index[unit], unit)) + if len(sources["tmpfile"]) != 0: + file.write_strip("mkdir -p %{buildroot}/usr/lib/tmpfiles.d") + file.write_strip("install -m 0644 %{{SOURCE{0}}} %{{buildroot}}/usr/lib/tmpfiles.d/{1}.conf" + .format(source_index[sources["tmpfile"][0]], tarball.name)) + + +def write_make_install_append(file): + """write out any custom supplied commands at the very end of the %install section""" + if make_install_append and make_install_append[0]: + file.write_strip("## make_install_append content") + for line in make_install_append: + file.write_strip("%s\n" % line) + file.write_strip("## make_install_append end") + + +def write_systemd_units(file): + """write out installs for systemd unit files""" + units = get_systemd_units() + for unit in units: + file.write("systemctl --root=%{{buildroot}} enable {0}\n".format(os.path.basename(unit))) + + +def write_buildpattern(file): + file.write_strip("\n") + + pattern_method = globals().get('write_%s_pattern' % default_pattern, None) + if pattern_method: + pattern_method(file) + + write_sources(file) + write_make_install_append(file) + # write_systemd_units(file) diff --git a/buildreq.py b/buildreq.py new file mode 100644 index 0000000..daf91e9 --- /dev/null +++ b/buildreq.py @@ -0,0 +1,374 @@ +#!/bin/true +# +# buildreq.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Deduce and manage build requirements +# + +import os +import re + +import buildpattern +import patches +import util + +buildreqs = set() +pythonreqs = set() +banned_buildreqs = set( + ["llvm-devel", "gcj", "pkgconfig(dnl)", "pkgconfig(hal)", "tslib-0.0", "pkgconfig(parallels-sdk)", "oslo-python"]) +verbose = False + +autoreconf_reqs = ["gettext-bin", "automake-dev", "automake", "m4", "libtool", "libtool-dev", "pkg-config-dev"] + + +def add_buildreq(req): + global verbose + new = True + if req in banned_buildreqs: + return False + if req in buildreqs: + new = False + if verbose and new: + print(" Adding buildreq:", req) + + buildreqs.add(req) + return new + + +def add_pythonreq(req): + global verbose + new = True + + if req in pythonreqs: + new = False + if new: + print("Adding python requirement:", req) + pythonreqs.add(req) + return new + + +def add_pkgconfig_buildreq(preq): + req = "pkgconfig(" + preq + ")" + return add_buildreq(req) + + +def configure_ac_line(line): + # print("----\n", line, "\n----") + # ignore comments + if line.startswith('#'): + return + + if line.find("AC_CHECK_FUNC\([tgetent]") >= 0: + add_buildreq("ncurses-devel") + if line.find("PROG_INTLTOOL") >= 0: + add_buildreq("intltool") + if line.find("GETTEXT_PACKAGE") >= 0: + add_buildreq("gettext") + add_buildreq("perl(XML::Parser)") + if line.find("AM_GLIB_GNU_GETTEXT") >= 0: + add_buildreq("gettext") + add_buildreq("perl(XML::Parser)") + if line.find("GTK_DOC_CHECK") >= 0: + add_buildreq("gtk-doc") + add_buildreq("gtk-doc-dev") + add_buildreq("libxslt-bin") + add_buildreq("docbook-xml") + if line.find("AC_PROG_SED") >= 0: + add_buildreq("sed") + if line.find("AC_PROG_GREP") >= 0: + add_buildreq("grep") + + line = line.strip() + + # print("--", line, "--") + pattern = re.compile(r"PKG_CHECK_MODULES\((.*)\)") + match = pattern.search(line) + L = [] + if match: + L = match.group(1).split(",") + if len(L) > 1: + rqlist = L[1].strip() + f = rqlist.find(">") + if f >= 0: + rqlist = rqlist[:f] + f = rqlist.find("<") + if f >= 0: + rqlist = rqlist[:f] + + L2 = rqlist.split(" ") + for rq in L2: + if len(rq) < 2: + continue + # remove [] if any + if rq[0] == "[": + rq = rq[1:] + f = rq.find("]") + if f >= 0: + rq = rq[:f] + f = rq.find(">") + if f >= 0: + rq = rq[:f] + f = rq.find("<") + if f >= 0: + rq = rq[:f] + f = rq.find("=") + if f >= 0: + rq = rq[:f] + rq = rq.strip() + if len(rq) > 0 and rq[0] != "$": + add_pkgconfig_buildreq(rq) + + pattern = re.compile(r"PKG_CHECK_EXISTS\((.*)\)") + match = pattern.search(line) + if match: + L = match.group(1).split(",") + # print("---", match.group(1).strip(), "---") + rqlist = L[0].strip() + L2 = rqlist.split(" ") + for rq in L2: + # remove [] if any + if rq[0] == "[": + rq = rq[1:] + f = rq.find("]") + if f >= 0: + rq = rq[:f] + f = rq.find(">") + if f >= 0: + rq = rq[:f] + f = rq.find("<") + if f >= 0: + rq = rq[:f] + f = rq.find("=") + if f >= 0: + rq = rq[:f] + rq = rq.strip() + # print("=== ", rq, "===") + if len(rq) > 0 and rq[0] != "$": + add_pkgconfig_buildreq(rq) + break + + pass + + +def parse_configure_ac(filename): + buffer = "" + depth = 0 + # print("Configure parse: ", filename) + buildpattern.set_build_pattern("configure_ac", 1) + file = open(filename, "r", encoding="latin-1") + while 1: + c = file.read(1) + if len(c) == 0: + break + if c == "(": + depth = depth + 1 + if c == ")" and depth > 0: + depth = depth - 1 + if c != "\n": + buffer = buffer + c + if c == "\n" and depth == 0: + configure_ac_line(buffer) + buffer = "" + + configure_ac_line(buffer) + file.close() + +gems = {"hoe": "rubygem-hoe", + "rspec/core/rake_task": "rubygem-rspec-core", + "bundler/gem_tasks": "rubygem-rubygems-tasks", + "bundler/setup": "rubygem-bundler", + "echoe": "rubygem-echoe", + "sass": "rubygem-sass", + "redcarpet": "rubygem-redcarpet", + "action_view/helpers/sanitize_helper": "rubygem-actionview", + "appraisal/file": "rubygem-appraisal", + "benchmark/ips": "rubygem-benchmark-ips", + "builder": "rubygem-builder", + "bundler": "rubygem-bundler", + "gem_hadar": "rubygem-gem_hadar", + "gherkin/rubify": "rubygem-gherkin", + "guard/compat/test/helper": "rubygem-guard-compat", + "html/pipeline": "rubygem-html-pipeline", + "minitest/autorun": "rubygem-minitest", + "minitest/unit": "rubygem-minitest", + "mocha/setup": "rubygem-mocha", + "nokogiri/diff": "rubygem-nokogiri-diff", + "pdf/reader": "rubygem-pdf-reader", + "pry": "rubygem-pry", + "rake/extensiontask": "rubygem-rake-compiler", + "rack/test": "rubygem-rack-test", + "rack/utils": "rubygem-rack", + "rspec/core": "rubygem-rspec-core", + "rspec/its": "rubygem-rspec-its", + "rspec/mocks": "rubygem-rspec-mocks", + "test/unit": "rubygem-test-unit", + } + + +def Rakefile(filename): + global gems + file = open(filename, "r", encoding="latin-1") + lines = file.readlines() + for line in lines: + pat = re.compile(r"^require '(.*)'$") + match = pat.search(line) + if match: + s = match.group(1) + if s != "rubygems" and s in gems: + print("Rakefile-dep: " + gems[s]) + add_buildreq(gems[s]) + else: + print("Rakefile-new: rubygem-" + s) + + +def clean_python_req(str): + if str.find("#") == 0: + return "" + ret = str.rstrip("\n\r").strip() + i = ret.find("<") + if i > 0: + ret = ret[:i] + i = ret.find("\n") + if i > 0: + ret = ret[:i] + i = ret.find(">") + if i > 0: + ret = ret[:i] + i = ret.find("=") + if i > 0: + ret = ret[:i] + i = ret.find("#") + if i > 0: + ret = ret[:i] + i = ret.find("!") + if i > 0: + ret = ret[:i] + # is ret actually a valid (non-empty) string? + if ret: + ret = ret.strip() + "-python" + # use the dictionary to translate funky names to our current pgk names + ret = util.translate(ret) + return ret + + +def grab_python_requirements(descfile): + file = open(descfile, "r", encoding="latin-1") + for line in file.readlines(): + add_pythonreq(clean_python_req(line)) + + +def setup_py_python3(filename): + try: + with open(filename) as FILE: + if ":: Python :: 3" in "".join(FILE.readlines()): + return 1 + except: + return 0 + return 0 + + +def scan_for_configure(package, dir, autospecdir): + global default_summary + count = 0 + for dirpath, dirnames, files in os.walk(dir): + default_score = 2 + if dirpath != dir: + default_score = 1 + + if "CMakeLists.txt" in files and "configure.ac" not in files: + add_buildreq("cmake") + buildpattern.set_build_pattern("cmake", default_score) + + if "configure" in files and os.access(dirpath + '/configure', os.X_OK): + buildpattern.set_build_pattern("configure", default_score) + + if "requires.txt" in files: + grab_python_requirements(dirpath + '/requires.txt') + + if "setup.py" in files: + add_buildreq("python-dev") + add_buildreq("setuptools") + add_buildreq("pbr") + add_buildreq("pip") + if setup_py_python3(dirpath + '/setup.py') or setup_py_python3(dirpath + '/PKG-INFO'): + add_buildreq("python3-dev") + buildpattern.set_build_pattern("distutils23", default_score) + # force override the pypi rule + if buildpattern.default_pattern == 'distutils' and buildpattern.pattern_strengh <= 10: + buildpattern.default_pattern = 'distutils23' + else: + # check for adding python3 support in patches + try: + with open(autospecdir + '/series', 'r') as series: + for patchname in series: + if setup_py_python3(autospecdir + '/' + patchname.strip()): + add_buildreq("python3-dev") + buildpattern.set_build_pattern("distutils23", default_score) + # force override the pypi rule + if buildpattern.default_pattern == 'distutils' and buildpattern.pattern_strengh <= 10: + buildpattern.default_pattern = 'distutils23' + except: + pass + buildpattern.set_build_pattern("distutils", default_score) + + if "Makefile.PL" in files or "Build.PL" in files: + buildpattern.set_build_pattern("cpan", default_score) + if "SConstruct" in files: + add_buildreq("scons") + add_buildreq("python-dev") + buildpattern.set_build_pattern("scons", default_score) + + if "requirements.txt" in files: + grab_python_requirements(dirpath + '/requirements.txt') + + for name in files: + if name.lower().startswith("configure."): + parse_configure_ac(os.path.join(dirpath, name)) + if name.lower().startswith("rakefile"): + Rakefile(os.path.join(dirpath, name)) + if name.lower() == "makefile": + buildpattern.set_build_pattern("make", default_score) + if name.lower() == "autogen.sh": + buildpattern.set_build_pattern("autogen", default_score) + if name.lower() == "cmakelists.txt": + buildpattern.set_build_pattern("cmake", default_score) + + can_reconf = os.path.exists(os.path.join(dir, "configure.ac")) + if not can_reconf: + can_reconf = os.path.exists(os.path.join(dir, "configure.in")) + + if can_reconf and patches.autoreconf: + print("Patches touch configure.*, adding autoreconf stage") + for breq in autoreconf_reqs: + add_buildreq(breq) + else: + patches.autoreconf = False + + print("Buildreqs : ", end="") + for lic in sorted(buildreqs): + if count > 4: + count = 0 + print("\nBuildreqs : ", end="") + count = count + 1 + print(lic + " ", end="") + print("") + + +def write_buildreq(file): + if len(buildreqs) > 0: + for lic in sorted(buildreqs): + file.write("BuildRequires : " + lic + "\n") diff --git a/config.py b/config.py new file mode 100644 index 0000000..b431754 --- /dev/null +++ b/config.py @@ -0,0 +1,250 @@ +#!/bin/true +# +# config.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Parse config files +# + +import buildpattern +import buildreq +import files +import license +import os +import sys +import patches +import re +import subprocess +import tarball +import test +import textwrap +import configparser +from util import call + +extra_configure = "" +keepstatic = 0 +asneeded = 1 +optimize_size = False +optimize_speed = False +insecure_build = False +config_files = set() +parallel_build = " %{?_smp_mflags} " +config_path = "" + +license_fetch = None +license_show = None +git_uri = None +config_file = None + + +def filter_blanks(lines): + return [l.strip() for l in lines if not l.strip().startswith("#") and l.split()] + + +def read_conf_file(name): + try: + with open(config_path + "/" + name) as f: + config_files.add(name) + return filter_blanks(f.readlines()) + except EnvironmentError: + return [] + + +def parse_config_files(path, bump): + global extra_configure + global keepstatic + global asneeded + global optimize_size + global optimize_speed + global insecure_build + global config_files + global config_path + global parallel_build + global license_fetch + global license_show + global git_uri + global config_file + + config_path = path + + # Require autospec.conf for additional features + if os.path.exists(config_file): + config = configparser.ConfigParser(interpolation=None) + config.read(config_file) + + if "autospec" not in config.sections(): + print("Missing autospec section..") + sys.exit(1) + + git_uri = config['autospec'].get('git', None) + license_fetch = config['autospec'].get('license_fetch', None) + license_show = config['autospec'].get('license_show', None) + + if not git_uri: + print("Warning: Set [autospec][git] upstream template for git support") + if not license_fetch: + print("Warning: Set [autospec][license_fetch] uri for license fetch support") + if not license_show: + print("Warning: Set [autospec][license_show] uri for license link check support") + + wrapper = textwrap.TextWrapper() + wrapper.initial_indent = "# " + wrapper.subsequent_indent = "# " + + def write_default_conf_file(name, description): + config_files.add(name) + filename = path + "/" + name + if os.path.isfile(filename): + return + + with open(filename, "w") as f: + f.write(wrapper.fill(description) + "\n") + + write_default_conf_file("buildreq_ban", "This file contains build requirements that get picked up but are undesirable. One entry per line, no whitespace.") + write_default_conf_file("pkgconfig_ban", "This file contains pkgconfig build requirements that get picked up but are undesirable. One entry per line, no whitespace.") + + write_default_conf_file("buildreq_add", "This file contains additional build requirements that did not get picked up automatically. One name per line, no whitespace.") + write_default_conf_file("pkgconfig_add", "This file contains additional pkgconfig build requirements that did not get picked up automatically. One name per line, no whitespace.") + + write_default_conf_file("excludes", "This file contains the output files that need %exclude. Full path names, one per line.") + + content = read_conf_file("release") + if content and content[0]: + r = int(content[0]) + if bump: + r += 1 + tarball.release = str(r) + print("Release :", tarball.release) + + content = read_conf_file("buildreq_ban") + for banned in content: + print("Banning build requirement: %s." % banned) + buildreq.banned_buildreqs.add(banned) + + content = read_conf_file("pkgconfig_ban") + for banned in content: + banned = "pkgconfig(%s)" % banned + print("Banning build requirement: %s." % banned) + buildreq.banned_buildreqs.add(banned) + + content = read_conf_file("buildreq_add") + for extra in content: + print("Adding additional build requirement: %s." % extra) + buildreq.add_buildreq(extra) + + content = read_conf_file("pkgconfig_add") + for extra in content: + extra = "pkgconfig(%s)" % extra + print("Adding additional build requirement: %s." % extra) + buildreq.add_buildreq(extra) + + content = read_conf_file("excludes") + for exclude in content: + print("%%exclude for: %s." % exclude) + files.excludes += content + + content = read_conf_file("extras") + for extra in content: + print("extras for: %s." % extra) + files.extras += content + + content = read_conf_file("setuid") + for suid in content: + print("setuid for: %s." % suid) + files.setuid += content + + content = read_conf_file("attrs") + for line in content: + attr = re.split('\(|\)|,', line) + attr = [a.strip() for a in attr] + filename = attr.pop() + print("attr for: %s." % filename) + files.attrs[filename] = attr + + patches.patches += read_conf_file("series") + pfiles = [("%s/%s" % (path, x.split(" ")[0])) for x in patches.patches] + cmd = "egrep \"(\+\+\+|\-\-\-).*((Makefile.am|Makefile.in)|(configure.ac|configure.in))\" %s" % \ + " ".join(pfiles) + if len(patches.patches) > 0 and call(cmd, check=False, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0: + patches.autoreconf = True + + content = read_conf_file("configure") + extra_configure = " \\\n".join(content) + + if read_conf_file("keepstatic"): + keepstatic = 1 + buildpattern.disable_static = "" + + if read_conf_file("asneeded"): + print("Disabling LD_AS_NEEDED\n") + asneeded = 0 + + if read_conf_file("optimize_size"): + optimize_size = True + if read_conf_file("funroll-loops"): + optimize_speed = True + if read_conf_file("insecure_build"): + insecure_build = True + if read_conf_file("broken_parallel_build"): + parallel_build = "" + + content = read_conf_file("make_args") + if content and content[0]: + buildpattern.extra_make = content[0] + + content = read_conf_file("make_install_args") + if content and content[0]: + buildpattern.extra_make_install = content[0] + + content = read_conf_file("install_macro") + if content and content[0]: + buildpattern.install_macro = content[0] + + content = read_conf_file("cmake_args") + if content and content[0]: + buildpattern.extra_cmake = content[0] + + content = read_conf_file("subdir") + if content and content[0]: + buildpattern.subdir = content[0] + + content = read_conf_file("build_pattern") + if content and content[0]: + buildpattern.set_build_pattern(content[0], 20) + patches.autoreconf = False + + if read_conf_file("skip_test_suite"): + test.skip_tests = True + + if read_conf_file("unit_tests_must_pass"): + test.new_pkg = False + + content = read_conf_file("make_check_command") + if content and content[0]: + test.tests_config = content[0] + + content = read_conf_file("allow_test_failures") + if content and content[0]: + test.allow_test_failures = True + + content = read_conf_file(tarball.name + ".license") + if content and content[0]: + words = content[0].split() + for word in words: + if word.find(":") < 0: + license.add_license(word) + + buildpattern.make_install_append = read_conf_file("make_install_append") diff --git a/count.pl b/count.pl new file mode 100644 index 0000000..43970b0 --- /dev/null +++ b/count.pl @@ -0,0 +1,1040 @@ +#!/usr/bin/perl +# +# count.pl - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +my %testcount; +my %testpass; +my %testfail; +my %testxfail; +my %testskip; +my $pkg_has_test = 0; + +my $total_tests; +my $total_pass; +my $total_fail; +my $total_xfail; +my $total_skip; + +my $counted_tests; +my $counted_pass; +my $counted_fail; +my $counted_xfail; +my $counted_skip; + +my $name,$v,$r;; + + +sub parse_log +{ + my ($fn) = @_; + my $incheck = 0; + + open(my $log, "<", "$fn") or return 0; + while (<$log>) { + my $line = $_; + chomp($line); + + if ($line =~ /Executing\(%check\)/) { + $incheck = 1; + } + if ($line =~ /\+ make check/) { + $incheck = 1; + } + if ($line =~ /##### Testing packages\./) { + $incheck = 1; + } + if ($line =~ /CLR-XTEST: Package: (.*)/) { + my $n = $1; + sanitize_counts(); + collect_output(); + $name = $n; + } +# print "line is -$line-\n"; + + # ACL package + #[22] $ rm -Rf d -- ok- + # 17 commands (17 passed, 0 failed)- + + if ($line =~ /\[[0-9]+\].*\-\- ok/) { + $counted_pass++; + } + if ($line =~ /[0-9]+ commands \(([0-9]+) passed, ([0-9]+) failed\)/) { + $total_pass += $1; + $total_fail += $2; + } + + # alembic package + #Ran 678 tests in 5.175s + #OK (SKIP=15) + if ($line =~ /Ran ([0-9]+) tests? in/) { + $total_tests += $1; + next; + } + if ($line =~ /OK \(SKIP=([0-9]+)\)/) { + $total_skip += $1; + next; + } + elsif ($line =~ /OK \(skipped=([0-9]+)\)/) { + $total_skip += $1; + next; + } + # anyjson + # test_implementations.test_default_serialization ... ok + # note: configure false positive + if ($line =~ /\.\.\. ok$/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /\.\.\. skipped$/ and $incheck == 1) { + $counted_skip++; + next; + } + + # apr + # testatomic : SUCCESS + # + if ($line =~ /\: SUCCESS$/ and $incheck == 1) { + $counted_pass++; + next; + } + # cryptography + # ================= 76230 passed, 267 skipped in 140.23 seconds ================== + # ==== 47 passed, 2 error in 10.36 seconds === + # ================ 10 failed, 16 passed, 4 error in 0.16 seconds ================= + # ========================== 43 passed in 2.90 seconds =========================== + # ======= 28 failed, 281 passed, 13 skipped, 10 warnings in 28.48 seconds ======== + # ===================== 5 failed, 318 passed in 1.06 seconds ===================== + # ============= 1628 passed, 72 skipped, 4 xfailed in 146.26 seconds ============= + # =============== 119 passed, 2 skipped, 54 error in 2.19 seconds ================ + # ========== 1 failed, 74 passed, 10 skipped, 55 error in 2.05 seconds =========== + # ==================== 68 passed, 1 warnings in 0.12 seconds ===================== + # ================ 3 failed, 250 passed, 3 error in 3.28 seconds ================= + # =============== 1 failed, 407 passed, 10 skipped in 4.71 seconds =============== + + + + if ($line =~ /== ([0-9]+) passed, ([0-9]+) skipped in / and $incheck == 1) { + $total_pass += $1; + $total_skip += $2; + next; + } + if ($line =~ /== ([0-9]+) passed, ([0-9]+) skipped, ([0-9]+) xfailed in / and $incheck == 1) { + $total_pass += $1; + $total_skip += $2; + $total_xfail += $3; + next; + } + if ($line =~ /== ([0-9]+) passed, ([0-9]+) skipped, ([0-9]+) error in / and $incheck == 1) { + $total_pass += $1; + $total_skip += $2; + $total_fail += $3; + next; + } + if ($line =~ /== ([0-9]+) failed, ([0-9]+) passed, ([0-9]+) skipped, ([0-9]+) error in / and $incheck == 1) { + $total_pass += $2; + $total_skip += $3; + $total_fail += $4 + $1; + next; + } + if ($line =~ /== ([0-9]+) failed, ([0-9]+) passed, ([0-9]+) error in / and $incheck == 1) { + $total_pass += $2; + $total_fail += $3 + $1; + next; + } + if ($line =~ /== ([0-9]+) passed, ([0-9]+) error in / and $incheck == 1) { + $total_pass += $1; + $total_fail += $2; + next; + } + if ($line =~ /== ([0-9]+) passed, ([0-9]+) warnings in / and $incheck == 1) { + $total_pass += $1; + $total_fail += $2; + next; + } + if ($line =~ /== ([0-9]+) failed, ([0-9]+) passed in / and $incheck == 1) { + $total_pass += $2; + $total_fail += $1; + next; + } + if ($line =~ /== ([0-9]+) failed, ([0-9]+) passed, ([0-9]+) xfailed in / and $incheck == 1) { + $total_pass += $2; + $total_fail += $1; + $total_xfail += $3; + next; + } + if ($line =~ /== ([0-9]+) failed, ([0-9]+) passed, ([0-9]+) skipped, ([0-9]+) warnings in / and $incheck == 1) { + $total_pass += $2; + $total_fail += ($1+$4); + $total_skip += $3; + next; + } + if ($line =~ /== ([0-9]+) passed in [0-9\.]+ seconds ====/ and $incheck == 1) { + $total_pass += $1; + $total_skip += $2; + next; + } + if ($line =~ /== ([0-9]+) failed, ([0-9]+) passed, ([0-9]+) skipped in [0-9\.]+ seconds ====/ and $incheck == 1) { + $total_pass += $2; + $total_fail += $1; + $total_skip += $3; + next; + } + # swift + # ========= 1 failed, 1287 passed, 1 warnings, 62 error in 35.77 seconds ========= + if ($line =~ /== ([0-9]+) failed\, ([0-9]+) passed\, ([0-9]+) warnings\, ([0-9]+) error in / and $incheck == 1) { + $total_fail+=($1+$3+$4); + $total_pass+=$2; + next; + } + # tox + # ======== 199 passed, 38 skipped, 1 xpassed, 1 warnings in 5.76 seconds ========= + if ($line =~/== ([0-9]+) passed\, ([0-9]+) skipped\, ([0-9]+) xpassed\, ([0-9]) warnings in / and $incheck == 1) { + $total_pass+=$1; + $total_skip+=$2; + $total_xfail+=$3; + $total_fail+=$4; + next; + } + # augeas + # TOTAL: 215 + # PASS: 212 + # SKIP: 3 + # XFAIL: 0 + # FAIL: 0 + # XPASS: 0 + # ERROR: 0 + if ($line =~ /# TOTAL: +([0-9]+)/ and $incheck == 1) { + $total_tests += $1; + } + if ($line =~ /# PASS: +([0-9]+)/ and $incheck == 1) { + $total_pass += $1; + } + if ($line =~ /# SKIP: +([0-9]+)/ and $incheck == 1) { + $total_skip += $1; + } + if ($line =~ /# FAIL: +([0-9]+)/ and $incheck == 1) { + $total_fail += $1; + } + if ($line =~ /# XFAIL: +([0-9]+)/ and $incheck == 1) { + $total_xfail += $1; + } + if ($line =~ /# XPASS: +([0-9]+)/ and $incheck == 1) { + $total_pass += $1; + } + # autoconf + # 493 tests behaved as expected. + # 10 tests were skipped. + # 495: AC_FUNC_STRNLEN ok + # 344: Erlang skipped (erlang.at:30) + # 26: autoupdating macros recursively expected failure (tools.at:945) + + + if ($line =~ /^([0-9]+) tests behaved as expected/ and $incheck == 1) { + $total_pass += $1; + } + if ($line =~ /^([0-9]+) tests were skipped/ and $incheck == 1) { + $total_skip += $1; + } + if ($line =~ /^[0-9]+\:.*ok$/ and $incheck == 1) { + $counted_pass++; + } + if ($line =~ /^[0-9]+\:.*skipped \(/ and $incheck == 1) { + $counted_skip++; + } + if ($line =~ /^[0-9]+\:.*expected failure \(/ and $incheck == 1) { + $counted_xfail++; + } + # bison + # 470 tests were successful. + if ($line =~ /^([0-9]+) tests were successful/ and $incheck == 1) { + $total_pass += $1; + } + + # binutils + # of expected passes 1144 + # of expected failures 57 + # of untested testcases 1 + # of unsupported tests 12 + + if ($line =~ /^# of expected passes.*\t([0-9]+)/ and $incheck == 1) { + $total_pass += $1; + } + + if ($line =~ /^# of expected failures.*\t([0-9]+)/ and $incheck == 1) { + $total_xfail += $1; + } + if ($line =~ /^# of unexpected failures.*\t([0-9]+)/ and $incheck == 1) { + $total_fail += $1; + } + + if ($line =~ /^# of unsupported tests.*\t([0-9]+)/ and $incheck == 1) { + $total_skip += $1; + } + # ccache + # PASSED: 448 assertions, 88 tests, 10 suites + if ($line =~ /PASSED: [0-9]+ assertions, ([0-9]+) tests, [0-9]+ suites/ and $incheck == 1) { + $total_pass += $1; + } + # rubygem-rack + # 701 tests, 2292 assertions, 0 failures, 0 errors + if ($line =~ /([0-9]+) tests, [0-9]+ assertions, ([0-9]+) failures, ([0-9])+ errors/ and $incheck == 1) { + $total_pass += $1; + $total_fail += $2; + $total_fail += $3; + } + # curl + # TESTDONE: 686 tests out of 686 reported OK: 100% + if ($line =~ /TESTDONE: ([0-9]+) tests out of ([0-9]+) reported OK: / and $incheck == 1) { + $total_tests += $1; + $total_pass += $2; + } + # gcc + # All 4 tests passed + # PASS: test-strtol-16. + + if ($line =~ /All ([0-9]+) tests passed/ and $incheck == 1) { + $total_tests += $1; + $total_pass += $1; + } + if ($line =~/^PASS\:/ and $incheck == 1) { + $counted_pass++; + } + if ($line =~/^FAIL\:/ and $incheck == 1) { + $counted_fail++; + } + # gdbm + # All 22 tests were successful. + if ($line =~ /All ([0-9]+) tests were successful./ and $incheck == 1) { + $total_tests += $1; + $total_pass += $1; + } + # glibc + # 3 FAIL + # 2182 PASS + # 1 UNRESOLVED + # 199 XFAIL + # 3 XPASS + if ($line =~ /^\s*([0-9]+) FAIL$/ and $incheck == 1) { + $total_fail += $1; + } + if ($line =~ /^\s*([0-9]+) PASS$/ and $incheck == 1) { + $total_pass += $1; + } + if ($line =~ /^\s*([0-9]+) XFAIL$/ and $incheck == 1) { + $total_xfail += $1; + } + if ($line =~ /^\s*([0-9]+) XPAS$/ and $incheck == 1) { + $total_pass += $1; + } + # libxml2 + # Total 2908 tests, no errors + # Total: 1171 functions, 291083 tests, 0 errors + if ($line =~ /Total ([0-9]+) tests, no errors/ and $incheck == 1) { + $total_pass += $1; + } + if ($line =~ /Total: ([0-9]+) functions, ([0-9]+) tests, 0 errors/ and $incheck == 1) { + $total_pass += $1 + } + # zlib + # *** zlib shared test OK *** + if (line =~ /\*\*\* .* test OK \*\*\*/ and $incheck == 1) { + $counted_pass++; + } + # e2fsprogs + # 153 tests succeeded 0 tests failed + if ($line =~ /([0-9]+) tests succeeded\s*([0-9]+) tests failed/ and $incheck == 1) { + $total_pass += $1; + $total_fail += $2; + } + # expect + # all.tcl: Total 29 Passed 29 Skipped 0 Failed 0 + + if ($line =~ /.*:\s*Total\s+([0-9]+)\s+Passed\s+([0-9]+)\s+Skipped\s+([0-9]+)\s+Failed\s+([0-9]+)/ and $incheck == 1) { + $total_tests += $1; + $total_pass += $2; + $total_skip += $3; + $total_fail += $4; + } + # expat + # 100%: Checks: 50, Failed: 0 + if ($line =~ /100%: Checks: ([0-9]+), Failed: ([0-9]+)/ and $incheck == 1) { + $total_pass += $1 - $2; + $total_fail += $2; + } + # flex + #Tests succeeded: 47 + #Tests FAILED: 0 + if ($line =~/^Tests succeeded: ([0-9]+)/ and $incheck == 1 and $incheck == 1) { + $total_pass += $1; + } + if ($line =~/^Tests FAILED: ([0-9]+)/ and $incheck == 1) { + $total_fail += $1; + } + # this one catches the generic TAP format! + # perl-Capture-tiny + # ok 580 - tee_merged|sys|stderr|short - got STDERR + if ($line =~ /^ok [0-9]+ \-/ and $incheck == 1) { + $counted_pass ++; + next; + } + if ($line =~ /^not ok [0-9]+ \-/ and $incheck == 1) { + if ($line =~ /# TODO known breakage/) { + $counted_xfail ++; + } else { + $counted_fail ++; + } + next; + } + if ($line =~ /^ok [0-9]+$/ and $incheck == 1) { + $counted_pass ++; + next; + } + if ($line =~ /^not ok [0-9]+$/ and $incheck == 1) { + $counted_fail ++; + next; + } + # tcpdump + # 0 tests failed + # 154 tests passed + if ($line =~ /^\s+([0-9]+) tests failed$/ and $incheck == 1) { + $total_fail += $1; + } + if ($line =~ /^\s+([0-9]+) tests passed$/ and $incheck == 1) { + $total_pass += $1; + } + # R packages + # * checking top-level files ... OK + if ($line =~ /\* .* \.\.\. OK/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /\* .* \.\.\. PASSED\./ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /\* .* \.\.\. SKIPPED/ and $incheck == 1) { + $counted_skip++; + } + # python + # 365 tests OK. + # 22 tests skipped: + if ($line =~ /^([0-9]+) tests skipped:$/ and $incheck == 1) { + $total_skip += $1; + } + if ($line =~ /^([0-9]+) tests OK.$/ and $incheck == 1) { + $total_pass += $1; + } + # go + # ok os/user 0.008s + #if ($line =~ /^ok\s+(.*)\s+[0-9\.]+s$/ and $incheck == 1) { + # $counted_pass++; + #} + #jemalloc + # Test suite summary: pass: 30/33, skip: 3/33, fail: 0/33 + if ($line =~ /Test suite summary: pass: ([0-9]+)\/([0-9]+), skip: ([0-9]+)\/([0-9]+), fail: ([0-9]+)\/([0-9]+)/ and $incheck == 1) { + $total_pass += $1; + $total_tests += $2; + $total_skip += $3; + $total_fail += $5; + } + # util-linux + # All 160 tests PASSED + if ($line =~ / All ([0-9]+) tests PASSED$/ and $incheck == 1) { + $total_pass += $1; + } + # onig + # OK: // 'a' + + if ($line =~ /^OK\: / and $incheck == 1) { + $counted_pass++; + } + + # nss + # cert.sh: #101: Import chain-2-serverCA-ec CA -t u,u,u for localhost.localdomain (ext.) - PASSED + #Passed: 13036 + #Failed: 6 + #Failed with core: 0 + #Unknown status: 0 + + + + if ($line =~ /^[a-z]+.sh: #[0-9]+: .* - PASSED$/ and $incheck == 1) { + $counted_pass++; + } + if ($line =~ /^[a-z]+.sh: #[0-9]+: .* - FAILED$/ and $incheck == 1) { + $counted_fail++; + } + if ($line =~ /^Passed:\s+([0-9]+)$/ and $incheck == 1) { + $total_pass += $1; + } + if ($line =~ /^Failed:\s+([0-9]+)$/ and $incheck == 1) { + $total_fail += $1; + } + if ($line =~ /^Failed with core:\s+([0-9]+)$/ and $incheck == 1) { + $total_fail += $1; + } + # rsync + # 34 passed + # 5 skipped + if ($line =~ /^\s+([0-9]+) passed$/ and $incheck == 1) { + $total_pass += $1; + } + if ($line =~ /^\s+([0-9]+) skipped$/ and $incheck == 1) { + $total_skip += $1; + } + # mariadb + # 100% tests passed, 0 tests failed out of 53 + if ($line =~ /tests passed, ([0-9]+) tests failed out of ([0-9]+)/ and $incheck == 1) { + $total_fail += $1; + $total_tests += $2; + $total_pass +- $2 - $1; + next; + } + + # python-runtime-tests + # FAILED (KNOWNFAIL=6, SKIP=18, errors=6) + # FAILED (failures=1) + # FAILED (failures=1, errors=499, skipped=48) + # OK (KNOWNFAIL=5, SKIP=15) + + if ($line =~ /FAILED \(KNOWNFAIL=([0-9]+), SKIP=([0-9]+), errors=([0-9]+)\)/ and $incheck == 1) { + $total_xfail += $1; + $total_skip += $2; + $total_fail += $3; + next; + } + if ($line =~ /FAILED \(failures=([0-9]+), errors=([0-9]+), skipped=([0-9]+)\)/ and $incheck == 1) { + $total_xfail += $2; + $total_skip += $3; + $total_fail += $1; + next; + } + if ($line =~ /FAILED \(failures=([0-9]+), errors=([0-9]+)\)/ and $incheck == 1) { + $total_xfail += $2; + $total_fail += $1; + next; + } + if ($line =~ /FAILED \(failures=([0-9]+)\)/ and $incheck == 1) { + $total_fail += $1; + next; + } + if ($line =~ /FAILED \(errors=([0-9]+)\)/ and $incheck == 1) { + $total_xfail += $1; + next; + } + if ($line =~ /OK \(KNOWNFAIL=([0-9]+), SKIP=([0-9]+)\)/ and $incheck == 1) { + $total_xfail += $1; + $total_skip += $2; + } + # qpid-python + # Totals: 318 tests, 200 passed, 112 skipped, 0 ignored, 6 failed + + if ($line =~ /Totals: ([0-9]+) tests, ([0-9]+) passed, ([0-9]+) skipped, ([0-9]+) ignored, ([0-9]+) failed/ and $incheck == 1) { + $total_tests += $1; + $total_pass += $2; + $total_skip += $3; + $total_xfail += $4; + $total_fail += $5; + } + # PyYAML + # TESTS: 2577 + if ($line =~ /^TESTS: ([0-9]+)$/ and $incheck == 1) { + $total_tests += $1; + } + # sudo + # visudo: 7/7 tests passed; 0/7 tests failed + # check_symbols: 7 tests run, 0 errors, 100% success rate + + if ($line =~ /[a-z_]+\:\s+([0-9]+)\/[0-9]+ tests passed; ([0-9]+)\/[0-9]+ tests failed/ and $incheck == 1) { + $total_pass += $1; + $total_fail += $2; + } + if ($line =~ /[a-z_]+\: ([0-9]+) tests run, ([0-9]+) errors/ and $incheck == 1) { + $total_tests += $1; + $total_fail += $2; + $total_pass += $1 - $2; + } + # R + # running code in 'reg-examples1.R' ... OK + # Status: 1 ERROR, 1 WARNING, 4 NOTEs + # OK: 749 SKIPPED: 4 FAILED: 2 + + if ($line =~ /running code in '.*\.R' \.\.. OK/ and $incheck == 1) { + $counted_pass ++; + next; + } + if ($line =~ /Status: ([0-9]+) ERROR, ([0-9]+) WARNING, ([0-9]+) NOTEs/ and $incheck == 1) { + $total_fail += $1; + } + if ($line =~ /OK: ([0-9]+) SKIPPED: ([0-9]+) FAILED: ([0-9]+)/ and $incheck == 1) { + $total_pass += $1; + $total_fail += $3; + $total_skip += $2; + } + # php + # Number of tests : 13526 9794 + # Tests skipped : 3732 ( 27.6%) -------- + # Tests warned : 0 ( 0.0%) ( 0.0%) + # Tests failed : 12 ( 0.1%) ( 0.1%) + # Expected fail : 31 ( 0.2%) ( 0.3%) + # Tests passed : 9751 ( 72.1%) ( 99.6%) + if ($line =~ /^Number of tests : ([0-9]+)/ and $incheck == 1) { + $total_tests += $1; + } + if ($line =~ /^Tests skipped :\s+([0-9]+) \(/ and $incheck == 1) { + $total_skip += $1; + } + if ($line =~ /^Tests failed :\s+([0-9]+) \(/ and $incheck == 1) { + $total_fail += $1; + } + if ($line =~ /^Expected fail :\s+([0-9]+) \(/ and $incheck == 1) { + $total_xfail += $1; + } + if ($line =~ /^Tests passed :\s+([0-9]+) \(/ and $incheck == 1) { + $total_pass += $1; + } + + # rubygem / rake + # 174 runs, 469 assertions, 0 failures, 0 errors, 0 skips + + if ($line =~ /([0-9]+) runs, ([0-9]+) assertions, ([0-9]+) failures, ([0-9]+) errors, ([0-9]+) skips/ and $incheck == 1) { + $total_tests += $1; + $total_fail += $3; + $total_skip += $5; + } + + # cryptsetup + # [OK] + if ($incheck == 1 && $line =~ / \[OK\]$/ and $incheck == 1) { + $counted_pass++; + } + # lzo + # test passed. + if ($line =~ / test passed.$/ and $incheck == 1) { + $counted_pass++; + next; + } + + # lsof + # LTnlink ... OK + # LTnfs ... ERROR!!! + if ($line =~ /^LT[a-zA-Z0-9]+ \.\.\. OK$/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /^LT[a-zA-Z0-9]+ \.\.\. ERROR\!\!\!/ and $incheck == 1) { + $counted_fail++; + next; + } + # libaio + # Pass: 11 Fail: 1 + if ($line =~ /^Pass: ([0-9]+) Fail: ([0-9]+)$/ and $incheck == 1) { + $total_pass += $1; + $total_fail += $1; + next; + } + + # gawk + if ($line =~ /^ALL TESTS PASSED$/ and $incheck == 1) { + $total_pass++; + next; + } + # gptfdisk + # **SUCCESS** ... + if ($line =~ /^\*\*SUCCESS\*\*/ and $incheck == 1) { + $counted_pass++; + next; + } + + # boost + # **passed** ... + # 8 errors detected. + + if ($line =~ /^\*\*passed\*\*/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~/([0-9]+) errors? detected\.?/ and $incheck == 1) { + $total_fail += $1; + next; + } + if ($line =~/([0-9]+) failures? detected\.?/ and $incheck == 1) { + $total_fail += $1; + next; + } + # make + # 534 Tests in 118 Categories Complete ... No Failures + if ($line =~ /([0-9]+) Tests in ([0-9]+) Categories Complete ... No Failures/ and $incheck == 1) { + $total_tests += $1; + $total_pass += $1; + } + # icu4c ---[OK] + if ($line =~ /---\[OK\]/ and $incheck == 1) { + $counted_pass++; + next; + } + # libxslt + # Pass 1 + + if ($line =~ /^Pass [0-9]+$/ and $incheck == 1) { + $counted_pass++; + next; + } + # apr-util + # : SUCCESS + if ($line =~ /: SUCCESS$/ and $incheck == 1) { + $counted_pass++; + next; + } + # bash + # < Failed 126 of 1378 Unicode tests + if ($line =~ /^[<,>] Failed ([0-9]+) of ([0-9]+)/ and $incheck == 1) { + $total_fail+=$1; + $total_tests+=$2; + next; + } + # crudini + # Test 95 OK (line 460) + if ($line =~ /^Test [0-9]+ OK/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /^Test [0-9]+ [A-Z!O][A-Z!K]/ and $incheck == 1) { + $counted_fail++; + next; + } + # discount + # Reddit-style automatic links ......................... OK + if ($line =~ /[a-z\-]+ \.\.\.+ (OK|GOOD)$/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /[a-z\-]+ \.\.\.+ [A-Z!O][A-Z!K]$/ and $incheck == 1) { + $counted_fail++; + next; + } + # libjpeg-turbo + # JPEG -> RGB Top-Down 2/1 ... Passed. + # JPEG -> RGB Top-Down 15/8 ... Passed. + # JPEG -> RGB Top-Down 7/4 ... Passed. + if ($line =~ /[A-Za-z0-9\ \>\<\/]+ \.\.\. Passed\./ and $incheck == 1) { + $counted_pass++; + next; + } + # *** zlib test OK *** + # *** zlib 64-bit test OK *** + if ($line =~ /\*\*\* zlib .*test OK \*\*\*/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /\*\*\* zlib .*test [A-Z!O][A-Z!K] \*\*\*/ and $incheck == 1) { + $counted_fail++; + next; + } + # LVM2 + # valgrind pool awareness ... fail + # dfa matching ... fail + # dfa matching ... fail + # dfa with non-print regex chars ... pass + # bitset iteration ... pass + # valgrind pool awareness ... fail + # dfa matching ... fail + # dfa matching ... fail + # dfa with non-print regex chars ... fail + # bitset iteration ... fail + if ($line =~ /[a-z\ ]+\ \.\.\.\ pass/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /[a-z\ ]+\ \.\.\.\ fail/ and $incheck == 1) { + $counted_fail++; + next; + } + # keyring + # 76 passed, 62 skipped, 50 xfailed, 14 xpassed, 2 warnings, 32 error in 2.13 seconds + if ($line =~ /([0-9]+) passed, ([0-9]+) skipped, ([0-9]+) xfailed, ([0-9]+) xpassed, ([0-9]+) warnings, ([0-9]+) error in [0-9\.]+ seconds/ and $incheck == 1) { + $total_pass+=$1+$4; + $total_skipp+=$2; + $total_xfail+=$3; + $total_fail=+$5+$6; + next; + } + # openblas + # Real BLAS Test Program Results + # Test of subprogram number 1 SDOT + # ----- PASS ----- + # Test of subprogram number 2 SAXPY + # ----- PASS ----- + # Test of subprogram number 3 SROTG + # ----- PASS ----- + if ($line =~ /\ \ +\-\-\-+\ PASS\ \-\-\-+/ and $incheck == 1) { + $counted_pass++; + next; + } + if ($line =~ /\ \ +\-\-\-+\ FAIL\ \-\-\-+/ and $incheck == 1) { + $counted_fail++; + next; + } + # rubygem-hashie + # Finished in 0.07221 seconds (files took 0.28356 seconds to load) + # 545 examples, 0 failures, 1 pending + if ($line =~ /([0-9]+) examples?, ([0-9]+) failures?, ([0-9]+) pending/ and $incheck == 1) { + $total_pass+=$1; + $total_fail+=$2; + $total_skip+=$3; + next; + } + # rubygem-warden + # Finished in 0.08928 seconds (files took 0.1046 seconds to load) + # 215 examples, 14 failures + if ($line =~ /([0-9]+) examples?, ([0-9]+) failures?/ and $incheck == 1) { + $total_pass+=$1; + $total_fail+=$2; + next; + } + # rubygem-ansi + # Executed 12 tests with 7 passing, 5 errors. + if ($line =~ /Executed ([0-9]+) tests with ([0-9+]) passing, ([0-9]+) errors\./ and $incheck == 1) { + $total_tests+=$1; + $total_pass+=$2; + $total_fail+=$3; + next; + } + # rubygem-formatador + # 9 succeeded in 0.00375661 seconds + if ($line =~ /([0-9]+) succeeded in [0-9]+\.[0-9]+ seconds/ and $incheck == 1) { + $total_pass+=$1 + } + # ./pigz -kf pigz.c ; ./pigz -t pigz.c.gz + # ./pigz -kfb 32 pigz.c ; ./pigz -t pigz.c.gz + if ($line =~ /.*\.\/pigz.+(\.\/pigz).+/ and $incheck == 1) { + $total_pass+=2; + } + elsif ($line =~ /.*\.\/pigz.+/ and $incheck == 1) { + $total_pass++; + } + # netifaces + # Interface lo: + # Interface enp2s0: + if ($line =~ /^Interface [a-zA-Z0-9]+\:/ and $incheck == 1) { + $total_pass++; + next; + } + # btrfs-progs + # [TEST] 001-bad-file-extent-bytenr + # [NOTRUN] Need to validate root privileges + # test failed for case + if ($line =~ / \[TEST\] .*/ and $incheck == 1) { + $total_pass++; + next; + } + if ($line =~ /test failed for case.*/ and $incheck == 1) { + $total_fail++; + $total_pass--; + next; + } + if ($line =~ / \[NOTRUN\] .*/ and $incheck == 1) { + $total_skip++; + next; + } + # chrpath + # success: chrpath changed rpath to larger path. + # error: chrpath unable to change rpath to larger path. + if ($line =~ /success\: chrpath .*/ and $incheck == 1) { + $total_pass++; + next; + } + elsif ($line =~ /error: chrpath .*/ and $incheck == 1) { + $total_fail++; + next; + } + elsif ($line =~ /warning: chrpath .*/ and $incheck == 1) { + $total_fail++; + next; + } + # yajl + # 58/58 tests successful + if ($line =~/([0-9]+)\/([0-9]+) tests successful/ and $incheck == 1) { + $total_pass+=$1; + $total_tests+=$2; + next; + } + # xmlsec1 + # Checking required transforms OK + # Verify existing signature Fail + # Checking required transforms Skip + # Checking required key data OK + if ($line =~ /^ [\w ]+\ +OK$/ and $incheck == 1) { + $total_pass++; + next; + } + elsif ($line =~ /^ [\w ]+\ +Fail$/ and $incheck == 1) { + $total_fail++; + next; + } + elsif ($line =~ /^ [\w ]+\ +Skip$/ and $incheck == 1) { + $total_skip++; + next; + } + # xdg-utils + # TOTAL: 4 tests failed, 90 of 116 tests passed. (140 attempted) + if ($line =~/TOTAL\: ([0-9]+) tests? failed\, ([0-9]+) of [0-9]+ tests? passed\. \(([0-9]+) attempted\)/ and $incheck == 1) { + $total_fail+=$1; + $total_pass+=$2; + $total_skip+=$3-($2+$1); + next; + } + # slang + # Testing argv processing ...Ok + # ./utf8.sl:14:check_sprintf:Test Error + if ($line =~/^Testing [\w ]+\.\.\.Ok$/ and $incheck == 1) { + $total_pass++; + next; + } + if ($line =~/^\.\/[A-Za-z0-9\.\<\>\:\ ]+\:Test Error$/ and $incheck == 1) { + $total_fail++; + next; + } + #go & golang + #ok golang.org/x/text/encoding/htmlindex 0.002s + #--- FAIL: TestParents (0.00s) + #FAIL golang.org/x/text/internal 0.002s + #if ($line =~/^ok\s+[\w_]+[0-9A-Za-z\._\/]*\s+[0-9]+\.[0-9]+s$/ and $incheck == 1) { + if ($line =~/^ok\s+[\w_]+[A-Za-z0-9\.\?_\-]*/ and $incheck == 1) { + $total_tests++; + $total_pass++; + next; + } + if ($line =~/---\s+FAIL:|FAIL\s+ / and $incheck == 1) { + $total_tests++; + $total_fail++; + next; + } + # valgrind + # == 5 tests, 0 stderr failures, 1 stdout failure, 0 stderrB failures, 0 stdoutB failures, 0 post failures == + # == 55 tests, 48 stderr failures, 6 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures == + # == 125 tests, 12 stderr failures, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures == + #if ($line =~/\=\= ([0-9]+) tests/ and $incheck == 1) { + if ($line =~/\=\= ([0-9]+) tests?\, ([0-9]+) stderr failures?\, ([0-9]+) stdout failures?\, ([0-9]+) stderrB failures?\, ([0-9]+) stdoutB failures?\, ([0-9]+) post failures? \=\=/ and $incheck == 1) { + $total_tests+=$1; + $total_fail+=($2+$3+$4+$5+$6); + $total_pass+=($1-($2+$3+$4+$5+$6)); + next; + } + } + close($log); +} + +sub sanitize_counts +{ + if ($total_tests > 0 && $total_pass == 0) { + $total_pass = $total_tests - $total_fail - $total_skip - $total_xfail; + } + if ($total_tests < $total_pass && $total_pass > 0) { + $total_tests = $total_pass + $total_fail + $total_skip + $total_xfail; + } + if ($counted_tests > 0 && $counted_pass == 0) { + $counted_pass = $counted_tests - $counted_fail - $counted_skip - $counted_xfail; + } + if ($counted_tests < $counted_pass && $counted_pass > 0) { + $counted_tests = $counted_pass + $counted_fail + $counted_skip + $counted_xfail; + } + if (($total_pass + $total_fail + $total_skip + $total_xfail) < $total_tests) { + $total_pass+=$total_tests-($total_pass + $total_fail + $total_skip + $total_xfail); + } +} + +sub collect_output +{ + + if ($counted_tests > $total_tests) { + $testcount{$name} += $counted_tests; + $testpass{$name} += $counted_pass; + $testfail{$name} += $counted_fail; + $testxfail{$name} += $counted_xfail; + $testskip{$name} += $counted_skip; + + if ($counted_tests > 0) { + $pkg_has_tests++; + } + } else { + $testcount{$name} += $total_tests; + $testpass{$name} += $total_pass; + $testfail{$name} += $total_fail; + $testxfail{$name} += $total_xfail; + $testskip{$name} += $total_skip; + if ($total_tests > 0) { + $pkg_has_tests++; + } + } + + $total_tests = 0; + $total_pass = 0; + $total_fail = 0; + $total_xfail = 0; + $total_skip = 0; + + $counted_tests = 0; + $counted_pass = 0; + $counted_fail = 0; + $counted_xfail = 0; + $counted_skip = 0; +} + +sub print_output +{ + $count = keys %testcount; + if ($count > 1) + { + foreach my $key (sort(keys(%testcount))) { + if ($key) + { + print $key; + print ",$testcount{$key},$testpass{$key},$testfail{$key},$testskip{$key},$testxfail{$key}"; + print "\n"; + } + } + } + else + { + foreach my $key (sort(keys(%testcount))) { + print ",$testcount{$key},$testpass{$key},$testfail{$key},$testskip{$key},$testxfail{$key}"; + print "\n"; + } + } +} + +$total_tests = 0; +$total_pass = 0; +$total_fail = 0; +$total_xfail = 0; +$total_skip = 0; + +$counted_tests = 0; +$counted_pass = 0; +$counted_fail = 0; +$counted_xfail = 0; +$counted_skip = 0; + +parse_log($ARGV[0]); + +sanitize_counts(); + +collect_output(); + +print_output(); diff --git a/files.py b/files.py new file mode 100644 index 0000000..d1cb69e --- /dev/null +++ b/files.py @@ -0,0 +1,400 @@ +#!/bin/true +# +# files.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# %files section management +# + +import build +from collections import OrderedDict +import lang +import re +import tarball +import buildreq +import config +# todo package splits + +# per sub-package file list for spec purposes +packages = OrderedDict() +main_requires = OrderedDict() + +# global file list to weed out dupes +files = [] +files_blacklist = [] +excludes = [] +extras = [] +setuid = [] +attrs = {} + +newfiles_printed = 0 + +# +# Do we need ALL include files in a dev package, even if they're not in /usr/include? +# Yes in the general case, but for example for R packages, +# the answer is No. +want_dev_split = 1 + + +def push_main_requires(package): + global main_requires + if (package not in main_requires): + main_requires[package] = set() + + +def push_package_file(filename, package="main"): + global packages + global newfiles_printed + + if (package not in packages): + packages[package] = set() + packages[package].add(filename) + build.must_restart = build.must_restart + 1 + if newfiles_printed == 0: + print(" New %files content found") + newfiles_printed = 1 + + +def file_pat_match(filename, pattern, package, replacement="", prefix=""): + if replacement == "": + replacement = prefix + filename + + pat = re.compile(pattern) + match = pat.search(filename) + if match: + if filename in excludes: + push_package_file("%exclude " + filename, package) + return True + push_package_file(replacement, package) + return True + else: + return False + + +def file_is_locale(filename): + pat = re.compile("^/usr/share/locale/.*/(.*)\.mo") + match = pat.search(filename) + if match: + l = match.group(1) + lang.add_lang(l) + return True + else: + return False + + +def push_file(filename): + global files + global files_blacklist + global extras + global setuid + global attrs + for file in files: + if file == filename: + return 0 + + if filename in files_blacklist: + return 0 + files.append(filename) + + if file_is_locale(filename): + return + + # extras + if filename in extras: + push_package_file(filename, "extras") + excludes.append(filename) + + if filename in setuid: + fn = "%attr(4755, root, root) " + filename + push_package_file(fn, "setuid") + excludes.append(filename) + + if filename in attrs: + fn = "%s(%s,%s,%s) %s" % (attrs[filename][0], attrs[filename][1], attrs[filename][2], + attrs[filename][3], filename) + push_package_file(fn, "attr") + excludes.append(filename) + + if file_pat_match(filename, r"^/usr/share/omf", "main", "/usr/share/omf/*"): + return + + if file_pat_match(filename, r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.so\.", "lib", "/usr/lib/*.so.*"): + return + if file_pat_match(filename, r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.so\.", "lib", "/usr/lib64/*.so.*"): + return + if file_pat_match(filename, r"^/usr/libexec/", "bin"): + return + if file_pat_match(filename, r"^/usr/bin/", "bin"): + return + if file_pat_match(filename, r"^/usr/sbin/", "bin"): + return + if file_pat_match(filename, r"^/sbin/", "bin"): + return + if file_pat_match(filename, r"^/bin/", "bin"): + return + if file_pat_match(filename, r"^/bin/", "bin"): + return + + if file_pat_match(filename, r"^/usr/lib/python.*/", "python", "/usr/lib/python*/*"): + return + if file_pat_match(filename, r"^/usr/lib64/python.*/", "python", "/usr/lib64/python*/*"): + return + if file_pat_match(filename, r"^/usr/share/gir-1\.0/.*\.gir\$", "data", "/usr/share/gir-1.0/*.gir"): + return + if file_pat_match(filename, r"^/usr/share/cmake/", "data", "/usr/share/cmake/*"): + return + if file_pat_match(filename, r"^/usr/share/cmake-3.1/", "data", "/usr/share/cmake-3.1/*"): + return + if file_pat_match(filename, r"^/usr/share/girepository-1\.0/.*\.typelib\$", "data", "/usr/share/girepository-1.0/*.typelib"): + return + + if file_pat_match(filename, r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.hxx", "dev", "/usr/include/*.hxx"): + return + if file_pat_match(filename, r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.hpp", "dev", "/usr/include/*.hpp"): + return + if file_pat_match(filename, r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.h\+\+", "dev", "/usr/include/*.h\+\+"): + return + if file_pat_match(filename, r"^/usr/include/[a-zA-Z0-9\.\_\-\+]*\.h", "dev", "/usr/include/*.h"): + return + if file_pat_match(filename, r"^/usr/include/", "dev"): + return + if want_dev_split > 0 and file_pat_match(filename, r"^/usr/.*/include/.*\.h$", "dev"): + return + if file_pat_match(filename, r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.so$", "dev", "/usr/lib/*.so"): + return + if file_pat_match(filename, r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.so$", "dev", "/usr/lib64/*.so"): + return + if file_pat_match(filename, r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev", "/usr/lib/*.a"): + return + if file_pat_match(filename, r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.a$", "dev", "/usr/lib64/*.a"): + return + if file_pat_match(filename, r"^/usr/lib/pkgconfig/[a-zA-Z0-9\.\_\-\+]*\.pc$", "dev", "/usr/lib/pkgconfig/*.pc"): + return + if file_pat_match(filename, r"^/usr/lib64/pkgconfig/[a-zA-Z0-9\.\_\-\+]*\.pc$", "dev", "/usr/lib64/pkgconfig/*.pc"): + return + if file_pat_match(filename, r"^/usr/share/aclocal/[a-zA-Z0-9\.\_\-\+]*\.ac$", "dev", "/usr/share/aclocal/*.ac"): + return + if file_pat_match(filename, r"^/usr/share/aclocal/[a-zA-Z0-9\.\_\-\+]*\.m4$", "dev", "/usr/share/aclocal/*.m4"): + return + if file_pat_match(filename, r"^/usr/share/aclocal-1.[0-9]+/[a-zA-Z0-9\.\_\-\+]*\.ac$", "dev", "/usr/share/aclocal-1.*/*.ac"): + return + if file_pat_match(filename, r"^/usr/share/aclocal-1.[0-9]+/[a-zA-Z0-9\.\_\-\+]*\.m4$", "dev", "/usr/share/aclocal-1.*/*.m4"): + return + + if file_pat_match(filename, r"^/usr/share/doc/" + tarball.name + "/", "doc", "%doc /usr/share/doc/" + tarball.name + "/*"): + return + if file_pat_match(filename, r"^/usr/share/gtk-doc/html", "doc"): + return + if file_pat_match(filename, r"^/usr/share/info/", "doc", "%doc /usr/share/info/*"): + return + + if file_pat_match(filename, r"^/usr/share/man/man0", "doc", "%doc /usr/share/man/man0/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man1", "doc", "%doc /usr/share/man/man1/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man2", "doc", "%doc /usr/share/man/man2/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man3", "doc", "%doc /usr/share/man/man3/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man4", "doc", "%doc /usr/share/man/man4/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man5", "doc", "%doc /usr/share/man/man5/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man6", "doc", "%doc /usr/share/man/man6/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man7", "doc", "%doc /usr/share/man/man7/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man8", "doc", "%doc /usr/share/man/man8/*"): + return + if file_pat_match(filename, r"^/usr/share/man/man9", "doc", "%doc /usr/share/man/man9/*"): + return + + if file_pat_match(filename, r"^/etc/systemd/system/.*\.wants/", "active-units"): + return + + # now a set of catch-all rules + if file_pat_match(filename, r"^/etc/", "config", "", "%config "): + return + if file_pat_match(filename, r"^/usr/etc/", "config", "", "%config "): + return + if file_pat_match(filename, r"^/lib/systemd", "config"): + return + if file_pat_match(filename, r"^/usr/lib/systemd", "config"): + return + if file_pat_match(filename, r"^/usr/lib/udev/rules.d", "config"): + return + if file_pat_match(filename, r"^/usr/lib/modules-load.d", "config"): + return + if file_pat_match(filename, r"^/usr/lib/tmpfiles.d", "config"): + return + if file_pat_match(filename, r"^/usr/lib/sysusers.d", "config"): + return + if file_pat_match(filename, r"^/usr/lib/sysctl.d", "config"): + return + + if file_pat_match(filename, r"^/usr/share/", "data"): + return + + # finally move any dynamically loadable plugins (not + # perl/python/ruby/etc.. extensions) into lib package + if file_pat_match(filename, r"^/usr/lib/.*/[a-zA-Z0-9\.\_\-\+]*\.so", "lib"): + return + if file_pat_match(filename, r"^/usr/lib64/.*/[a-zA-Z0-9\.\_\-\+]*\.so", "lib"): + return + +# locale data gets picked up via find_lang + if file_pat_match(filename, r"^/usr/share/locale/", "ignore"): + return + + if filename in excludes: + push_package_file("%exclude " + filename) + return + + push_package_file(filename) + + +def remove_file(file): + global files + global packages + global files_blacklist + hit = False + + if file in files: + files.remove(file) + print("File no longer present: %s" % file) + hit = True + for pkg in packages: + if file in packages[pkg]: + packages[pkg].remove(file) + print("File no longer present in %s: %s" % (pkg, file)) + hit = True + if hit: + if file not in files_blacklist: + files_blacklist.append(file) + build.must_restart = build.must_restart + 1 + + +def write_files_header(file): + global files + global packages + + groups = dict() + groups["dev"] = "Development" + groups["bin"] = "Binaries" + groups["lib"] = "Libraries" + groups["doc"] = "Documentation" + groups["data"] = "Data" + + deps = dict() + + deps["dev"] = ["lib", "bin", "data"] + deps["bin"] = ["data", "config", "setuid", "attr"] + deps["lib"] = ["data", "config"] + + provides = dict() + provides["dev"] = ["devel"] + + for pkg in sorted(packages): + if pkg == "ignore": + continue + if pkg == "main": + continue + + file.write("\n%package " + pkg + "\n") + file.write("Summary: " + pkg + + " components for the " + tarball.name + " package.\n") + if pkg in groups: + file.write("Group: " + groups[pkg] + "\n") + else: + file.write("Group: Default\n") + for dep in deps.get(pkg, []): + if dep in packages: + file.write("Requires: " + tarball.name + "-" + dep + "\n") + for prov in provides.get(pkg, []): + file.write("Provides: " + tarball.name + "-" + prov + "\n") + if pkg == "python": + if tarball.name != tarball.name.lower(): + file.write("Provides: %s-python\n" % tarball.name.lower()) + for req in sorted(buildreq.pythonreqs): + if req in buildreq.buildreqs: + file.write("Requires: " + req + "\n") + file.write("\n") + file.write("%description " + pkg + "\n") + file.write(pkg + " components for the " + tarball.name + " package.\n") + file.write("\n") + + +def write_files(file): + global files + global packages + + file.write("\n%files\n") + file.write("%defattr(-,root,root,-)\n") + if "main" in packages: + for filename in sorted(packages["main"]): + file.write(filename + "\n") + + for pkg in sorted(packages): + if pkg == "ignore": + continue + if pkg == "main": + continue + if pkg == "locales": + continue + file.write("\n%files " + pkg + "\n") + file.write("%defattr(-,root,root,-)\n") + for filename in sorted(packages[pkg]): + file.write(filename + "\n") + + +def write_scriplets(file): + global files + global packages + + for pkg in sorted(packages): + if pkg == "ignore": + continue + if pkg == "main": + continue + if pkg == "locales": + continue + for script in ["post", "pre"]: + content = config.read_conf_file("%s.%s" % (pkg, script)) + if content: + file.write("\n%{0} {1}\n".format(script, pkg)) + file.writelines(content) + + +def write_main_subpackage_requires(file): + global files + global packages + global main_requires + + for pkg in packages: + if pkg == "ignore": + continue + if pkg == "main": + continue + if pkg == "dev": + continue + if pkg == "active-units": + continue + if pkg == "extras": + continue + file.write("Requires: " + tarball.name + "-" + pkg + "\n") + + for pkg in main_requires: + file.write("Requires: " + pkg + "\n") diff --git a/git.py b/git.py new file mode 100644 index 0000000..5e3d69a --- /dev/null +++ b/git.py @@ -0,0 +1,66 @@ +#!/bin/true +# +# git.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Commit to git +# + +import subprocess + +import build +import buildpattern +import tarball +import test +from util import call +import config + + +def commit_to_git(path): + + if not config.git_uri: + return + + call("git init", stdout=subprocess.DEVNULL, cwd=path) + + try: + call("git config --get remote.origin.url", cwd=path) + except subprocess.CalledProcessError: + upstream_uri = config.git_uri % {'NAME': tarball.name} + call("git remote add origin %s" % upstream_uri, cwd=path) + + for config_file in config.config_files: + call("git add %s" % config_file, cwd=path) + for unit in buildpattern.sources["unit"]: + call("git add %s" % unit, cwd=path) + call("git add Makefile", cwd=path) + call("git add upstream", cwd=path) + call("git add *.spec", cwd=path) + if test.unit_pass_written: + call("git add unit_tests_must_pass", cwd=path) + call("git add %s.tmpfiles" % tarball.name, check=False, stderr=subprocess.DEVNULL, cwd=path) + call("git add make_install_append", check=False, stderr=subprocess.DEVNULL, cwd=path) + call("git add funroll-loops", check=False, stderr=subprocess.DEVNULL, cwd=path) + call("git add series", check=False, stderr=subprocess.DEVNULL, cwd=path) + call("git add make_check_command", check=False, stderr=subprocess.DEVNULL, cwd=path) + call("git add keepstatic", check=False, stderr=subprocess.DEVNULL, cwd=path) + call("git add *.patch", check=False, stderr=subprocess.DEVNULL, cwd=path) + call("git add release", cwd=path) + + if build.success == 0: + return + + call("git commit -a -m \"Autospec creation for version " + tarball.version + "\"", cwd=path) diff --git a/lang.py b/lang.py new file mode 100644 index 0000000..996bd6b --- /dev/null +++ b/lang.py @@ -0,0 +1,52 @@ +#!/bin/true +# +# lang.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Parse config files +# + +import files + + +locales = [] + + +def add_lang(lang): + global locales + if lang in locales: + return + locales.append(lang) + print(" New locale:", lang) + + if "locales" in files.packages: + return + files.packages["locales"] = [] + + +def write_find_lang(file): + for lang in locales: + file.write("%find_lang " + lang + "\n") + + +def write_lang_files(file): + global locales + if len(locales) == 0: + return + file.write("\n%files locales ") + for lang in locales: + file.write("-f " + lang + ".lang ") + file.write("\n%defattr(-,root,root,-)\n\n") diff --git a/license.py b/license.py new file mode 100644 index 0000000..8beacc0 --- /dev/null +++ b/license.py @@ -0,0 +1,275 @@ +#!/bin/true +# +# license.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Deduce the upstream version from the package content +# based on both license file pattern matching and +# exact matches on hashes of the COPYING file +# + +import os +import tarball +import urllib +import config + +default_license = "TO BE DETERMINED" + +LICENSE_HASH_FILE = "common/licenses" + +licenses = [] + +license_translations = { + "GPL-2.0": "GPL-2.0", + "GPLv2": "GPL-2.0", + "GPLV2": "GPL-2.0", + "GPLV3": "GPL-3.0", + "GPL-2": "GPL-2.0", + "GPL-2+": "GPL-2.0+", + "GPL-2.0+": "GPL-2.0+", + "GPLv2+": "GPL-2.0+", + "GPL(>=2)": "GPL-2.0+", + "GPL(>=-2)": "GPL-2.0+", + "LGPL(>=2)": "LGPL-2.0+", + "LGPL(>=-2)": "LGPL-2.0+", + "LGPLv2": "LGPL-2.0", + "LGPLv2.1": "LGPL-2.1", + "LGPLv2+": "LGPL-2.1+", + "LGPL-2.0+": "LGPL-2.0+", + "LGPL-2.1": "LGPL-2.1", + "LGPLv2.1": "LGPL-2.1", + "LGPL-2.1+": "LGPL-2.1+", + "LGPLv2.1+": "LGPL-2.1+", + "LGPLv3+": "LGPL-3.0+", + "LGPLv3": "LGPL-3.0", + "GPL-3.0": "GPL-3.0", + "GPLv3": "GPL-3.0", + "GPL-3": "GPL-3.0", + "LGPL-3": "LGPL-3.0", + "zlib": "Zlib", + "zlib/libpng": "zlib-acknowledgement", + "Boost": "BSL-1.0", + "GPL-3.0+": "GPL-3.0+", + "GPLv3+": "GPL-3.0+", + "GPL3": "GPL-3.0", + "GPL(>=3)": "GPL-3.0+", + "http://opensource.org/licenses/MIT": "MIT", + "mit": "MIT", + "http://www.apache.org/licenses/LICENSE-2.0": "Apache-2.0", + "Apache License, Version 2.0": "Apache-2.0", + "Apache License 2.0": "Apache-2.0", + "APL2.0": "Apache-2.0", + "APL2": "Apache-2.0", + "ASL 2.0": "Apache-2.0", + "ASL-2.0": "Apache-2.0", + "APL-2.0": "Apache-2.0", + "ASL-2": "Apache-2.0", + "Apache2.0": "Apache-2.0", + "Apache 2.0": "Apache-2.0", + "Apache": "Apache-2.0", + "apache": "Apache-2.0", + "Apache-2": "Apache-2.0", + "artistic_2": "Artistic-2.0", + "MPLv1.1": "MPL-1.1", + "ZPL 2.1": "ZPL-2.1", + "ZPL": "ZPL-2.0", + "http://creativecommons.org/licenses/BSD/": "BSD-2-Clause", + "BSD_3_clause": "BSD-3-Clause", + "perl": "Artistic-1.0-Perl", + "PSF": "Python-2.0", + "Python": "Python-2.0", + "BSD_2_clause": "BSD-2-Clause", + "Expat": "MIT", + "VIM": "Vim" +} + +license_blacklist = { + "and": True, + "BSD": True, + "3BSD": True, + "LGPL": True, + "GPL": True, + "ASL": True, + "2.0": True, + "advertising": True, + "LGPL+BSD": True, + "UN": True, + "GNU": True, + "new": True, + "none": True, + "License": True, + "License": True, + "license": True, + "Standard": True, + "PIL": True, + "Software": True, + "|": True, + "+": True, + "UNKNOWN": True, + "unknown": True, + "BSD-like": True, + "or": True, + "Modified": True, + "3-clause": True, + "Unlimited": True, + "BSD_3_clause": True, + "BSD(3": True, + "clause)": True, + "GFDL": True, + "MPL": True, + "Muddy-MIT": True, + "LGPL/MIT": True, + "License,": True, + "LICENCE": True, + "-": True, + "See": True, + "details": True, + "for": True, + "Version-2.0": True, + "exceptions": True, + "http://nmap.org/man/man-legal.html": True, + "with": True, + "style": True, + "Foundation": True, + "~": True, + "open_source": True, + "BSDish": True, + "EPL": True, + "Artistic": True, + "(specified": True, + "using": True, + "classifiers)": True, + "APL-2.0": True, + "dual": True +} + + +def add_license(lic): + global licenses + lic = lic.strip() + + # Bail if the license isn't one we recognize, is a blacklisted word or has already been added + if lic in licenses: + return False + if lic in license_blacklist: + return False + if lic not in license_translations: + licenses.append(lic) + return True + if license_translations[lic] in licenses: + return False + + licenses.append(license_translations[lic]) + return True + + +def license_from_copying_content(copying): + with open(copying, 'r', encoding="latin-1") as content_file: + content = content_file.read() + if content.find("Version 2, June 1991") >= 0: + add_license("GPL-2.0") + if content.find("Version 3, 29 June 2007") >= 0: + add_license("GPL-3.0") + if content.find("Version 2.1, February 1999") >= 0: + add_license("LGPL-2.1") + if content.find("Source Code is licensed under MIT license") >= 0: + add_license("MIT") + if content.find("Version 2.0, January 2004") >= 0: + add_license("Apache-2.0") + + +def license_from_copying_hash(copying): + """Add licenses based on the hash of the copying file""" + licenses_list = [] + hash_sum = tarball.get_sha1sum(copying) + + licenses_dict = dict() + + if config.license_fetch: + with open(copying, "r", encoding="latin-1") as myfile: + data = myfile.read() + url = config.license_fetch + values = {'hash': hash_sum, 'text': data, 'package': tarball.name} + data = urllib.parse.urlencode(values) + data = data.encode('utf-8') + req = urllib.request.Request(url, data) + response = urllib.request.urlopen(req) + the_page = response.read().decode('utf-8') + if len(the_page.strip()) > 0: + print("License : ", the_page.strip(), " (server) (", hash_sum, ")") + add_license(the_page.strip()) + return + else: + with open(LICENSE_HASH_FILE, "r") as file: + licenses_list = file.readlines() + licenses_dict = dict(license.split(" | ") for license in licenses_list) + + if hash_sum in licenses_dict: + add_license(licenses_dict[hash_sum]) + else: + if not config.license_show: + return + print("Unknown license {0} with hash {1}".format(copying, hash_sum)) + hashUrl = config.license_show % {'HASH': hash_sum} + print("Visit {0} to enter".format(hashUrl)) + + +def license_from_doc(doc): + """ Scan for documentation license in the given file """ + with open(doc, 'r', encoding="latin-1") as content_file: + content = content_file.read() + if content.find("GNU Free Documentation License, Version 1.3") >= 0: + add_license("GFDL-1.3") + elif content.find("GNU Free Documentation License, Version 1.2") >= 0: + add_license("GFDL-1.2") + elif content.find("GNU Free Documentation License, Version 1.1") >= 0: + add_license("GFDL-1.1") + elif content.find("(The MIT License)") >= 0: + add_license("MIT") + + +# +# Scan the project directory for things we can use to guess a description +# and summary +# + +def scan_for_licenses(package, dir): + for dirpath, dirnames, files in os.walk(dir): + for name in files: + if (name.lower() in ("copyright", "apache-2.0", "libcurllicense", "gpl.txt", "gplv2.txt", "notice", "copyrights", "about_bsd.txt") or + name.lower().startswith("copying") or name.lower().startswith("license") or name.lower().endswith("license") or name.lower().startswith("licence") or name.lower().endswith("licence")): + license_from_copying_hash(os.path.join(dirpath, name)) + license_from_copying_content(os.path.join(dirpath, name)) + else: + if "." not in name: + continue + ext = name.split(".")[-1].lower() + if ext in ("man", "texi", "rdoc"): + license_from_doc(os.path.join(dirpath, name)) + + if len(licenses) == 0: + print("\n*ERROR: cannot find any license or " + tarball.name + ".license file!\n") + quit() + else: + print("Licenses : ", " ".join(sorted(licenses))) + + +def write_license(file): + if len(licenses) == 0: + file.write("License : " + default_license + "\n") + else: + file.write("License : " + " ".join(sorted(licenses))) + file.write("\n") diff --git a/patches.py b/patches.py new file mode 100644 index 0000000..4c0c044 --- /dev/null +++ b/patches.py @@ -0,0 +1,44 @@ +#!/bin/true +# +# patches.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Parse config files +# + + +patches = [] +autoreconf = False + + +def write_patch_header(file): + counter = 1 + for p in patches: + file.write("Patch" + str(counter) + ": " + p.split()[0] + "\n") + counter = counter + 1 + + +def apply_patches(file): + counter = 1 + for p in patches: + name = p.split(None, 1)[0] + if name == p: + options = "-p1" + else: + options = p.split(None, 1)[1] + if not p.split()[0].endswith(".nopatch"): + file.write("%%patch%d %s\n" % (counter, options)) + counter = counter + 1 diff --git a/specdescription.py b/specdescription.py new file mode 100644 index 0000000..8b2ece3 --- /dev/null +++ b/specdescription.py @@ -0,0 +1,289 @@ +#!/bin/true +# +# specdescription.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# objective +# +# create the following parts of the spec file +# +# %description +# Summary +# Group +# %description +# + +import os +import license + +default_group = "Development/Tools" +default_description = "No detailed description available" +default_description_score = 0 +default_summary = "No detailed summary available" +default_summary_score = 0 + + +def clean_license_string(str): + + if str.find("same as") >= 0: + return "" + str = str.replace(" (", "(") + str = str.replace(" v2", "-2") + str = str.replace(" v3", "-3") + str = str.replace(" 2", "-2") + str = str.replace(" 3", "-3") + str = str.replace(" <", "<") + str = str.replace(" >", ">") + str = str.replace("= ", "=") + str = str.replace("GPL(>=-2)", "GPL-2.0+") + + str = str.replace("Modified", "") + str = str.replace("OSI", "") + str = str.replace("Approved", "") + str = str.replace("Simplified", "") + str = str.replace("file", "") + str = str.replace("LICENSE", "") + + return str + + +# +# Parse any existing RPM specfiles +# + +def description_from_spec(specfile): + global default_description + global default_summary + global default_summary_score + global default_description_score + specdesc = "" + phase = 0 + file = open(specfile, "r", encoding="latin-1") + for line in file.readlines(): + if line.startswith("#"): + continue + + if line.startswith("%"): + phase = 0 + + if line.startswith("License:") and line.find("Copyright") < 0 and line.find("see ") < 0 and line.find("(") < 0: + splits = line.split(":")[1:] + words = ":".join(splits).strip() + if words in license.license_translations: + print("Adding license from spec:", words) + license.add_license(words) + else: + words = clean_license_string(words).split() + for word in words: + if word.find(":") < 0 or word.startswith('http'): + print("Adding license from spec:", word) + license.add_license(word) + + if line.startswith("Summary: ") and default_summary_score < 4: + default_summary = line[9:] + default_summary_score = 4 + + if phase == 1: + specdesc = specdesc + line + + if line.endswith("%description\n"): + phase = 1 + if default_description_score < 4: + default_description = specdesc + default_description_score = 4 + file.close() + + +def description_from_pkginfo(specfile): + global default_description + global default_summary + global default_summary_score + global default_description_score + specdesc = "" + phase = 0 + file = open(specfile, "r", encoding="latin-1") + for line in file.readlines(): + if line.find(":") and phase == 1: + phase = 0 + + if line.lower().startswith("license:") and line.find("Copyright") < 0 and line.find("see ") < 0: + splits = line.split(":")[1:] + words = ":".join(splits).strip() + if words in license.license_translations: + print("Adding license from PKG-INFO:", words) + license.add_license(words) + else: + words = clean_license_string(words).split() + for word in words: + if word.find(":") < 0: + print("Adding license from PKG-INFO:", word) + license.add_license(word) + + if line.startswith("Summary: ") and default_summary_score < 4: + default_summary = line[9:] + default_summary_score = 4 + + if line.startswith("abstract:") and default_summary_score < 4: + default_summary = line[9:].strip() + default_summary_score = 4 + + if phase == 1: + specdesc = specdesc + line + + if line.startswith("Description:"): + phase = 1 + if default_description_score < 4 and len(specdesc) > 10: + default_description = specdesc + default_description_score = 4 + file.close() + +# +# Parse pkgconfig files for Description: lines +# + + +def summary_from_pkgconfig(pkgfile, package): + global default_summary + global default_summary_score + score = 2 + + if pkgfile.find(package + ".pc") >= 0: + score = 3 + + file = open(pkgfile, "r") + for line in file.readlines(): + if line.startswith("Description:") and default_summary_score < score: + default_summary = line[13:] + default_summary_score = score + file.close() + + +def summary_from_R(pkgfile, package): + global default_summary + global default_summary_score + score = 2 + + if pkgfile.find("DESCRIPTION") >= 0: + score = 3 + + file = open(pkgfile, "r", encoding="latin-1") + for line in file.readlines(): + if line.startswith("Title:") and default_summary_score < score: + default_summary = line[7:] + default_summary_score = score + file.close() + + +# +# some lines from a readme are just boilerplate and should be skipped +# +def skipline(line): + if line.find("Copyright") >= 0: + return 1 + if line.find("Free Software Foundation, Inc.") >= 0: + return 1 + if line.find("Copying and distribution of") >= 0: + return 1 + if line.find("are permitted in any") >= 0: + return 1 + if line.find("notice and this notice") >= 0: + return 1 + if line.find("README") >= 0: + return 1 + if line.find("-*-") >= 0: + return 1 + + if line.endswith("introduction"): + return 1 + return 0 + + +# +# Try to pick the first paragraph or two from the readme file +# +def description_from_readme(readmefile): + global default_description + global default_description_score + state = 0 + desc = "" + score = 1 + + if readmefile.lower().endswith("readme"): + score = 1.5 + + file = open(readmefile, "r", encoding="latin-1") + for line in file.readlines(): + if state == 1 and len(line) < 2 and len(desc) > 80: + state = 2 + if state == 0 and len(line) > 2: + state = 1 + if state == 1: + if skipline(line) == 0 and len(line) > 2: + desc = desc + line.strip() + "\n" + + if default_description_score < score: + default_description = desc + default_description_score = score + file.close() + +# +# Scan the project directory for things we can use to guess a description +# and summary +# + + +def scan_for_description(package, dir): + global default_summary + for dirpath, dirnames, files in os.walk(dir): + for name in files: + if name.lower().endswith(".spec"): + description_from_spec(os.path.join(dirpath, name)) + if name.lower().endswith("pkg-info"): + description_from_pkginfo(os.path.join(dirpath, name)) + if name.lower().endswith("meta.yml"): + description_from_pkginfo(os.path.join(dirpath, name)) + if name.lower().endswith("description"): + description_from_pkginfo(os.path.join(dirpath, name)) + if name.lower().endswith(".pc"): + summary_from_pkgconfig(os.path.join(dirpath, name), package) + if name.startswith("DESCRIPTION"): + summary_from_R(os.path.join(dirpath, name), package) + if name.lower().endswith(".pc.in"): + summary_from_pkgconfig(os.path.join(dirpath, name), package) + if name.lower().startswith("readme"): + description_from_readme(os.path.join(dirpath, name)) + + print("Summary :", default_summary.strip()) + +# print("Summary: ", default_summary) +# print("%description") +# print(default_description) + + +def write_summary(file): + global default_summary + global default_group + file.write("Summary : " + default_summary.strip() + "\n") + file.write("Group : " + default_group.strip() + "\n") + + +def write_description(file, package=""): + global default_description + if len(package) == 0: + file.write("\n%description\n" + default_description.strip() + "\n") + else: + file.write("\n%description " + package + + "\n Subpackage " + package + "\n\n") diff --git a/tarball.py b/tarball.py new file mode 100644 index 0000000..91fd9af --- /dev/null +++ b/tarball.py @@ -0,0 +1,294 @@ +#!/usr/bin/true +# +# tarball.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import build +import buildpattern +import buildreq +import files +import glob +import hashlib +import os +import re +import shutil +import subprocess +import urllib +import urllib.request +from util import call + +name = "" +rawname = "" +version = "" +release = "1" +url = "" +path = "" +tarball_prefix = "" +gcov_file = "" + + +def get_sha1sum(filename): + sh = hashlib.sha1() + with open(filename, "rb") as f: + sh.update(f.read()) + return sh.hexdigest() + + +def really_download(url, destination, tarfile): + with urllib.request.urlopen(url) as response: + with open(destination, "wb") as dfile: + dfile.write(response.read()) + + +def check_or_get_file(url, tarfile): + tarball_path = build.download_path + "/" + tarfile + if not os.path.isfile(tarball_path): + really_download(url, tarball_path, tarfile) + return tarball_path + + +def build_untar(tarball_path): + tarball_contents = subprocess.check_output( + ["tar", "-tf", tarball_path], universal_newlines=True) + extract_cmd = "tar --directory={0} -xf {1}".format(build.base_path, tarball_path) + if tarball_contents: + tarball_prefix = tarball_contents.splitlines()[0].rsplit("/")[0] + if tarball_prefix == ".": + tarball_prefix = tarball_contents.splitlines()[0].rsplit("/")[1] + return extract_cmd, tarball_prefix + + +def download_tarball(url_argument, name_argument, archives): + global name + global rawname + global version + global url + global path + global tarball_prefix + global gcov_file + + url = url_argument + tarfile = os.path.basename(url) + pattern_options = [ + r"(.*?)[\-_](v*[0-9]+[alpha\+_spbfourcesigedsvstableP0-9\.\-\~]*)\.src\.(tgz|tar|zip)", + r"(.*?)[\-_](v*[0-9]+[alpha\+_sbpfourcesigedsvstableP0-9\.\-\~]*)\.(tgz|tar|zip)", + r"(.*?)[\-_](v*[0-9]+[a-zalpha\+_spbfourcesigedsvstableP0-9\.\-\~]*)\.orig\.tar", + r"(.*?)[\-_](v*[0-9]+[\+_spbfourcesigedsvstableP0-9\.\~]*)(-.*?)?\.tar", + ] + for pattern in pattern_options: + p = re.compile(pattern) + m = p.search(tarfile) + if m: + name = m.group(1).strip() + version = m.group(2).strip() + b = version.find("-") + if b >= 0: + version = version[:b] + break + + rawname = name + # R package + if url_argument.find("cran.r-project.org") > 0 or url_argument.find("cran.rstudio.com") > 0: + buildpattern.set_build_pattern("R", 10) + files.want_dev_split = 0 + buildreq.add_buildreq("clr-R-helpers") + p = re.compile(r"([A-Za-z0-9]+)_(v*[0-9]+[\+_spbfourcesigedsvstableP0-9\.\~\-]*)\.tar\.gz") + m = p.search(tarfile) + if m: + name = "R-" + m.group(1).strip() + rawname = m.group(1).strip() + version = m.group(2).strip() + b = version.find("-") + if b >= 0: + version = version[:b] + + if url_argument.find("pypi.python.org") > 0: + buildpattern.set_build_pattern("distutils", 10) + + if url_argument.find(".cpan.org/CPAN/") > 0: + buildpattern.set_build_pattern("cpan", 10) + if name: + name = "perl-" + name + if url_argument.find(".metacpan.org/") > 0: + buildpattern.set_build_pattern("cpan", 10) + if name: + name = "perl-" + name + + if url_argument.find("github.com") > 0: + p = re.compile(r"https://github.com/.*/(.*?)/archive/v?(.*).tar") + m = p.search(url_argument) + if m: + name = m.group(1).strip() + version = m.group(2).strip() + + if url_argument.find("bitbucket.org") > 0: + p = re.compile(r"https://bitbucket.org/.*/(.*?)/get/[a-zA-Z_-]*([0-9][0-9_.]*).tar") + m = p.search(url_argument) + if m: + name = m.group(1).strip() + version = m.group(2).strip().replace('_', '.') + + # ruby + if url_argument.find("rubygems.org/") > 0: + buildpattern.set_build_pattern("ruby", 10) + p = re.compile(r"(.*?)[\-_](v*[0-9]+[alpha\+_spbfourcesigedsvstableP0-9\.\-\~]*)\.gem") + m = p.search(tarfile) + if m: + buildreq.add_buildreq("ruby") + buildreq.add_buildreq("rubygem-rdoc") + name = "rubygem-" + m.group(1).strip() + rawname = m.group(1).strip() + version = m.group(2).strip() + b = version.find("-") + if b >= 0: + version = version[:b] + + # override from commandline + if name_argument and name_argument[0] != name: + pattern = name_argument[0] + r"[\-]*(.*)\.(tgz|tar|zip)" + p = re.compile(pattern) + m = p.search(tarfile) + if m: + name = name_argument[0] + rawname = name + version = m.group(1).strip() + b = version.find("-") + if b >= 0: + version = version[:b] + if version.startswith('.'): + version = version[1:] + else: + name = name_argument[0] + + if not name: + split = url_argument.split('/') + if len(split) > 3 and split[-2] in ('archive', 'tarball'): + name = split[-3] + version = split[-1] + if version.startswith('v'): + version = version[1:] + # remove extension + version = '.'.join(version.split('.')[:-1]) + if version.endswith('.tar'): + version = '.'.join(version.split('.')[:-1]) + + b = version.find("-") + if b >= 0: + b = b + 1 + version = version[b:] + + if version[0] in ['v', 'r']: + version = version[1:] + + assert name != "" + + build.download_path = os.getcwd() + "/" + name + call("mkdir -p %s" % build.download_path) + + gcov_path = build.download_path + "/" + name + ".gcov" + if os.path.isfile(gcov_path): + gcov_file = name + ".gcov" + + tarball_path = check_or_get_file(url, tarfile) + sha1 = get_sha1sum(tarball_path) + with open(build.download_path + "/upstream", "w") as file: + file.write(sha1 + "/" + tarfile + "\n") + + tarball_prefix = name + "-" + version + if tarfile.lower().endswith('.zip'): + tarball_contents = subprocess.check_output( + ["unzip", "-l", tarball_path], universal_newlines=True) + if tarball_contents and len(tarball_contents.splitlines()) > 3: + tarball_prefix = tarball_contents.splitlines()[3].rsplit("/")[0].split()[-1] + extract_cmd = "unzip -d {0} {1}".format(build.base_path, tarball_path) + + elif tarfile.lower().endswith('.gem'): + tarball_contents = subprocess.check_output( + ["gem", "unpack", "--verbose", tarball_path], universal_newlines=True) + extract_cmd = "gem unpack --target={0} {1}".format(build.base_path, tarball_path) + if tarball_contents: + tarball_prefix = tarball_contents.splitlines()[-1].rsplit("/")[-1] + if tarball_prefix.endswith("'"): + tarball_prefix = tarball_prefix[:-1] + else: + extract_cmd, tarball_prefix = build_untar(tarball_path) + + print("\n") + + print("Processing", url_argument) + print( + "=============================================================================================") + print("Name :", name) + print("Version :", version) + print("Prefix :", tarball_prefix) + + with open(build.download_path + "/Makefile", "w") as file: + file.write("PKG_NAME := " + name + "\n") + file.write("URL := " + url_argument + "\n") + file.write("ARCHIVES :=") + for archive in archives: + file.write(" {}".format(archive)) + file.write("\n") + file.write("\n") + file.write("include ../common/Makefile.common\n") + + shutil.rmtree("{}".format(build.base_path), ignore_errors=True) + os.makedirs("{}".format(build.output_path)) + call("mkdir -p %s" % build.download_path) + call(extract_cmd) + + path = build.base_path + tarball_prefix + + for archive, destination in zip(archives[::2], archives[1::2]): + source_tarball_path = check_or_get_file(archive, os.path.basename(archive)) + if source_tarball_path.lower().endswith('.zip'): + tarball_contents = subprocess.check_output( + ["unzip", "-l", source_tarball_path], universal_newlines=True) + if tarball_contents and len(tarball_contents.splitlines()) > 3: + source_tarball_prefix = tarball_contents.splitlines()[3].rsplit("/")[0].split()[-1] + extract_cmd = "unzip -d {0} {1}".format(build.base_path, source_tarball_path) + else: + extract_cmd, source_tarball_prefix = build_untar(source_tarball_path) + buildpattern.archive_details[archive + "prefix"] = source_tarball_prefix + call(extract_cmd) + tar_files = glob.glob("{0}{1}/*".format(build.base_path, source_tarball_prefix)) + move_cmd = "mv " + for tar_file in tar_files: + move_cmd += tar_file + " " + move_cmd += '{0}/{1}'.format(path, destination) + + mkdir_cmd = "mkdir -p " + mkdir_cmd += '{0}/{1}'.format(path, destination) + + print("mkdir " + mkdir_cmd) + call(mkdir_cmd) + call(move_cmd) + + sha1 = get_sha1sum(source_tarball_path) + with open(build.download_path + "/upstream", "a") as file: + file.write(sha1 + "/" + os.path.basename(archive) + "\n") + + +def write_nvr(file): + global name + global version + global release + file.write("Name : " + name + "\n") + file.write("Version : " + version + "\n") + file.write("Release : " + str(release) + "\n") + file.write("URL : " + url + "\n") + file.write("Source0 : " + url + "\n") diff --git a/test.py b/test.py new file mode 100644 index 0000000..8125408 --- /dev/null +++ b/test.py @@ -0,0 +1,165 @@ +#!/bin/true +# +# test.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Deduce and emmit the patterns for %check +# + +import buildpattern +import buildreq +import glob +import os +import tarball +import subprocess + +tests_config = "" +skip_tests = False +allow_test_failures = False +new_pkg = True +unit_pass_written = False + + +def check_regression(dir): + + global skip_tests + if skip_tests: + return + + build_log_path = os.path.join(dir, "results/build.log") + perl_cmd = ["perl", os.path.dirname(__file__) + "/count.pl", build_log_path] + result = subprocess.check_output(perl_cmd) + result = result.decode("utf-8") + lines = result.strip('\n').split('\n') + titles = ['package name', 'total tests', 'tests passing', 'tests failing', + 'tests skipped', 'expected fail'] + if len(lines) > 1: + for l in lines: + split_lines = l.split(',') + for x in range(0, len(split_lines)): + print(titles[x] + ": " + split_lines[x]) + else: + split_list = lines[0].split(',') + for x in range(1, len(split_list)): + print(titles[x] + ": " + split_list[x]) + + +def scan_for_tests(dir): + global tests_config + global skip_tests + global allow_test_failures + + if skip_tests: + return + + if len(tests_config) > 0: + return + + testsuites = { + "makecheck": "make VERBOSE=1 V=1 %{?_smp_mflags} check", + "perlcheck": "make TEST_VERBOSE=1 test", + "setup.py": "PYTHONPATH=%{buildroot}/usr/lib/python2.7/site-packages python2 setup.py test", + "cmake": "pushd clr-build ; make test ; popd", + "rakefile": "pushd %{buildroot}%{gem_dir}/gems/" + tarball.tarball_prefix + "\nrake --trace test TESTOPTS=\"-v\"\npopd", + # "rubygems": "pushd %{buildroot}%{gem_dir}/gems/" + tarball.tarball_prefix + "\nruby -I\"lib:test*\" test*/*_test.rb \nruby -I\"lib:test*\" test*/test_*.rb\npopd", + "rspec": "pushd %{buildroot}%{gem_dir}/gems/" + tarball.tarball_prefix + "\nrspec -I.:lib spec/\npopd" + } + + files = os.listdir(dir) + + if "CMakeLists.txt" in files: + makefile_path = os.path.join(dir, "CMakeLists.txt") + if not os.path.isfile(makefile_path): + return + with open(makefile_path, encoding="latin-1") as fp: + lines = fp.readlines() + for line in lines: + if line.find("enable_testing") >= 0: + tests_config = testsuites["cmake"] + break + + if "Makefile.in" in files: + makefile_path = os.path.join(dir, "Makefile.in") + if not os.path.isfile(makefile_path): + return + with open(makefile_path) as fp: + lines = fp.readlines() + for line in lines: + if line.startswith("check:"): + tests_config = testsuites["makecheck"] + break + if line.startswith("test:"): + tests_config = testsuites["perlcheck"] + break + elif "Makefile.am" in files: + tests_config = testsuites["makecheck"] + elif tarball.name.startswith("rubygem"): + if "test" in files or "tests" in files: + r_testdir = [f for f in files if "test" in f if "." not in f].pop() + pre_test = glob.glob(os.path.join(dir, "test*/test_*.rb")) + post_test = glob.glob(os.path.join(dir, "test*/*_test.rb")) + tests_config = "pushd %{buildroot}%{gem_dir}/gems/" + tarball.tarball_prefix + if len(pre_test) > 0: + tests_config += "\nruby -v -I.:lib:" + r_testdir + " test*/test_*.rb" + if len(post_test) > 0: + tests_config += "\nruby -v -I.:lib:" + r_testdir + " test*/*_test.rb" + tests_config += "\npopd" + + elif "spec" in files: + buildreq.add_buildreq("rubygem-rspec") + buildreq.add_buildreq("rubygem-rspec-core") + buildreq.add_buildreq("rubygem-rspec-expectations") + buildreq.add_buildreq("rubygem-rspec-support") + buildreq.add_buildreq("rubygem-rspec-mocks") + buildreq.add_buildreq("rubygem-devise") + buildreq.add_buildreq("rubygem-diff-lcs") + tests_config = testsuites["rspec"] + elif "Rakefile" in files: + with open(os.path.join(dir, "Rakefile"), encoding="ascii", errors="surrogateescape") as fp: + setup_contents = fp.read() + # if setup_contents.find("task :test") >= 0 or setup_contents.find("task 'test'") >= 0: + tests_config = testsuites["rakefile"] + buildreq.add_buildreq("ruby") + buildreq.add_buildreq("rubygem-rake") + buildreq.add_buildreq("rubygem-test-unit") + buildreq.add_buildreq("rubygem-minitest") + elif "Makefile.PL" in files: + tests_config = testsuites["perlcheck"] + elif "setup.py" in files: + with open(os.path.join(dir, "setup.py"), encoding="ascii", errors="surrogateescape") as fp: + setup_contents = fp.read() + if "test_suite" in setup_contents or "pbr=True" in setup_contents: + tests_config = testsuites["setup.py"] + elif buildpattern.default_pattern == "R": + tests_config = "export _R_CHECK_FORCE_SUGGESTS_=false\nR CMD check --no-manual --no-examples --no-codoc -l %{buildroot}/usr/lib64/R/library " + tarball.rawname + + if "tox.ini" in files: + buildreq.add_buildreq("tox") + buildreq.add_buildreq("pytest") + buildreq.add_buildreq("virtualenv") + buildreq.add_buildreq("pluggy") + buildreq.add_buildreq("py-python") + + if tests_config != "" and allow_test_failures: + if tarball.name.startswith("rubygem"): + config_elements = tests_config.split("\n") + config_elements.pop() + tests_config = "\n".join(config_elements) + " || :\npopd" + elif tests_config == testsuites["cmake"]: + tests_config = "pushd clr-build ; make test ||: ; popd" + else: + tests_config = tests_config + " || :" + print(tests_config) diff --git a/translate.dic b/translate.dic new file mode 100644 index 0000000..6f8ec16 --- /dev/null +++ b/translate.dic @@ -0,0 +1,52 @@ +babel=Babel +barbicanclient-python=python-barbicanclient +BeautifulSoup=beautifulsoup4 +cryptography-python=cryptography +Crypto-python=pycrypt-python +dateutil.relativedelta-python=python-dateutil +designateclient-python=python-designateclient +django-python=Django +enum-python=enum34-python +formencode=FormEncode +Genshi-python=Genshi +hacking-python=hacking +httplib2-python=httplib2 +ironicclient-python=python-ironicclient +jinja2-python=Jinja2 +Jinja2-python=Jinja2 +keystoneclient.auth-python=python-keystoneclient +keystoneclient.v3-python=python-keystoneclient +keystonemiddleware-python=keystonemiddleware +manilaclient-python=python-manilaclient +mistralclient.api.v2-python=python-mistralclient +mock=python-mock +netaddr-python=netaddr +openstackclient.tests-python=python-openstackclient +openstack.nose-plugin-python=openstack.nose_plugin +os_brick.initiator-python=os-brick +oslo_cache-python=oslo.cache +oslo.config-python=oslo.config +oslo_config-python=oslo.config +oslo_policy-python=oslo.policy +oslo_reports-python=oslo.reports +oslo_versionedobjects-python=oslo.versionedobjects +oslo_versionedobjects.tests-python=oslo.versionedobjects +pep8-python=pep8 +posix-ipc-python=posix_ipc +PrettyTable-python=prettytable +pyaml-python=pyaml +PyECLib-python=pyeclib +Pygments-python=Pygments +pylibmc-python=pylibmc +python-memcached-python=python-memcached +setuptools-scm-python=setuptools_scm +simplejson-python=simplejson +sphinx=Sphinx +sqlparse-python=sqlparse +stevedore-python=stevedore +testresources-python=testresources +testscenarios-python=testscenarios +WebTest-python=WebTest +yaml-python=PyYAML +zaqarclient.queues.v1-python=python-zaqarclient +zaqarclient.transport-python=python-zaqarclient diff --git a/util.py b/util.py new file mode 100644 index 0000000..76acca1 --- /dev/null +++ b/util.py @@ -0,0 +1,62 @@ +#!/bin/true +# +# util.py - part of autospec +# Copyright (C) 2015 Intel Corporation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import shlex +import subprocess + +dictionary_filename = os.path.dirname(__file__) + "/translate.dic" +dictionary = [line.strip() for line in open(dictionary_filename, 'r')] + + +def call(command, logfile=None, check=True, **kwargs): + returncode = 1 + full_args = { + "args": shlex.split(command), + "universal_newlines": True, + } + full_args.update(kwargs) + + if logfile: + full_args["stdout"] = open(logfile, "w") + full_args["stderr"] = subprocess.STDOUT + returncode = subprocess.call(**full_args) + full_args["stdout"].close() + else: + returncode = subprocess.call(**full_args) + + if check and returncode != 0: + raise subprocess.CalledProcessError(returncode, full_args["args"], None) + + return returncode + + +def _file_write(self, s): + s = s.strip() + if not s.endswith("\n"): + s += "\n" + self.write(s) + + +def translate(package): + global dictionary + for item in dictionary: + if item.startswith(package + "="): + return item.split("=")[1] + return package