pax_global_header00006660000000000000000000000064131514546670014526gustar00rootroot0000000000000052 comment=6a779861111c3e0e850f65de830f7c49ba19cde1 abi-monitor-1.12/000077500000000000000000000000001315145466700136715ustar00rootroot00000000000000abi-monitor-1.12/GPL-2.0000066400000000000000000000432541315145466700145430ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. 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 convey 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This 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. abi-monitor-1.12/LGPL-2.1000066400000000000000000000636421315145466700146630ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey 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 library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! abi-monitor-1.12/LICENSE000066400000000000000000000001731315145466700146770ustar00rootroot00000000000000This program is free software. You may use, redistribute and/or modify it under the terms of either GPL 2.0+ or LGPL 2.1+. abi-monitor-1.12/Makefile000066400000000000000000000002221315145466700153250ustar00rootroot00000000000000prefix ?= /usr .PHONY: install install: perl Makefile.pl -install -prefix "$(prefix)" uninstall: perl Makefile.pl -remove -prefix "$(prefix)" abi-monitor-1.12/Makefile.pl000066400000000000000000000145611315145466700157520ustar00rootroot00000000000000#!/usr/bin/perl ########################################################################### # Makefile for ABI Monitor # Install/remove the tool for GNU/Linux # # Copyright (C) 2015 Andrey Ponomarenko's ABI Laboratory # # Written by Andrey Ponomarenko # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License or the GNU Lesser # General Public License as published by the Free Software Foundation. # # 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 # and the GNU Lesser General Public License along with this program. # If not, see . ########################################################################### use Getopt::Long; Getopt::Long::Configure ("posix_default", "no_ignore_case"); use File::Path qw(mkpath rmtree); use File::Copy qw(copy); use File::Basename qw(dirname); use Cwd qw(abs_path); use File::Find; use strict; my $TOOL_SNAME = "abi-monitor"; my $ARCHIVE_DIR = abs_path(dirname($0)); my $HELP_MSG = " NAME: Makefile for ABI Monitor DESCRIPTION: Install $TOOL_SNAME command and private modules. USAGE: sudo perl $0 -install -prefix /usr sudo perl $0 -remove -prefix /usr OPTIONS: -h|-help Print this help. --prefix=PREFIX Install files in PREFIX [/usr]. -install Command to install the tool. -remove Command to remove the tool. EXTRA OPTIONS: --destdir=DESTDIR This option is for maintainers to build RPM or DEB packages inside the build root. The environment variable DESTDIR is also supported. \n"; if(not @ARGV) { print $HELP_MSG; exit(0); } my ($PREFIX, $DESTDIR, $Help, $Install, $Remove); GetOptions( "h|help!" => \$Help, "prefix=s" => \$PREFIX, "destdir=s" => \$DESTDIR, "install!" => \$Install, "remove!" => \$Remove ) or exit(1); sub scenario() { if($Help) { print $HELP_MSG; exit(0); } if(not $Install and not $Remove) { print STDERR "ERROR: command is not selected (-install or -remove)\n"; exit(1); } if($Install) { # remove old version first $Remove = 1; } if($PREFIX ne "/") { $PREFIX=~s/[\/]+\Z//g; } if(not $PREFIX) { # default prefix $PREFIX = "/usr"; } if(my $Var = $ENV{"DESTDIR"}) { print "Using DESTDIR environment variable\n"; $DESTDIR = $Var; } if($DESTDIR) { if($DESTDIR ne "/") { $DESTDIR=~s/[\/]+\Z//g; } if($DESTDIR!~/\A\//) { print STDERR "ERROR: destdir is not absolute path\n"; exit(1); } if(not -d $DESTDIR) { print STDERR "ERROR: you should create destdir directory first\n"; exit(1); } $PREFIX = $DESTDIR.$PREFIX; if(not -d $PREFIX) { print STDERR "ERROR: you should create installation directory first (destdir + prefix):\n mkdir -p $PREFIX\n"; exit(1); } } else { if($PREFIX!~/\A\//) { print STDERR "ERROR: prefix is not absolute path\n"; exit(1); } if(not -d $PREFIX) { print STDERR "ERROR: you should create prefix directory first\n"; exit(1); } } print "INSTALL PREFIX: $PREFIX\n"; # paths my $EXE_PATH = "$PREFIX/bin"; my $MODULES_PATH = "$PREFIX/share/$TOOL_SNAME"; my $REL_PATH = "../share/$TOOL_SNAME"; my $TOOL_PATH = "$EXE_PATH/$TOOL_SNAME"; if(not -w $PREFIX) { print STDERR "ERROR: you should be root\n"; exit(1); } if($Remove) { if(-e $EXE_PATH."/".$TOOL_SNAME) { # remove executable print "-- Removing $TOOL_PATH\n"; unlink($EXE_PATH."/".$TOOL_SNAME); } elsif(not $Install) { print "The tool is not installed\n"; } if(-d $ARCHIVE_DIR."/modules") { if(-d $MODULES_PATH) { # remove modules print "-- Removing $MODULES_PATH\n"; rmtree($MODULES_PATH); } elsif(not $Install) { print "The modules of the tool are not installed\n"; } } } if($Install) { # configure my $Content = readFile($ARCHIVE_DIR."/".$TOOL_SNAME.".pl"); if($DESTDIR) { # relative path $Content=~s/MODULES_INSTALL_PATH/$REL_PATH/; } else { # absolute path $Content=~s/MODULES_INSTALL_PATH/$MODULES_PATH/; } # copy executable print "-- Installing $TOOL_PATH\n"; mkpath($EXE_PATH); writeFile($EXE_PATH."/".$TOOL_SNAME, $Content); chmod(0755, $EXE_PATH."/".$TOOL_SNAME); # copy modules if(-d $ARCHIVE_DIR."/modules") { print "-- Installing $MODULES_PATH\n"; mkpath($MODULES_PATH); copyDir($ARCHIVE_DIR."/modules", $MODULES_PATH); } # check PATH if($ENV{"PATH"}!~/(\A|:)\Q$EXE_PATH\E[\/]?(\Z|:)/) { print "WARNING: your PATH variable doesn't include \'$EXE_PATH\'\n"; } } exit(0); } sub copyDir($$) { my ($From, $To) = @_; my %Files; find(\&wanted, $From); sub wanted { $Files{$File::Find::dir."/$_"} = 1 if($_ ne "."); } foreach my $Path (sort keys(%Files)) { my $Inst = $Path; $Inst=~s/\A\Q$ARCHIVE_DIR\E/$To/; if(-d $Path) { # directories mkpath($Inst); } else { # files mkpath(dirname($Inst)); copy($Path, $Inst); } } } sub readFile($) { my $Path = $_[0]; return "" if(not $Path or not -f $Path); open(FILE, $Path) || die ("can't open file \'$Path\': $!\n"); local $/ = undef; my $Content = ; close(FILE); return $Content; } sub writeFile($$) { my ($Path, $Content) = @_; return if(not $Path); open(FILE, ">".$Path) || die ("can't open file \'$Path\': $!\n"); print FILE $Content; close(FILE); } scenario(); abi-monitor-1.12/README000066400000000000000000000034001315145466700145460ustar00rootroot00000000000000NAME: ABI Monitor - monitor new versions of a software library, try to build them and create profile for ABI Tracker: https://github.com/lvc/abi-tracker The tool is intended to be used with the ABI Tracker tool to visualize API/ABI changes timeline of a C/C++ library. The tool is developed by Andrey Ponomarenko: http://abi-laboratory.pro/ INSTALL: sudo make install prefix=/usr REQUIRES: Perl 5 (5.8 or newer) cURL wget CMake Automake GCC G++ USAGE: abi-monitor [options] [profile] The input profile will be extended after execution. Then it can be passed to the ABI Tracker. EXAMPLES: abi-monitor -get -build libssh.json abi-monitor -rebuild -v 0.7.0 libssh.json PROFILE FORMAT: { "Name": "SHORT LIBRARY NAME", "SourceUrl": "URL TO DOWNLOAD PACKAGES", "Git": "GIT ADDRESS TO CLONE" } PROFILE EXAMPLE: { "Name": "libssh", "SourceUrl": "https://red.libssh.org/projects/libssh/files", "Git": "https://git.libssh.org/projects/libssh.git" } See more profile examples in this directory: https://github.com/lvc/upstream-tracker/tree/master/profile ADV. OPTIONS: You can set additional option "BuildScript" to define the path to the shell script that should be used to build packages. It will be executed inside the source tree of a package. The script should install the library to the output directory defined by the INSTALL_TO environment variable. The code should be compiled with the "-g -Og" GCC options. If you just want to add some configure options then you can define the "Configure" option of the profile. The other option "SourceDir" allows to index packages from a local directory instead of downloading them from "SourceUrl". ADV. USAGE: For advanced usage, see output of --help option. abi-monitor-1.12/abi-monitor.pl000066400000000000000000002066711315145466700164620ustar00rootroot00000000000000#!/usr/bin/perl ################################################################## # ABI Monitor 1.12 # A tool to monitor new versions of a software library, build them # and create profile for ABI Tracker. # # Copyright (C) 2015-2017 Andrey Ponomarenko's ABI Laboratory # # Written by Andrey Ponomarenko # # PLATFORMS # ========= # Linux (x86, x86_64) # # REQUIREMENTS # ============ # Perl 5 # cURL # wget # CMake # Automake # GCC # G++ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License or the GNU Lesser # General Public License as published by the Free Software Foundation. # # 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 # and the GNU Lesser General Public License along with this program. # If not, see . ################################################################## use Getopt::Long; Getopt::Long::Configure ("posix_default", "no_ignore_case", "permute"); use File::Path qw(mkpath rmtree); use File::Copy qw(copy move); use File::Temp qw(tempdir); use File::Basename qw(dirname basename); use Cwd qw(abs_path cwd); use Data::Dumper; my $TOOL_VERSION = "1.12"; my $DB_PATH = "Monitor.data"; my $REPO = "src"; my $INSTALLED = "installed"; my $BUILD_LOGS = "build_logs"; my $BUILD_SUBDIR = "MONITOR_build"; my $TMP_DIR = tempdir(CLEANUP=>1); my $TMP_DIR_LOC = "Off"; my $ACCESS_TIMEOUT = 15; my $CONNECT_TIMEOUT = 5; my $ACCESS_TRIES = 2; my $USE_CURL = 1; my $PKG_EXT = "tar\\.bz2|tar\\.gz|tar\\.xz|tar\\.lzma|tar\\.lz|tar\\.Z|tbz2|tgz|txz|zip"; # Internal modules my $MODULES_DIR = get_Modules(); push(@INC, dirname($MODULES_DIR)); my $CMAKE = "cmake"; my $GCC = "gcc"; my $C_FLAGS_B = "-g -Og -w -fpermissive"; my $CXX_FLAGS_B = $C_FLAGS_B; my ($Help, $DumpVersion, $Get, $Build, $Rebuild, $OutputProfile, $TargetVersion, $LimitOps, $BuildShared, $BuildNew, $Debug, $GetOld, $MakeAddOpt); my $CmdName = basename($0); my $ORIG_DIR = cwd(); my %ERROR_CODE = ( "Success"=>0, # Undifferentiated error code "Error"=>2, # System command is not found "Not_Found"=>3, # Cannot access input files "Access_Error"=>4, # Cannot find a module "Module_Error"=>9 ); my $ShortUsage = "ABI Monitor $TOOL_VERSION A tool to monitor new versions of a software library Copyright (C) 2017 Andrey Ponomarenko's ABI Laboratory License: GPL or LGPL Usage: $CmdName [options] [profile] Example: $CmdName -get -build profile.json More info: $CmdName --help\n"; if($#ARGV==-1) { printMsg("INFO", $ShortUsage); exit(0); } GetOptions("h|help!" => \$Help, "dumpversion!" => \$DumpVersion, # general options "get!" => \$Get, "get-old!" => \$GetOld, "build!" => \$Build, "rebuild!" => \$Rebuild, "limit=s" => \$LimitOps, "v=s" => \$TargetVersion, "output=s" => \$OutputProfile, "build-shared!" => \$BuildShared, "build-new!" => \$BuildNew, "debug!" => \$Debug, # other options "make=s" => \$MakeAddOpt ) or ERR_MESSAGE(); sub ERR_MESSAGE() { printMsg("INFO", "\n".$ShortUsage); exit($ERROR_CODE{"Error"}); } my $HelpMessage=" NAME: ABI Monitor ($CmdName) Monitor and build new versions of a C/C++ software library DESCRIPTION: ABI Tracker is a tool to monitor new versions of a software library, try to build them and create profile for ABI Tracker. The tool is intended to be used with the ABI Tracker tool for visualizing API/ABI changes timeline. This tool is free software: you can redistribute it and/or modify it under the terms of the GNU LGPL or GNU GPL. USAGE: $CmdName [options] [profile] EXAMPLES: $CmdName -get -build profile.json INFORMATION OPTIONS: -h|-help Print this help. -dumpversion Print the tool version ($TOOL_VERSION) and don't do anything else. GENERAL OPTIONS: -get Download new library versions. -get-old Download old packages from OldSourceUrl option of the profile. -build Build library versions. -rebuild Re-build library versions. -limit NUM Limit number of operations to NUM. This is usefull if you want to download or build only NUM packages. -v NUM Build only one particular version. -output PATH Path to output profile. The tool will overwrite the input profile by default. -build-shared Build shared objects from static ones if they cannot be build by the library makefile or build script. -build-new Build newly found packages only. This option should be used with -get option. -debug Enable debug messages. OTHER OPTIONS: -make OPT Add options to 'make' command (e.g. '-j4'). "; # Global my $Profile_Path; my $Profile; my $DB; my $TARGET_LIB; my $TARGET_TITLE; my $C_FLAGS; my $CXX_FLAGS; my %Cache; my %NewVer; sub get_Modules() { my $TOOL_DIR = dirname($0); my @SEARCH_DIRS = ( # tool's directory abs_path($TOOL_DIR), # relative path to modules abs_path($TOOL_DIR)."/../share/abi-monitor", # install path 'MODULES_INSTALL_PATH' ); foreach my $DIR (@SEARCH_DIRS) { if(not $DIR=~/\A\//) { # relative path $DIR = abs_path($TOOL_DIR)."/".$DIR; } if(-d $DIR."/modules") { return $DIR."/modules"; } } exitStatus("Module_Error", "can't find modules"); } sub loadModule($) { my $Name = $_[0]; my $Path = $MODULES_DIR."/Internals/$Name.pm"; if(not -f $Path) { exitStatus("Module_Error", "can't access \'$Path\'"); } require $Path; } sub readModule($$) { my ($Module, $Name) = @_; my $Path = $MODULES_DIR."/Internals/$Module/".$Name; if(not -f $Path) { exitStatus("Module_Error", "can't access \'$Path\'"); } return readFile($Path); } sub exitStatus($$) { my ($Code, $Msg) = @_; printMsg("ERROR", $Msg); exit($ERROR_CODE{$Code}); } sub printMsg($$) { my ($Type, $Msg) = @_; if($Type!~/\AINFO/) { $Msg = $Type.": ".$Msg; } if($Type!~/_C\Z/) { $Msg .= "\n"; } if($Type eq "ERROR") { print STDERR $Msg; } else { print $Msg; } } sub readProfile($) { my $Content = $_[0]; my %Res = (); if($Content=~/\A\s*\{\s*((.|\n)+?)\s*\}\s*\Z/) { my $Info = $1; if($Info=~/\"Versions\"/) { my $Pos = 0; while($Info=~s/(\"Versions\"\s*:\s*\[\s*)(\{\s*(.|\n)+?\s*\})\s*,?\s*/$1/) { my $VInfo = readProfile($2); if(my $VNum = $VInfo->{"Number"}) { $VInfo->{"Pos"} = $Pos++; $Res{"Versions"}{$VNum} = $VInfo; } else { printMsg("ERROR", "version number is missed in the profile"); } } } # arrays while($Info=~s/\"(\w+)\"\s*:\s*\[\s*(.*?)\s*\]\s*(\,|\Z)//) { my ($K, $A) = ($1, $2); if($K eq "Versions") { next; } $Res{$K} = []; foreach my $E (split(/\s*\,\s*/, $A)) { $E=~s/\A[\"\']//; $E=~s/[\"\']\Z//; push(@{$Res{$K}}, $E); } } # scalars while($Info=~s/\"(\w+)\"\s*:\s*(.+?)\s*\,?\s*$//m) { my ($K, $V) = ($1, $2); if($K eq "Versions") { next; } $V=~s/\A[\"\']//; $V=~s/[\"\']\Z//; $Res{$K} = $V; } } return \%Res; } sub getCurrent() { my $CurRepo = $REPO."/".$TARGET_LIB."/current"; my $Git = defined $Profile->{"Git"}; my $Svn = defined $Profile->{"Svn"}; my $Hg = defined $Profile->{"Hg"}; my $Branch = $Profile->{"Branch"}; if($Git) { if(not checkCmd("git")) { printMsg("ERROR", "can't find \"git\""); return; } } elsif($Svn) { if(not checkCmd("svn")) { printMsg("ERROR", "can't find \"svn\""); return; } } elsif($Hg) { if(not checkCmd("hg")) { printMsg("ERROR", "can't find \"hg\""); return; } } my $UpToDate = 0; if(-d $CurRepo) { chdir($CurRepo); if($Git) { printMsg("INFO", "Updating source code in repository"); if($Branch) { system("git checkout ".$Branch); } my $Log = qx/git pull/; if($Log=~/Already up\-to\-date/i) { $UpToDate = 1; } } elsif($Svn) { printMsg("INFO", "Updating source code in repository"); my $Log = qx/svn update/; if($Log!~/Updated to revision/i) { $UpToDate = 1; } } elsif($Hg) { printMsg("INFO", "Updating source code in repository"); my $Log = qx/hg pull/; if($Log=~/no changes found/i) { $UpToDate = 1; } } } else { if($Git) { printMsg("INFO", "Cloning git repository"); system("git clone ".$Profile->{"Git"}." ".$CurRepo); chdir($CurRepo); if($Branch) { system("git checkout ".$Branch); } } elsif($Svn) { printMsg("INFO", "Checkouting svn repository"); system("svn checkout ".$Profile->{"Svn"}." ".$CurRepo); } elsif($Hg) { printMsg("INFO", "Checkouting hg repository"); system("hg clone ".$Profile->{"Hg"}." ".$CurRepo); } } chdir($ORIG_DIR); $DB->{"Source"}{"current"} = $CurRepo; my $UTime = getScmUpdateTime(); if(not $UpToDate) { if($DB->{"ScmUpdateTime"}) { if($DB->{"ScmUpdateTime"} ne $UTime) { $NewVer{"current"} = 1; } } else { $NewVer{"current"} = 1; } } $DB->{"ScmUpdateTime"} = $UTime; } sub getScmUpdateTime() { if(my $Source = $DB->{"Source"}{"current"}) { if(not -d $Source) { return undef; } my $Time = undef; my $Head = undef; if(defined $Profile->{"Git"}) { $Head = "$Source/.git/refs/heads/master"; if(not -f $Head) { # is not updated yet $Head = "$Source/.git/FETCH_HEAD"; } if(not -f $Head) { $Head = undef; } } elsif(defined $Profile->{"Svn"}) { $Head = "$Source/.svn/wc.db"; if(not -f $Head) { $Head = undef; } } elsif(defined $Profile->{"Hg"}) { $Head = "$Source/.hg/store"; if(not -e $Head) { $Head = undef; } } if($Head) { $Time = `stat -c \%Y \"$Head\"`; chomp($Time); } if($Time) { return $Time; } } return undef; } sub getVersions_Local() { if(not defined $Profile->{"SourceDir"}) { return 0; } my $SourceDir = $Profile->{"SourceDir"}; if(not $SourceDir) { return 0; } if(not -d $SourceDir) { exitStatus("Access_Error", "can't access \'$SourceDir\'"); return 0; } printMsg("INFO", "Copying packages from \'$SourceDir\' to \'$REPO/$TARGET_LIB\'"); my @Files = findFiles($SourceDir, "f"); foreach my $File (sort {$b cmp $a} @Files) { if($File=~/\/(\Q$TARGET_LIB\E[\_\-]*([^\/]+?)\.($PKG_EXT))\Z/) { my ($P, $V) = ($1, $2); my $To = $REPO."/".$TARGET_LIB."/".$V; if(not -d $To or not listDir($To)) { printMsg("INFO", "Found $File"); # copy to local directory # mkpath($To); # if(copy($File, $To)) # { # $DB->{"Source"}{$V} = $To."/".$P; # } $DB->{"Source"}{$V} = $File; } } } } sub getVersions() { my $SourceTag = "SourceUrl"; if($GetOld) { $SourceTag = "OldSourceUrl"; } my $SourceUrl = $Profile->{$SourceTag}; if(not $SourceUrl) { if(not defined $Profile->{"SourceDir"}) { printMsg("WARNING", "$SourceTag is not specified in the profile"); } return; } if($GetOld) { printMsg("INFO", "Searching for old source packages"); } else { printMsg("INFO", "Searching for new packages"); } if($USE_CURL) { if(not checkCmd("curl")) { printMsg("ERROR", "can't find \"curl\""); return; } } else { if(not checkCmd("wget")) { printMsg("ERROR", "can't find \"wget\""); return; } } my @Links = getLinks(\$SourceUrl); my $Depth = 2; if($GetOld) { if(defined $Profile->{"OldSourceUrlDepth"}) { # More steps into directory tree $Depth = $Profile->{"OldSourceUrlDepth"}; } } else { if(defined $Profile->{"SourceUrlDepth"}) { # More steps into directory tree $Depth = $Profile->{"SourceUrlDepth"}; } } if($Depth>=2) { my %Checked = (); $Checked{$SourceUrl} = 1; foreach my $D (1 .. $Depth - 1) { my @Pages = getPages($SourceUrl, \@Links); foreach my $Page (@Pages) { if(not defined $Checked{$Page}) { $Checked{$Page} = 1; foreach my $Link (getLinks(\$Page)) { push(@Links, $Link); } } } } } my $Packages = getPackages(@Links); my $NumOp = 0; my @Versions = keys(%{$Packages}); @Versions = naturalSequence($Profile, @Versions); @Versions = reverse(@Versions); foreach my $V (@Versions) { my $R = getPackage($Packages->{$V}{"Url"}, $Packages->{$V}{"Pkg"}, $V); if($R>0) { $NumOp += 1; } if(defined $LimitOps) { if($NumOp>=$LimitOps) { last; } } } if(not $NumOp) { printMsg("INFO", "No new packages found"); } } sub getHighestRelease() { if(defined $Cache{"HighestRelease"}) { return $Cache{"HighestRelease"}; } my @Vers = keys(%{$DB->{"Source"}}); @Vers = naturalSequence($Profile, @Vers); @Vers = reverse(@Vers); foreach my $V (@Vers) { if(getVersionType($V, $Profile) eq "release") { return ($Cache{"HighestRelease"} = $V); } } return undef; } sub isOldMicro($$) { my ($V, $L) = @_; my $M = getMajor($V, $L); foreach my $Ver (sort keys(%{$DB->{"Source"}})) { if(getMajor($Ver, $L) eq $M) { if(cmpVersions_P($Ver, $V, $Profile)>=0) { return 1; } } } return 0; } sub getPackage($$$) { my ($Link, $P, $V) = @_; if(defined $DB->{"Source"}{$V}) { # already downloaded return -1; } if(getVersionType($V, $Profile) ne "release") { if(my $HighestRelease = getHighestRelease()) { if(cmpVersions_P($V, $HighestRelease, $Profile)==-1) { # do not download old alfa/beta/pre releases return -1; } } } if(defined $Profile->{"LatestMicro"}) { if(isOldMicro($V, 2)) { # do not download old micro releases return -1; } } if(defined $Profile->{"LatestNano"}) { if(isOldMicro($V, 3)) { # do not download old nano releases return -1; } } my $Dir = $REPO."/".$TARGET_LIB."/".$V; if(not -e $Dir) { mkpath($Dir); } my $To = $Dir."/".$P; if(-f $To) { return -1; } printMsg("INFO", "Downloading package \'$P\' ($TARGET_TITLE)"); if($Debug) { printMsg("INFO", "Link: \'$Link\'"); } my $Pid = fork(); unless($Pid) { # child my $Cmd = ""; if($USE_CURL) { $Cmd = "curl -L \"$Link\" --connect-timeout 5 --retry 1 --output \"$To\""; } else { $Cmd = "wget --no-check-certificate \"$Link\" --connect-timeout=5 --tries=1 --output-document=\"$To\""; # -U '' } system($Cmd." >".$TMP_DIR."/wget_log 2>&1"); writeFile($TMP_DIR."/wget_res", $?); exit(0); } local $SIG{INT} = sub { rmtree($Dir); safeExit(); }; waitpid($Pid, 0); my $Log = readFile($TMP_DIR."/wget_log"); my $R = readFile($TMP_DIR."/wget_res"); if($Log=~/\[text\/html\]/ or not -B $To) { rmtree($Dir); printMsg("ERROR", "\'$Link\' is not a package\n"); return 0; } elsif($R or not -f $To or not -s $To) { rmtree($Dir); printMsg("ERROR", "can't access \'$Link\'\n"); return 0; } $DB->{"Source"}{$V} = $To; $NewVer{$V} = 1; $Cache{"HighestRelease"} = undef; return 1; } sub readPage($) { my $Page = $_[0]; my $To = $TMP_DIR."/page.html"; unlink($To); my $Url = $Page; if($Page=~/\Aftp:.+[^\/]\Z/ and getFilename($Page)!~/\./) { # wget for ftp # tail "/" should be added $Page .= "/"; } my $UserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"; my $Cmd = ""; if($USE_CURL and index($Page, "ftp:")!=0) { # TODO: how to list absolute paths in FTP directory using curl? $Cmd = "curl -L \"$Page\""; $Cmd .= " --connect-timeout $CONNECT_TIMEOUT"; $Cmd .= " --retry $ACCESS_TRIES --output \"$To\""; $Cmd .= " -w \"\%{url_effective}\\n\""; $Cmd .= " -A \"$UserAgent\""; } else { $Cmd = "wget --no-check-certificate \"$Page\""; # $Cmd .= " -U ''"; $Cmd .= " --no-remove-listing"; # $Cmd .= " --quiet"; $Cmd .= " --connect-timeout=$CONNECT_TIMEOUT"; $Cmd .= " --tries=$ACCESS_TRIES --output-document=\"$To\""; $Cmd .= " --user-agent=\"$UserAgent\""; } my $Pid = fork(); unless($Pid) { # child system($Cmd." >".$TMP_DIR."/output 2>&1"); writeFile($TMP_DIR."/result", $?); exit(0); } $SIG{ALRM} = sub { kill(9, $Pid); }; alarm $ACCESS_TIMEOUT; waitpid($Pid, 0); alarm 0; my $Output = readFile($TMP_DIR."/output"); while($Output=~s/((http|https|ftp):\/\/[^\s]+)//) { # real URL $Url = $1; } my $Res = readFile($TMP_DIR."/result"); if(not $Res) { return ($To, $Url); } printMsg("ERROR", "can't access page \'$Page\'"); return ("", ""); } sub getPackages(@) { my %Res = (); my $Pkg = $TARGET_LIB; my $Suffix = ""; if(defined $Profile->{"Package"}) { $Pkg = $Profile->{"Package"}; } if($Pkg=~/\A(.+)\{V\}(.+)\Z/) { ($Pkg, $Suffix) = ($1, $2); } foreach my $Link (@_) { if($Link=~/\/\Z/) { next; } my ($P, $V, $E) = (); if($Link=~/(\A|[\/\=])(\Q$Pkg\E[_\-]*([^\/"'<>+%]+?)(\-src|\-source|\Q$Suffix\E|)\.($PKG_EXT))([\/\?]|\Z)/i) { ($P, $V, $E) = ($2, $3, $5); } elsif($Link=~/(archive|get)\/(|\w+\/)v?([\d\.\-\_]+([ab]\d*|alpha\d*|beta\d*|rc\d*|stable|))(\-src|\-source|\Q$Suffix\E|)\.(tar\.gz)/i) { # github # bitbucket ($V, $E) = ($3, $6); } elsif($Link=~/\/archive\.($PKG_EXT)\?ref=(.+)\Z/i) { # gitlab ($V, $E) = ($2, $1); } if(not $V or not $E) { next; } if(not $P) { $P = $Pkg."-".$V.".".$E; } $V=~s/\A(v|version)(|_)(\d)/$3/i; # v1.1, VERSION_1.22 $V=~s/[\-\_\.](src|source|sources)\Z//i; # pkg-X.Y.Z-Source.tar.gz if(defined $Res{$V}) { if($Res{$V}{"Ext"} ne "zip" or $E eq "zip") { next; } } if($V=~/mingw|msvc/i) { next; } if($V=~/snapshot/i) { next; } if(getVersionType($V, $Profile) eq "unknown") { next; } if(my $Release = checkReleasePattern($V, $Profile)) { $V = $Release; } if(skipVersion($V, $Profile)) { next; } if(defined $TargetVersion) { if($TargetVersion ne $V) { next; } } if($P) { $Res{$V}{"Url"} = $Link; $Res{$V}{"Pkg"} = $P; $Res{$V}{"Ext"} = $E; } } return \%Res; } sub getPages($$) { my ($Top, $Links) = @_; my @Res = (); $Top=~s/\?.*\Z//g; $Top=~s&\A\w+://&//&; # do not match protocol foreach my $Link (@{$Links}) { if($Link!~/\/\Z/ and $Link!~/\/v?\d[\d\.\-]*\Z/i) { if($Link!~/github\.com\/.+\?after\=/) { next; } } if(index($Link, $Top)==-1) { next; } my $PLink = $Link; $PLink=~s/\%20/ /gi; my $DirVer = undef; if($PLink=~/https:\/\/sourceforge\.net\/projects\/[^\/]+\/files\/[^\/]+\/($TARGET_LIB[\-_ ]*|)v?(\d[^\/]*?)[ _-]*(Src|Source|Sources|)\/\Z/i) { $DirVer = $2; } elsif($PLink=~/\/($TARGET_LIB[\-_ ]*|)v?(\d[^\/]*?)[\/]*\Z/i) { # 9.1.1rc7 $DirVer = $2; } if($DirVer) { if(skipOldLink($DirVer)) { if($Debug) { printMsg("INFO", "Skip (Old dir): $Link"); } next; } } push(@Res, $Link); } return @Res; } sub skipOldLink($) { my $V = $_[0]; my $VType = getVersionType($V, $Profile); if($VType eq "unknown") { return 0; } if(defined $DB->{"Source"}{$V}) { return 1; } elsif(skipVersion($V, $Profile, 0)) { return 1; } elsif(my $Min = $Profile->{"MinimalVersion"}) { if(getVDepth($V)>=getVDepth($Min)) { if(cmpVersions_P($V, $Min, $Profile)==-1) { return 1; } } } if($VType ne "release" and my $HighestRel = getHighestRelease()) { if(cmpVersions_P($V, $HighestRel, $Profile)==-1) { # do not download old betas return 1; } } return 0; } sub getLinks($) { my $PageRef = $_[0]; my $Page = ${$PageRef}; if($Debug) { printMsg("INFO", "Reading ".$Page); } my ($To, $Url) = readPage($Page); if(not $To) { return (); } my $Content = readFile($To); unlink($To); my (%Links1, %Links2, %Links3, %Links4, %Links5) = (); my @Lines = split(/\n/, $Content); foreach my $Line (@Lines) { while($Line=~s/(src|href)\s*\=\s*["']\s*((ftp|http|https):\/\/[^"'<>\s]+?)\s*["']//i) { $Links1{$2} = 1; } while($Line=~s/(src|href)\s*\=\s*["']\s*([^"'<>\s]+?)\s*["']//i) { $Links2{linkSum($Url, $2)} = 1; } while($Line=~s/((ftp|http|https):\/\/[^"'<>\s]+?)([\s"']|\Z)//i) { $Links3{$1} = 1; } while($Line=~s/["']([^"'<>\s]+\.($PKG_EXT))["']//i) { $Links4{linkSum($Url, $1)} = 1; } while($Line=~s/(src|href)\s*\=\s*([^"'<>\s]+?)[ >]//i) { $Links5{linkSum($Url, $2)} = 1; } } foreach my $U (keys(%Links4)) { my $F = getFilename($U); if(grep {getFilename($_) eq $F} keys(%Links1)) { delete($Links4{$U}); } } my @L1 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links1); my @L2 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links2); my @L3 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links3); my @L4 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links4); my @L5 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links5); my @AllLinks = (@L1, @L2, @L3, @L4, @L5); foreach (@AllLinks) { while($_=~s/\/[^\/]+\/\.\.\//\//g){}; } my $SiteAddr = getSiteAddr($Page); my $SiteProtocol = getSiteProtocol($Page); my @Res = (); foreach my $Link (@AllLinks) { if(skipUrl($Link)) { if($Debug) { printMsg("INFO", "Skip: $Link"); } next; } if($Link!~/github\.com\/.*\?after\=/ and $Link!~/\?.*\.($PKG_EXT)/ and $Link!~/\?ref=/) { $Link=~s/\?.+\Z//g; } $Link=~s/\%2B/+/gi; $Link=~s/\%2D/-/gi; $Link=~s/[\/]{2,}\Z/\//g; if($Link=~/\A(\Q$Page\E|\Q$Url\E|\Q$SiteAddr\E)[\/]*\Z/) { next; } # if(getSiteAddr($Link) ne getSiteAddr($Page)) { # next; # } if(not getSiteProtocol($Link)) { $Link = $SiteProtocol.$Link; } if(index($Link, "sourceforge")!=-1) { if($Link=~/\.($PKG_EXT)(\/.+|)\Z/) { if($2 ne "/download") { next; } } if($Link=~/(http[s]*):\/\/sourceforge.net\/projects\/(\w+)\/files\/(.+)\/download\Z/) { # fix for SF $Link = "$1://sourceforge.net/projects/$2/files/$3/download?use_mirror=autoselect"; } } $Link=~s/\:21\//\//; push(@Res, $Link); } ${$PageRef} = $Url; return @Res; } sub skipUrl($$) { my $Link = $_[0]; if(defined $Profile->{"SkipUrl"}) { foreach my $Url (@{$Profile->{"SkipUrl"}}) { if(not $Url) { next; } if($Url=~/[\*\+\(\|\\]/) { # pattern if($Link=~/$Url/) { return 1; } } else { if($Link=~/\Q$Url\E/) { return 1; } } } } return 0; } sub linkSum($$) { my ($Page, $Path) = @_; $Page=~s/\?.+?\Z//g; $Path=~s/\A\.\///g; if($Path=~/\A\/\/([^\/:]+\.[a-z]+\/.+)\Z/) { # //liblouis.googlecode.com/files/liblouis-1.6.2.tar.gz return $1; } elsif(index($Path, "://")!=-1) { return $Path; } elsif(index($Path, "/")==0) { return getSite($Page).$Path; } elsif($Page=~/\/\Z/) { return $Page.$Path; } return getDirname($Page)."/".$Path; } sub buildVersions() { if(not defined $DB->{"Source"}) { printMsg("INFO", "Nothing to build"); return; } if(checkCmd($GCC)) { if(my $Machine = qx/$GCC -dumpmachine/) { if($Machine=~/x86_64/) { $C_FLAGS_B .= " -fPIC"; $CXX_FLAGS_B .= " -fPIC"; } } } if(defined $BuildNew) { if(not defined $DB->{"Installed"}{"current"}) { # NOTE: try to build current again $NewVer{"current"} = 1; } } my @Versions = keys(%{$DB->{"Source"}}); @Versions = naturalSequence($Profile, @Versions); @Versions = reverse(@Versions); my $NumOp = 0; foreach my $V (@Versions) { if(defined $TargetVersion) { if($TargetVersion ne $V) { next; } } if(defined $BuildNew) { if(not defined $NewVer{$V}) { next; } } if(defined $Profile->{"Versions"} and defined $Profile->{"Versions"}{$V} and defined $Profile->{"Versions"}{$V}{"Deleted"}) { next; } my $R = buildPackage($DB->{"Source"}{$V}, $V); if($R>0) { $NumOp += 1; } if(defined $LimitOps) { if($NumOp>=$LimitOps) { last; } } } if(not $NumOp) { printMsg("INFO", "Nothing to build"); return; } } sub createProfile() { my $To = $OutputProfile; if(not $To) { $To = $Profile_Path; } if(not defined $DB->{"Installed"}) { printMsg("INFO", "No installed versions of the library to create profile"); return; } my @ProfileKeys = ("Name", "Title", "SourceUrl", "SourceUrlDepth", "OldSourceUrl", "OldSourceUrlDepth", "SourceDir", "SkipUrl", "Git", "Svn", "Hg", "Doc", "Maintainer", "MaintainerUrl", "BuildSystem", "Configure", "CurrentConfigure", "BuildScript", "PreInstall", "CurrentPreInstall", "PostInstall", "CurrentPostInstall", "SkipObjects", "SkipHeaders", "SkipSymbols", "SkipInternalSymbols", "SkipTypes", "SkipInternalTypes"); my $MaxLen_P = 13; my %UnknownKeys = (); foreach my $K (keys(%{$Profile})) { if(not grep {$_ eq $K} @ProfileKeys) { $UnknownKeys{$K} = 1; } } if(keys(%UnknownKeys)) { push(@ProfileKeys, sort keys(%UnknownKeys)); } my @Content_L = (); foreach my $K (@ProfileKeys) { if(defined $Profile->{$K}) { my $Val = $Profile->{$K}; my $Ref = ref($Val); if($Ref eq "HASH") { next; } my $St = ""; foreach (0 .. $MaxLen_P - length($K)) { $St .= " "; } if($Ref eq "ARRAY") { push(@Content_L, "\"$K\": ".$St."[ \"".join("\", \"", @{$Val})."\" ]"); } else { push(@Content_L, "\"$K\": ".$St."\"$Val\""); } } } my @Content_V = (); my @Versions = keys(%{$DB->{"Installed"}}); @Versions = naturalSequence($Profile, @Versions); if(defined $Profile->{"Versions"}) { if(not keys(%{$Profile->{"Versions"}})) { $Profile->{"Versions"} = undef; } } if(defined $Profile->{"Versions"}) { # save order of versions in the profile if manually edited foreach my $V (keys(%{$Profile->{"Versions"}})) { # clear variable if(not defined $Profile->{"Versions"}{$V}{"Pos"}) { delete($Profile->{"Versions"}{$V}); } } my @O_Versions = keys(%{$Profile->{"Versions"}}); @O_Versions = sort {int($Profile->{"Versions"}{$b}{"Pos"})<=>int($Profile->{"Versions"}{$a}{"Pos"})} @O_Versions; my %Added = map {$_=>1} @O_Versions; my @Merged = (); foreach my $P1 (0 .. $#O_Versions) { my $V1 = $O_Versions[$P1]; foreach my $V2 (@Versions) { if(not defined $Added{$V2}) { if(cmpVersions_P($V2, $V1, $Profile)==-1) { push(@Merged, $V2); $Added{$V2} = 1; } } } push(@Merged, $V1); if($P1==$#O_Versions) { foreach my $V2 (@Versions) { if(not defined $Added{$V2}) { if(cmpVersions_P($V2, $V1, $Profile)==1) { push(@Merged, $V2); $Added{$V2} = 1; } } } } } @Versions = @Merged; } # Mark old unstable releases as "deleted" if(not defined $Profile->{"KeepOldBeta"}) { my $MaxBeta = undef; my $MaxRelease = undef; foreach my $V (reverse(@Versions)) { if($V eq "current") { next; } if(getVersionType($V, $Profile) eq "release") { if(not defined $MaxRelease) { $MaxRelease = $V; } } else { if(defined $MaxBeta or defined $MaxRelease) { if(not defined $Profile->{"Versions"}{$V}{"Deleted"}) { # One can set Deleted to 0 in order to prevent deleting $Profile->{"Versions"}{$V}{"Deleted"} = 1; } } if(not defined $MaxBeta) { $MaxBeta = $V; } } } } if(defined $Profile->{"LatestMicro"}) { my %MaxMicro = (); foreach my $V (reverse(@Versions)) { if($V eq "current") { next; } my $M = getMajor($V, 2); if(defined $MaxMicro{$M}) { if(not defined $Profile->{"Versions"}{$V}{"Deleted"}) { # One can set Deleted to 0 in order to prevent deleting $Profile->{"Versions"}{$V}{"Deleted"} = 1; } } else { $MaxMicro{$M} = $V; } } } if(defined $Profile->{"LatestNano"}) { my %MaxNano = (); foreach my $V (reverse(@Versions)) { if($V eq "current") { next; } my $M = getMajor($V, 3); if(defined $MaxNano{$M}) { if(not defined $Profile->{"Versions"}{$V}{"Deleted"}) { # One can set Deleted to 0 in order to prevent deleting $Profile->{"Versions"}{$V}{"Deleted"} = 1; } } else { $MaxNano{$M} = $V; } } } foreach my $V (reverse(@Versions)) { my @Info = (); my $Sp = " "; my $N_Info = {}; $N_Info->{"Number"} = $V; $N_Info->{"Installed"} = $DB->{"Installed"}{$V}; $N_Info->{"Source"} = $DB->{"Source"}{$V}; if(defined $Profile->{"Changelog"}) { $N_Info->{"Changelog"} = $Profile->{"Changelog"}; } else { if($DB->{"Changelog"}{$V}) { $N_Info->{"Changelog"} = $DB->{"Changelog"}{$V}; } else { if($V eq "current") { $N_Info->{"Changelog"} = "On"; } else { $N_Info->{"Changelog"} = "Off"; } } } if(not $N_Info->{"Changelog"}) { # default } if(defined $Profile->{"PkgDiff"}) { $N_Info->{"PkgDiff"} = $Profile->{"PkgDiff"}; } else { $N_Info->{"PkgDiff"} = "Off"; } if(defined $Profile->{"HeadersDiff"}) { $N_Info->{"HeadersDiff"} = $Profile->{"HeadersDiff"}; } else { $N_Info->{"HeadersDiff"} = "On"; } # Non-free high detailed analysis $N_Info->{"ABIView"} = "Off"; $N_Info->{"ABIDiff"} = "Off"; if(defined $Profile->{"Versions"} and defined $Profile->{"Versions"}{$V}) { my $O_Info = $Profile->{"Versions"}{$V}; foreach my $K (sort keys(%{$O_Info})) { # if($K eq "PublicSymbols" # or $K eq "PublicTypes") # { # obsolete # next; # } if($K ne "Pos") { if(defined $O_Info->{$K}) { $N_Info->{$K} = $O_Info->{$K}; } } } } my @VersionKeys = ("Number", "Installed", "Source", "Changelog", "HeadersDiff", "PkgDiff", "ABIView", "ABIDiff", "BuildShared", "Deleted"); my $MaxLen_V = 13; my %UnknownKeys_V = (); foreach my $K (keys(%{$N_Info})) { if(not grep {$_ eq $K} @VersionKeys) { $UnknownKeys_V{$K} = 1; } } if(keys(%UnknownKeys_V)) { push(@VersionKeys, sort keys(%UnknownKeys_V)); } foreach my $K (@VersionKeys) { if(defined $N_Info->{$K}) { my $St = ""; foreach (0 .. $MaxLen_V - length($K)) { $St .= " "; } if(int($N_Info->{$K}) eq $N_Info->{$K}) { # integer push(@Info, $Sp."\"$K\": $St".$N_Info->{$K}); } else { # string push(@Info, $Sp."\"$K\": $St\"".$N_Info->{$K}."\""); } } } push(@Content_V, "{\n".join(",\n", @Info)."\n }"); } writeFile($To, "{\n ".join(",\n ", @Content_L).",\n\n \"Versions\": [\n ".join(",\n ", @Content_V)."]\n}\n"); } sub findChangelog($) { my $Dir = $_[0]; my $MIN_LOG = 250; foreach my $Name ("NEWS", "CHANGES", "CHANGES.txt", "RELEASE_NOTES", "ChangeLog", "ChangeLog.md", "Changelog", "changelog", "RELEASE_NOTES.md", "CHANGELOG.md", "CHANGELOG.txt", "RELEASE_NOTES.markdown", "NEWS.md", "CHANGES.md", "changes.txt", "changes", "CHANGELOG", "RELEASE-NOTES", "WHATSNEW", "CHANGE_LOG", "doc/ChangeLog", "ChangeLog.txt") { if(-f $Dir."/".$Name and (-s $Dir."/".$Name > $MIN_LOG)) { return $Name; } } return "None"; } sub autoBuild($$$) { my ($To, $LogDir, $V) = @_; my $LogDir_R = $LogDir; $LogDir_R=~s/\A$ORIG_DIR\///; my $PreInstall = $Profile->{"PreInstall"}; if($V eq "current") { if(defined $Profile->{"CurrentPreInstall"}) { $PreInstall = $Profile->{"CurrentPreInstall"}; } } if($PreInstall) { $PreInstall = addParams($PreInstall, $To, $V); my $Cmd_P = $PreInstall." >$LogDir/pre_install 2>&1"; qx/$Cmd_P/; # execute if($?) { printMsg("ERROR", "pre install has failed"); printMsg("ERROR", "see error log in '$LogDir_R/pre_install'"); return 0; } } my $PreMake = $Profile->{"PreMake"}; if($V eq "current") { if(defined $Profile->{"CurrentPreMake"}) { $PreMake = $Profile->{"CurrentPreMake"}; } } my @Files = listDir("."); my ($CMake, $Autotools, $Scons, $Waf) = (0, 0, 0, 0); my ($Configure, $Autogen, $Bootstrap, $Buildconf) = (0, 0, 0, 0); foreach my $File (sort @Files) { if($File eq "CMakeLists.txt") { $CMake = 1; } elsif($File eq "configure") { $Autotools = 1; $Configure = 1; } elsif($File eq "configure.ac" or $File eq "configure.in") { $Autotools = 1; } elsif($File eq "autogen.sh") { $Autotools = 1; $Autogen = $File; } elsif($File eq "bootstrap" or $File eq "bootstrap.sh") { $Autotools = 1; $Bootstrap = $File; } elsif($File eq "buildconf") { $Buildconf = 1; } elsif($File eq "SConstruct") { $Scons = 1; } elsif($File eq "waf") { $Waf = 1; } } if($Autotools) { $CMake = 0; } elsif($CMake) { $Autotools = 0; } if(defined $Profile->{"BuildSystem"}) { if($Profile->{"BuildSystem"} eq "CMake") { $CMake = 1; $Autotools = 0; } elsif($Profile->{"BuildSystem"} eq "Autotools") { $CMake = 0; $Autotools = 1; } } if($Autotools) { if(not $Configure) { # try to generate configure script if($Autogen) { my $Cmd_A = "NOCONFIGURE=1 NO_CONFIGURE=1 sh $Autogen --no-configure"; $Cmd_A .= " >\"$LogDir/autogen\" 2>&1"; qx/$Cmd_A/; if(not -f "configure") { printMsg("ERROR", "failed to 'autogen'"); printMsg("ERROR", "see error log in '$LogDir_R/autogen'"); return 0; } } elsif($Bootstrap) { my $Cmd_B = "sh ".$Bootstrap; $Cmd_B .= " >\"$LogDir/bootstrap\" 2>&1"; qx/$Cmd_B/; if(not -f "configure") { printMsg("ERROR", "failed to 'bootstrap'"); printMsg("ERROR", "see error log in '$LogDir_R/bootstrap'"); return 0; } } elsif($Buildconf) { my $Cmd_B = "sh buildconf"; $Cmd_B .= " >\"$LogDir/buildconf\" 2>&1"; qx/$Cmd_B/; if(not -f "configure") { printMsg("ERROR", "failed to 'buildconf'"); printMsg("ERROR", "see error log in '$LogDir_R/buildconf'"); return 0; } } else { my $Cmd_R = "autoreconf --force --verbose --install"; $Cmd_R .= " >\"$LogDir/autoreconf\" 2>&1"; qx/$Cmd_R/; if(not -f "configure") { printMsg("ERROR", "failed to 'autoreconf'"); printMsg("ERROR", "see error log in '$LogDir_R/autoreconf'"); return 0; } } } } my $ConfigureKey = "Configure"; if($V eq "current" and defined $Profile->{"CurrentConfigure"}) { $ConfigureKey = "CurrentConfigure"; } else { if($CMake) { if(defined $Profile->{"CMakeConfigure"}) { $ConfigureKey = "CMakeConfigure"; } } elsif($Autotools) { if(defined $Profile->{"AutotoolsConfigure"}) { $ConfigureKey = "AutotoolsConfigure"; } } } my $ConfigOptions = $Profile->{$ConfigureKey}; if($ConfigOptions) { $ConfigOptions = addParams($ConfigOptions, $To, $V); } my $ConfigGlobalVars = $Profile->{"ConfigureGlobal"}; if($ConfigGlobalVars) { $ConfigGlobalVars = addParams($ConfigGlobalVars, $To, $V); } if($Autotools) { my $ConfigLog = "$LogDir/configure"; my $Cmd_C = "./configure --enable-shared"; $Cmd_C .= " --prefix=\"$To\""; $Cmd_C .= " CFLAGS=\"$C_FLAGS\" CXXFLAGS=\"$CXX_FLAGS\""; if($ConfigOptions) { $Cmd_C .= " ".$ConfigOptions; } if($ConfigGlobalVars) { $Cmd_C = $ConfigGlobalVars." ".$Cmd_C; } writeFile($ConfigLog, $Cmd_C."\n\n"); $Cmd_C .= " >>\"$ConfigLog\" 2>&1"; qx/$Cmd_C/; # execute if($?) { printMsg("ERROR", "failed to 'configure'"); printMsg("ERROR", "see error log in '$LogDir_R/configure'"); return 0; } } elsif($CMake) { my $ConfigLog = "$LogDir/cmake"; my $CMake_C = $CMAKE; if($Profile->{"CMakePath"}) { $CMake_C = $Profile->{"CMakePath"}; } if(not checkCmd($CMake_C)) { printMsg("ERROR", "can't find \"$CMake_C\""); return; } my $BDir = $BUILD_SUBDIR; mkpath($BDir); chdir($BDir); my $Cmd_C = $CMake_C." .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON"; $Cmd_C .= " -DCMAKE_INSTALL_PREFIX=\"$To\""; $Cmd_C .= " -DCMAKE_C_FLAGS=\"$C_FLAGS\" -DCMAKE_CXX_FLAGS=\"$CXX_FLAGS\""; if($ConfigOptions) { $Cmd_C .= " ".$ConfigOptions; } if($ConfigGlobalVars) { $Cmd_C = $ConfigGlobalVars." ".$Cmd_C; } writeFile($ConfigLog, $Cmd_C."\n\n"); $Cmd_C .= " >>\"$ConfigLog\" 2>&1"; qx/$Cmd_C/; # execute if($?) { printMsg("ERROR", "failed to 'cmake'"); printMsg("ERROR", "see error log in '$LogDir_R/cmake'"); return 0; } } elsif($Scons) { my $Cmd_I = "scons prefix=\"$To\" debug=True"; if($ConfigOptions) { $Cmd_I .= " ".$ConfigOptions; } if($ConfigGlobalVars) { $Cmd_I = $ConfigGlobalVars." ".$Cmd_I; } $Cmd_I .= " install"; $Cmd_I .= " >\"$LogDir/scons\" 2>&1"; my $SConstruct = readFile("SConstruct"); $SConstruct=~s/'-O[0123]'/'-Og'/; writeFile("SConstruct", $SConstruct); qx/$Cmd_I/; # execute if($?) { printMsg("ERROR", "failed to 'scons'"); printMsg("ERROR", "see error log in '$LogDir_R/scons'"); return 0; } } elsif($Waf) { my $ConfigLog = "$LogDir/configure"; my $Cmd_C = "./waf configure --prefix=\"$To\""; $Cmd_C = "CFLAGS=\"$C_FLAGS\" CXXFLAGS=\"$CXX_FLAGS\" ".$Cmd_C; if($ConfigOptions) { $Cmd_C .= " ".$ConfigOptions; } if($ConfigGlobalVars) { $Cmd_C = $ConfigGlobalVars." ".$Cmd_C; } writeFile($ConfigLog, $Cmd_C."\n\n"); $Cmd_C .= " >>\"$ConfigLog\" 2>&1"; qx/$Cmd_C/; # execute if($?) { printMsg("ERROR", "failed to './waf configure'"); printMsg("ERROR", "see error log in '$LogDir_R/configure'"); return 0; } } else { printMsg("ERROR", "unknown build system, please set \"BuildScript\" in the profile"); return 0; } my $MakeOptions = $Profile->{"Make"}; if($MakeAddOpt) { $MakeOptions = $MakeAddOpt; } $MakeOptions = addParams($MakeOptions, $To, $V); my $MakeGlobalVars = $Profile->{"MakeGlobal"}; $MakeGlobalVars = addParams($MakeGlobalVars, $To, $V); my $InstallGlobalVars = $Profile->{"InstallGlobal"}; $InstallGlobalVars = addParams($InstallGlobalVars, $To, $V); if($PreMake) { $PreMake = addParams($PreMake, $To, $V); my $Cmd_PM = $PreMake." >$LogDir/pre_make 2>&1"; qx/$Cmd_PM/; # execute if($?) { printMsg("ERROR", "pre make has failed"); printMsg("ERROR", "see error log in '$LogDir_R/pre_make'"); return 0; } } if($CMake or $Autotools) { my $Cmd_M = "make"; my $MakeLog = "$LogDir/make"; if($MakeOptions) { $Cmd_M .= " ".$MakeOptions; } if($MakeGlobalVars) { $Cmd_M = $MakeGlobalVars." ".$Cmd_M; } writeFile($MakeLog, $Cmd_M."\n\n"); $Cmd_M .= " >>$MakeLog 2>&1"; qx/$Cmd_M/; # execute if($?) { printMsg("ERROR", "failed to 'make'"); printMsg("ERROR", "see error log in '$LogDir_R/make'"); return 0; } if(not defined $Profile->{"Install"} or $Profile->{"Install"} eq "On") { my $Cmd_I = "make install"; if($InstallGlobalVars) { $Cmd_I = $InstallGlobalVars." ".$Cmd_I; } $Cmd_I .= " >$LogDir/install 2>&1"; qx/$Cmd_I/; # execute if($?) { printMsg("ERROR", "failed to 'make install'"); printMsg("ERROR", "see error log in '$LogDir_R/install'"); return 0; } } } elsif($Waf) { my $Cmd_M = "./waf build"; $Cmd_M .= " >$LogDir/build 2>&1"; qx/$Cmd_M/; # execute if($?) { printMsg("ERROR", "failed to './waf build'"); printMsg("ERROR", "see error log in '$LogDir_R/build'"); return 0; } my $Cmd_I = "./waf install >$LogDir/install 2>&1"; qx/$Cmd_I/; # execute if($?) { printMsg("ERROR", "failed to './waf install'"); printMsg("ERROR", "see error log in '$LogDir_R/install'"); return 0; } } my $PostInstall = $Profile->{"PostInstall"}; if($V eq "current") { if(defined $Profile->{"CurrentPostInstall"}) { $PostInstall = $Profile->{"CurrentPostInstall"}; } } if($CMake) { chdir(".."); } if($PostInstall) { $PostInstall = addParams($PostInstall, $To, $V); my $Cmd_P = $PostInstall." >$LogDir/post_install 2>&1"; qx/$Cmd_P/; # execute if($?) { printMsg("ERROR", "post install has failed"); printMsg("ERROR", "see error log in '$LogDir_R/post_install'"); return 0; } } copyFiles($To); clearInstallTree($To); if(not listDir($To)) { return 0; } return 1; } sub prepareInstallTree($) { my $Dir = $_[0]; foreach my $D ("lib", "lib64", "include") { mkpath($Dir."/".$D); } } sub clearInstallTree($) { my $Dir = $_[0]; foreach my $D ("lib", "lib64", "include") { my $SDir = $Dir."/".$D; if(-d $SDir and not listDir($SDir)) { # remove empty rmtree($SDir); } } } sub copyFiles($) { my $To = $_[0]; foreach my $Tag ("CopyHeaders", "CopyObjects", "CopyStatic") { if(not defined $Profile->{$Tag}) { next; } my $Dir = undef; if($Tag eq "CopyHeaders") { $Dir = "include"; } else { $Dir = "lib"; } if(my $Elems = $Profile->{$Tag}) { foreach my $D (@{$Elems}) { my @Files = (); if(-d $D) { if($Tag eq "CopyHeaders") { @Files = findHeaders($D); } elsif($Tag eq "CopyObjects") { @Files = findObjects($D); } else { @Files = findStatic($D); } } elsif(-f $D) { @Files = ($D); } foreach my $F (@Files) { my $O_To = $To."/".$Dir."/".$F; $O_To=~s&/\.libs/&/&g; my $D_To = getDirname($O_To); mkpath($D_To); copy($F, $D_To); } } } } } sub addParams($$$) { my ($Cmd, $To, $V) = @_; $Cmd=~s/{INSTALL_TO}/$To/g; $Cmd=~s/\$INSTALL_TO/$To/g; $Cmd=~s/{VERSION}/$V/g; $Cmd=~s/\$VERSION/$V/g; $Cmd=~s/{BUILD_SUBDIR}/$BUILD_SUBDIR/g; $Cmd=~s/\$BUILD_SUBDIR/$BUILD_SUBDIR/g; my $InstallRoot_A = $ORIG_DIR."/".$INSTALLED; $Cmd=~s/{INSTALL_ROOT}/$InstallRoot_A/g; $Cmd=~s/\$INSTALL_ROOT/$InstallRoot_A/g; return $Cmd; } sub findObjects($) { my $Dir = $_[0]; my @Files = (); if($Profile->{"Mode"} eq "Kernel") { @Files = findFiles($Dir, "f", ".*\\.ko"); @Files = (@Files, findFiles($Dir, "f", "", "vmlinux")); } else { @Files = findFiles($Dir, "f", ".*\\.so\\..*"); @Files = (@Files, findFiles($Dir, "f", ".*\\.so")); } my @Res = (); foreach my $F (@Files) { if(-B $F) { push(@Res, $F); } } return @Res; } sub findStatic($) { my $Dir = $_[0]; my @Files = findFiles($Dir, "f", ".*\\.a"); my @Res = (); foreach my $F (@Files) { if(-B $F) { push(@Res, $F); } } return @Res; } sub findHeaders($) { my $Dir = $_[0]; my @Files = findFiles($Dir, "f"); my @Headers = (); foreach my $File (sort {lc($a) cmp lc($b)} @Files) { if(isHeader($File)) { push(@Headers, $File); } } return @Headers; } sub buildPackage($$) { my ($Package, $V) = @_; if(not $Rebuild) { if(defined $DB->{"Installed"}{$V}) { if($V ne "current" or not defined $NewVer{$V}) { return -1; } } } printMsg("INFO", "Building \'".getFilename($Package)."\'"); my $BuildScript = undef; if(defined $Profile->{"BuildScript"}) { $BuildScript = $Profile->{"BuildScript"}; if(not -f $BuildScript) { exitStatus("Access_Error", "can't access build script \'$BuildScript\'"); } $BuildScript = abs_path($BuildScript); } my $LogDir_R = $BUILD_LOGS."/".$TARGET_LIB."/".$V; rmtree($LogDir_R); mkpath($LogDir_R); my $LogDir = abs_path($LogDir_R); my $InstallDir = $INSTALLED."/".$TARGET_LIB."/".$V; rmtree($InstallDir); mkpath($InstallDir); my $InstallDir_A = abs_path($InstallDir); my $InstallRoot_A = abs_path($INSTALLED); local $SIG{INT} = sub { # clean up install tree rmtree($InstallDir_A); # generate profile chdir($ORIG_DIR); createProfile(); safeExit(); }; $C_FLAGS = $C_FLAGS_B; $CXX_FLAGS = $CXX_FLAGS_B; if(my $AddCFlags = $Profile->{"CFlags"}) { $C_FLAGS .= " ".addParams($AddCFlags, $InstallDir_A, $V); } if(my $AddCxxFlags = $Profile->{"CxxFlags"}) { $CXX_FLAGS .= " ".addParams($AddCxxFlags, $InstallDir_A, $V); } my $BuildDir = $TMP_DIR."/build/"; mkpath($BuildDir); if($V eq "current") { my $Cmd_E = "cp -fr $Package $BuildDir"; qx/$Cmd_E/; # execute $BuildDir .= "/current"; } else { if(my $Cmd_E = extractPackage($Package, $BuildDir)) { qx/$Cmd_E/; # execute if($?) { printMsg("ERROR", "Failed to extract package \'".getFilename($Package)."\'"); rmtree($BuildDir); return 0; } } else { printMsg("ERROR", "Unknown package format \'".getFilename($Package)."\'"); return 0; } } chdir($BuildDir); while(1) { my @Files = listDir("."); if($#Files==0 and -d $Files[0]) { # one step deeper chdir($Files[0]); } else { last; } } if($V ne "current" and not defined $Profile->{"Changelog"}) { my $Found = findChangelog("."); if($Found ne "None") { $DB->{"Changelog"}{$V} = $Found; } else { $DB->{"Changelog"}{$V} = "Off"; } } if($V eq "current" and my $CurCustomDir = $Profile->{"CurrentBuildDir"}) { chdir($CurCustomDir); } elsif(my $CustomDir = $Profile->{"BuildDir"}) { chdir($CustomDir); } prepareInstallTree($InstallDir_A); if(defined $BuildScript) { my $Cmd_I = "INSTALL_TO=\"$InstallDir_A\" M_INSTALL_ROOT=\"$InstallRoot_A\" VERSION=\"$V\" sh \"".$BuildScript."\""; $Cmd_I .= " >\"$LogDir/build\" 2>&1"; qx/$Cmd_I/; # execute my $Err = $?; if(defined $Profile->{"SkipBuildErrors"} and $Profile->{"SkipBuildErrors"} eq "On") { $Err = 0; } copyFiles($InstallDir_A); clearInstallTree($InstallDir_A); if($Err) { delete($DB->{"Installed"}{$V}); printMsg("ERROR", "custom build has failed (exit code $Err)"); printMsg("ERROR", "see error log in '$LogDir_R/build'"); } elsif(not listDir($InstallDir_A)) { delete($DB->{"Installed"}{$V}); printMsg("ERROR", "custom build has failed (empty install tree)"); printMsg("ERROR", "see error log in '$LogDir_R/build'"); } else { $DB->{"Installed"}{$V} = $InstallDir; } } else { if(autoBuild($InstallDir_A, $LogDir, $V)) { $DB->{"Installed"}{$V} = $InstallDir; } else { delete($DB->{"Installed"}{$V}); } } chdir($ORIG_DIR); rmtree($BuildDir); if($DB->{"Installed"}{$V}) { if((defined $Profile->{"Versions"} and defined $Profile->{"Versions"}{$V} and $Profile->{"Versions"}{$V}{"BuildShared"} and $Profile->{"Versions"}{$V}{"BuildShared"} ne "Off") or ($Profile->{"BuildShared"} and $Profile->{"BuildShared"} ne "Off")) { buildShared($V); } if(not defined $Profile->{"ClearInstalled"} or $Profile->{"ClearInstalled"} eq "On") { foreach my $D ("share", "bin", "sbin", "etc", "var", "opt", "libexec", "doc", "manual", "man", "logs", "icons", "conf", "cgi-bin", "docs", "systemd", "udev", "tmp", "info", "mkspecs", "gir", "fonts", "aclocal", "tutorials", "test") { if(-d $InstallDir."/".$D) { rmtree($InstallDir."/".$D); } } foreach my $D ("systemd", "udev", "girepository-1.0", "python2.7", "sysctl.d", "qml", "libexec") { if(-d $InstallDir."/lib/".$D) { rmtree($InstallDir."/lib/".$D); } if(-d $InstallDir."/lib64/".$D) { rmtree($InstallDir."/lib64/".$D); } } clearInstallTree($InstallDir); my @Fs = listPaths($InstallDir."/lib"); my @Fs64 = listPaths($InstallDir."/lib64"); my $Shared = undef; foreach my $F (@Fs, @Fs64) { if($F=~/\.so(\.|\Z)/) { $Shared = 1; last; } } foreach my $F (@Fs, @Fs64) { if(-f $F) { if($F=~/\.(la|jar|o)\Z/) { unlink($F) } if(defined $Shared) { if($F=~/\.a\Z/) { unlink($F) } } } } if(not listDir($InstallDir)) { # empty after cleaning delete($DB->{"Installed"}{$V}); printMsg("ERROR", "failed to build (empty tree)"); rmtree($InstallDir); return 1; } } if(my @Objects = findObjects($InstallDir)) { foreach my $Obj (sort {lc($a) cmp lc($b)} @Objects) { my $Producer = `readelf --debug-dump=info \"$Obj\" | grep DW_AT_producer | grep -v 'GNU AS' | grep -m1 DW_AT_producer`; if(not $Producer) { printMsg("WARNING", "debug-info is not found in the object ".getFilename($Obj)); } my %Opts = (); while($Producer=~s/(\A| )(\-O([0-3]|g))( |\Z)/ /) { $Opts{keys(%Opts)} = $2; } if(keys(%Opts)) { if($Opts{keys(%Opts)-1} ne "-Og") { printMsg("WARNING", "incompatible build option detected in the object ".getFilename($Obj).": ".$Opts{keys(%Opts)-1}." (required -Og for better analysis)"); } } else { printMsg("WARNING", "the object ".getFilename($Obj)." should be compiled with -Og option for better analysis"); } } } else { if(not findStatic($InstallDir)) { delete($DB->{"Installed"}{$V}); printMsg("ERROR", "no binary objects installed"); rmtree($InstallDir); return 1; } else { printMsg("WARNING", "no shared objects installed"); } } } else { printMsg("ERROR", "failed to build"); rmtree($InstallDir); } return 1; } sub buildShared($) { my $V = $_[0]; my $Installed = $DB->{"Installed"}{$V}; if(not -d $Installed) { return 0; } if(not checkCmd($GCC)) { return 0; } my @Objects = findStatic($Installed); foreach my $Object (@Objects) { my $Object_A = abs_path($Object); my $To = getDirname($Object); my $Object_S = getFilename($Object); $Object_S=~s/\.a\Z/.so/g; if(-e $To."/".$Object_S) { printMsg("INFO", "shared object already exists"); return 1; } chdir($To); my $Cmd_B = $GCC." -shared -o \"$Object_S\" -Wl,--whole-archive \"$Object_A\" -Wl,--no-whole-archive"; # -nostdlib qx/$Cmd_B/; if($? or not -f $Object_S) { print STDERR "ERROR: failed to build shared object(s)\n"; chdir($ORIG_DIR); return 0; } chdir($ORIG_DIR); print "Created \'$To/$Object_S\'\n"; } } sub findStatic($) { my $Dir = $_[0]; return findFiles($Dir, "f", ".*\\.a"); } sub readDB($) { my $Path = $_[0]; if(-f $Path) { my $P = eval(readFile($Path)); if(not $P) { exitStatus("Error", "please remove 'use strict' from code and retry"); } return $P; } return {}; } sub writeDB($) { my $Path = $_[0]; if($Path and $DB and keys(%{$DB})) { writeFile($Path, Dumper($DB)); } } sub checkFiles() { my $Repo = $REPO."/".$TARGET_LIB; foreach my $V (listDir($Repo)) { if($V eq "current") { $DB->{"Source"}{$V} = $Repo."/".$V; } else { if(my @Files = listFiles($Repo."/".$V)) { $DB->{"Source"}{$V} = $Repo."/".$V."/".$Files[0]; } } } my $Installed = $INSTALLED."/".$TARGET_LIB; foreach my $V (listDir($Installed)) { if(my @Files = listDir($Installed."/".$V)) { $DB->{"Installed"}{$V} = $Installed."/".$V; } else { rmtree($Installed."/".$V); } } } sub checkDB() { foreach my $V (keys(%{$DB->{"Source"}})) { if(not -f $DB->{"Source"}{$V}) { delete($DB->{"Source"}{$V}); } } foreach my $V (keys(%{$DB->{"Installed"}})) { if(not -d $DB->{"Installed"}{$V}) { delete($DB->{"Installed"}{$V}); } } } sub safeExit() { chdir($ORIG_DIR); printMsg("INFO", "\nReceived SIGINT"); printMsg("INFO", "Exiting"); if($TMP_DIR_LOC eq "On") { rmtree($TMP_DIR); } writeDB($DB_PATH); exit(1); } sub scenario() { $Data::Dumper::Sortkeys = 1; $SIG{INT} = \&safeExit; if($Rebuild or $BuildNew) { $Build = 1; } if(defined $LimitOps) { if($LimitOps<=0) { exitStatus("Error", "the value of -limit option should be a positive integer"); } } if($DumpVersion) { printMsg("INFO", $TOOL_VERSION); exit(0); } if($Help) { printMsg("INFO", $HelpMessage); exit(0); } if(-d "archives_report") { exitStatus("Error", "Can't execute inside the Java API tracker home directory"); } $Profile_Path = $ARGV[0]; if(not $Profile_Path) { exitStatus("Error", "profile path is not specified"); } if(not -e $Profile_Path) { exitStatus("Access_Error", "can't access \'$Profile_Path\'"); } loadModule("Basic"); loadModule("CmpVersions"); $Profile = readProfile(readFile($Profile_Path)); if(not $Profile->{"Name"}) { exitStatus("Error", "name of the library is not specified in profile"); } if(defined $Profile->{"LocalBuild"} and $Profile->{"LocalBuild"} eq "On") { $TMP_DIR_LOC = "On"; $TMP_DIR = ".tmp_build_".$$; # pid mkpath($TMP_DIR); $TMP_DIR = abs_path($TMP_DIR); } $TARGET_LIB = $Profile->{"Name"}; $DB_PATH = "db/".$TARGET_LIB."/".$DB_PATH; $TARGET_TITLE = $TARGET_LIB; if($Profile->{"Title"}) { $TARGET_TITLE = $Profile->{"Title"}; } $DB = readDB($DB_PATH); checkDB(); checkFiles(); if($GetOld) { getVersions(); } if($Get) { getVersions_Local(); getVersions(); if(defined $Profile->{"Git"} or defined $Profile->{"Svn"} or defined $Profile->{"Hg"}) { getCurrent(); } } if($Build) { buildVersions(); } if($BuildShared) { if(defined $TargetVersion) { buildShared($TargetVersion); } else { print STDERR "ERROR: target version should be specified to build shared objects from static ones\n"; } } writeDB($DB_PATH); createProfile(); if($TMP_DIR_LOC eq "On") { rmtree($TMP_DIR); } } scenario(); abi-monitor-1.12/modules/000077500000000000000000000000001315145466700153415ustar00rootroot00000000000000abi-monitor-1.12/modules/Internals/000077500000000000000000000000001315145466700173005ustar00rootroot00000000000000abi-monitor-1.12/modules/Internals/Basic.pm000066400000000000000000000070751315145466700206700ustar00rootroot00000000000000################################################################## # Module for ABI Monitor with basic functions # # Copyright (C) 2016 Andrey Ponomarenko's ABI Laboratory # # Written by Andrey Ponomarenko # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License or the GNU Lesser # General Public License as published by the Free Software Foundation. # # 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 # and the GNU Lesser General Public License along with this program. # If not, see . ################################################################## use strict; sub findFiles(@) { my ($Path, $Type, $Regex) = @_; my $Cmd = "find \"$Path\""; if($Type) { $Cmd .= " -type ".$Type; } if($Regex) { $Cmd .= " -regex \"".$Regex."\""; } my @Res = split(/\n/, `$Cmd`); return @Res; } sub listDir($) { my $Path = $_[0]; return () if(not $Path); opendir(my $DH, $Path); return () if(not $DH); my @Contents = grep { $_ ne "." && $_ ne ".." } readdir($DH); return @Contents; } sub listFiles($) { my $Path = $_[0]; return () if(not $Path); my @Files = (); foreach my $F (listDir($Path)) { if(-f $Path."/".$F) { push(@Files, $F); } } return @Files; } sub listPaths($) { my $Path = $_[0]; return () if(not $Path); my @Paths = (); foreach my $F (listDir($Path)) { push(@Paths, $Path."/".$F); } return @Paths; } sub getFilename($) { # much faster than basename() from File::Basename module if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) { return $1; } return ""; } sub getDirname($) { # much faster than dirname() from File::Basename module if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) { return $1; } return ""; } sub readFile($) { my $Path = $_[0]; return "" if(not $Path or not -f $Path); open(FILE, $Path); local $/ = undef; my $Content = ; close(FILE); return $Content; } sub writeFile($$) { my ($Path, $Content) = @_; return if(not $Path); if(my $Dir = dirname($Path)) { mkpath($Dir); } open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n"); print FILE $Content; close(FILE); } sub getSiteAddr($) { if($_[0]=~/\A([a-z]+\:\/\/|)([^\/]+\.[a-z]+)(:[0-9]+|)(\/|\Z)/i) { return $2; } return $_[0]; } sub getSiteProtocol($) { if($_[0]=~/\A([a-z]+\:\/\/)/i) { return $1; } return ""; } sub getSite($) { return getSiteProtocol($_[0]).getSiteAddr($_[0]); } sub extractPackage($$) { my ($Path, $OutDir) = @_; if($Path=~/\.(tar\.\w+|tgz|tbz2|txz)\Z/i) { return "tar -xf $Path --directory=$OutDir"; } elsif($Path=~/\.zip\Z/i) { return "unzip $Path -d $OutDir"; } return undef; } sub isHeader($) { my $Path = $_[0]; return ($Path=~/\.(h|hh|hp|hxx|hpp|h\+\+|tcc)\Z/i); } sub checkCmd($) { my $Cmd = $_[0]; if(-x $Cmd) { return 1; } foreach my $Path (sort {length($a)<=>length($b)} split(/:/, $ENV{"PATH"})) { if(-x $Path."/".$Cmd) { return 1; } } return 0; } return 1; abi-monitor-1.12/modules/Internals/CmpVersions.pm000066400000000000000000000300611315145466700221060ustar00rootroot00000000000000################################################################## # Module for ABI Monitor to compare library versions # # Copyright (C) 2017 Andrey Ponomarenko's ABI Laboratory # # Written by Andrey Ponomarenko # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License or the GNU Lesser # General Public License as published by the Free Software Foundation. # # 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 # and the GNU Lesser General Public License along with this program. # If not, see . ################################################################## use strict; sub cmpVersions($$) { my ($A, $B) = @_; if($A eq "" and $B eq "") { return 0; } elsif($A eq "" or $B eq "current") { return -1; } elsif($B eq "" or $A eq "current") { return 1; } # speed up if($A=~/\A(\d+)\./) { my $A1 = $1; if($B=~/\A(\d+)\./) { my $B1 = $1; if($A1>$B1) { return 1; } elsif($A1<$B1) { return -1; } } } # speed up if($A=~/\A[\d\.]+\Z/ and $B=~/\A[\d\.]+\Z/) { my @N1 = split(/\./, $A); my @N2 = split(/\./, $B); foreach (0 .. $#N1) { if($_>$#N2) { return 1; } if($N1[$_]>$N2[$_]) { return 1; } elsif($N1[$_]<$N2[$_]) { return -1; } } } # version-release # 0.12-20140410 vs 0.12.1-20160607 if($A=~/\A([^\-]+)\-([^\-]+)\Z/) { my ($AV, $AR) = ($1, $2); if($B=~/\A([^\-]+)\-([^\-]+)\Z/) { my ($BV, $BR) = ($1, $2); my $VR = cmpVersions($AV, $BV); if($VR!=0) { return $VR; } return cmpVersions($AR, $BR); } } $A=~s/(\d)([a-z])/$1.$2/ig; $B=~s/(\d)([a-z])/$1.$2/ig; $A=~s/[_~-]/./g; $B=~s/[_~-]/./g; $A=~s/\A[.]+//g; $B=~s/\A[.]+//g; $A=~s/\A[0]+([1-9]\d*)\Z/$1/g; $B=~s/\A[0]+([1-9]\d*)\Z/$1/g; $A=~s/\A[0]+\Z/0/g; $B=~s/\A[0]+\Z/0/g; my $PS1 = index($A, "."); my $PS2 = index($B, "."); if($PS1==-1 and $PS2==-1) { return mixedCmp($_[0], $_[1]); } elsif($PS1==-1) { return cmpVersions($A.".0", $B); } elsif($PS2==-1) { return cmpVersions($A, $B.".0"); } else { my ($P1, $P2) = (); if($A=~s/\A([^\.]+)\.//o) { $P1 = $1; } if($B=~s/\A([^\.]+)\.//o) { $P2 = $1; } if(my $CmpPartRes = mixedCmp($P1, $P2)) { # compare first parts return $CmpPartRes; } else { # compare other parts return cmpVersions($A, $B); } } } sub mixedCmp($$) { my ($A, $B) = @_; if($A eq $B) { return 0; } while($A ne "" and $B ne "") { my $A_Token = get_Token($A); my $B_Token = get_Token($B); my $CmpRes = tokensCmp($A_Token, $B_Token); if(not defined $CmpRes) { # safety lock return 0; } elsif($CmpRes != 0) { return $CmpRes; } else { $A=~s/\A\Q$A_Token\E//g; $B=~s/\A\Q$B_Token\E//g; } } if($A ne "" or $A eq "0") { return 1; } elsif($B ne "" or $B eq "0") { return -1; } return 0; } sub get_Token($) { if($_[0]=~/\A(\d+)[a-z]/i) { return $1; } elsif($_[0]=~/\A([a-z]+)\d/i) { return $1; } elsif($_[0]=~/\A(\d+)[^a-z0-9]/i) { return $1; } elsif($_[0]=~/\A([a-z]+)[^a-z0-9]/i) { return $1; } elsif($_[0]=~/\A([^a-z0-9]+)/i) { return $1; } return $_[0]; } sub tokensCmp($$) { my ($A, $B) = @_; if($A eq $B) { return 0; } elsif($A=~/\A[^a-z0-9]+\Z/i and $B=~/\A[^a-z0-9]+\Z/i) { return 0; } elsif($A=~/\A[a-z]+\Z/i and $B=~/\A[a-z]+\Z/i) { return symbolCmp(lc($A), lc($B)); } elsif($A=~/\A\d+\Z/ and $B=~/\A\d+\Z/) { return int($A)<=>int($B); } elsif($A=~/\A[a-z]+\Z/i and $B=~/\A\d+\Z/) { return -1; } elsif($A=~/\A\d+\Z/ and $B=~/\A[a-z]+\Z/i) { return 1; } elsif($A and $B eq "") { return 1; } elsif($B and $A eq "") { return -1; } return undef; } sub symbolCmp($$) { my ($A, $B) = @_; if($A gt $B) { return 1; } elsif($A eq $B) { return 0; } return -1; } sub cmpVersions_P($$$) { my ($A, $B, $Profile) = @_; if(defined $Profile->{"LetterReleases"}) { # 0.9.8k and 0.9.8 my $TA = getVersionType($A, $Profile); my $TB = getVersionType($B, $Profile); if($TA eq $TB) { if(index($A, $B)==0) { return 1; } elsif(index($B, $A)==0) { return -1; } } } elsif(defined $Profile->{"StringReleases"}) { # compare as strings letter by letter return ($A cmp $B); } elsif(defined $Profile->{"ExtendVersion"}) { my $Extend = $Profile->{"ExtendVersion"}; my $AL = length($A); my $BL = length($B); if($AL<$Extend) { foreach (1 .. $Extend-$AL) { $A .= "0"; } } if($BL<$Extend) { foreach (1 .. $Extend-$BL) { $B .= "0"; } } } return cmpVersions($A, $B); } sub skipVersion(@) { my $V = shift(@_); my $Profile = shift(@_); my $MinCheck = 1; if(@_) { $MinCheck = shift(@_); } if(defined $Profile->{"SkipVersions"}) { my @Skip = @{$Profile->{"SkipVersions"}}; foreach my $E (@Skip) { if($E=~/[\*\+\[\(\|\\]/) { # pattern if($V=~/\A$E\Z/) { return 1; } } elsif($E eq $V) { return 1; } } } if(defined $Profile->{"KeepMiniMult"}) { my @KeepMult = @{$Profile->{"KeepMiniMult"}}; if(my $Mini = getVerNum($V, 2)) { my $Keep = 0; foreach my $K (@KeepMult) { if($Mini % $K == 0) { $Keep = 1; last; } } if(not $Keep) { return 1; } } } if(defined $Profile->{"KeepMicroMult"}) { my @KeepMult = @{$Profile->{"KeepMicroMult"}}; if(my $Micro = getVerNum($V, 3)) { my $Keep = 0; foreach my $K (@KeepMult) { if($Micro % $K == 0) { $Keep = 1; last; } } if(not $Keep) { return 1; } } } if(defined $Profile->{"SkipOdd"}) { if($V=~/\A\d+\.(\d+)/) { if($1 % 2 == 1) { return 1; } } } if($MinCheck) { if(my $Min = $Profile->{"MinimalVersion"}) { if(cmpVersions_P($V, $Min, $Profile)==-1) { return 1; } } } return 0; } sub naturalSequence(@) { my $Profile = shift(@_); my @Releases = (); my @Unstables = (); my @Previews = (); foreach my $Version (sort {cmpVersions_P($a, $b, $Profile)} @_) { my $Type = getVersionType($Version, $Profile); if($Type eq "unknown" or $Version eq "current") { next; } if(skipVersion($Version, $Profile)) { next; } if($Type eq "release") { push(@Releases, $Version); } elsif($Type eq "technology-preview") { push(@Previews, $Version); } else { push(@Unstables, $Version); } } my ($LastRelease, $LastUnstable, $LastPreview) = (); if(@Releases) { $LastRelease = $Releases[$#Releases]; } if(@Unstables) { $LastUnstable = $Unstables[$#Unstables]; } if(@Previews) { $LastPreview = $Previews[$#Previews]; } my @NaturalSequence = @Releases; if(not $LastUnstable and $LastPreview) { $LastUnstable = $LastPreview; } if($LastUnstable) { if($LastRelease) { if(cmpVersions_P($LastUnstable, $LastRelease, $Profile)==1) { push(@NaturalSequence, $LastUnstable); } } else { push(@NaturalSequence, $LastUnstable); } } if(grep {$_ eq "current"} @_) { push(@NaturalSequence, "current"); } return @NaturalSequence; } sub checkReleasePattern($$) { my ($Version, $Profile) = @_; if(my $RPattern = $Profile->{"ReleasePattern"}) { if($Version=~/$RPattern/i) { return $1; } } return undef; } sub getVersionType($$) { my ($Version, $Profile) = @_; if(defined $Profile->{"LetterReleases"}) { if($Version=~/\A[\d\.\-]+[a-z]{0,2}\Z/i and index($Version, "beta")==-1) { return "release"; } } if(defined $Profile->{"NumericBeta"}) { if($Version=~/\A\d+\.\d+\.9\d+(|\.\d+)\Z/i) { return "beta"; } } if(checkReleasePattern($Version, $Profile)) { return "release"; } if($Version!~/[a-z]/i or $Version=~/\A[\d\.]+[\-\_]*r\d+\Z/i or $Version=~/\A[\d\.]+\.v\d+\Z/i) { # 1.5_r04 # 9.3.7.v20160115 return "release"; } my @Words = (); while($Version=~s/(\A|[^a-z])([a-z]+)([^a-z]|\Z)/$1$3/i) { push(@Words, $2); } my %Type = (); foreach my $W (sort @Words) { if($W=~/\A(final)\Z/i) { $Type{"release"}=1; } elsif($W=~/\A(r|rel|release)\Z/i and $Version=~/\b$W\d/) { $Type{"release"}=1; } elsif($W=~/\A(devel|dev|exp)\Z/i) { $Type{"devel"}=1; } elsif($W=~/\A(snapshot|snap|master)\Z/i) { $Type{"snapshot"}=1; } elsif($W=~/\A(alfa|alpha|a)\Z/i) { $Type{"alfa"}=1; } elsif($W=~/\A(tp|preview)\Z/i) { $Type{"technology-preview"}=1; } elsif($W=~/\A(beta|b)\Z/i) { $Type{"beta"}=1; } elsif($W=~/\A(pre)\Z/i) { $Type{"pre-release"}=1; } elsif($W=~/\A(rc|cr)\Z/i) { $Type{"release-candidate"}=1; } elsif($W=~/\A(current)\Z/) { $Type{"current"}=1; } else { return "unknown"; } } if(my @Types = keys(%Type)) { if($#Types==0) { return $Types[0]; } } return "unknown"; } sub getMajor($$) { my ($V, $L) = @_; $V=~s/[\-_]/./g; my @P = split(/\./, $V); if($#P>=$L) { return join(".", splice(@P, 0, $L)); } return $V; } sub getVerNum($$) { my ($V, $N) = @_; $V=~s/[\-_]/./g; my @P = split(/\./, $V); return $P[$N-1]; } sub getVDepth($) { return $_[0]=~tr!\.!!; } return 1;