├── .github └── FUNDING.yml ├── LICENSE ├── Makefile ├── Makefile.pl ├── README.md ├── abi-monitor.pl └── modules └── Internals ├── Basic.pm ├── CmpVersions.pm └── Input.pm /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | patreon: LINUXABI 3 | custom: https://abi-laboratory.pro/?view=donate 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | , 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! 505 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | prefix ?= /usr 2 | 3 | .PHONY: install 4 | install: 5 | perl Makefile.pl -install -prefix "$(prefix)" 6 | 7 | uninstall: 8 | perl Makefile.pl -remove -prefix "$(prefix)" 9 | -------------------------------------------------------------------------------- /Makefile.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | ########################################################################### 3 | # Makefile for ABI Monitor 4 | # Install/remove the tool for GNU/Linux 5 | # 6 | # Copyright (C) 2015-2018 Andrey Ponomarenko's ABI Laboratory 7 | # 8 | # Written by Andrey Ponomarenko 9 | # 10 | # This library is free software; you can redistribute it and/or 11 | # modify it under the terms of the GNU Lesser General Public 12 | # License as published by the Free Software Foundation; either 13 | # version 2.1 of the License, or (at your option) any later version. 14 | # 15 | # This library is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | # Lesser General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU Lesser General Public 21 | # License along with this library; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 | # MA 02110-1301 USA 24 | ########################################################################### 25 | use Getopt::Long; 26 | Getopt::Long::Configure ("posix_default", "no_ignore_case"); 27 | use File::Path qw(mkpath rmtree); 28 | use File::Copy qw(copy); 29 | use File::Basename qw(dirname); 30 | use Cwd qw(abs_path); 31 | use File::Find; 32 | use strict; 33 | 34 | my $TOOL_SNAME = "abi-monitor"; 35 | my $ARCHIVE_DIR = abs_path(dirname($0)); 36 | 37 | my $HELP_MSG = " 38 | NAME: 39 | Makefile for ABI Monitor 40 | 41 | DESCRIPTION: 42 | Install $TOOL_SNAME command and private modules. 43 | 44 | USAGE: 45 | sudo perl $0 -install -prefix /usr 46 | sudo perl $0 -remove -prefix /usr 47 | 48 | OPTIONS: 49 | -h|-help 50 | Print this help. 51 | 52 | --prefix=PREFIX 53 | Install files in PREFIX [/usr]. 54 | 55 | -install 56 | Command to install the tool. 57 | 58 | -remove 59 | Command to remove the tool. 60 | 61 | EXTRA OPTIONS: 62 | --destdir=DESTDIR 63 | This option is for maintainers to build 64 | RPM or DEB packages inside the build root. 65 | The environment variable DESTDIR is also 66 | supported. 67 | \n"; 68 | 69 | if(not @ARGV) 70 | { 71 | print $HELP_MSG; 72 | exit(0); 73 | } 74 | 75 | my ($PREFIX, $DESTDIR, $Help, $Install, $Remove); 76 | 77 | GetOptions( 78 | "h|help!" => \$Help, 79 | "prefix=s" => \$PREFIX, 80 | "destdir=s" => \$DESTDIR, 81 | "install!" => \$Install, 82 | "remove!" => \$Remove 83 | ) or exit(1); 84 | 85 | sub scenario() 86 | { 87 | if($Help) 88 | { 89 | print $HELP_MSG; 90 | exit(0); 91 | } 92 | if(not $Install and not $Remove) 93 | { 94 | print STDERR "ERROR: command is not selected (-install or -remove)\n"; 95 | exit(1); 96 | } 97 | 98 | if($Install) 99 | { # remove old version first 100 | $Remove = 1; 101 | } 102 | 103 | if($PREFIX ne "/") { 104 | $PREFIX=~s/[\/]+\Z//g; 105 | } 106 | if(not $PREFIX) 107 | { # default prefix 108 | $PREFIX = "/usr"; 109 | } 110 | if(my $Var = $ENV{"DESTDIR"}) 111 | { 112 | print "Using DESTDIR environment variable\n"; 113 | $DESTDIR = $Var; 114 | } 115 | if($DESTDIR) 116 | { 117 | if($DESTDIR ne "/") { 118 | $DESTDIR=~s/[\/]+\Z//g; 119 | } 120 | if($DESTDIR!~/\A\//) 121 | { 122 | print STDERR "ERROR: destdir is not absolute path\n"; 123 | exit(1); 124 | } 125 | if(not -d $DESTDIR) 126 | { 127 | print STDERR "ERROR: you should create destdir directory first\n"; 128 | exit(1); 129 | } 130 | $PREFIX = $DESTDIR.$PREFIX; 131 | if(not -d $PREFIX) 132 | { 133 | print STDERR "ERROR: you should create installation directory first (destdir + prefix):\n mkdir -p $PREFIX\n"; 134 | exit(1); 135 | } 136 | } 137 | else 138 | { 139 | if($PREFIX!~/\A\//) 140 | { 141 | print STDERR "ERROR: prefix is not absolute path\n"; 142 | exit(1); 143 | } 144 | if(not -d $PREFIX) 145 | { 146 | print STDERR "ERROR: you should create prefix directory first\n"; 147 | exit(1); 148 | } 149 | } 150 | 151 | print "INSTALL PREFIX: $PREFIX\n"; 152 | 153 | # paths 154 | my $EXE_PATH = "$PREFIX/bin"; 155 | my $MODULES_PATH = "$PREFIX/share/$TOOL_SNAME"; 156 | my $REL_PATH = "../share/$TOOL_SNAME"; 157 | my $TOOL_PATH = "$EXE_PATH/$TOOL_SNAME"; 158 | 159 | if(not -w $PREFIX) 160 | { 161 | print STDERR "ERROR: you should be root\n"; 162 | exit(1); 163 | } 164 | if($Remove) 165 | { 166 | if(-e $EXE_PATH."/".$TOOL_SNAME) 167 | { # remove executable 168 | print "-- Removing $TOOL_PATH\n"; 169 | unlink($EXE_PATH."/".$TOOL_SNAME); 170 | } 171 | elsif(not $Install) { 172 | print "The tool is not installed\n"; 173 | } 174 | 175 | if(-d $ARCHIVE_DIR."/modules") 176 | { 177 | if(-d $MODULES_PATH) 178 | { # remove modules 179 | print "-- Removing $MODULES_PATH\n"; 180 | rmtree($MODULES_PATH); 181 | } 182 | elsif(not $Install) { 183 | print "The modules of the tool are not installed\n"; 184 | } 185 | } 186 | } 187 | if($Install) 188 | { 189 | # configure 190 | my $Content = readFile($ARCHIVE_DIR."/".$TOOL_SNAME.".pl"); 191 | if($DESTDIR) { # relative path 192 | $Content=~s/MODULES_INSTALL_PATH/$REL_PATH/; 193 | } 194 | else { # absolute path 195 | $Content=~s/MODULES_INSTALL_PATH/$MODULES_PATH/; 196 | } 197 | 198 | # copy executable 199 | print "-- Installing $TOOL_PATH\n"; 200 | mkpath($EXE_PATH); 201 | writeFile($EXE_PATH."/".$TOOL_SNAME, $Content); 202 | chmod(0755, $EXE_PATH."/".$TOOL_SNAME); 203 | 204 | # copy modules 205 | if(-d $ARCHIVE_DIR."/modules") 206 | { 207 | print "-- Installing $MODULES_PATH\n"; 208 | mkpath($MODULES_PATH); 209 | copyDir($ARCHIVE_DIR."/modules", $MODULES_PATH); 210 | } 211 | 212 | # check PATH 213 | if($ENV{"PATH"}!~/(\A|:)\Q$EXE_PATH\E[\/]?(\Z|:)/) { 214 | print "WARNING: your PATH variable doesn't include \'$EXE_PATH\'\n"; 215 | } 216 | } 217 | exit(0); 218 | } 219 | 220 | sub copyDir($$) 221 | { 222 | my ($From, $To) = @_; 223 | my %Files; 224 | find(\&wanted, $From); 225 | sub wanted { 226 | $Files{$File::Find::dir."/$_"} = 1 if($_ ne "."); 227 | } 228 | foreach my $Path (sort keys(%Files)) 229 | { 230 | my $Inst = $Path; 231 | $Inst=~s/\A\Q$ARCHIVE_DIR\E/$To/; 232 | if(-d $Path) 233 | { # directories 234 | mkpath($Inst); 235 | } 236 | else 237 | { # files 238 | mkpath(dirname($Inst)); 239 | copy($Path, $Inst); 240 | } 241 | } 242 | } 243 | 244 | sub readFile($) 245 | { 246 | my $Path = $_[0]; 247 | return "" if(not $Path or not -f $Path); 248 | open(FILE, $Path) || die ("can't open file \'$Path\': $!\n"); 249 | local $/ = undef; 250 | my $Content = ; 251 | close(FILE); 252 | return $Content; 253 | } 254 | 255 | sub writeFile($$) 256 | { 257 | my ($Path, $Content) = @_; 258 | return if(not $Path); 259 | open(FILE, ">".$Path) || die ("can't open file \'$Path\': $!\n"); 260 | print FILE $Content; 261 | close(FILE); 262 | } 263 | 264 | scenario(); 265 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ABI Monitor 1.12 2 | ================ 3 | 4 | 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 5 | 6 | Contents 7 | -------- 8 | 9 | 1. [ About ](#about) 10 | 2. [ Install ](#install) 11 | 3. [ Usage ](#usage) 12 | 4. [ Profile ](#profile) 13 | 14 | About 15 | ----- 16 | 17 | The tool is intended to be used with the ABI Tracker tool to visualize API/ABI changes timeline of a C/C++ library. 18 | 19 | The tool is developed by Andrey Ponomarenko: http://abi-laboratory.pro/ 20 | 21 | Install 22 | ------- 23 | 24 | sudo make install prefix=/usr 25 | 26 | ###### Requires 27 | 28 | * Perl 5 (5.8 or newer) 29 | * perl-Data-Dumper 30 | * curl 31 | * wget 32 | 33 | ###### Recommends 34 | * cmake 35 | * autotools 36 | * meson 37 | * gcc 38 | * g++ 39 | 40 | Usage 41 | ----- 42 | 43 | abi-monitor [options] [profile] 44 | 45 | The input profile will be extended after execution. Then it can be passed to the ABI Tracker. 46 | 47 | ###### Examples 48 | 49 | abi-monitor -get -build libssh.json 50 | abi-monitor -rebuild -v 0.7.0 libssh.json 51 | 52 | Profile 53 | ------- 54 | 55 | { 56 | "Name": "SHORT LIBRARY NAME", 57 | "SourceUrl": "URL TO DOWNLOAD PACKAGES", 58 | "Git": "GIT ADDRESS TO CLONE" 59 | } 60 | 61 | ###### Profile example 62 | 63 | { 64 | "Name": "libssh", 65 | "SourceUrl": "https://red.libssh.org/projects/libssh/files", 66 | "Git": "https://git.libssh.org/projects/libssh.git" 67 | } 68 | 69 | See more profile examples in this directory: https://github.com/lvc/upstream-tracker/tree/master/profile 70 | 71 | ###### Adv. options 72 | 73 | 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. 74 | 75 | If you just want to add some configure options then you can define the `Configure` option of the profile. 76 | 77 | The other option `SourceDir` allows to index packages from a local directory instead of downloading them from `SourceUrl`. 78 | 79 | ###### Adv. usage 80 | 81 | For advanced usage, see output of `-help` option. 82 | -------------------------------------------------------------------------------- /abi-monitor.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | ################################################################## 3 | # ABI Monitor 1.12 4 | # A tool to monitor new versions of a software library, build them 5 | # and create profile for ABI Tracker. 6 | # 7 | # Copyright (C) 2015-2021 Andrey Ponomarenko's ABI Laboratory 8 | # 9 | # Written by Andrey Ponomarenko 10 | # 11 | # PLATFORMS 12 | # ========= 13 | # Linux (x86, x86_64) 14 | # 15 | # REQUIRES 16 | # ======== 17 | # Perl 5 18 | # perl-Data-Dumper 19 | # curl 20 | # wget 21 | # 22 | # RECOMMENDS 23 | # ========== 24 | # cmake 25 | # autotools 26 | # meson 27 | # gcc 28 | # g++ 29 | # 30 | # This library is free software; you can redistribute it and/or 31 | # modify it under the terms of the GNU Lesser General Public 32 | # License as published by the Free Software Foundation; either 33 | # version 2.1 of the License, or (at your option) any later version. 34 | # 35 | # This library is distributed in the hope that it will be useful, 36 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 38 | # Lesser General Public License for more details. 39 | # 40 | # You should have received a copy of the GNU Lesser General Public 41 | # License along with this library; if not, write to the Free Software 42 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 43 | # MA 02110-1301 USA 44 | ################################################################## 45 | use Getopt::Long; 46 | Getopt::Long::Configure ("posix_default", "no_ignore_case", "permute"); 47 | use File::Path qw(mkpath rmtree); 48 | use File::Copy qw(copy move); 49 | use File::Temp qw(tempdir); 50 | use File::Basename qw(dirname); 51 | use Cwd qw(abs_path cwd); 52 | use Data::Dumper; 53 | 54 | my $TOOL_VERSION = "1.12"; 55 | my $DB_PATH = "Monitor.data"; 56 | my $REPO = "src"; 57 | my $INSTALLED = "installed"; 58 | my $BUILD_LOGS = "build_logs"; 59 | my $BUILD_SUBDIR = "MONITOR_build"; 60 | my $TMP_DIR = tempdir(CLEANUP=>1); 61 | my $TMP_DIR_LOC = "Off"; 62 | my $ACCESS_TIMEOUT = 15; 63 | my $CONNECT_TIMEOUT = 5; 64 | my $ACCESS_TRIES = 2; 65 | my $USE_CURL = 1; 66 | my $PKG_EXT = "tar\\.bz2|tar\\.gz|tar\\.xz|tar\\.lzma|tar\\.lz|tar\\.Z|tbz2|tgz|txz|zip"; 67 | 68 | # Internal modules 69 | my $MODULES_DIR = get_Modules(); 70 | push(@INC, dirname($MODULES_DIR)); 71 | 72 | # Basic modules 73 | my %LoadedModules = (); 74 | loadModule("Basic"); 75 | loadModule("Input"); 76 | loadModule("CmpVersions"); 77 | 78 | my $CMAKE = "cmake"; 79 | my $GCC = "gcc"; 80 | 81 | my $C_FLAGS_B = "-g -Og -w -fpermissive"; 82 | my $CXX_FLAGS_B = $C_FLAGS_B; 83 | 84 | my $CmdName = getFilename($0); 85 | my $ORIG_DIR = cwd(); 86 | 87 | my %ERROR_CODE = ( 88 | "Success"=>0, 89 | # Undifferentiated error code 90 | "Error"=>2, 91 | # System command is not found 92 | "Not_Found"=>3, 93 | # Cannot access input files 94 | "Access_Error"=>4, 95 | # Cannot find a module 96 | "Module_Error"=>9 97 | ); 98 | 99 | my $ShortUsage = "ABI Monitor $TOOL_VERSION 100 | A tool to monitor new versions of a software library 101 | Copyright (C) 2021 Andrey Ponomarenko's ABI Laboratory 102 | License: GNU LGPLv2.1+ 103 | 104 | Usage: $CmdName [options] [profile] 105 | Example: 106 | $CmdName -get -build profile.json 107 | 108 | More info: $CmdName --help\n"; 109 | 110 | if($#ARGV==-1) 111 | { 112 | printMsg("INFO", $ShortUsage); 113 | exit(0); 114 | } 115 | 116 | GetOptions("h|help!" => \$In::Opt{"Help"}, 117 | "dumpversion!" => \$In::Opt{"DumpVersion"}, 118 | # general options 119 | "get!" => \$In::Opt{"Get"}, 120 | "get-old!" => \$In::Opt{"GetOld"}, 121 | "get-new!" => \$In::Opt{"GetNew"}, 122 | "build!" => \$In::Opt{"Build"}, 123 | "rebuild!" => \$In::Opt{"Rebuild"}, 124 | "limit=s" => \$In::Opt{"LimitOps"}, 125 | "v=s" => \$In::Opt{"TargetVersion"}, 126 | "output=s" => \$In::Opt{"OutputProfile"}, 127 | "build-shared!" => \$In::Opt{"BuildShared"}, 128 | "build-new!" => \$In::Opt{"BuildNew"}, 129 | "analyze!" => \$In::Opt{"Analyze"}, 130 | "debug!" => \$In::Opt{"Debug"}, 131 | "clean-unused!" => \$In::Opt{"CleanUnused"}, 132 | "clear-installed!" => \$In::Opt{"ClearInstalled"}, 133 | "confirm!" => \$In::Opt{"Confirm"}, 134 | "redownload!" => \$In::Opt{"Redownload"}, 135 | # other options 136 | "make=s" => \$In::Opt{"MakeAddOpt"}, 137 | "detect-deps!" => \$In::Opt{"DetectDeps"} 138 | ) or ERR_MESSAGE(); 139 | 140 | sub ERR_MESSAGE() 141 | { 142 | printMsg("INFO", "\n".$ShortUsage); 143 | exit($ERROR_CODE{"Error"}); 144 | } 145 | 146 | my $HelpMessage=" 147 | NAME: 148 | ABI Monitor ($CmdName) 149 | Monitor and build new versions of a C/C++ software library 150 | 151 | DESCRIPTION: 152 | ABI Monitor is a tool to monitor new versions of a software 153 | library, try to build them and create profile for ABI Tracker. 154 | 155 | The tool is intended to be used with the ABI Tracker tool for 156 | visualizing API/ABI changes timeline. 157 | 158 | This tool is free software: you can redistribute it and/or 159 | modify it under the terms of the GNU LGPLv2.1+. 160 | 161 | USAGE: 162 | $CmdName [options] [profile] 163 | 164 | EXAMPLES: 165 | $CmdName -get -build profile.json 166 | 167 | INFORMATION OPTIONS: 168 | -h|-help 169 | Print this help. 170 | 171 | -dumpversion 172 | Print the tool version ($TOOL_VERSION) and don't do 173 | anything else. 174 | 175 | GENERAL OPTIONS: 176 | -get 177 | Download new library versions. 178 | 179 | -get-old 180 | Download old packages from OldSourceUrl option of the profile. 181 | 182 | -redownload 183 | Redownload installed source packages. 184 | 185 | -build 186 | Build library versions. 187 | 188 | -rebuild 189 | Re-build library versions. 190 | 191 | -limit NUM 192 | Limit number of operations to NUM. This is useful if 193 | you want to download or build only NUM packages. 194 | 195 | -v NUM 196 | Build only one particular version. 197 | 198 | -output PATH 199 | Path to output profile. The tool will overwrite the 200 | input profile by default. 201 | 202 | -build-shared 203 | Build shared objects from static ones if they cannot 204 | be build by the library makefile or build script. 205 | 206 | -build-new 207 | Build newly found packages only. This option should 208 | be used with -get option. 209 | 210 | -debug 211 | Enable debug messages. 212 | 213 | -clean-unused 214 | Remove unused files: sources of installed library 215 | versions, unused install trees and static objects. 216 | 217 | -clear-installed On/Off 218 | Reset ClearInstalled profile option. 219 | 220 | OTHER OPTIONS: 221 | -make OPT 222 | Add options to 'make' command (e.g. '-j4'). 223 | "; 224 | 225 | # Global 226 | my $Profile_Path; 227 | my $Profile; 228 | my $DB; 229 | my $TARGET_LIB; 230 | my $TARGET_TITLE; 231 | my $C_FLAGS; 232 | my $CXX_FLAGS; 233 | 234 | my %Cache; 235 | my %NewVer; 236 | 237 | sub get_Modules() 238 | { 239 | my $TOOL_DIR = dirname($0); 240 | my @SEARCH_DIRS = ( 241 | # tool's directory 242 | abs_path($TOOL_DIR), 243 | # relative path to modules 244 | abs_path($TOOL_DIR)."/../share/abi-monitor", 245 | # install path 246 | 'MODULES_INSTALL_PATH' 247 | ); 248 | foreach my $DIR (@SEARCH_DIRS) 249 | { 250 | if(not $DIR=~/\A\//) 251 | { # relative path 252 | $DIR = abs_path($TOOL_DIR)."/".$DIR; 253 | } 254 | if(-d $DIR."/modules") { 255 | return $DIR."/modules"; 256 | } 257 | } 258 | exitStatus("Module_Error", "can't find modules"); 259 | } 260 | 261 | sub loadModule($) 262 | { 263 | my $Name = $_[0]; 264 | if(defined $LoadedModules{$Name}) { 265 | return; 266 | } 267 | my $Path = $MODULES_DIR."/Internals/$Name.pm"; 268 | if(not -f $Path) { 269 | exitStatus("Module_Error", "can't access \'$Path\'"); 270 | } 271 | require $Path; 272 | $LoadedModules{$Name} = 1; 273 | } 274 | 275 | sub readModule($$) 276 | { 277 | my ($Module, $Name) = @_; 278 | my $Path = $MODULES_DIR."/Internals/$Module/".$Name; 279 | if(not -f $Path) { 280 | exitStatus("Module_Error", "can't access \'$Path\'"); 281 | } 282 | return readFile($Path); 283 | } 284 | 285 | sub exitStatus($$) 286 | { 287 | my ($Code, $Msg) = @_; 288 | printMsg("ERROR", $Msg); 289 | exit($ERROR_CODE{$Code}); 290 | } 291 | 292 | sub printMsg($$) 293 | { 294 | my ($Type, $Msg) = @_; 295 | if($Type!~/\AINFO/) { 296 | $Msg = $Type.": ".$Msg; 297 | } 298 | if($Type!~/_C\Z/) { 299 | $Msg .= "\n"; 300 | } 301 | if($Type eq "ERROR") { 302 | print STDERR $Msg; 303 | } 304 | else { 305 | print $Msg; 306 | } 307 | } 308 | 309 | sub readProfile($) 310 | { 311 | my $Content = $_[0]; 312 | 313 | my %Res = (); 314 | 315 | if($Content=~/\A\s*\{\s*((.|\n)+?)\s*\}\s*\Z/) 316 | { 317 | my $Info = $1; 318 | 319 | if($Info=~/\"Versions\"/) 320 | { 321 | my $Pos = 0; 322 | 323 | while($Info=~s/(\"Versions\"\s*:\s*\[\s*)(\{\s*(.|\n)+?\s*\})\s*,?\s*/$1/) 324 | { 325 | my $VInfo = readProfile($2); 326 | if(my $VNum = $VInfo->{"Number"}) 327 | { 328 | $VInfo->{"Pos"} = $Pos++; 329 | $Res{"Versions"}{$VNum} = $VInfo; 330 | } 331 | else { 332 | printMsg("ERROR", "version number is missed in the profile"); 333 | } 334 | } 335 | } 336 | 337 | # arrays 338 | while($Info=~s/\"(\w+)\"\s*:\s*\[\s*(.*?)\s*\]\s*(\,|\Z)//) 339 | { 340 | my ($K, $A) = ($1, $2); 341 | 342 | if($K eq "Versions") { 343 | next; 344 | } 345 | 346 | $Res{$K} = []; 347 | 348 | foreach my $E (split(/\s*\,\s*/, $A)) 349 | { 350 | $E=~s/\A[\"\']//; 351 | $E=~s/[\"\']\Z//; 352 | 353 | push(@{$Res{$K}}, $E); 354 | } 355 | } 356 | 357 | # scalars 358 | while($Info=~s/\"(\w+)\"\s*:\s*(.+?)\s*\,?\s*$//m) 359 | { 360 | my ($K, $V) = ($1, $2); 361 | 362 | if($K eq "Versions") { 363 | next; 364 | } 365 | 366 | $V=~s/\A[\"\']//; 367 | $V=~s/[\"\']\Z//; 368 | 369 | $Res{$K} = $V; 370 | } 371 | } 372 | 373 | return \%Res; 374 | } 375 | 376 | sub getCurrent() 377 | { 378 | my $CurRepo = $REPO."/".$TARGET_LIB."/current"; 379 | 380 | my $Git = defined $Profile->{"Git"}; 381 | my $Svn = defined $Profile->{"Svn"}; 382 | my $Hg = defined $Profile->{"Hg"}; 383 | 384 | my $Branch = $Profile->{"Branch"}; 385 | 386 | if($Git) 387 | { 388 | if(not checkCmd("git")) 389 | { 390 | printMsg("ERROR", "can't find \"git\""); 391 | return; 392 | } 393 | } 394 | elsif($Svn) 395 | { 396 | if(not checkCmd("svn")) 397 | { 398 | printMsg("ERROR", "can't find \"svn\""); 399 | return; 400 | } 401 | } 402 | elsif($Hg) 403 | { 404 | if(not checkCmd("hg")) 405 | { 406 | printMsg("ERROR", "can't find \"hg\""); 407 | return; 408 | } 409 | } 410 | 411 | my $UpToDate = 0; 412 | my $NeedUpdate = 0; 413 | 414 | if(-d $CurRepo) 415 | { 416 | chdir($CurRepo); 417 | 418 | if($Git) 419 | { 420 | printMsg("INFO", "Updating source code in repository"); 421 | 422 | if($Branch) { 423 | system("git checkout ".$Branch); 424 | } 425 | 426 | my $Log = qx/git pull/; 427 | 428 | if($Log=~/Already up\-to\-date/i) { 429 | $UpToDate = 1; 430 | } 431 | 432 | if($Log=~/Enumerating objects|Unpacking objects/i) { 433 | $NeedUpdate = 1; 434 | } 435 | } 436 | elsif($Svn) 437 | { 438 | printMsg("INFO", "Updating source code in repository"); 439 | my $Log = qx/svn update/; 440 | 441 | if($Log!~/Updated to revision/i) { 442 | $UpToDate = 1; 443 | } 444 | } 445 | elsif($Hg) 446 | { 447 | printMsg("INFO", "Updating source code in repository"); 448 | my $Log = qx/hg pull/; 449 | 450 | if($Log=~/no changes found/i) { 451 | $UpToDate = 1; 452 | } 453 | } 454 | } 455 | else 456 | { 457 | if($Git) 458 | { 459 | printMsg("INFO", "Cloning git repository"); 460 | system("git clone ".$Profile->{"Git"}." ".$CurRepo); 461 | 462 | chdir($CurRepo); 463 | 464 | if($Branch) { 465 | system("git checkout ".$Branch); 466 | } 467 | } 468 | elsif($Svn) 469 | { 470 | printMsg("INFO", "Checkouting svn repository"); 471 | system("svn checkout ".$Profile->{"Svn"}." ".$CurRepo); 472 | } 473 | elsif($Hg) 474 | { 475 | printMsg("INFO", "Checkouting hg repository"); 476 | system("hg clone ".$Profile->{"Hg"}." ".$CurRepo); 477 | } 478 | } 479 | 480 | chdir($ORIG_DIR); 481 | 482 | $DB->{"Source"}{"current"} = $CurRepo; 483 | 484 | my $UTime = getScmUpdateTime(); 485 | if(not $UpToDate) 486 | { 487 | if($DB->{"ScmUpdateTime"}) 488 | { 489 | if($DB->{"ScmUpdateTime"} ne $UTime or $NeedUpdate) { 490 | $NewVer{"current"} = 1; 491 | } 492 | } 493 | else { 494 | $NewVer{"current"} = 1; 495 | } 496 | } 497 | $DB->{"ScmUpdateTime"} = $UTime; 498 | } 499 | 500 | sub getScmUpdateTime() 501 | { 502 | if(my $Source = $DB->{"Source"}{"current"}) 503 | { 504 | if(not -d $Source) { 505 | return undef; 506 | } 507 | 508 | my $Time = undef; 509 | my $Head = undef; 510 | 511 | if(defined $Profile->{"Git"}) 512 | { 513 | $Head = "$Source/.git/refs/heads/master"; 514 | 515 | if(defined $Profile->{"Branch"}) { 516 | $Head = "$Source/.git/refs/heads/".$Profile->{"Branch"}; 517 | } 518 | 519 | if(not -f $Head) 520 | { # is not updated yet 521 | $Head = "$Source/.git/FETCH_HEAD"; 522 | } 523 | 524 | if(not -f $Head) { 525 | $Head = undef; 526 | } 527 | } 528 | elsif(defined $Profile->{"Svn"}) 529 | { 530 | $Head = "$Source/.svn/wc.db"; 531 | 532 | if(not -f $Head) { 533 | $Head = undef; 534 | } 535 | } 536 | elsif(defined $Profile->{"Hg"}) 537 | { 538 | $Head = "$Source/.hg/store"; 539 | 540 | if(not -e $Head) { 541 | $Head = undef; 542 | } 543 | } 544 | 545 | if($Head) 546 | { 547 | $Time = `stat -c \%Y \"$Head\"`; 548 | chomp($Time); 549 | } 550 | 551 | if($Time) { 552 | return $Time; 553 | } 554 | } 555 | 556 | return undef; 557 | } 558 | 559 | sub getVersions_Local() 560 | { 561 | if(not defined $Profile->{"SourceDir"}) { 562 | return 0; 563 | } 564 | 565 | my $SourceDir = $Profile->{"SourceDir"}; 566 | 567 | if(not $SourceDir) { 568 | return 0; 569 | } 570 | 571 | if(not -d $SourceDir) 572 | { 573 | exitStatus("Access_Error", "can't access \'$SourceDir\'"); 574 | return 0; 575 | } 576 | 577 | printMsg("INFO", "Copying packages from \'$SourceDir\' to \'$REPO/$TARGET_LIB\'"); 578 | 579 | my @Files = findFiles($SourceDir, "f"); 580 | 581 | foreach my $File (sort {$b cmp $a} @Files) 582 | { 583 | if($File=~/\/(\Q$TARGET_LIB\E[\_\-]*([^\/]+?)\.($PKG_EXT))\Z/) 584 | { 585 | my ($P, $V) = ($1, $2); 586 | my $To = $REPO."/".$TARGET_LIB."/".$V; 587 | 588 | if(not -d $To or not listDir($To)) 589 | { 590 | printMsg("INFO", "Found $File"); 591 | 592 | # copy to local directory 593 | # mkpath($To); 594 | # if(copy($File, $To)) 595 | # { 596 | # $DB->{"Source"}{$V} = $To."/".$P; 597 | # } 598 | 599 | $DB->{"Source"}{$V} = $File; 600 | } 601 | } 602 | } 603 | } 604 | 605 | sub getVersions() 606 | { 607 | my $SourceTag = "SourceUrl"; 608 | if($In::Opt{"GetOld"}) { 609 | $SourceTag = "OldSourceUrl"; 610 | } 611 | 612 | my $SourceUrl = $Profile->{$SourceTag}; 613 | 614 | if(not $SourceUrl) 615 | { 616 | if(not defined $Profile->{"SourceDir"}) 617 | { 618 | printMsg("WARNING", "$SourceTag is not specified in the profile"); 619 | } 620 | return; 621 | } 622 | 623 | if($In::Opt{"GetOld"}) { 624 | printMsg("INFO", "Searching for old source packages"); 625 | } 626 | else { 627 | printMsg("INFO", "Searching for new packages"); 628 | } 629 | 630 | if($USE_CURL) 631 | { 632 | if(not checkCmd("curl")) 633 | { 634 | printMsg("ERROR", "can't find \"curl\""); 635 | return; 636 | } 637 | } 638 | else 639 | { 640 | if(not checkCmd("wget")) 641 | { 642 | printMsg("ERROR", "can't find \"wget\""); 643 | return; 644 | } 645 | } 646 | 647 | my @Links = getLinks(\$SourceUrl); 648 | 649 | my $Depth = 2; 650 | 651 | if($In::Opt{"GetOld"}) 652 | { 653 | if(defined $Profile->{"OldSourceUrlDepth"}) 654 | { # More steps into directory tree 655 | $Depth = $Profile->{"OldSourceUrlDepth"}; 656 | } 657 | } 658 | else 659 | { 660 | if(defined $Profile->{"SourceUrlDepth"}) 661 | { # More steps into directory tree 662 | $Depth = $Profile->{"SourceUrlDepth"}; 663 | } 664 | } 665 | 666 | if($Depth>=2) 667 | { 668 | my %Checked = (); 669 | $Checked{$SourceUrl} = 1; 670 | 671 | foreach my $D (1 .. $Depth - 1) 672 | { 673 | my @Pages = getPages($SourceUrl, \@Links); 674 | foreach my $Page (@Pages) 675 | { 676 | if(not defined $Checked{$Page}) 677 | { 678 | $Checked{$Page} = 1; 679 | foreach my $Link (getLinks(\$Page)) 680 | { 681 | push(@Links, $Link); 682 | } 683 | } 684 | } 685 | } 686 | } 687 | 688 | my $Packages = getPackages(@Links); 689 | my $NumOp = 0; 690 | 691 | my @Versions = keys(%{$Packages}); 692 | @Versions = naturalSequence($Profile, @Versions); 693 | @Versions = reverse(@Versions); 694 | 695 | foreach my $V (@Versions) 696 | { 697 | my $R = getPackage($Packages->{$V}{"Url"}, $Packages->{$V}{"Pkg"}, $V); 698 | 699 | if($R>0) { 700 | $NumOp += 1; 701 | } 702 | 703 | if(defined $In::Opt{"LimitOps"}) 704 | { 705 | if($NumOp>=$In::Opt{"LimitOps"}) 706 | { 707 | last; 708 | } 709 | } 710 | } 711 | 712 | if(not $NumOp) { 713 | printMsg("INFO", "No new packages found"); 714 | } 715 | } 716 | 717 | sub getKnownVersions() 718 | { # all source packages including installed/cleaned 719 | my @List = uniqueArray((keys(%{$DB->{"Source"}}), keys(%{$DB->{"Installed"}}), keys(%{$Profile->{"Versions"}}))); 720 | 721 | return grep { $_ ne "current" } @List; 722 | } 723 | 724 | sub getHighestRelease() 725 | { 726 | if(defined $Cache{"HighestRelease"}) { 727 | return $Cache{"HighestRelease"}; 728 | } 729 | my @Vers = getKnownVersions(); 730 | @Vers = naturalSequence($Profile, @Vers); 731 | @Vers = reverse(@Vers); 732 | 733 | foreach my $V (@Vers) 734 | { 735 | if(getVersionType($V, $Profile) eq "release") 736 | { 737 | return ($Cache{"HighestRelease"} = $V); 738 | } 739 | } 740 | 741 | return undef; 742 | } 743 | 744 | sub getLatestVersion() 745 | { 746 | if(defined $Cache{"LatestVersion"}) { 747 | return $Cache{"LatestVersion"}; 748 | } 749 | 750 | if(my @Vers = getKnownVersions()) 751 | { 752 | @Vers = naturalSequence($Profile, @Vers); 753 | @Vers = reverse(@Vers); 754 | 755 | return ($Cache{"LatestVersion"} = $Vers[0]); 756 | } 757 | 758 | return undef; 759 | } 760 | 761 | sub isOldMicro($$) 762 | { 763 | my ($V, $L) = @_; 764 | my $M = getMajor($V, $L); 765 | 766 | foreach my $Ver (getKnownVersions()) 767 | { 768 | if(getMajor($Ver, $L) eq $M) 769 | { 770 | if(cmpVersions_P($Ver, $V, $Profile)>0) 771 | { 772 | return 1; 773 | } 774 | } 775 | } 776 | 777 | return 0; 778 | } 779 | 780 | sub isOldVer($) 781 | { 782 | my $V = $_[0]; 783 | 784 | if(defined $Profile->{"LatestMinor"}) 785 | { 786 | if(isOldMicro($V, 1)) 787 | { # do not download old minor releases 788 | return 1; 789 | } 790 | } 791 | 792 | if(defined $Profile->{"LatestMicro"}) 793 | { 794 | if(isOldMicro($V, 2)) 795 | { # do not download old micro releases 796 | return 1; 797 | } 798 | } 799 | 800 | if(defined $Profile->{"LatestNano"}) 801 | { 802 | if(isOldMicro($V, 3)) 803 | { # do not download old nano releases 804 | return 1; 805 | } 806 | } 807 | 808 | return 0; 809 | } 810 | 811 | sub notNeededSrc($) 812 | { 813 | my $V = $_[0]; 814 | 815 | if(-d "abi_dump/".$TARGET_LIB."/".$V) { 816 | return "dumped"; 817 | } 818 | elsif(defined $DB->{"Installed"}{$V}) { 819 | return "installed"; 820 | } 821 | elsif(defined $Profile->{"Versions"}{$V} 822 | and $Profile->{"Versions"}{$V}{"Deleted"}) { 823 | return "deleted"; 824 | } 825 | elsif(isOldVer($V)) 826 | { # old micro/nano releases 827 | return "obsoleted"; 828 | } 829 | 830 | return undef; 831 | } 832 | 833 | sub getPackage($$$) 834 | { 835 | my ($Link, $P, $V) = @_; 836 | 837 | my $Dir = $REPO."/".$TARGET_LIB."/".$V; 838 | 839 | if(defined $DB->{"Source"}{$V}) 840 | { # already downloaded 841 | return -1; 842 | } 843 | 844 | my $NotNeeded = notNeededSrc($V); 845 | 846 | if($NotNeeded and not defined $In::Opt{"Redownload"}) 847 | { # Do not download installed packages to save space 848 | printMsg("INFO", "Skip downloading of already $NotNeeded package for $V"); 849 | if(not defined $Cache{"RedownloadInfo"}) 850 | { 851 | printMsg("TIP", "Use -redownload option to download it again"); 852 | $Cache{"RedownloadInfo"} = 1; 853 | } 854 | return -1; 855 | } 856 | 857 | if(defined $Profile->{"MinimalDownload"}) 858 | { 859 | if(cmpVersions_P($V, $Profile->{"MinimalDownload"}, $Profile)==-1) { 860 | return -1; 861 | } 862 | } 863 | 864 | if($In::Opt{"GetNew"}) 865 | { 866 | if(cmpVersions_P($V, getHighestRelease(), $Profile)==-1) 867 | { # do not download old versions 868 | return -1; 869 | } 870 | } 871 | 872 | if(getVersionType($V, $Profile) ne "release") 873 | { 874 | if(my $HighestRelease = getHighestRelease()) 875 | { 876 | if(cmpVersions_P($V, $HighestRelease, $Profile)==-1) 877 | { # do not download old alfa/beta/pre releases 878 | return -1; 879 | } 880 | } 881 | 882 | if(my $LatestVersion = getLatestVersion()) 883 | { 884 | if(cmpVersions_P($V, $LatestVersion, $Profile)==-1) 885 | { # do not download previous alfa/beta/pre releases 886 | print $V." $LatestVersion\n";return -1; 887 | } 888 | } 889 | } 890 | 891 | my $To = $Dir."/".$P; 892 | if(-f $To) { 893 | return -1; 894 | } 895 | 896 | if(not -e $Dir) { 897 | mkpath($Dir); 898 | } 899 | 900 | printMsg("INFO", "Downloading package \'$P\' ($TARGET_TITLE)"); 901 | 902 | if($In::Opt{"Debug"}) { 903 | printMsg("INFO", "Link: \'$Link\'"); 904 | } 905 | 906 | my $Pid = fork(); 907 | unless($Pid) 908 | { # child 909 | my $Cmd = ""; 910 | 911 | if($USE_CURL) { 912 | $Cmd = "curl -L \"$Link\" --connect-timeout 5 --retry 1 --output \"$To\""; 913 | } 914 | else { 915 | $Cmd = "wget --no-check-certificate \"$Link\" --connect-timeout=5 --tries=1 --output-document=\"$To\""; # -U '' 916 | } 917 | 918 | system($Cmd." >".$TMP_DIR."/wget_log 2>&1"); 919 | writeFile($TMP_DIR."/wget_res", $?); 920 | exit(0); 921 | } 922 | local $SIG{INT} = sub 923 | { 924 | rmtree($Dir); 925 | safeExit(); 926 | }; 927 | waitpid($Pid, 0); 928 | 929 | my $Log = readFile($TMP_DIR."/wget_log"); 930 | my $R = readFile($TMP_DIR."/wget_res"); 931 | 932 | if($Log=~/\[text\/html\]/ or not -B $To) 933 | { 934 | rmtree($Dir); 935 | printMsg("ERROR", "\'$Link\' is not a package\n"); 936 | return 0; 937 | } 938 | elsif($R or not -f $To or not -s $To) 939 | { 940 | rmtree($Dir); 941 | printMsg("ERROR", "can't access \'$Link\'\n"); 942 | return 0; 943 | } 944 | 945 | $DB->{"Source"}{$V} = $To; 946 | 947 | $NewVer{$V} = 1; 948 | $Cache{"HighestRelease"} = undef; 949 | $Cache{"LatestVersion"} = undef; 950 | 951 | return 1; 952 | } 953 | 954 | sub readPage($) 955 | { 956 | my $Page = $_[0]; 957 | 958 | my $To = $TMP_DIR."/page.html"; 959 | unlink($To); 960 | my $Url = $Page; 961 | 962 | if($Page=~/\Aftp:.+[^\/]\Z/ 963 | and getFilename($Page)!~/\./) 964 | { # wget for ftp 965 | # tail "/" should be added 966 | $Page .= "/"; 967 | } 968 | 969 | my $UserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"; 970 | 971 | my $Cmd = ""; 972 | 973 | if($USE_CURL and index($Page, "ftp:")!=0) 974 | { # TODO: how to list absolute paths in FTP directory using curl? 975 | $Cmd = "curl -L \"$Page\""; 976 | $Cmd .= " --connect-timeout $CONNECT_TIMEOUT"; 977 | $Cmd .= " --retry $ACCESS_TRIES --output \"$To\""; 978 | $Cmd .= " -w \"\%{url_effective}\\n\""; 979 | $Cmd .= " -A \"$UserAgent\""; 980 | } 981 | else 982 | { 983 | $Cmd = "wget --no-check-certificate \"$Page\""; 984 | # $Cmd .= " -U ''"; 985 | $Cmd .= " --no-remove-listing"; 986 | # $Cmd .= " --quiet"; 987 | $Cmd .= " --connect-timeout=$CONNECT_TIMEOUT"; 988 | $Cmd .= " --tries=$ACCESS_TRIES --output-document=\"$To\""; 989 | $Cmd .= " --user-agent=\"$UserAgent\""; 990 | } 991 | 992 | my $Pid = fork(); 993 | unless($Pid) 994 | { # child 995 | system($Cmd." >".$TMP_DIR."/output 2>&1"); 996 | writeFile($TMP_DIR."/result", $?); 997 | exit(0); 998 | } 999 | $SIG{ALRM} = sub { 1000 | kill(9, $Pid); 1001 | }; 1002 | alarm $ACCESS_TIMEOUT; 1003 | waitpid($Pid, 0); 1004 | alarm 0; 1005 | 1006 | my $Output = readFile($TMP_DIR."/output"); 1007 | 1008 | while($Output=~s/((http|https|ftp):\/\/[^\s]+)//) 1009 | { # real URL 1010 | $Url = $1; 1011 | } 1012 | 1013 | my $Res = readFile($TMP_DIR."/result"); 1014 | 1015 | if(not $Res) { 1016 | return ($To, $Url); 1017 | } 1018 | 1019 | printMsg("ERROR", "can't access page \'$Page\'"); 1020 | return ("", ""); 1021 | } 1022 | 1023 | sub getPackages(@) 1024 | { 1025 | my %Res = (); 1026 | 1027 | my $Pkg = $TARGET_LIB; 1028 | my $Suffix = ""; 1029 | 1030 | if(defined $Profile->{"Package"}) { 1031 | $Pkg = $Profile->{"Package"}; 1032 | } 1033 | 1034 | if($Pkg=~/\A(.*)\{V\}(.*)\Z/) { 1035 | ($Pkg, $Suffix) = ($1, $2); 1036 | } 1037 | 1038 | foreach my $Link (@_) 1039 | { 1040 | if($Link=~/\/\Z/) { 1041 | next; 1042 | } 1043 | 1044 | my ($P, $V, $E) = (); 1045 | 1046 | if($Link=~/(\A|[\/\=])(\Q$Pkg\E[_\-]*([^\/"'<>+%]+?)(\-src|\-source|\Q$Suffix\E|)\.($PKG_EXT))([\/\?]|\Z)/i) 1047 | { 1048 | ($P, $V, $E) = ($2, $3, $5); 1049 | } 1050 | elsif($Link=~/(archive|get)\/(refs\/tags\/|)(|\w+\/)[v_]*([\d\.\-\_]+?([ab]\d*|alpha\.?\d*|beta\.?\d*|rc\d*|stable|release|))(\-src|\-source|\Q$Suffix\E|)\.(tar\.gz)/i) 1051 | { # github 1052 | # bitbucket 1053 | ($V, $E) = ($4, $7); 1054 | } 1055 | elsif($Link=~/\/archive\.($PKG_EXT)\?ref=(.+)\Z/i) 1056 | { # gitlab 1057 | ($V, $E) = ($2, $1); 1058 | } 1059 | 1060 | if($E and defined $Profile->{"SkipExt"}) 1061 | { 1062 | if(grep {$_ eq $E} @{$Profile->{"SkipExt"}}) { 1063 | next; 1064 | } 1065 | } 1066 | 1067 | if(not $V or not $E) { 1068 | next; 1069 | } 1070 | 1071 | if(not $P) { 1072 | $P = $Pkg."-".$V.".".$E; 1073 | } 1074 | 1075 | $V=~s/\A(v|version)(|_)(\d)/$3/i; # v1.1, VERSION_1.22 1076 | $V=~s/[\-\_\.](src|source|sources)\Z//i; # pkg-X.Y.Z-Source.tar.gz 1077 | 1078 | if(defined $Res{$V}) 1079 | { 1080 | if($Res{$V}{"Ext"} ne "zip" or $E eq "zip") 1081 | { 1082 | next; 1083 | } 1084 | } 1085 | 1086 | if($V=~/mingw|msvc/i) { 1087 | next; 1088 | } 1089 | 1090 | if(getVersionType($V, $Profile) eq "unknown") { 1091 | next; 1092 | } 1093 | 1094 | if(my $Release = checkReleasePattern($V, $Profile)) 1095 | { 1096 | $V = $Release; 1097 | } 1098 | 1099 | if($V=~/snapshot/i) { 1100 | next; 1101 | } 1102 | 1103 | if(skipVersion($V, $Profile)) { 1104 | next; 1105 | } 1106 | 1107 | if(defined $In::Opt{"TargetVersion"}) 1108 | { 1109 | if($In::Opt{"TargetVersion"} ne $V) { 1110 | next; 1111 | } 1112 | } 1113 | 1114 | if($P) 1115 | { 1116 | $Res{$V}{"Url"} = $Link; 1117 | $Res{$V}{"Pkg"} = $P; 1118 | $Res{$V}{"Ext"} = $E; 1119 | } 1120 | } 1121 | 1122 | return \%Res; 1123 | } 1124 | 1125 | sub getPages($$) 1126 | { 1127 | my ($Top, $Links) = @_; 1128 | my @Res = (); 1129 | 1130 | $Top=~s/\?.*\Z//g; 1131 | $Top=~s&\A\w+://&//&; # do not match protocol 1132 | 1133 | foreach my $Link (@{$Links}) 1134 | { 1135 | if($Link!~/\/\Z/ and $Link!~/\/v?\d[\d\.\-]*\Z/i) 1136 | { 1137 | if($Link!~/github\.com\/.+\?after\=/) 1138 | { 1139 | next; 1140 | } 1141 | } 1142 | 1143 | if(index($Link, $Top)==-1) 1144 | { 1145 | next; 1146 | } 1147 | 1148 | my $PLink = $Link; 1149 | $PLink=~s/\%20/ /gi; 1150 | 1151 | my $DirVer = undef; 1152 | 1153 | if($PLink=~/https:\/\/sourceforge\.net\/projects\/[^\/]+\/files\/[^\/]+\/($TARGET_LIB[\-_ ]*|)v?(\d[^\/]*?)[ _-]*(Src|Source|Sources|)\/\Z/i) { 1154 | $DirVer = $2; 1155 | } 1156 | elsif($PLink=~/\/($TARGET_LIB[\-_ ]*|)v?(\d[^\/]*?)\.($PKG_EXT)[\/]*\Z/i) 1157 | { # libaio-0.3.100.tar.gz/ (fedora) 1158 | $DirVer = $2; 1159 | } 1160 | elsif($PLink=~/\/($TARGET_LIB[\-_ ]*|)v?(\d[^\/]*?)[\/]*\Z/i) 1161 | { # 9.1.1rc7/ 1162 | $DirVer = $2; 1163 | } 1164 | 1165 | if($DirVer) 1166 | { 1167 | if(skipOldLink($DirVer)) 1168 | { 1169 | if($In::Opt{"Debug"}) { 1170 | printMsg("INFO", "Skip (Old dir): $Link"); 1171 | } 1172 | next; 1173 | } 1174 | } 1175 | 1176 | push(@Res, $Link); 1177 | } 1178 | 1179 | return @Res; 1180 | } 1181 | 1182 | sub skipOldLink($) 1183 | { 1184 | my $V = $_[0]; 1185 | 1186 | my $VType = getVersionType($V, $Profile); 1187 | 1188 | if($VType eq "unknown") { 1189 | return 0; 1190 | } 1191 | 1192 | if(defined $DB->{"Source"}{$V} 1193 | and not defined $In::Opt{"Redownload"}) { 1194 | return 1; 1195 | } 1196 | elsif(notNeededSrc($V) 1197 | and not defined $In::Opt{"Redownload"}) { 1198 | return 1; 1199 | } 1200 | elsif(skipVersion($V, $Profile, 0)) { 1201 | return 1; 1202 | } 1203 | elsif(my $Min = $Profile->{"MinimalVersion"}) 1204 | { 1205 | if(getVDepth($V)>=getVDepth($Min)) 1206 | { 1207 | if(cmpVersions_P($V, $Min, $Profile)==-1) { 1208 | return 1; 1209 | } 1210 | } 1211 | } 1212 | 1213 | if($VType ne "release" 1214 | and my $HighestRel = getHighestRelease()) 1215 | { 1216 | if(cmpVersions_P($V, $HighestRel, $Profile)==-1) 1217 | { # do not download old betas 1218 | return 1; 1219 | } 1220 | } 1221 | 1222 | return 0; 1223 | } 1224 | 1225 | sub getLinks($) 1226 | { 1227 | my $PageRef = $_[0]; 1228 | my $Page = ${$PageRef}; 1229 | 1230 | if($In::Opt{"Debug"}) { 1231 | printMsg("INFO", "Reading ".$Page); 1232 | } 1233 | 1234 | my ($To, $Url) = readPage($Page); 1235 | 1236 | if(not $To) { 1237 | return (); 1238 | } 1239 | 1240 | my $Content = readFile($To); 1241 | unlink($To); 1242 | 1243 | my (%Links1, %Links2, %Links3, %Links4, %Links5) = (); 1244 | 1245 | my @Lines = split(/\n/, $Content); 1246 | 1247 | foreach my $Line (@Lines) 1248 | { 1249 | while($Line=~s/(src|href)\s*\=\s*["']\s*((ftp|http|https):\/\/[^"'<>\s]+?)\s*["']//i) { 1250 | $Links1{$2} = 1; 1251 | } 1252 | while($Line=~s/(src|href)\s*\=\s*["']\s*([^"'<>\s]+?)\s*["']//i) { 1253 | $Links2{linkSum($Url, $2)} = 1; 1254 | } 1255 | while($Line=~s/((ftp|http|https):\/\/[^"'<>\s]+?)([\s"']|\Z)//i) { 1256 | $Links3{$1} = 1; 1257 | } 1258 | while($Line=~s/["']([^"'<>\s]+\.($PKG_EXT))["']//i) { 1259 | $Links4{linkSum($Url, $1)} = 1; 1260 | } 1261 | while($Line=~s/(src|href)\s*\=\s*([^"'<>\s]+?)[ >]//i) { 1262 | $Links5{linkSum($Url, $2)} = 1; 1263 | } 1264 | } 1265 | 1266 | foreach my $U (keys(%Links4)) 1267 | { 1268 | my $F = getFilename($U); 1269 | 1270 | if(grep {getFilename($_) eq $F} keys(%Links1)) { 1271 | delete($Links4{$U}); 1272 | } 1273 | } 1274 | 1275 | my @L1 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links1); 1276 | my @L2 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links2); 1277 | my @L3 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links3); 1278 | my @L4 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links4); 1279 | my @L5 = sort {length($a)<=>length($b)} sort {$b cmp $a} keys(%Links5); 1280 | 1281 | my @AllLinks = (@L1, @L2, @L3, @L4, @L5); 1282 | 1283 | foreach (@AllLinks) { 1284 | while($_=~s/\/[^\/]+\/\.\.\//\//g){}; 1285 | } 1286 | 1287 | my $SiteAddr = getSiteAddr($Page); 1288 | my $SiteProtocol = getSiteProtocol($Page); 1289 | 1290 | my @Res = (); 1291 | foreach my $Link (@AllLinks) 1292 | { 1293 | if(skipUrl($Link)) 1294 | { 1295 | if($In::Opt{"Debug"}) { 1296 | printMsg("INFO", "Skip: $Link"); 1297 | } 1298 | next; 1299 | } 1300 | 1301 | if($Link!~/github\.com\/.*\?after\=/ 1302 | and $Link!~/\?.*\.($PKG_EXT)/ 1303 | and $Link!~/\?ref=/) { 1304 | $Link=~s/\?.+\Z//g; 1305 | } 1306 | 1307 | $Link=~s/\%2B/+/gi; 1308 | $Link=~s/\%2D/-/gi; 1309 | $Link=~s/[\/]{2,}\Z/\//g; 1310 | 1311 | if($Link=~/\A(\Q$Page\E|\Q$Url\E|\Q$SiteAddr\E)[\/]*\Z/) { 1312 | next; 1313 | } 1314 | 1315 | # if(getSiteAddr($Link) ne getSiteAddr($Page)) { 1316 | # next; 1317 | # } 1318 | 1319 | if(not getSiteProtocol($Link)) { 1320 | $Link = $SiteProtocol.$Link; 1321 | } 1322 | 1323 | if(index($Link, "sourceforge")!=-1) 1324 | { 1325 | if($Link=~/\.($PKG_EXT)(\/.+|)\Z/) 1326 | { 1327 | if($2 ne "/download") { 1328 | next; 1329 | } 1330 | } 1331 | if($Link=~/(http[s]*):\/\/sourceforge.net\/projects\/(\w+)\/files\/(.+)\/download\Z/) 1332 | { # fix for SF 1333 | $Link = "$1://sourceforge.net/projects/$2/files/$3/download?use_mirror=autoselect"; 1334 | } 1335 | } 1336 | 1337 | $Link=~s/\:21\//\//; 1338 | 1339 | push(@Res, $Link); 1340 | } 1341 | 1342 | ${$PageRef} = $Url; 1343 | 1344 | return @Res; 1345 | } 1346 | 1347 | sub skipUrl($$) 1348 | { 1349 | my $Link = $_[0]; 1350 | 1351 | if(defined $Profile->{"SkipUrl"}) 1352 | { 1353 | foreach my $Url (@{$Profile->{"SkipUrl"}}) 1354 | { 1355 | if(not $Url) { 1356 | next; 1357 | } 1358 | 1359 | if($Url=~/[\*\+\(\|\\]/) 1360 | { # pattern 1361 | if($Link=~/$Url/) { 1362 | return 1; 1363 | } 1364 | } 1365 | else 1366 | { 1367 | if($Link=~/\Q$Url\E/) { 1368 | return 1; 1369 | } 1370 | } 1371 | } 1372 | } 1373 | 1374 | return 0; 1375 | } 1376 | 1377 | sub linkSum($$) 1378 | { 1379 | my ($Page, $Path) = @_; 1380 | 1381 | $Page=~s/\?.+?\Z//g; 1382 | $Path=~s/\A\.\///g; 1383 | 1384 | if($Path=~/\A\/\/([^\/:]+\.[a-z]+\/.+)\Z/) 1385 | { # //liblouis.googlecode.com/files/liblouis-1.6.2.tar.gz 1386 | return $1; 1387 | } 1388 | elsif(index($Path, "://")!=-1) { 1389 | return $Path; 1390 | } 1391 | elsif(index($Path, "/")==0) { 1392 | return getSite($Page).$Path; 1393 | } 1394 | elsif($Page=~/\/\Z/) 1395 | { 1396 | #if($Path=~/\//) { 1397 | # return getSite($Page)."/".$Path; 1398 | #} 1399 | 1400 | return $Page.$Path; 1401 | } 1402 | 1403 | return getDirname($Page)."/".$Path; 1404 | } 1405 | 1406 | sub cleanUnused() 1407 | { 1408 | printMsg("INFO", "Cleaning unused data"); 1409 | 1410 | foreach my $V (sort {cmpVersions_P($b, $a, $Profile)} keys(%{$DB->{"Installed"}})) 1411 | { 1412 | if($V eq "current") { 1413 | next; 1414 | } 1415 | 1416 | my $IDir = $DB->{"Installed"}{$V}; 1417 | 1418 | my @Static = findFiles($IDir, "f", ".*\\.a"); 1419 | foreach my $F (@Static) 1420 | { 1421 | if(defined $In::Opt{"Confirm"}) 1422 | { 1423 | printMsg("INFO", "Removing: $F"); 1424 | rmtree($F); 1425 | } 1426 | else { 1427 | printMsg("INFO", "To remove: $F"); 1428 | } 1429 | } 1430 | 1431 | if((defined $Profile->{"Versions"} and (not defined $Profile->{"Versions"}{$V} 1432 | or $Profile->{"Versions"}{$V}{"Deleted"})) or skipVersion($V, $Profile, 1)) 1433 | { 1434 | if(defined $In::Opt{"Confirm"}) 1435 | { 1436 | printMsg("INFO", "Removing: $IDir"); 1437 | rmtree($IDir); 1438 | } 1439 | else { 1440 | printMsg("INFO", "To remove: $IDir"); 1441 | } 1442 | } 1443 | } 1444 | 1445 | foreach my $V (sort {cmpVersions_P($b, $a, $Profile)} keys(%{$DB->{"Source"}})) 1446 | { 1447 | if($V eq "current") { 1448 | next; 1449 | } 1450 | 1451 | if(skipVersion($V, $Profile, 1) 1452 | or notNeededSrc($V)) 1453 | { 1454 | if(defined $In::Opt{"Confirm"}) 1455 | { 1456 | printMsg("INFO", "Removing: ".$DB->{"Source"}{$V}); 1457 | rmtree(getDirname($DB->{"Source"}{$V})); 1458 | } 1459 | else { 1460 | printMsg("INFO", "To remove: ".$DB->{"Source"}{$V}); 1461 | } 1462 | } 1463 | } 1464 | 1465 | if(not defined $In::Opt{"Confirm"}) { 1466 | printMsg("INFO", "Retry with -confirm option to remove files"); 1467 | } 1468 | } 1469 | 1470 | sub buildVersions() 1471 | { 1472 | if(not defined $DB->{"Source"}) 1473 | { 1474 | printMsg("INFO", "Nothing to build"); 1475 | return; 1476 | } 1477 | 1478 | if(checkCmd($GCC)) 1479 | { 1480 | if(my $Machine = qx/$GCC -dumpmachine/) 1481 | { 1482 | if($Machine=~/x86_64/) 1483 | { 1484 | $C_FLAGS_B .= " -fPIC"; 1485 | $CXX_FLAGS_B .= " -fPIC"; 1486 | } 1487 | } 1488 | } 1489 | 1490 | if(defined $In::Opt{"BuildNew"}) 1491 | { 1492 | if(not defined $DB->{"Installed"}{"current"}) 1493 | { # NOTE: try to build current again 1494 | $NewVer{"current"} = 1; 1495 | } 1496 | } 1497 | 1498 | my @Versions = keys(%{$DB->{"Source"}}); 1499 | @Versions = naturalSequence($Profile, @Versions); 1500 | @Versions = reverse(@Versions); 1501 | 1502 | if(defined $In::Opt{"TargetVersion"}) 1503 | { 1504 | if(not -e $DB->{"Source"}{$In::Opt{"TargetVersion"}}) 1505 | { 1506 | printMsg("ERROR", "No source package for ".$In::Opt{"TargetVersion"}); 1507 | return; 1508 | } 1509 | elsif(not $In::Opt{"Rebuild"} and defined $DB->{"Installed"}{$In::Opt{"TargetVersion"}}) 1510 | { 1511 | if($In::Opt{"TargetVersion"} ne "current" or not defined $NewVer{"current"}) 1512 | { 1513 | printMsg("INFO", "Package for ".$In::Opt{"TargetVersion"}." is already installed"); 1514 | return; 1515 | } 1516 | } 1517 | } 1518 | 1519 | my $NumOp = 0; 1520 | 1521 | foreach my $V (@Versions) 1522 | { 1523 | if(defined $In::Opt{"TargetVersion"}) 1524 | { 1525 | if($In::Opt{"TargetVersion"} ne $V) { 1526 | next; 1527 | } 1528 | } 1529 | 1530 | if(defined $In::Opt{"BuildNew"}) 1531 | { 1532 | if(not defined $NewVer{$V}) { 1533 | next; 1534 | } 1535 | } 1536 | 1537 | if(defined $Profile->{"Versions"} and defined $Profile->{"Versions"}{$V} 1538 | and $Profile->{"Versions"}{$V}{"Deleted"}) { 1539 | next; 1540 | } 1541 | 1542 | if(not $In::Opt{"Rebuild"}) 1543 | { 1544 | if(defined $DB->{"Installed"}{$V}) 1545 | { 1546 | if($V ne "current" or not defined $NewVer{"current"}) { 1547 | next; 1548 | } 1549 | } 1550 | } 1551 | 1552 | if($In::Opt{"Rebuild"} or not defined $DB->{"Installed"}{$V}) 1553 | { 1554 | if(not defined $DB->{"Source"}{$V}) 1555 | { 1556 | printMsg("INFO", "No source package for $V"); 1557 | if(not defined $Cache{"NoSource"}) 1558 | { 1559 | printMsg("TIP", "Redownload it by -redownload option"); 1560 | $Cache{"NoSource"} = 1; 1561 | } 1562 | next; 1563 | } 1564 | } 1565 | 1566 | if(isOldVer($V)) 1567 | { # do not build old micro/nano releases 1568 | next; 1569 | } 1570 | 1571 | my $R = buildPackage($DB->{"Source"}{$V}, $V); 1572 | 1573 | if($R>0) { 1574 | $NumOp += 1; 1575 | } 1576 | 1577 | if(defined $In::Opt{"LimitOps"}) 1578 | { 1579 | if($NumOp>=$In::Opt{"LimitOps"}) 1580 | { 1581 | last; 1582 | } 1583 | } 1584 | } 1585 | 1586 | if(not $NumOp) 1587 | { 1588 | printMsg("INFO", "Nothing to build"); 1589 | return; 1590 | } 1591 | } 1592 | 1593 | sub createProfile() 1594 | { 1595 | my $To = $In::Opt{"OutputProfile"}; 1596 | if(not $To) { 1597 | $To = $Profile_Path; 1598 | } 1599 | 1600 | if(not defined $DB->{"Installed"}) 1601 | { 1602 | printMsg("INFO", "No installed versions of the library to create profile"); 1603 | return; 1604 | } 1605 | 1606 | my @ProfileKeys = ("Name", "Title", "SourceUrl", "SourceUrlDepth", "OldSourceUrl", "OldSourceUrlDepth", "SourceDir", "SkipUrl", "Git", "Svn", "Hg", "Doc", 1607 | "Maintainer", "MaintainerUrl", "BuildSystem", "Configure", "CurrentConfigure", "BuildScript", "BuildScenario", "InstallScenario", "PreInstall", "CurrentPreInstall", "PostInstall", "CurrentPostInstall", "SkipObjects", "SkipHeaders", "SkipSymbols", "SkipInternalSymbols", "SkipTypes", "SkipInternalTypes"); 1608 | my $MaxLen_P = 13; 1609 | 1610 | my %UnknownKeys = (); 1611 | foreach my $K (keys(%{$Profile})) 1612 | { 1613 | if(not grep {$_ eq $K} @ProfileKeys) 1614 | { 1615 | $UnknownKeys{$K} = 1; 1616 | } 1617 | } 1618 | if(keys(%UnknownKeys)) { 1619 | push(@ProfileKeys, sort keys(%UnknownKeys)); 1620 | } 1621 | 1622 | my @Content_L = (); 1623 | 1624 | foreach my $K (@ProfileKeys) 1625 | { 1626 | if(defined $Profile->{$K}) 1627 | { 1628 | my $Val = $Profile->{$K}; 1629 | my $Ref = ref($Val); 1630 | 1631 | if($Ref eq "HASH") { 1632 | next; 1633 | } 1634 | 1635 | my $St = ""; 1636 | foreach (0 .. $MaxLen_P - length($K)) { 1637 | $St .= " "; 1638 | } 1639 | 1640 | if($Ref eq "ARRAY") { 1641 | push(@Content_L, "\"$K\": ".$St."[ \"".join("\", \"", @{$Val})."\" ]"); 1642 | } 1643 | else { 1644 | push(@Content_L, "\"$K\": ".$St."\"$Val\""); 1645 | } 1646 | } 1647 | } 1648 | 1649 | my @Content_V = (); 1650 | 1651 | my @Versions = keys(%{$DB->{"Installed"}}); 1652 | @Versions = naturalSequence($Profile, @Versions); 1653 | 1654 | if(defined $Profile->{"Versions"}) 1655 | { 1656 | if(not keys(%{$Profile->{"Versions"}})) { 1657 | $Profile->{"Versions"} = undef; 1658 | } 1659 | } 1660 | 1661 | if(defined $Profile->{"Versions"}) 1662 | { # save order of versions in the profile if manually edited 1663 | foreach my $V (keys(%{$Profile->{"Versions"}})) 1664 | { # clear variable 1665 | if(not defined $Profile->{"Versions"}{$V}{"Pos"}) { 1666 | delete($Profile->{"Versions"}{$V}); 1667 | } 1668 | } 1669 | 1670 | my @O_Versions = keys(%{$Profile->{"Versions"}}); 1671 | @O_Versions = sort {int($Profile->{"Versions"}{$b}{"Pos"})<=>int($Profile->{"Versions"}{$a}{"Pos"})} @O_Versions; 1672 | my %Added = map {$_=>1} @O_Versions; 1673 | my @Merged = (); 1674 | 1675 | foreach my $P1 (0 .. $#O_Versions) 1676 | { 1677 | my $V1 = $O_Versions[$P1]; 1678 | 1679 | foreach my $V2 (@Versions) 1680 | { 1681 | if(not defined $Added{$V2}) 1682 | { 1683 | if(cmpVersions_P($V2, $V1, $Profile)==-1) 1684 | { 1685 | push(@Merged, $V2); 1686 | $Added{$V2} = 1; 1687 | } 1688 | } 1689 | } 1690 | 1691 | push(@Merged, $V1); 1692 | 1693 | if($P1==$#O_Versions) 1694 | { 1695 | foreach my $V2 (@Versions) 1696 | { 1697 | if(not defined $Added{$V2}) 1698 | { 1699 | if(cmpVersions_P($V2, $V1, $Profile)==1) 1700 | { 1701 | push(@Merged, $V2); 1702 | $Added{$V2} = 1; 1703 | } 1704 | } 1705 | } 1706 | } 1707 | } 1708 | 1709 | @Versions = @Merged; 1710 | } 1711 | 1712 | # Mark old unstable releases as "deleted" 1713 | if(not defined $Profile->{"KeepOldBeta"}) 1714 | { 1715 | my $MaxBeta = undef; 1716 | my $MaxRelease = undef; 1717 | foreach my $V (reverse(@Versions)) 1718 | { 1719 | if($V eq "current") { 1720 | next; 1721 | } 1722 | 1723 | if(getVersionType($V, $Profile) eq "release") 1724 | { 1725 | if(not defined $MaxRelease) { 1726 | $MaxRelease = $V; 1727 | } 1728 | } 1729 | else 1730 | { 1731 | if(defined $MaxBeta or defined $MaxRelease) 1732 | { 1733 | if(not defined $Profile->{"Versions"}{$V}{"Deleted"}) 1734 | { # One can set Deleted to 0 in order to prevent deleting 1735 | $Profile->{"Versions"}{$V}{"Deleted"} = 1; 1736 | } 1737 | } 1738 | 1739 | if(not defined $MaxBeta) { 1740 | $MaxBeta = $V; 1741 | } 1742 | } 1743 | } 1744 | } 1745 | 1746 | if(defined $Profile->{"LatestMinor"}) 1747 | { 1748 | my %MaxMinor = (); 1749 | foreach my $V (reverse(@Versions)) 1750 | { 1751 | if($V eq "current") { 1752 | next; 1753 | } 1754 | 1755 | my $M = getMajor($V, 1); 1756 | 1757 | if(defined $MaxMinor{$M}) 1758 | { 1759 | if(not defined $Profile->{"Versions"}{$V}{"Deleted"}) 1760 | { # One can set Deleted to 0 in order to prevent deleting 1761 | $Profile->{"Versions"}{$V}{"Deleted"} = 1; 1762 | } 1763 | } 1764 | else { 1765 | $MaxMinor{$M} = $V; 1766 | } 1767 | } 1768 | } 1769 | 1770 | if(defined $Profile->{"LatestMicro"}) 1771 | { 1772 | my %MaxMicro = (); 1773 | foreach my $V (reverse(@Versions)) 1774 | { 1775 | if($V eq "current") { 1776 | next; 1777 | } 1778 | 1779 | my $M = getMajor($V, 2); 1780 | 1781 | if(defined $MaxMicro{$M}) 1782 | { 1783 | if(not defined $Profile->{"Versions"}{$V}{"Deleted"}) 1784 | { # One can set Deleted to 0 in order to prevent deleting 1785 | $Profile->{"Versions"}{$V}{"Deleted"} = 1; 1786 | } 1787 | } 1788 | else { 1789 | $MaxMicro{$M} = $V; 1790 | } 1791 | } 1792 | } 1793 | 1794 | if(defined $Profile->{"LatestNano"}) 1795 | { 1796 | my %MaxNano = (); 1797 | foreach my $V (reverse(@Versions)) 1798 | { 1799 | if($V eq "current") { 1800 | next; 1801 | } 1802 | 1803 | my $M = getMajor($V, 3); 1804 | 1805 | if(defined $MaxNano{$M}) 1806 | { 1807 | if(not defined $Profile->{"Versions"}{$V}{"Deleted"}) 1808 | { # One can set Deleted to 0 in order to prevent deleting 1809 | $Profile->{"Versions"}{$V}{"Deleted"} = 1; 1810 | } 1811 | } 1812 | else { 1813 | $MaxNano{$M} = $V; 1814 | } 1815 | } 1816 | } 1817 | 1818 | foreach my $V (reverse(@Versions)) 1819 | { 1820 | my @Info = (); 1821 | my $Sp = " "; 1822 | my $N_Info = {}; 1823 | 1824 | $N_Info->{"Number"} = $V; 1825 | $N_Info->{"Installed"} = $DB->{"Installed"}{$V}; 1826 | $N_Info->{"Source"} = $DB->{"Source"}{$V}; 1827 | 1828 | if(defined $Profile->{"Changelog"}) { 1829 | $N_Info->{"Changelog"} = $Profile->{"Changelog"}; 1830 | } 1831 | else 1832 | { 1833 | if($DB->{"Changelog"}{$V}) { 1834 | $N_Info->{"Changelog"} = $DB->{"Changelog"}{$V}; 1835 | } 1836 | else 1837 | { 1838 | if($V eq "current") { 1839 | $N_Info->{"Changelog"} = "On"; 1840 | } 1841 | else { 1842 | $N_Info->{"Changelog"} = "Off"; 1843 | } 1844 | } 1845 | } 1846 | 1847 | if(not $N_Info->{"Changelog"}) 1848 | { # default 1849 | 1850 | } 1851 | if(defined $Profile->{"PkgDiff"}) { 1852 | $N_Info->{"PkgDiff"} = $Profile->{"PkgDiff"}; 1853 | } 1854 | else { 1855 | $N_Info->{"PkgDiff"} = "Off"; 1856 | } 1857 | 1858 | if(defined $Profile->{"HeadersDiff"}) { 1859 | $N_Info->{"HeadersDiff"} = $Profile->{"HeadersDiff"}; 1860 | } 1861 | else { 1862 | $N_Info->{"HeadersDiff"} = "On"; 1863 | } 1864 | 1865 | # Non-free high detailed analysis 1866 | $N_Info->{"ABIView"} = "Off"; 1867 | $N_Info->{"ABIDiff"} = "Off"; 1868 | 1869 | if(defined $Profile->{"Versions"} and defined $Profile->{"Versions"}{$V}) 1870 | { 1871 | my $O_Info = $Profile->{"Versions"}{$V}; 1872 | 1873 | foreach my $K (sort keys(%{$O_Info})) 1874 | { 1875 | # if($K eq "PublicSymbols" 1876 | # or $K eq "PublicTypes") 1877 | # { # obsolete 1878 | # next; 1879 | # } 1880 | 1881 | if($K ne "Pos") 1882 | { 1883 | if(defined $O_Info->{$K}) { 1884 | $N_Info->{$K} = $O_Info->{$K}; 1885 | } 1886 | } 1887 | } 1888 | } 1889 | 1890 | my @VersionKeys = ("Number", "Installed", "Source", "Changelog", "HeadersDiff", "PkgDiff", "ABIView", 1891 | "ABIDiff", "BuildShared", "Deleted"); 1892 | 1893 | my $MaxLen_V = 13; 1894 | 1895 | my %UnknownKeys_V = (); 1896 | foreach my $K (keys(%{$N_Info})) 1897 | { 1898 | if(not grep {$_ eq $K} @VersionKeys) 1899 | { 1900 | $UnknownKeys_V{$K} = 1; 1901 | } 1902 | } 1903 | if(keys(%UnknownKeys_V)) { 1904 | push(@VersionKeys, sort keys(%UnknownKeys_V)); 1905 | } 1906 | 1907 | foreach my $K (@VersionKeys) 1908 | { 1909 | if(defined $N_Info->{$K}) 1910 | { 1911 | my $St = ""; 1912 | foreach (0 .. $MaxLen_V - length($K)) { 1913 | $St .= " "; 1914 | } 1915 | 1916 | if(int($N_Info->{$K}) eq $N_Info->{$K}) { # integer 1917 | push(@Info, $Sp."\"$K\": $St".$N_Info->{$K}); 1918 | } 1919 | else { # string 1920 | push(@Info, $Sp."\"$K\": $St\"".$N_Info->{$K}."\""); 1921 | } 1922 | } 1923 | } 1924 | 1925 | push(@Content_V, "{\n".join(",\n", @Info)."\n }"); 1926 | } 1927 | 1928 | writeFile($To, "{\n ".join(",\n ", @Content_L).",\n\n \"Versions\": [\n ".join(",\n ", @Content_V)."]\n}\n"); 1929 | } 1930 | 1931 | sub findChangelog($) 1932 | { 1933 | my $Dir = $_[0]; 1934 | 1935 | my $MIN_LOG = 250; 1936 | 1937 | foreach my $Name ("NEWS", "CHANGES", "CHANGES.txt", "RELEASE_NOTES", "ChangeLog", "ChangeLog.md", "Changelog", 1938 | "changelog", "RELEASE_NOTES.md", "CHANGELOG.md", "CHANGELOG.txt", "RELEASE_NOTES.markdown", "NEWS.md", 1939 | "CHANGES.md", "changes.txt", "changes", "CHANGELOG", "RELEASE-NOTES", "WHATSNEW", "CHANGE_LOG", "doc/ChangeLog", 1940 | "ChangeLog.txt") 1941 | { 1942 | if(-f $Dir."/".$Name 1943 | and (-s $Dir."/".$Name > $MIN_LOG)) 1944 | { 1945 | return $Name; 1946 | } 1947 | } 1948 | 1949 | return "None"; 1950 | } 1951 | 1952 | sub autoBuild($$$) 1953 | { 1954 | my ($To, $LogDir, $V) = @_; 1955 | 1956 | my $LogDir_R = $LogDir; 1957 | $LogDir_R=~s/\A$ORIG_DIR\///; 1958 | 1959 | my $PreInstall = $Profile->{"PreInstall"}; 1960 | 1961 | if($V eq "current") 1962 | { 1963 | if(defined $Profile->{"CurrentPreInstall"}) { 1964 | $PreInstall = $Profile->{"CurrentPreInstall"}; 1965 | } 1966 | } 1967 | 1968 | if($PreInstall) 1969 | { 1970 | $PreInstall = addParams($PreInstall, $To, $V); 1971 | my $Cmd_P = $PreInstall." >$LogDir/pre_install 2>&1"; 1972 | qx/$Cmd_P/; # execute 1973 | if($?) 1974 | { 1975 | printMsg("ERROR", "pre install has failed"); 1976 | printMsg("ERROR", "see error log in '$LogDir_R/pre_install'"); 1977 | return 0; 1978 | } 1979 | } 1980 | 1981 | my $PreMake = $Profile->{"PreMake"}; 1982 | 1983 | if($V eq "current") 1984 | { 1985 | if(defined $Profile->{"CurrentPreMake"}) { 1986 | $PreMake = $Profile->{"CurrentPreMake"}; 1987 | } 1988 | } 1989 | 1990 | my @Files = listDir("."); 1991 | 1992 | my ($CMake, $Autotools, $Meson, $Scons, $Waf) = (0, 0, 0, 0, 0); 1993 | 1994 | my ($Configure, $Autogen, $Bootstrap, $Buildconf) = (0, 0, 0, 0); 1995 | 1996 | foreach my $File (sort @Files) 1997 | { 1998 | if($File eq "CMakeLists.txt") { 1999 | $CMake = 1; 2000 | } 2001 | elsif($File eq "configure") 2002 | { 2003 | $Autotools = 1; 2004 | $Configure = 1; 2005 | } 2006 | elsif($File eq "configure.ac" 2007 | or $File eq "configure.in") { 2008 | $Autotools = 1; 2009 | } 2010 | elsif($File eq "autogen.sh") 2011 | { 2012 | $Autotools = 1; 2013 | $Autogen = $File; 2014 | } 2015 | elsif($File eq "bootstrap" 2016 | or $File eq "bootstrap.sh") 2017 | { 2018 | $Autotools = 1; 2019 | $Bootstrap = $File; 2020 | } 2021 | elsif($File eq "buildconf") { 2022 | $Buildconf = 1; 2023 | } 2024 | elsif($File eq "SConstruct") { 2025 | $Scons = 1; 2026 | } 2027 | elsif($File eq "waf") { 2028 | $Waf = 1; 2029 | } 2030 | elsif($File eq "meson.build") { 2031 | $Meson = 1; 2032 | } 2033 | } 2034 | 2035 | 2036 | if($Autotools) 2037 | { 2038 | $CMake = 0; 2039 | $Meson = 0; 2040 | } 2041 | elsif($CMake) 2042 | { 2043 | $Autotools = 0; 2044 | $Meson = 0; 2045 | } 2046 | elsif($Meson) 2047 | { 2048 | $CMake = 0; 2049 | $Autotools = 0; 2050 | } 2051 | 2052 | if(defined $Profile->{"BuildSystem"}) 2053 | { 2054 | if($Profile->{"BuildSystem"} eq "CMake") 2055 | { 2056 | $CMake = 1; 2057 | $Autotools = 0; 2058 | $Meson = 0; 2059 | } 2060 | elsif($Profile->{"BuildSystem"} eq "Autotools") 2061 | { 2062 | $CMake = 0; 2063 | $Autotools = 1; 2064 | $Meson = 0; 2065 | } 2066 | elsif($Profile->{"BuildSystem"} eq "Meson") 2067 | { 2068 | $CMake = 0; 2069 | $Autotools = 0; 2070 | $Meson = 1; 2071 | } 2072 | } 2073 | 2074 | if($Autotools) 2075 | { 2076 | if(not $Configure) 2077 | { # try to generate configure script 2078 | if($Autogen) 2079 | { 2080 | my $Cmd_A = "NOCONFIGURE=1 NO_CONFIGURE=1 sh $Autogen --no-configure"; 2081 | $Cmd_A .= " >\"$LogDir/autogen\" 2>&1"; 2082 | 2083 | qx/$Cmd_A/; 2084 | 2085 | if(not -f "configure") 2086 | { 2087 | printMsg("ERROR", "failed to 'autogen'"); 2088 | printMsg("ERROR", "see error log in '$LogDir_R/autogen'"); 2089 | return 0; 2090 | } 2091 | } 2092 | elsif($Bootstrap) 2093 | { 2094 | my $Cmd_B = "sh ".$Bootstrap; 2095 | $Cmd_B .= " >\"$LogDir/bootstrap\" 2>&1"; 2096 | 2097 | qx/$Cmd_B/; 2098 | 2099 | if(not -f "configure") 2100 | { 2101 | printMsg("ERROR", "failed to 'bootstrap'"); 2102 | printMsg("ERROR", "see error log in '$LogDir_R/bootstrap'"); 2103 | return 0; 2104 | } 2105 | } 2106 | elsif($Buildconf) 2107 | { 2108 | my $Cmd_B = "sh buildconf"; 2109 | $Cmd_B .= " >\"$LogDir/buildconf\" 2>&1"; 2110 | 2111 | qx/$Cmd_B/; 2112 | 2113 | if(not -f "configure") 2114 | { 2115 | printMsg("ERROR", "failed to 'buildconf'"); 2116 | printMsg("ERROR", "see error log in '$LogDir_R/buildconf'"); 2117 | return 0; 2118 | } 2119 | } 2120 | else 2121 | { 2122 | my $Cmd_R = "autoreconf --force --verbose --install"; 2123 | $Cmd_R .= " >\"$LogDir/autoreconf\" 2>&1"; 2124 | 2125 | qx/$Cmd_R/; 2126 | 2127 | if(not -f "configure") 2128 | { 2129 | printMsg("ERROR", "failed to 'autoreconf'"); 2130 | printMsg("ERROR", "see error log in '$LogDir_R/autoreconf'"); 2131 | return 0; 2132 | } 2133 | } 2134 | } 2135 | } 2136 | 2137 | my $ConfigureKey = "Configure"; 2138 | if($V eq "current" and defined $Profile->{"CurrentConfigure"}) { 2139 | $ConfigureKey = "CurrentConfigure"; 2140 | } 2141 | else 2142 | { 2143 | if($CMake) 2144 | { 2145 | if(defined $Profile->{"CMakeConfigure"}) { 2146 | $ConfigureKey = "CMakeConfigure"; 2147 | } 2148 | } 2149 | elsif($Autotools) 2150 | { 2151 | if(defined $Profile->{"AutotoolsConfigure"}) { 2152 | $ConfigureKey = "AutotoolsConfigure"; 2153 | } 2154 | } 2155 | elsif($Meson) 2156 | { 2157 | if(defined $Profile->{"MesonConfigure"}) { 2158 | $ConfigureKey = "MesonConfigure"; 2159 | } 2160 | } 2161 | } 2162 | 2163 | my $ConfigOptions = $Profile->{$ConfigureKey}; 2164 | 2165 | if($ConfigOptions) { 2166 | $ConfigOptions = addParams($ConfigOptions, $To, $V); 2167 | } 2168 | 2169 | my $ConfigGlobalVars = $Profile->{"ConfigureGlobal"}; 2170 | 2171 | if($ConfigGlobalVars) { 2172 | $ConfigGlobalVars = addParams($ConfigGlobalVars, $To, $V); 2173 | } 2174 | 2175 | if($Autotools) 2176 | { 2177 | my $ConfigLog = "$LogDir/configure"; 2178 | my $Cmd_C = "./configure"; 2179 | 2180 | my $ConfScript = readFile("configure"); 2181 | if($ConfScript=~/enable-shared/) { 2182 | $Cmd_C .= " --enable-shared"; 2183 | } 2184 | $Cmd_C .= " --prefix=\"$To\""; 2185 | $Cmd_C .= " CFLAGS=\"$C_FLAGS\" CXXFLAGS=\"$CXX_FLAGS\""; 2186 | 2187 | if($ConfigOptions) { 2188 | $Cmd_C .= " ".$ConfigOptions; 2189 | } 2190 | 2191 | if($ConfigGlobalVars) { 2192 | $Cmd_C = $ConfigGlobalVars." ".$Cmd_C; 2193 | } 2194 | 2195 | writeFile($ConfigLog, $Cmd_C."\n\n"); 2196 | $Cmd_C .= " >>\"$ConfigLog\" 2>&1"; 2197 | 2198 | qx/$Cmd_C/; # execute 2199 | if($?) 2200 | { 2201 | printMsg("ERROR", "failed to 'configure'"); 2202 | printMsg("ERROR", "see error log in '$LogDir_R/configure'"); 2203 | return 0; 2204 | } 2205 | } 2206 | elsif($CMake) 2207 | { 2208 | my $ConfigLog = "$LogDir/cmake"; 2209 | my $CMake_C = $CMAKE; 2210 | 2211 | if($Profile->{"CMakePath"}) { 2212 | $CMake_C = $Profile->{"CMakePath"}; 2213 | } 2214 | 2215 | if(not checkCmd($CMake_C)) 2216 | { 2217 | printMsg("ERROR", "can't find \"$CMake_C\""); 2218 | return; 2219 | } 2220 | 2221 | my $BDir = $BUILD_SUBDIR; 2222 | mkpath($BDir); 2223 | chdir($BDir); 2224 | 2225 | my $Cmd_C = $CMake_C." .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON"; 2226 | $Cmd_C .= " -DCMAKE_INSTALL_PREFIX=\"$To\""; 2227 | $Cmd_C .= " -DCMAKE_C_FLAGS=\"$C_FLAGS\" -DCMAKE_CXX_FLAGS=\"$CXX_FLAGS\""; 2228 | 2229 | if($ConfigOptions) { 2230 | $Cmd_C .= " ".$ConfigOptions; 2231 | } 2232 | 2233 | if($ConfigGlobalVars) { 2234 | $Cmd_C = $ConfigGlobalVars." ".$Cmd_C; 2235 | } 2236 | 2237 | writeFile($ConfigLog, $Cmd_C."\n\n"); 2238 | $Cmd_C .= " >>\"$ConfigLog\" 2>&1"; 2239 | 2240 | qx/$Cmd_C/; # execute 2241 | if($?) 2242 | { 2243 | printMsg("ERROR", "failed to 'cmake'"); 2244 | printMsg("ERROR", "see error log in '$LogDir_R/cmake'"); 2245 | return 0; 2246 | } 2247 | } 2248 | elsif($Meson) 2249 | { 2250 | my $ConfigLog = "$LogDir/meson"; 2251 | my $BDir = "meson_build"; 2252 | 2253 | my $Cmd_C = "CFLAGS=\"$C_FLAGS\" CXXFLAGS=\"$CXX_FLAGS\" meson . $BDir --prefix=\"$To\" --buildtype=plain"; 2254 | 2255 | my $MesonOptions = readFile("meson_options.txt"); 2256 | while($MesonOptions=~/'(docs|enable\-docs|documentation|enable\-documentation|enable_docs|introspection|tests|enable\-tests|build\-tests|vapi|udev_rules|systemd|bash_completion|enable\-bash\-completion|man|enable\-man|enable\-systemd|enable\-vala|demos|enable\-udev\-rules|gtk_doc)'/g) 2257 | { 2258 | my $Opt = $1; 2259 | if($ConfigOptions!~/D$Opt=/) { 2260 | $Cmd_C .= " -D$Opt=false"; 2261 | } 2262 | } 2263 | 2264 | if($ConfigOptions) { 2265 | $Cmd_C .= " ".$ConfigOptions; 2266 | } 2267 | 2268 | if($ConfigGlobalVars) { 2269 | $Cmd_C = $ConfigGlobalVars." ".$Cmd_C; 2270 | } 2271 | 2272 | writeFile($ConfigLog, $Cmd_C."\n\n"); 2273 | $Cmd_C .= " >>\"$ConfigLog\" 2>&1"; 2274 | 2275 | qx/$Cmd_C/; # execute 2276 | if($?) 2277 | { 2278 | printMsg("ERROR", "failed to 'meson'"); 2279 | printMsg("ERROR", "see error log in '$LogDir_R/meson'"); 2280 | return 0; 2281 | } 2282 | 2283 | chdir($BDir); 2284 | } 2285 | elsif($Scons) 2286 | { 2287 | my $ConfigLog = "$LogDir/scons"; 2288 | my $Cmd_I = "scons prefix=\"$To\" debug=True"; 2289 | 2290 | if($ConfigOptions) { 2291 | $Cmd_I .= " ".$ConfigOptions; 2292 | } 2293 | 2294 | if($ConfigGlobalVars) { 2295 | $Cmd_I = $ConfigGlobalVars." ".$Cmd_I; 2296 | } 2297 | 2298 | $Cmd_I .= " install"; 2299 | 2300 | writeFile($ConfigLog, $Cmd_I."\n\n"); 2301 | $Cmd_I .= " >>\"$ConfigLog\" 2>&1"; 2302 | 2303 | my $SConstruct = readFile("SConstruct"); 2304 | $SConstruct=~s/'-O[0123]'/'-Og'/; 2305 | writeFile("SConstruct", $SConstruct); 2306 | 2307 | qx/$Cmd_I/; # execute 2308 | if($?) 2309 | { 2310 | printMsg("ERROR", "failed to 'scons'"); 2311 | printMsg("ERROR", "see error log in '$LogDir_R/scons'"); 2312 | return 0; 2313 | } 2314 | } 2315 | elsif($Waf) 2316 | { 2317 | my $ConfigLog = "$LogDir/configure"; 2318 | my $Cmd_C = "./waf configure --prefix=\"$To\""; 2319 | $Cmd_C = "CFLAGS=\"$C_FLAGS\" CXXFLAGS=\"$CXX_FLAGS\" ".$Cmd_C; 2320 | 2321 | if($ConfigOptions) { 2322 | $Cmd_C .= " ".$ConfigOptions; 2323 | } 2324 | 2325 | if($ConfigGlobalVars) { 2326 | $Cmd_C = $ConfigGlobalVars." ".$Cmd_C; 2327 | } 2328 | 2329 | writeFile($ConfigLog, $Cmd_C."\n\n"); 2330 | $Cmd_C .= " >>\"$ConfigLog\" 2>&1"; 2331 | 2332 | qx/$Cmd_C/; # execute 2333 | if($?) 2334 | { 2335 | printMsg("ERROR", "failed to './waf configure'"); 2336 | printMsg("ERROR", "see error log in '$LogDir_R/configure'"); 2337 | return 0; 2338 | } 2339 | } 2340 | else 2341 | { 2342 | printMsg("ERROR", "unknown build system, please set \"BuildScript\" or \"BuildScenario\" in the profile"); 2343 | return 0; 2344 | } 2345 | 2346 | my $MakeOptions = $Profile->{"Make"}; 2347 | 2348 | if($In::Opt{"MakeAddOpt"}) { 2349 | $MakeOptions = $In::Opt{"MakeAddOpt"}; 2350 | } 2351 | 2352 | $MakeOptions = addParams($MakeOptions, $To, $V); 2353 | 2354 | my $MakeGlobalVars = $Profile->{"MakeGlobal"}; 2355 | $MakeGlobalVars = addParams($MakeGlobalVars, $To, $V); 2356 | 2357 | my $InstallGlobalVars = $Profile->{"InstallGlobal"}; 2358 | $InstallGlobalVars = addParams($InstallGlobalVars, $To, $V); 2359 | 2360 | if($PreMake) 2361 | { 2362 | $PreMake = addParams($PreMake, $To, $V); 2363 | my $Cmd_PM = $PreMake." >$LogDir/pre_make 2>&1"; 2364 | qx/$Cmd_PM/; # execute 2365 | if($?) 2366 | { 2367 | printMsg("ERROR", "pre make has failed"); 2368 | printMsg("ERROR", "see error log in '$LogDir_R/pre_make'"); 2369 | return 0; 2370 | } 2371 | } 2372 | 2373 | if($CMake or $Autotools) 2374 | { 2375 | my $Cmd_M = "make"; 2376 | my $MakeLog = "$LogDir/make"; 2377 | 2378 | if($MakeOptions) { 2379 | $Cmd_M .= " ".$MakeOptions; 2380 | } 2381 | if($MakeGlobalVars) { 2382 | $Cmd_M = $MakeGlobalVars." ".$Cmd_M; 2383 | } 2384 | 2385 | writeFile($MakeLog, $Cmd_M."\n\n"); 2386 | $Cmd_M .= " >>$MakeLog 2>&1"; 2387 | 2388 | qx/$Cmd_M/; # execute 2389 | if($?) 2390 | { 2391 | printMsg("ERROR", "failed to 'make'"); 2392 | printMsg("ERROR", "see error log in '$LogDir_R/make'"); 2393 | return 0; 2394 | } 2395 | 2396 | my $InstallTarget = "install"; 2397 | if($Profile->{"InstallTarget"}) { 2398 | $InstallTarget = $Profile->{"InstallTarget"}; 2399 | } 2400 | 2401 | if(not defined $Profile->{"Install"} 2402 | or $Profile->{"Install"} eq "On") 2403 | { 2404 | my $Cmd_I = "make $InstallTarget"; 2405 | 2406 | if($InstallGlobalVars) { 2407 | $Cmd_I = $InstallGlobalVars." ".$Cmd_I; 2408 | } 2409 | 2410 | $Cmd_I .= " >$LogDir/install 2>&1"; 2411 | 2412 | qx/$Cmd_I/; # execute 2413 | if($?) 2414 | { 2415 | printMsg("ERROR", "failed to 'make $InstallTarget'"); 2416 | printMsg("ERROR", "see error log in '$LogDir_R/install'"); 2417 | return 0; 2418 | } 2419 | } 2420 | } 2421 | elsif($Meson) 2422 | { 2423 | my $Cmd_M = "ninja"; 2424 | my $MakeLog = "$LogDir/ninja"; 2425 | 2426 | if($MakeOptions) { 2427 | $Cmd_M .= " ".$MakeOptions; 2428 | } 2429 | if($MakeGlobalVars) { 2430 | $Cmd_M = $MakeGlobalVars." ".$Cmd_M; 2431 | } 2432 | 2433 | writeFile($MakeLog, $Cmd_M."\n\n"); 2434 | $Cmd_M .= " >>$MakeLog 2>&1"; 2435 | 2436 | qx/$Cmd_M/; # execute 2437 | if($?) 2438 | { 2439 | printMsg("ERROR", "failed to 'ninja'"); 2440 | printMsg("ERROR", "see error log in '$LogDir_R/ninja'"); 2441 | return 0; 2442 | } 2443 | 2444 | if(not defined $Profile->{"Install"} 2445 | or $Profile->{"Install"} eq "On") 2446 | { 2447 | my $Cmd_I = "ninja install"; 2448 | 2449 | if($InstallGlobalVars) { 2450 | $Cmd_I = $InstallGlobalVars." ".$Cmd_I; 2451 | } 2452 | 2453 | $Cmd_I .= " >$LogDir/install 2>&1"; 2454 | 2455 | qx/$Cmd_I/; # execute 2456 | if($?) 2457 | { 2458 | printMsg("ERROR", "failed to 'ninja install'"); 2459 | printMsg("ERROR", "see error log in '$LogDir_R/install'"); 2460 | return 0; 2461 | } 2462 | } 2463 | } 2464 | elsif($Waf) 2465 | { 2466 | my $Cmd_M = "./waf build"; 2467 | 2468 | $Cmd_M .= " >$LogDir/build 2>&1"; 2469 | 2470 | qx/$Cmd_M/; # execute 2471 | if($?) 2472 | { 2473 | printMsg("ERROR", "failed to './waf build'"); 2474 | printMsg("ERROR", "see error log in '$LogDir_R/build'"); 2475 | return 0; 2476 | } 2477 | 2478 | my $Cmd_I = "./waf install >$LogDir/install 2>&1"; 2479 | qx/$Cmd_I/; # execute 2480 | if($?) 2481 | { 2482 | printMsg("ERROR", "failed to './waf install'"); 2483 | printMsg("ERROR", "see error log in '$LogDir_R/install'"); 2484 | return 0; 2485 | } 2486 | } 2487 | 2488 | my $PostInstall = $Profile->{"PostInstall"}; 2489 | if($V eq "current") 2490 | { 2491 | if(defined $Profile->{"CurrentPostInstall"}) { 2492 | $PostInstall = $Profile->{"CurrentPostInstall"}; 2493 | } 2494 | } 2495 | 2496 | if($CMake or $Meson) { 2497 | chdir(".."); 2498 | } 2499 | 2500 | if($PostInstall) 2501 | { 2502 | $PostInstall = addParams($PostInstall, $To, $V); 2503 | my $Cmd_P = $PostInstall." >$LogDir/post_install 2>&1"; 2504 | qx/$Cmd_P/; # execute 2505 | if($?) 2506 | { 2507 | printMsg("ERROR", "post install has failed"); 2508 | printMsg("ERROR", "see error log in '$LogDir_R/post_install'"); 2509 | return 0; 2510 | } 2511 | } 2512 | 2513 | copyFiles($To); 2514 | clearInstallTree($To); 2515 | 2516 | if(not listDir($To)) 2517 | { 2518 | return 0; 2519 | } 2520 | 2521 | return 1; 2522 | } 2523 | 2524 | sub prepareInstallTree($) 2525 | { 2526 | my $Dir = $_[0]; 2527 | 2528 | foreach my $D ("lib", "lib64", "include") 2529 | { 2530 | mkpath($Dir."/".$D); 2531 | } 2532 | } 2533 | 2534 | sub clearInstallTree($) 2535 | { 2536 | my $Dir = $_[0]; 2537 | 2538 | foreach my $D ("lib", "lib64", "include") 2539 | { 2540 | my $SDir = $Dir."/".$D; 2541 | if(-d $SDir 2542 | and not listDir($SDir)) 2543 | { # remove empty 2544 | rmtree($SDir); 2545 | } 2546 | } 2547 | } 2548 | 2549 | sub copyFiles($) 2550 | { 2551 | my $To = $_[0]; 2552 | 2553 | foreach my $Tag ("CopyHeaders", "CopyObjects", "CopyStatic") 2554 | { 2555 | if(not defined $Profile->{$Tag}) { 2556 | next; 2557 | } 2558 | 2559 | my $Dir = undef; 2560 | 2561 | if($Tag eq "CopyHeaders") { 2562 | $Dir = "include"; 2563 | } 2564 | else { 2565 | $Dir = "lib"; 2566 | } 2567 | 2568 | if(my $Elems = $Profile->{$Tag}) 2569 | { 2570 | foreach my $D (@{$Elems}) 2571 | { 2572 | my @Files = (); 2573 | 2574 | if(-d $D) 2575 | { 2576 | if($Tag eq "CopyHeaders") { 2577 | @Files = findHeaders($D); 2578 | } 2579 | elsif($Tag eq "CopyObjects") { 2580 | @Files = findObjects($D); 2581 | } 2582 | else { 2583 | @Files = findStatic($D); 2584 | } 2585 | } 2586 | elsif(-f $D) { 2587 | @Files = ($D); 2588 | } 2589 | 2590 | foreach my $F (@Files) 2591 | { 2592 | my $O_To = $To."/".$Dir."/".$F; 2593 | $O_To=~s&/(\.libs|build|$BUILD_SUBDIR)/&/&g; 2594 | my $D_To = getDirname($O_To); 2595 | mkpath($D_To); 2596 | copy($F, $D_To); 2597 | } 2598 | } 2599 | } 2600 | } 2601 | } 2602 | 2603 | sub addParams($$$) 2604 | { 2605 | my ($Cmd, $To, $V) = @_; 2606 | 2607 | $Cmd=~s/\{INSTALL_TO\}/$To/g; 2608 | $Cmd=~s/\$INSTALL_TO/$To/g; 2609 | 2610 | $Cmd=~s/\{VERSION\}/$V/g; 2611 | $Cmd=~s/\$VERSION/$V/g; 2612 | 2613 | $Cmd=~s/\{BUILD_SUBDIR\}/$BUILD_SUBDIR/g; 2614 | $Cmd=~s/\$BUILD_SUBDIR/$BUILD_SUBDIR/g; 2615 | 2616 | my $InstallRoot_A = $ORIG_DIR."/".$INSTALLED; 2617 | $Cmd=~s/\{INSTALL_ROOT\}/$InstallRoot_A/g; 2618 | $Cmd=~s/\$INSTALL_ROOT/$InstallRoot_A/g; 2619 | 2620 | return $Cmd; 2621 | } 2622 | 2623 | sub findObjects($) 2624 | { 2625 | my $Dir = $_[0]; 2626 | 2627 | my @Files = (); 2628 | 2629 | if($Profile->{"Mode"} eq "Kernel") 2630 | { 2631 | @Files = findFiles($Dir, "f", ".*\\.ko"); 2632 | @Files = (@Files, findFiles($Dir, "f", "", "vmlinux")); 2633 | } 2634 | else 2635 | { 2636 | @Files = findFiles($Dir, "f", ".*\\.so\\..*"); 2637 | @Files = (@Files, findFiles($Dir, "f", ".*\\.so")); 2638 | } 2639 | 2640 | my @Res = (); 2641 | 2642 | foreach my $F (@Files) 2643 | { 2644 | if(-B $F) { 2645 | push(@Res, $F); 2646 | } 2647 | } 2648 | 2649 | return @Res; 2650 | } 2651 | 2652 | sub findStatic($) 2653 | { 2654 | my $Dir = $_[0]; 2655 | 2656 | my @Files = findFiles($Dir, "f", ".*\\.a"); 2657 | 2658 | my @Res = (); 2659 | 2660 | foreach my $F (@Files) 2661 | { 2662 | if(-B $F) { 2663 | push(@Res, $F); 2664 | } 2665 | } 2666 | 2667 | return @Res; 2668 | } 2669 | 2670 | sub findHeaders($) 2671 | { 2672 | my $Dir = $_[0]; 2673 | 2674 | my @Files = findFiles($Dir, "f"); 2675 | my @Headers = (); 2676 | 2677 | foreach my $File (sort {lc($a) cmp lc($b)} @Files) 2678 | { 2679 | if(isHeader($File)) { 2680 | push(@Headers, $File); 2681 | } 2682 | } 2683 | 2684 | return @Headers; 2685 | } 2686 | 2687 | sub buildPackage($$) 2688 | { 2689 | my ($Package, $V) = @_; 2690 | 2691 | printMsg("INFO", "Building \'".getFilename($Package)."\'"); 2692 | 2693 | my $InstallDir = $INSTALLED."/".$TARGET_LIB."/".$V; 2694 | rmtree($InstallDir); 2695 | mkpath($InstallDir); 2696 | 2697 | my $InstallDir_A = abs_path($InstallDir); 2698 | my $InstallRoot_A = abs_path($INSTALLED); 2699 | 2700 | my $BuildScript = undef; 2701 | my $BuildScriptCode = undef; 2702 | 2703 | if(defined $Profile->{"BuildScript"}) 2704 | { 2705 | if(not -f $Profile->{"BuildScript"}) { 2706 | exitStatus("Access_Error", "can't access build script \'".$Profile->{"BuildScript"}."\'"); 2707 | } 2708 | $BuildScriptCode = addParams(readFile($Profile->{"BuildScript"}), $InstallDir_A, $V); 2709 | } 2710 | elsif(defined $Profile->{"BuildScenario"}) { 2711 | $BuildScriptCode = addParams($Profile->{"BuildScenario"}, $InstallDir_A, $V); 2712 | } 2713 | 2714 | if($BuildScriptCode) 2715 | { 2716 | my $PreInstall = $Profile->{"PreInstall"}; 2717 | 2718 | if($V eq "current") 2719 | { 2720 | if(defined $Profile->{"CurrentPreInstall"}) { 2721 | $PreInstall = $Profile->{"CurrentPreInstall"}; 2722 | } 2723 | } 2724 | 2725 | if($PreInstall) { 2726 | $BuildScriptCode = addParams($PreInstall, $InstallDir_A, $V)."\n".$BuildScriptCode; 2727 | } 2728 | 2729 | $BuildScript = $TMP_DIR."/build_script.sh"; 2730 | writeFile($BuildScript, $BuildScriptCode); 2731 | } 2732 | 2733 | my $LogDir_R = $BUILD_LOGS."/".$TARGET_LIB."/".$V; 2734 | rmtree($LogDir_R); 2735 | mkpath($LogDir_R); 2736 | 2737 | my $LogDir = abs_path($LogDir_R); 2738 | 2739 | local $SIG{INT} = sub 2740 | { 2741 | # clean up install tree 2742 | rmtree($InstallDir_A); 2743 | 2744 | # generate profile 2745 | chdir($ORIG_DIR); 2746 | createProfile(); 2747 | 2748 | safeExit(); 2749 | }; 2750 | 2751 | $C_FLAGS = $C_FLAGS_B; 2752 | $CXX_FLAGS = $CXX_FLAGS_B; 2753 | 2754 | if(my $AddCFlags = $Profile->{"CFlags"}) { 2755 | $C_FLAGS .= " ".addParams($AddCFlags, $InstallDir_A, $V); 2756 | } 2757 | 2758 | if(my $AddCxxFlags = $Profile->{"CxxFlags"}) { 2759 | $CXX_FLAGS .= " ".addParams($AddCxxFlags, $InstallDir_A, $V); 2760 | } 2761 | 2762 | my $BuildDir = $TMP_DIR."/build/"; 2763 | mkpath($BuildDir); 2764 | 2765 | if($V eq "current") 2766 | { 2767 | my $Cmd_E = "cp -fr $Package $BuildDir"; 2768 | qx/$Cmd_E/; # execute 2769 | 2770 | $BuildDir .= "/current"; 2771 | } 2772 | else 2773 | { 2774 | if(my $Cmd_E = extractPackage($Package, $BuildDir)) 2775 | { 2776 | qx/$Cmd_E/; # execute 2777 | if($?) 2778 | { 2779 | printMsg("ERROR", "Failed to extract package \'".getFilename($Package)."\'"); 2780 | rmtree($BuildDir); 2781 | return 0; 2782 | } 2783 | } 2784 | else 2785 | { 2786 | printMsg("ERROR", "Unknown package format \'".getFilename($Package)."\'"); 2787 | return 0; 2788 | } 2789 | } 2790 | 2791 | chdir($BuildDir); 2792 | 2793 | while(1) 2794 | { 2795 | my @Files = grep { $_!~/\A\./ } listDir("."); 2796 | if($#Files==0 and -d $Files[0]) 2797 | { # one step deeper 2798 | chdir($Files[0]); 2799 | } 2800 | else { 2801 | last; 2802 | } 2803 | } 2804 | 2805 | if($V ne "current" and not defined $Profile->{"Changelog"}) 2806 | { 2807 | my $Found = findChangelog("."); 2808 | 2809 | if($Found ne "None") { 2810 | $DB->{"Changelog"}{$V} = $Found; 2811 | } 2812 | else { 2813 | $DB->{"Changelog"}{$V} = "Off"; 2814 | } 2815 | } 2816 | 2817 | if($V eq "current" and my $CurCustomDir = $Profile->{"CurrentBuildDir"}) { 2818 | chdir($CurCustomDir); 2819 | } 2820 | elsif(my $CustomDir = $Profile->{"BuildDir"}) { 2821 | chdir($CustomDir); 2822 | } 2823 | 2824 | prepareInstallTree($InstallDir_A); 2825 | 2826 | if(defined $BuildScript) 2827 | { 2828 | my $Cmd_I = "INSTALL_TO=\"$InstallDir_A\" M_INSTALL_ROOT=\"$InstallRoot_A\" VERSION=\"$V\" sh \"".$BuildScript."\""; 2829 | $Cmd_I .= " >\"$LogDir/build\" 2>&1"; 2830 | 2831 | qx/$Cmd_I/; # execute 2832 | 2833 | my $Err = $?; 2834 | 2835 | if(defined $Profile->{"SkipBuildErrors"} 2836 | and $Profile->{"SkipBuildErrors"} eq "On") { 2837 | $Err = 0; 2838 | } 2839 | 2840 | copyFiles($InstallDir_A); 2841 | clearInstallTree($InstallDir_A); 2842 | 2843 | if($Err) 2844 | { 2845 | delete($DB->{"Installed"}{$V}); 2846 | printMsg("ERROR", "custom build has failed (exit code $Err)"); 2847 | printMsg("ERROR", "see error log in '$LogDir_R/build'"); 2848 | } 2849 | elsif(not listDir($InstallDir_A)) 2850 | { 2851 | delete($DB->{"Installed"}{$V}); 2852 | printMsg("ERROR", "custom build has failed (empty install tree)"); 2853 | printMsg("ERROR", "see error log in '$LogDir_R/build'"); 2854 | } 2855 | else { 2856 | $DB->{"Installed"}{$V} = $InstallDir; 2857 | } 2858 | } 2859 | else 2860 | { 2861 | if(autoBuild($InstallDir_A, $LogDir, $V)) { 2862 | $DB->{"Installed"}{$V} = $InstallDir; 2863 | } 2864 | else { 2865 | delete($DB->{"Installed"}{$V}); 2866 | } 2867 | } 2868 | 2869 | chdir($ORIG_DIR); 2870 | rmtree($BuildDir); 2871 | 2872 | if($DB->{"Installed"}{$V}) 2873 | { 2874 | if((defined $Profile->{"Versions"} and defined $Profile->{"Versions"}{$V} 2875 | and $Profile->{"Versions"}{$V}{"BuildShared"} and $Profile->{"Versions"}{$V}{"BuildShared"} ne "Off") 2876 | or ($Profile->{"BuildShared"} and $Profile->{"BuildShared"} ne "Off")) 2877 | { 2878 | buildShared($V); 2879 | } 2880 | 2881 | if((not defined $Profile->{"ClearInstalled"} or $Profile->{"ClearInstalled"} eq "On") 2882 | and (not $In::Opt{"ClearInstalled"} or $In::Opt{"ClearInstalled"} eq "On")) 2883 | { 2884 | foreach my $D ("share", "bin", "sbin", 2885 | "etc", "var", "opt", "libexec", "doc", 2886 | "manual", "man", "logs", "icons", "conf", 2887 | "cgi-bin", "docs", "systemd", "udev", 2888 | "tmp", "info", "mkspecs", "gir", "fonts", 2889 | "aclocal", "tutorials", "test") 2890 | { 2891 | if(-d $InstallDir."/".$D) { 2892 | rmtree($InstallDir."/".$D); 2893 | } 2894 | } 2895 | 2896 | foreach my $D ("systemd", "udev", 2897 | "girepository-1.0", "python2.7", "sysctl.d", 2898 | "qml", "libexec") 2899 | { 2900 | if(-d $InstallDir."/lib/".$D) { 2901 | rmtree($InstallDir."/lib/".$D); 2902 | } 2903 | if(-d $InstallDir."/lib64/".$D) { 2904 | rmtree($InstallDir."/lib64/".$D); 2905 | } 2906 | } 2907 | 2908 | clearInstallTree($InstallDir); 2909 | 2910 | my @Fs = listPaths($InstallDir."/lib"); 2911 | my @Fs64 = listPaths($InstallDir."/lib64"); 2912 | my $Shared = undef; 2913 | 2914 | foreach my $F (@Fs, @Fs64) 2915 | { 2916 | if($F=~/\.so(\.|\Z)/) 2917 | { 2918 | $Shared = 1; 2919 | last; 2920 | } 2921 | } 2922 | 2923 | foreach my $F (@Fs, @Fs64) 2924 | { 2925 | if(-f $F) 2926 | { 2927 | if($F=~/\.(la|jar|o)\Z/) { 2928 | unlink($F) 2929 | } 2930 | 2931 | if(defined $Shared) 2932 | { 2933 | if($F=~/\.a\Z/) { 2934 | unlink($F) 2935 | } 2936 | } 2937 | } 2938 | } 2939 | 2940 | if(not listDir($InstallDir)) 2941 | { # empty after cleaning 2942 | delete($DB->{"Installed"}{$V}); 2943 | printMsg("ERROR", "failed to build (empty tree)"); 2944 | rmtree($InstallDir); 2945 | return 1; 2946 | } 2947 | } 2948 | 2949 | if(my @Objects = findObjects($InstallDir)) 2950 | { 2951 | foreach my $Obj (sort {lc($a) cmp lc($b)} @Objects) 2952 | { 2953 | my $Producer = `readelf --debug-dump=info \"$Obj\" | grep DW_AT_producer | grep -v 'GNU AS' | grep -m1 DW_AT_producer`; 2954 | 2955 | if(not $Producer) { 2956 | printMsg("WARNING", "debug-info is not found in the object ".getFilename($Obj)); 2957 | } 2958 | 2959 | my %Opts = (); 2960 | while($Producer=~s/(\A|\s)(\-O([0-3]|g))(\s|\Z)/ /) { 2961 | $Opts{keys(%Opts)} = $2; 2962 | } 2963 | 2964 | if(keys(%Opts)) 2965 | { 2966 | if($Opts{keys(%Opts)-1} ne "-Og") { 2967 | printMsg("WARNING", "incompatible build option detected in the object ".getFilename($Obj).": ".$Opts{keys(%Opts)-1}." (required -Og for better analysis)"); 2968 | } 2969 | } 2970 | else { 2971 | printMsg("WARNING", "the object ".getFilename($Obj)." should be compiled with -Og option for better analysis"); 2972 | } 2973 | } 2974 | } 2975 | else 2976 | { 2977 | if(not findStatic($InstallDir)) 2978 | { 2979 | delete($DB->{"Installed"}{$V}); 2980 | printMsg("ERROR", "no binary objects installed"); 2981 | rmtree($InstallDir); 2982 | return 1; 2983 | } 2984 | else { 2985 | printMsg("WARNING", "no shared objects installed"); 2986 | } 2987 | } 2988 | } 2989 | else 2990 | { 2991 | printMsg("ERROR", "failed to build"); 2992 | rmtree($InstallDir); 2993 | } 2994 | 2995 | return 1; 2996 | } 2997 | 2998 | sub buildShared($) 2999 | { 3000 | my $V = $_[0]; 3001 | 3002 | my $Installed = $DB->{"Installed"}{$V}; 3003 | 3004 | if(not -d $Installed) { 3005 | return 0; 3006 | } 3007 | 3008 | if(not checkCmd($GCC)) { 3009 | return 0; 3010 | } 3011 | 3012 | my @Objects = findStatic($Installed); 3013 | 3014 | foreach my $Object (@Objects) 3015 | { 3016 | my $Object_A = abs_path($Object); 3017 | my $To = getDirname($Object); 3018 | 3019 | my $Object_S = getFilename($Object); 3020 | $Object_S=~s/\.a\Z/.so/g; 3021 | 3022 | if(-e $To."/".$Object_S) 3023 | { 3024 | printMsg("INFO", "shared object already exists"); 3025 | return 1; 3026 | } 3027 | 3028 | chdir($To); 3029 | my $Cmd_B = $GCC." -shared -o \"$Object_S\" -Wl,--whole-archive \"$Object_A\" -Wl,--no-whole-archive"; # -nostdlib 3030 | if(my $AddOpt = $Profile->{"BuildSharedFlags"}) { 3031 | $Cmd_B .= " ".$AddOpt; 3032 | } 3033 | qx/$Cmd_B/; 3034 | 3035 | if($? or not -f $Object_S) 3036 | { 3037 | print STDERR "ERROR: failed to build shared object(s)\n"; 3038 | chdir($ORIG_DIR); 3039 | return 0; 3040 | } 3041 | 3042 | chdir($ORIG_DIR); 3043 | print "Created \'$To/$Object_S\'\n"; 3044 | } 3045 | } 3046 | 3047 | sub findStatic($) 3048 | { 3049 | my $Dir = $_[0]; 3050 | 3051 | return findFiles($Dir, "f", ".*\\.a"); 3052 | } 3053 | 3054 | sub readDB($) 3055 | { 3056 | my $Path = $_[0]; 3057 | 3058 | if(-f $Path) 3059 | { 3060 | my $P = eval(readFile($Path)); 3061 | 3062 | if(not $P) { 3063 | exitStatus("Error", "please remove 'use strict' from code and retry"); 3064 | } 3065 | 3066 | return $P; 3067 | } 3068 | 3069 | return {}; 3070 | } 3071 | 3072 | sub writeDB($) 3073 | { 3074 | my $Path = $_[0]; 3075 | 3076 | if($Path and $DB and keys(%{$DB})) { 3077 | writeFile($Path, Dumper($DB)); 3078 | } 3079 | } 3080 | 3081 | sub checkFiles() 3082 | { 3083 | my $Repo = $REPO."/".$TARGET_LIB; 3084 | foreach my $V (listDir($Repo)) 3085 | { 3086 | if($V eq "current") { 3087 | $DB->{"Source"}{$V} = $Repo."/".$V; 3088 | } 3089 | else 3090 | { 3091 | if(my @Files = listFiles($Repo."/".$V)) 3092 | { 3093 | $DB->{"Source"}{$V} = $Repo."/".$V."/".$Files[0]; 3094 | } 3095 | } 3096 | } 3097 | 3098 | my $Installed = $INSTALLED."/".$TARGET_LIB; 3099 | foreach my $V (listDir($Installed)) 3100 | { 3101 | if(my @Files = listDir($Installed."/".$V)) 3102 | { 3103 | $DB->{"Installed"}{$V} = $Installed."/".$V; 3104 | } 3105 | else 3106 | { 3107 | rmtree($Installed."/".$V); 3108 | } 3109 | } 3110 | } 3111 | 3112 | sub checkDB() 3113 | { 3114 | foreach my $V (keys(%{$DB->{"Source"}})) 3115 | { 3116 | if(not -f $DB->{"Source"}{$V}) 3117 | { 3118 | delete($DB->{"Source"}{$V}); 3119 | } 3120 | } 3121 | 3122 | foreach my $V (keys(%{$DB->{"Installed"}})) 3123 | { 3124 | if(not -d $DB->{"Installed"}{$V}) 3125 | { 3126 | delete($DB->{"Installed"}{$V}); 3127 | } 3128 | } 3129 | } 3130 | 3131 | sub safeExit() 3132 | { 3133 | chdir($ORIG_DIR); 3134 | 3135 | printMsg("INFO", "\nReceived SIGINT"); 3136 | printMsg("INFO", "Exiting"); 3137 | 3138 | if($TMP_DIR_LOC eq "On") { 3139 | rmtree($TMP_DIR); 3140 | } 3141 | 3142 | writeDB($DB_PATH); 3143 | exit(1); 3144 | } 3145 | 3146 | sub scenario() 3147 | { 3148 | $Data::Dumper::Sortkeys = 1; 3149 | 3150 | $SIG{INT} = \&safeExit; 3151 | 3152 | if($In::Opt{"Rebuild"} or $In::Opt{"BuildNew"}) { 3153 | $In::Opt{"Build"} = 1; 3154 | } 3155 | 3156 | if($In::Opt{"Redownload"}) { 3157 | $In::Opt{"Get"} = 1; 3158 | } 3159 | 3160 | if(defined $In::Opt{"LimitOps"}) 3161 | { 3162 | if($In::Opt{"LimitOps"}<=0) { 3163 | exitStatus("Error", "the value of -limit option should be a positive integer"); 3164 | } 3165 | } 3166 | 3167 | if($In::Opt{"DumpVersion"}) 3168 | { 3169 | printMsg("INFO", $TOOL_VERSION); 3170 | exit(0); 3171 | } 3172 | 3173 | if($In::Opt{"Help"}) 3174 | { 3175 | printMsg("INFO", $HelpMessage); 3176 | exit(0); 3177 | } 3178 | 3179 | if(-d "archives_report") { 3180 | exitStatus("Error", "Can't execute inside the Java API tracker home directory"); 3181 | } 3182 | 3183 | if($In::Opt{"DetectDeps"}) 3184 | { 3185 | my %Deps = (); 3186 | 3187 | foreach my $D ("build_script", "profile") 3188 | { 3189 | if(not -d $D) { 3190 | next; 3191 | } 3192 | my $Out = `grep -nR INSTALL_ROOT $D`; 3193 | my @Deps = ($Out=~/INSTALL_ROOT}?\/([^\/]+\/[^\/ '":;{]+)/g); 3194 | foreach (@Deps) { 3195 | $Deps{$_} = 1; 3196 | } 3197 | } 3198 | 3199 | foreach my $Dep (sort keys(%Deps)) 3200 | { 3201 | if(not -d $INSTALLED."/".$Dep) { 3202 | print $INSTALLED."/".$Dep."\n"; 3203 | } 3204 | } 3205 | 3206 | exit(0); 3207 | } 3208 | 3209 | $Profile_Path = $ARGV[0]; 3210 | 3211 | if(not $Profile_Path) { 3212 | exitStatus("Error", "profile path is not specified"); 3213 | } 3214 | 3215 | if(not -e $Profile_Path) { 3216 | exitStatus("Access_Error", "can't access \'$Profile_Path\'"); 3217 | } 3218 | 3219 | $Profile = readProfile(readFile($Profile_Path)); 3220 | 3221 | if(not $Profile->{"Name"}) { 3222 | exitStatus("Error", "name of the library is not specified in profile"); 3223 | } 3224 | 3225 | if(defined $Profile->{"InstallScenario"}) 3226 | { 3227 | $Profile->{"Install"} = "Off"; 3228 | $Profile->{"PostInstall"} = $Profile->{"InstallScenario"}; 3229 | delete($Profile->{"InstallScenario"}); 3230 | } 3231 | 3232 | if(defined $Profile->{"LocalBuild"} 3233 | and $Profile->{"LocalBuild"} eq "On") 3234 | { 3235 | $TMP_DIR_LOC = "On"; 3236 | $TMP_DIR = ".tmp_build_".$$; # pid 3237 | mkpath($TMP_DIR); 3238 | $TMP_DIR = abs_path($TMP_DIR); 3239 | } 3240 | 3241 | $TARGET_LIB = $Profile->{"Name"}; 3242 | $DB_PATH = "db/".$TARGET_LIB."/".$DB_PATH; 3243 | 3244 | $TARGET_TITLE = $TARGET_LIB; 3245 | if($Profile->{"Title"}) { 3246 | $TARGET_TITLE = $Profile->{"Title"}; 3247 | } 3248 | 3249 | $DB = readDB($DB_PATH); 3250 | 3251 | checkDB(); 3252 | checkFiles(); 3253 | 3254 | if($In::Opt{"CleanUnused"}) { 3255 | cleanUnused(); 3256 | } 3257 | 3258 | if($In::Opt{"GetNew"}) { 3259 | $In::Opt{"Get"} = 1; 3260 | } 3261 | 3262 | if($In::Opt{"GetOld"}) { 3263 | getVersions(); 3264 | } 3265 | 3266 | if($In::Opt{"Get"}) 3267 | { 3268 | getVersions_Local(); 3269 | getVersions(); 3270 | 3271 | if(defined $Profile->{"Git"} 3272 | or defined $Profile->{"Svn"} 3273 | or defined $Profile->{"Hg"}) 3274 | { 3275 | getCurrent(); 3276 | } 3277 | } 3278 | 3279 | if($In::Opt{"Build"}) { 3280 | buildVersions(); 3281 | } 3282 | 3283 | if($In::Opt{"BuildShared"}) 3284 | { 3285 | if(defined $In::Opt{"TargetVersion"}) 3286 | { 3287 | buildShared($In::Opt{"TargetVersion"}); 3288 | } 3289 | else { 3290 | print STDERR "ERROR: target version should be specified to build shared objects from static ones\n"; 3291 | } 3292 | } 3293 | 3294 | writeDB($DB_PATH); 3295 | createProfile(); 3296 | 3297 | if($TMP_DIR_LOC eq "On") { 3298 | rmtree($TMP_DIR); 3299 | } 3300 | 3301 | if($In::Opt{"Analyze"} and checkCmd("abi-tracker")) { 3302 | system("abi-tracker", $Profile_Path, "-build"); 3303 | } 3304 | } 3305 | 3306 | scenario(); 3307 | -------------------------------------------------------------------------------- /modules/Internals/Basic.pm: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # Module for ABI Monitor with basic functions 3 | # 4 | # Copyright (C) 2016-2018 Andrey Ponomarenko's ABI Laboratory 5 | # 6 | # Written by Andrey Ponomarenko 7 | # 8 | # This library is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU Lesser General Public 10 | # License as published by the Free Software Foundation; either 11 | # version 2.1 of the License, or (at your option) any later version. 12 | # 13 | # This library is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public 19 | # License along with this library; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 | # MA 02110-1301 USA 22 | ################################################################## 23 | use strict; 24 | 25 | sub findFiles(@) 26 | { 27 | my ($Path, $Type, $Regex) = @_; 28 | my $Cmd = "find \"$Path\""; 29 | 30 | if($Type) { 31 | $Cmd .= " -type ".$Type; 32 | } 33 | 34 | if($Regex) { 35 | $Cmd .= " -regex \"".$Regex."\""; 36 | } 37 | 38 | my @Res = split(/\n/, `$Cmd`); 39 | return @Res; 40 | } 41 | 42 | sub listDir($) 43 | { 44 | my $Path = $_[0]; 45 | return () if(not $Path); 46 | opendir(my $DH, $Path); 47 | return () if(not $DH); 48 | my @Contents = grep { $_ ne "." && $_ ne ".." } readdir($DH); 49 | return @Contents; 50 | } 51 | 52 | sub listFiles($) 53 | { 54 | my $Path = $_[0]; 55 | return () if(not $Path); 56 | 57 | my @Files = (); 58 | 59 | foreach my $F (listDir($Path)) 60 | { 61 | if(-f $Path."/".$F) { 62 | push(@Files, $F); 63 | } 64 | } 65 | 66 | return @Files; 67 | } 68 | 69 | sub listPaths($) 70 | { 71 | my $Path = $_[0]; 72 | return () if(not $Path); 73 | 74 | my @Paths = (); 75 | 76 | foreach my $F (listDir($Path)) { 77 | push(@Paths, $Path."/".$F); 78 | } 79 | 80 | return @Paths; 81 | } 82 | 83 | sub getFilename($) 84 | { # much faster than basename() from File::Basename module 85 | if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) { 86 | return $1; 87 | } 88 | return ""; 89 | } 90 | 91 | sub getDirname($) 92 | { # much faster than dirname() from File::Basename module 93 | if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) { 94 | return $1; 95 | } 96 | return ""; 97 | } 98 | 99 | sub readFile($) 100 | { 101 | my $Path = $_[0]; 102 | return "" if(not $Path or not -f $Path); 103 | open(FILE, $Path); 104 | local $/ = undef; 105 | my $Content = ; 106 | close(FILE); 107 | return $Content; 108 | } 109 | 110 | sub writeFile($$) 111 | { 112 | my ($Path, $Content) = @_; 113 | return if(not $Path); 114 | if(my $Dir = dirname($Path)) { 115 | mkpath($Dir); 116 | } 117 | open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n"); 118 | print FILE $Content; 119 | close(FILE); 120 | } 121 | 122 | sub getSiteAddr($) 123 | { 124 | if($_[0]=~/\A([a-z]+\:\/\/|)([^\/]+\.[a-z]+)(:[0-9]+|)(\/|\Z)/i) { 125 | return $2; 126 | } 127 | 128 | return $_[0]; 129 | } 130 | 131 | sub getSiteProtocol($) 132 | { 133 | if($_[0]=~/\A([a-z]+\:\/\/)/i) { 134 | return $1; 135 | } 136 | return ""; 137 | } 138 | 139 | sub getSite($) { 140 | return getSiteProtocol($_[0]).getSiteAddr($_[0]); 141 | } 142 | 143 | sub extractPackage($$) 144 | { 145 | my ($Path, $OutDir) = @_; 146 | 147 | if($Path=~/\.(tar\.\w+|tgz|tbz2|txz)\Z/i) { 148 | return "tar -xf $Path --directory=$OutDir"; 149 | } 150 | elsif($Path=~/\.zip\Z/i) { 151 | return "unzip $Path -d $OutDir"; 152 | } 153 | 154 | return undef; 155 | } 156 | 157 | sub isHeader($) 158 | { 159 | my $Path = $_[0]; 160 | return ($Path=~/\.(h|hh|hp|hxx|hpp|h\+\+|tcc)\Z/i); 161 | } 162 | 163 | sub checkCmd($) 164 | { 165 | my $Cmd = $_[0]; 166 | 167 | if(-x $Cmd) { 168 | return 1; 169 | } 170 | 171 | foreach my $Path (sort {length($a)<=>length($b)} split(/:/, $ENV{"PATH"})) 172 | { 173 | if(-x $Path."/".$Cmd) { 174 | return 1; 175 | } 176 | } 177 | 178 | return 0; 179 | } 180 | 181 | sub uniqueArray(@) 182 | { 183 | my %Elem = (); 184 | return grep {!$Elem{$_}++} sort @_; 185 | } 186 | 187 | return 1; 188 | -------------------------------------------------------------------------------- /modules/Internals/CmpVersions.pm: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # Module for ABI Monitor to compare library versions 3 | # 4 | # Copyright (C) 2017-2018 Andrey Ponomarenko's ABI Laboratory 5 | # 6 | # Written by Andrey Ponomarenko 7 | # 8 | # This library is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU Lesser General Public 10 | # License as published by the Free Software Foundation; either 11 | # version 2.1 of the License, or (at your option) any later version. 12 | # 13 | # This library is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public 19 | # License along with this library; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 | # MA 02110-1301 USA 22 | ################################################################## 23 | use strict; 24 | 25 | sub cmpVersions($$) 26 | { 27 | my ($A, $B) = @_; 28 | 29 | if($A eq "" and $B eq "") { 30 | return 0; 31 | } 32 | elsif($A eq "" 33 | or $B eq "current") { 34 | return -1; 35 | } 36 | elsif($B eq "" 37 | or $A eq "current") { 38 | return 1; 39 | } 40 | 41 | # speed up 42 | if($A=~/\A(\d+)\./) 43 | { 44 | my $A1 = $1; 45 | if($B=~/\A(\d+)\./) 46 | { 47 | my $B1 = $1; 48 | 49 | if($A1>$B1) { 50 | return 1; 51 | } 52 | elsif($A1<$B1) { 53 | return -1; 54 | } 55 | } 56 | } 57 | 58 | # speed up 59 | if($A=~/\A[\d\.]+\Z/ and $B=~/\A[\d\.]+\Z/) 60 | { 61 | my @N1 = split(/\./, $A); 62 | my @N2 = split(/\./, $B); 63 | 64 | foreach (0 .. $#N1) 65 | { 66 | if($_>$#N2) { 67 | return 1; 68 | } 69 | if($N1[$_]>$N2[$_]) { 70 | return 1; 71 | } 72 | elsif($N1[$_]<$N2[$_]) { 73 | return -1; 74 | } 75 | } 76 | } 77 | 78 | # version-release 79 | # 0.12-20140410 vs 0.12.1-20160607 80 | if($A=~/\A([^\-]+)\-([^\-]+)\Z/) 81 | { 82 | my ($AV, $AR) = ($1, $2); 83 | if($B=~/\A([^\-]+)\-([^\-]+)\Z/) 84 | { 85 | my ($BV, $BR) = ($1, $2); 86 | 87 | my $VR = cmpVersions($AV, $BV); 88 | 89 | if($VR!=0) { 90 | return $VR; 91 | } 92 | 93 | return cmpVersions($AR, $BR); 94 | } 95 | } 96 | 97 | $A=~s/(\d)([a-z])/$1.$2/ig; 98 | $B=~s/(\d)([a-z])/$1.$2/ig; 99 | 100 | $A=~s/[_~-]/./g; 101 | $B=~s/[_~-]/./g; 102 | 103 | $A=~s/\A[.]+//g; 104 | $B=~s/\A[.]+//g; 105 | 106 | $A=~s/\A[0]+([1-9]\d*)\Z/$1/g; 107 | $B=~s/\A[0]+([1-9]\d*)\Z/$1/g; 108 | 109 | $A=~s/\A[0]+\Z/0/g; 110 | $B=~s/\A[0]+\Z/0/g; 111 | 112 | my $PS1 = index($A, "."); 113 | my $PS2 = index($B, "."); 114 | 115 | if($PS1==-1 and $PS2==-1) { 116 | return mixedCmp($_[0], $_[1]); 117 | } 118 | elsif($PS1==-1) { 119 | return cmpVersions($A.".0", $B); 120 | } 121 | elsif($PS2==-1) { 122 | return cmpVersions($A, $B.".0"); 123 | } 124 | else 125 | { 126 | my ($P1, $P2) = (); 127 | if($A=~s/\A([^\.]+)\.//o) { 128 | $P1 = $1; 129 | } 130 | if($B=~s/\A([^\.]+)\.//o) { 131 | $P2 = $1; 132 | } 133 | 134 | if(my $CmpPartRes = mixedCmp($P1, $P2)) 135 | { # compare first parts 136 | return $CmpPartRes; 137 | } 138 | else 139 | { # compare other parts 140 | return cmpVersions($A, $B); 141 | } 142 | } 143 | } 144 | 145 | sub mixedCmp($$) 146 | { 147 | my ($A, $B) = @_; 148 | if($A eq $B) { 149 | return 0; 150 | } 151 | 152 | while($A ne "" 153 | and $B ne "") 154 | { 155 | my $A_Token = get_Token($A); 156 | my $B_Token = get_Token($B); 157 | 158 | my $CmpRes = tokensCmp($A_Token, $B_Token); 159 | if(not defined $CmpRes) 160 | { # safety lock 161 | return 0; 162 | } 163 | elsif($CmpRes != 0) { 164 | return $CmpRes; 165 | } 166 | else 167 | { 168 | $A=~s/\A\Q$A_Token\E//g; 169 | $B=~s/\A\Q$B_Token\E//g; 170 | } 171 | } 172 | 173 | if($A ne "" 174 | or $A eq "0") { 175 | return 1; 176 | } 177 | elsif($B ne "" 178 | or $B eq "0") { 179 | return -1; 180 | } 181 | 182 | return 0; 183 | } 184 | 185 | sub get_Token($) 186 | { 187 | if($_[0]=~/\A(\d+)[a-z]/i) { 188 | return $1; 189 | } 190 | elsif($_[0]=~/\A([a-z]+)\d/i) { 191 | return $1; 192 | } 193 | elsif($_[0]=~/\A(\d+)[^a-z0-9]/i) { 194 | return $1; 195 | } 196 | elsif($_[0]=~/\A([a-z]+)[^a-z0-9]/i) { 197 | return $1; 198 | } 199 | elsif($_[0]=~/\A([^a-z0-9]+)/i) { 200 | return $1; 201 | } 202 | 203 | return $_[0]; 204 | } 205 | 206 | sub tokensCmp($$) 207 | { 208 | my ($A, $B) = @_; 209 | 210 | if($A eq $B) { 211 | return 0; 212 | } 213 | elsif($A=~/\A[^a-z0-9]+\Z/i 214 | and $B=~/\A[^a-z0-9]+\Z/i) { 215 | return 0; 216 | } 217 | elsif($A=~/\A[a-z]+\Z/i 218 | and $B=~/\A[a-z]+\Z/i) { 219 | return symbolCmp(lc($A), lc($B)); 220 | } 221 | elsif($A=~/\A\d+\Z/ 222 | and $B=~/\A\d+\Z/) { 223 | return int($A)<=>int($B); 224 | } 225 | elsif($A=~/\A[a-z]+\Z/i 226 | and $B=~/\A\d+\Z/) { 227 | return -1; 228 | } 229 | elsif($A=~/\A\d+\Z/ 230 | and $B=~/\A[a-z]+\Z/i) { 231 | return 1; 232 | } 233 | elsif($A and $B eq "") { 234 | return 1; 235 | } 236 | elsif($B and $A eq "") { 237 | return -1; 238 | } 239 | 240 | return undef; 241 | } 242 | 243 | sub symbolCmp($$) 244 | { 245 | my ($A, $B) = @_; 246 | 247 | if($A gt $B) { 248 | return 1; 249 | } 250 | elsif($A eq $B) { 251 | return 0; 252 | } 253 | 254 | return -1; 255 | } 256 | 257 | sub cmpVersions_P($$$) 258 | { 259 | my ($A, $B, $Profile) = @_; 260 | 261 | if(defined $Profile->{"LetterReleases"}) 262 | { # 0.9.8k and 0.9.8 263 | my $TA = getVersionType($A, $Profile); 264 | my $TB = getVersionType($B, $Profile); 265 | 266 | if($TA eq $TB) 267 | { 268 | if(index($A, $B)==0) { 269 | return 1; 270 | } 271 | elsif(index($B, $A)==0) { 272 | return -1; 273 | } 274 | } 275 | } 276 | elsif(defined $Profile->{"StringReleases"}) 277 | { # compare as strings letter by letter 278 | return ($A cmp $B); 279 | } 280 | elsif(defined $Profile->{"ExtendVersion"}) 281 | { 282 | my $Extend = $Profile->{"ExtendVersion"}; 283 | my $AL = length($A); 284 | my $BL = length($B); 285 | 286 | if($AL<$Extend) 287 | { 288 | foreach (1 .. $Extend-$AL) { 289 | $A .= "0"; 290 | } 291 | } 292 | 293 | if($BL<$Extend) 294 | { 295 | foreach (1 .. $Extend-$BL) { 296 | $B .= "0"; 297 | } 298 | } 299 | } 300 | 301 | return cmpVersions($A, $B); 302 | } 303 | 304 | sub skipVersion(@) 305 | { 306 | my $V = shift(@_); 307 | my $Profile = shift(@_); 308 | 309 | my $MinCheck = 1; 310 | 311 | if(@_) { 312 | $MinCheck = shift(@_); 313 | } 314 | 315 | if(defined $Profile->{"SkipVersions"}) 316 | { 317 | my @Skip = @{$Profile->{"SkipVersions"}}; 318 | 319 | foreach my $E (@Skip) 320 | { 321 | if($E=~/[\*\+\[\(\|\\]/) 322 | { # pattern 323 | if($V=~/\A$E\Z/) { 324 | return 1; 325 | } 326 | } 327 | elsif($E eq $V) { 328 | return 1; 329 | } 330 | } 331 | } 332 | 333 | if(defined $Profile->{"KeepMiniMult"}) 334 | { 335 | my @KeepMult = @{$Profile->{"KeepMiniMult"}}; 336 | 337 | if(my $Mini = getVerNum($V, 2)) 338 | { 339 | my $Keep = 0; 340 | 341 | foreach my $K (@KeepMult) 342 | { 343 | if($Mini % $K == 0) 344 | { 345 | $Keep = 1; 346 | last; 347 | } 348 | } 349 | 350 | if(not $Keep) { 351 | return 1; 352 | } 353 | } 354 | } 355 | 356 | if(defined $Profile->{"KeepMicroMult"}) 357 | { 358 | my @KeepMult = @{$Profile->{"KeepMicroMult"}}; 359 | 360 | if(my $Micro = getVerNum($V, 3)) 361 | { 362 | my $Keep = 0; 363 | 364 | foreach my $K (@KeepMult) 365 | { 366 | if($Micro % $K == 0) 367 | { 368 | $Keep = 1; 369 | last; 370 | } 371 | } 372 | 373 | if(not $Keep) { 374 | return 1; 375 | } 376 | } 377 | } 378 | 379 | if(defined $Profile->{"SkipOdd"}) 380 | { 381 | if($V=~/\A\d+\.(\d+)/) 382 | { 383 | if($1 % 2 == 1) 384 | { 385 | return 1; 386 | } 387 | } 388 | } 389 | 390 | if($MinCheck) 391 | { 392 | if(my $Min = $Profile->{"MinimalVersion"}) 393 | { 394 | if(cmpVersions_P($V, $Min, $Profile)==-1) 395 | { 396 | return 1; 397 | } 398 | } 399 | } 400 | 401 | return 0; 402 | } 403 | 404 | sub naturalSequence(@) 405 | { 406 | my $Profile = shift(@_); 407 | 408 | my @Releases = (); 409 | my @Unstables = (); 410 | my @Previews = (); 411 | 412 | foreach my $Version (sort {cmpVersions_P($a, $b, $Profile)} @_) 413 | { 414 | my $Type = getVersionType($Version, $Profile); 415 | 416 | if($Type eq "unknown" 417 | or $Version eq "current") { 418 | next; 419 | } 420 | 421 | if(skipVersion($Version, $Profile)) { 422 | next; 423 | } 424 | 425 | if($Type eq "release") { 426 | push(@Releases, $Version); 427 | } 428 | elsif($Type eq "technology-preview") { 429 | push(@Previews, $Version); 430 | } 431 | else { 432 | push(@Unstables, $Version); 433 | } 434 | } 435 | 436 | my ($LastRelease, $LastUnstable, $LastPreview) = (); 437 | 438 | if(@Releases) { 439 | $LastRelease = $Releases[$#Releases]; 440 | } 441 | 442 | if(@Unstables) { 443 | $LastUnstable = $Unstables[$#Unstables]; 444 | } 445 | 446 | if(@Previews) { 447 | $LastPreview = $Previews[$#Previews]; 448 | } 449 | 450 | my @NaturalSequence = @Releases; 451 | 452 | if(not $LastUnstable and $LastPreview) { 453 | $LastUnstable = $LastPreview; 454 | } 455 | 456 | if($LastUnstable) 457 | { 458 | if($LastRelease) 459 | { 460 | if(cmpVersions_P($LastUnstable, $LastRelease, $Profile)==1) { 461 | push(@NaturalSequence, $LastUnstable); 462 | } 463 | } 464 | else { 465 | push(@NaturalSequence, $LastUnstable); 466 | } 467 | } 468 | 469 | if(grep {$_ eq "current"} @_) { 470 | push(@NaturalSequence, "current"); 471 | } 472 | 473 | return @NaturalSequence; 474 | } 475 | 476 | sub checkReleasePattern($$) 477 | { 478 | my ($Version, $Profile) = @_; 479 | 480 | if(my $RPattern = $Profile->{"ReleasePattern"}) 481 | { 482 | if($Version=~/$RPattern/i) 483 | { 484 | return $1; 485 | } 486 | } 487 | 488 | return undef; 489 | } 490 | 491 | sub getVersionType($$) 492 | { 493 | my ($Version, $Profile) = @_; 494 | 495 | if(defined $Profile->{"LetterReleases"}) 496 | { 497 | if($Version=~/\A[\d\.\-]+[a-z]{0,2}\Z/i 498 | and index($Version, "beta")==-1) 499 | { 500 | return "release"; 501 | } 502 | } 503 | 504 | if(defined $Profile->{"NumericBeta"}) 505 | { 506 | if($Version=~/\A\d+\.\d+\.9\d+(|\.\d+)\Z/i) { 507 | return "beta"; 508 | } 509 | } 510 | 511 | if(checkReleasePattern($Version, $Profile)) { 512 | return "release"; 513 | } 514 | 515 | if($Version!~/[a-z]/i 516 | or $Version=~/\A[\d\.]+[\-\_]*r\d+\Z/i 517 | or $Version=~/\A[\d\.]+\.v\d+\Z/i) 518 | { # 1.5_r04 519 | # 9.3.7.v20160115 520 | return "release"; 521 | } 522 | 523 | my @Words = (); 524 | while($Version=~/(\A|[^a-z])([a-z]+)([^a-z]|\Z)/gi) { 525 | push(@Words, $2); 526 | } 527 | 528 | my %Type = (); 529 | foreach my $W (sort @Words) 530 | { 531 | if($W=~/\A(final)\Z/i) { 532 | $Type{"release"}=1; 533 | } 534 | elsif($W=~/\A(r|rel|release)\Z/i 535 | and $Version=~/\b$W\d/) { 536 | $Type{"release"}=1; 537 | } 538 | elsif($W=~/\A(devel|dev|exp)\Z/i) { 539 | $Type{"devel"}=1; 540 | } 541 | elsif($W=~/\A(snapshot|snap|master)\Z/i) { 542 | $Type{"snapshot"}=1; 543 | } 544 | elsif($W=~/\A(alfa|alpha|a)\Z/i) { 545 | $Type{"alfa"}=1; 546 | } 547 | elsif($W=~/\A(tp|preview)\Z/i) { 548 | $Type{"technology-preview"}=1; 549 | } 550 | elsif($W=~/\A(beta|b)\Z/i) { 551 | $Type{"beta"}=1; 552 | } 553 | elsif($W=~/\A(pre)\Z/i) { 554 | $Type{"pre-release"}=1; 555 | } 556 | elsif($W=~/\A(rc|cr)\Z/i) { 557 | $Type{"release-candidate"}=1; 558 | } 559 | elsif($W=~/\A(current)\Z/) { 560 | $Type{"current"}=1; 561 | } 562 | else { 563 | return "unknown"; 564 | } 565 | } 566 | if(my @Types = keys(%Type)) 567 | { 568 | if($#Types==0) { 569 | return $Types[0]; 570 | } 571 | } 572 | return "unknown"; 573 | } 574 | 575 | sub getMajor($$) 576 | { 577 | my ($V, $L) = @_; 578 | 579 | $V=~s/[\-_]/./g; 580 | 581 | my @P = split(/\./, $V); 582 | 583 | if($#P>=$L) { 584 | return join(".", splice(@P, 0, $L)); 585 | } 586 | return $V; 587 | } 588 | 589 | sub getVerNum($$) 590 | { 591 | my ($V, $N) = @_; 592 | 593 | $V=~s/[\-_]/./g; 594 | 595 | my @P = split(/\./, $V); 596 | 597 | return $P[$N-1]; 598 | } 599 | 600 | sub getVDepth($) { 601 | return $_[0]=~tr!\.!!; 602 | } 603 | 604 | return 1; 605 | -------------------------------------------------------------------------------- /modules/Internals/Input.pm: -------------------------------------------------------------------------------- 1 | ################################################################## 2 | # A module to handle input data 3 | # 4 | # Copyright (C) 2018 Andrey Ponomarenko's ABI Laboratory 5 | # 6 | # Written by Andrey Ponomarenko 7 | # 8 | # This library is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU Lesser General Public 10 | # License as published by the Free Software Foundation; either 11 | # version 2.1 of the License, or (at your option) any later version. 12 | # 13 | # This library is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public 19 | # License along with this library; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 | # MA 02110-1301 USA 22 | ################################################################## 23 | package In; 24 | 25 | # Input options 26 | our %Opt; 27 | 28 | return 1; 29 | --------------------------------------------------------------------------------