CPAN-SQLite-0.220/000755 000766 000024 00000000000 14327144611 013533 5ustar00strostaff000000 000000 CPAN-SQLite-0.220/INSTALL000644 000766 000024 00000000620 14327144611 014562 0ustar00strostaff000000 000000 This package requires the following Perl modules: File::Spec Archive::Tar IO::Zlib CPAN::DistnameInfo DBD::SQLite File::HomeDir Installation follows the standard perl Makefile.PL $MAKE $MAKE test $MAKE install or, if Module::Build is available, perl Build.PL perl Build perl Build test perl Build install See the README file for a quick overview of the useage. CPAN-SQLite-0.220/LICENSE000644 000766 000024 00000043672 14327144611 014554 0ustar00strostaff000000 000000 This software is copyright (c) 2022 by Serguei Trouchelle. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2022 by Serguei Trouchelle. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2022 by Serguei Trouchelle. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End CPAN-SQLite-0.220/bin/000755 000766 000024 00000000000 14327144611 014303 5ustar00strostaff000000 000000 CPAN-SQLite-0.220/Changes000644 000766 000024 00000016563 14327144611 015041 0ustar00strostaff000000 000000 Revision history for Perl extension CPAN::SQLite. 0.220 October 29, 2022 - Fixed a test failure (RT#140735) 0.219 May 30, 2020 - More FP protections 0.218 May 27, 2020 - Make Test::Memory::Cycle test optional - Modified the dot-cpan directory for t/0[234]* - Added a FP protection again one particular crappy cpan tester 0.217 Jan 29, 2019 - Updated HTTP::Tiny prerequisite to make it working with proxy auth - Removed search limits (RT#128387) 0.216 Jan 24, 2019 - Fixed test problems in Perl 5.8 0.215 Jan 23, 2019 - Weaken some references to avoid memory leaks 0.214 Jan 4, 2019 - Removed 03modlist-related code as that file is not updated anymore - Made sure tests pass when CPAN_SQLITE_DOWNLOAD variable is set 0.213 Jan 3, 2019 - Added ability to download precompiled database to save even more memory/CPU 0.212 Aug 3, 2018 - Fixed a long-standing bug with missing CPAN::Shell on some systems 0.211 Jul 14, 2015 - Fixed t/06retrieve.t by using predefined CPAN urllist 0.210 Jul 11, 2015 - Moved from LWP::Simple to HTTP::Tiny 0.209 Jul 8, 2015 - Removed some additional tests that don't work well on 5.6.2 - Better handling of parallel testing 0.208 Jul 5, 2015 - Got rid of [AssertOS] 0.207 Jul 4, 2015 - Detect HARNESS_OPTIONS and bail out - Back to Dist::Zilla 0.206 Jun 29, 2015 - No more Module::Build - Fixed test failures on Windows - Typo fixed RT#86588: https://rt.cpan.org/Public/Bug/Display.html?id=86588 (reported by David Steinbrunner) 0.205 Nov 22, 2014 - Fixed test failures 0.204 Aug 04, 2014 - Fixed problem with locked database in DBD::SQLite 1.38_01 and higher RT#90635: https://rt.cpan.org/Ticket/Display.html?id=90635 (reported by Alexandr Ciornii) 0.203 Jun 29, 2013 - Automatically cleanup log files older than 30 days. Use CPAN_SQLITE_LOG_FILES_CLEANUP environment variable to override. RT#76943: https://rt.cpan.org/Ticket/Update.html?id=76943 (reported by Nigel Horne) See also RT#36411 - Fixed POD RT#83818 :https://rt.cpan.org/Ticket/Display.html?id=83818 (reported by Alceu Rodrigues de Freitas Junior) - Added additional checks to make sure cpandb.sql is correctly populated RT#64628: https://rt.cpan.org/Ticket/Display.html?id=64628 RT#71323: https://rt.cpan.org/Ticket/Display.html?id=71323 RT#76197: https://rt.cpan.org/Ticket/Display.html?id=76197 (reported by Slaven Rezic, Alexandr Ciornii, Randy Stauner) - Tests updated - "base" replaced with "parent" - Minor tweaks 0.202 Jun 25, 2011 - Fixed test configuration which caused problems on Cygwin - Added CPAN root directory creation in case it's missing 0.201 Jun 16, 2011 - Fixed problem with 3-argument open with '>&' on 5.6.2 - Updated repository link 0.200 Jun 11, 2011 - SQLite REGEXP is used instead of custom function to prevent "Use of uninitialized value $x in pattern match" warning in modern Perl versions RT#67442: https://rt.cpan.org/Ticket/Display.html?id=67442 (reported by Mike Doherty) - "warn"s are replaced with $CPAN::FrontEnd calls RT#59691: https://rt.cpan.org/Ticket/Display.html?id=59691 (reported by Randy J. Ray) 0.199 Dec 29, 2009 - require CPAN::DistnameInfo 0.09, which normalizes dist() for CGI.pm (reported by Pete Armstrong) 0.198 Sep 19, 2009 - CPAN::SQLite::DBI::Index had an extra right parenthesis (reported by Alexey Borzenkov) - CPAN::SQLite::META braces bug in oneliner; see http://rt.cpan.org/Ticket/Display.html?id=47353 - add Compress:Zib dependency; see http://rt.cpan.org/Ticket/Display.html?id=45783 - better error reporting in cases where index files aren't fetched; see http://rt.cpan.org/Ticket/Display.html?id=47322 0.197 Feb 16, 2009 - add LWP::Simple to prerequisites of Build.PL, to help CPAN testers: http://www.cpantesters.org/show/CPAN-SQLite.html#CPAN-SQLite-0.196 0.196 June 6, 2008 - turn off creation of log files during indexing procedures via setting $ENV{CPAN_SQLITE_NO_LOG_FILES}, as suggested by DAGOLDEN: http://rt.cpan.org/Ticket/Display.html?id=36411 0.195 Feb 16, 2008 - fix further bugs where sometimes a regex search for distributions and/or modules, followed by a distribution search for a specific distribution, didn't properly populate the CONTAINSMODS field - add CPAN::Shell->reload('index') in the t/05meta.t test to ensure the database is created, and test that it has non-zero size - fix bug where sometimes a regex module search, followed by a distribution search for a specific distribution, didn't properly set the abstract and version fields - fix bug in t/05meta_*.t tests so as to correctly compare modules in a distribution. - honour $Config::CPAN->{index_expire} to decide when to update the database - improved error checking for the exisitence of the database, including also a check on the size, if it exists, when deciding whether to update or create the database. 0.19 Feb 3, 2008 - fix bug whereby a query for a module, followed by a query for the distribution containing that module, would only list the module first queried for CONTAINSMODS - fix (hopefully) failing tests on Darwin: http://rt.cpan.org/Ticket/Display.html?id=28890 resulting from CPAN::MyConfig not getting picked up from PERL5LIB (thanks to Michael Schwern and David Wheeler) - have information messages printed out only if CPAN_SQLITE_DEBUG is set, as requested at http://rt.cpan.org/Ticket/Display.html?id=32740 (thanks to ZOFFIX) 0.18 Aug 15, 2007 - as some older versions of DBD::SQLite don't support "drop table if exists $table", use an alternate construction - add vcmp function in TestSQL.pm to test equality of versions - when testing with CPAN.pm, remove the database file before testing 0.15 July 26, 2007 - add a message of when the database was last updated: http://rt.cpan.org/Ticket/Display.html?id=27953 - don't ignore a previously set PERL5LIB in the tests: http://rt.cpan.org/Ticket/Display.html?id=28297 0.1 Feb 17, 2007 - first non-developer release; no code changes from 0.1_04 0.1_04 Jan 11, 2007 - improve diagnostics of some of the tests using Test::More - check that we loaded the correct CPAN::Config in 05meta.t (test suggested by Andreas Koenig) - add auto_commit variable to the test's CPAN::Config, so as to work with CPAN.pm 1.88_69 0.1_03 Dec 31, 2006 - in the t/05meta.t test, remove an underscore from the version strings, as older versions of CPAN::Version seem to have problems comparing versions with underscores. - don't try to update database if a $db_name-journal file exists, indicating another process is updating the database - in a regex search for Bundles within CPAN::SQLite::META, don't prepend 'Bundle' if special regex characters are present, to help in tab completion of Bundles within CPAN.pm - get tab completion within CPAN.pm working 0.1_02 Dec 21, 2006 - change name of database to cpandb.sql, and make it fixed, as there was little need to have it configureable. - support cpan> d ANDK/CPAN-xxx.tar.gz for distributions. - fixes to handle Bundle ids - undef $sth after an $sth->finish, to help with concurrent access - when using Test::More, use is(), rather than ok() 0.1_01 Dec 12, 2006 - initial version, derived from a minimal version of CPAN::Search::Lite CPAN-SQLite-0.220/MANIFEST000644 000766 000024 00000001273 14327144611 014667 0ustar00strostaff000000 000000 bin/cpandb INSTALL lib/CPAN/SQLite.pm lib/CPAN/SQLite/DBI.pm lib/CPAN/SQLite/DBI/Index.pm lib/CPAN/SQLite/DBI/Search.pm lib/CPAN/SQLite/Index.pm lib/CPAN/SQLite/Info.pm lib/CPAN/SQLite/META.pm lib/CPAN/SQLite/Populate.pm lib/CPAN/SQLite/Search.pm lib/CPAN/SQLite/State.pm lib/CPAN/SQLite/Util.pm Makefile.PL MANIFEST This list of files README Changes t/01basic.t t/02drop.t t/03info.t t/04search.t t/04search_everything.t t/05meta_new.t t/05meta_update.t t/06retrieve.t t/07download.t t/08circular_references.t t/cpan/authors/01mailrc.txt.gz t/cpan/modules/02packages.details.txt.gz t/dot-cpan/CPAN/TestConfig.pm t/lib/TestShell.pm t/lib/TestShellDiag.pm t/lib/TestSQL.pm t/testrules.yml CPAN-SQLite-0.220/t/000755 000766 000024 00000000000 14327144611 013776 5ustar00strostaff000000 000000 CPAN-SQLite-0.220/README000644 000766 000024 00000005546 14327144611 014425 0ustar00strostaff000000 000000 This is the README for CPAN::SQLite, which is used for setting up, maintaining, and searching through a local CPAN database consisting of information in the three main CPAN index files: $CPAN/modules/03modlist.data.gz $CPAN/modules/02packages.details.txt.gz $CPAN/authors/01mailrc.txt.gz DBD::SQLite is used as the database engine. Installation proceeds through the usual perl Makefile.PL $MAKE $MAKE test $MAKE install or, if Module::Build is available, perl Build.PL perl Build perl Build test perl Build install The package consists of a number of modules: CPAN::SQLite: the top-level package CPAN::SQLite::Index: set up and maintain the database CPAN::SQLite::Info: extract information from the CPAN indices CPAN::SQLite::META: helper module for CPAN.pm integration CPAN::SQLite::State: gather information on the state of the database CPAN::SQLite::Search: methods to search the database CPAN::SQLite::Populate: populate the database tables CPAN::SQLite::DBI: DBI information for the database CPAN::SQLite::DBI::Index: DBI information for indexing the database CPAN::SQLite::DBI:Search: DBI information for searching the database See the pod documentation of the specific modules for details. Perhaps the easiest way to set up and maintain the database is through the supplied cpandb script. If we assume that there is a CPAN.pm client available and configured, the database can be created via cpandb --setup which will create the database file cpandb.sql under the "cpan_home" defined in CPAN::Config (this is the same location as where CPAN.pm's Metadata is found). Subsequent updates to the database can be done through cpandb --update This scenario assumes that updates to the CPAN index files are handled by CPAN.pm. The cpandb script also provides some elementary searches: cpandb --module My::Module cpandb --dist My-Dist cpandb --cpanid ME which will provide some information on, respectively, the specified CPAN module, distribution, and CPAN author id. The query terms are assumed to match exactly, and are case-insensitive. As of CPAN.pm version 1.88_65, there is experimental support within CPAN.pm for using CPAN::SQLite to obtain information on packages, modules, and authors. One goal of this is to reduce the memory footprint of the CPAN.pm shell, as this information is no longer all preloaded into memory. This can be enabled through perl -MCPAN -e shell cpan> o conf use_sqlite 1 This version is considered alpha. Please report bugs and feature requests to CPAN's request tracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-SQLite or directly to the author. Development takes place at http://cpan-search.svn.sourceforge.net/viewvc/cpan-search/CPAN-SQLite/ This software is copyright 2006,2008 by Randy Kobes . Use and redistribution are under the same terms as Perl itself. CPAN-SQLite-0.220/META.yml000644 000766 000024 00000002232 14327144611 015003 0ustar00strostaff000000 000000 --- abstract: 'maintain and search a minimal CPAN database' author: - 'Serguei Trouchelle ' build_requires: CPAN::HandleConfig: '0' CPAN::Version: '0' Carp: '0' DBD::SQLite: '0' ExtUtils::MakeMaker: '0' File::Copy: '0' File::Spec: '0' FindBin: '0' IO::Handle: '0' IPC::Open3: '0' Test::More: '0.94' base: '0' lib: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.025, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: CPAN-SQLite requires: CPAN: '0' CPAN::DistnameInfo: '0' Compress::Zlib: '0' Cwd: '0' DBI: '0' English: '0' Exporter: '0' File::Basename: '0' File::Find: '0' File::HomeDir: '0' File::Path: '0' File::Spec: '0' File::Spec::Functions: '0' Getopt::Long: '0' HTTP::Tiny: '0' Safe: '0' Scalar::Util: '0' constant: '0' parent: '0' strict: '0' utf8: '0' warnings: '0' version: '0.220' x_generated_by_perl: v5.36.0 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' CPAN-SQLite-0.220/lib/000755 000766 000024 00000000000 14327144611 014301 5ustar00strostaff000000 000000 CPAN-SQLite-0.220/Makefile.PL000644 000766 000024 00000004700 14327144611 015506 0ustar00strostaff000000 000000 # $Id: Makefile.PL 84 2020-05-31 06:29:34Z stro $ use strict; use warnings; use ExtUtils::MakeMaker; my %broken_smokers_roots = map { $_ => 1 } ( '/home/opc/perl5/perlbrew', '/home/njh/perl5/perlbrew', ); if ($ENV{'PERLBREW_ROOT'} && $broken_smokers_roots{ $ENV{'PERLBREW_ROOT'} }) { my $honest_answer = ExtUtils::MakeMaker::prompt('This smoker setup is most definitely broken and the author is tired of FP. Please type "Yes. I swear I fixed it. Please continue." to continue: '); unless ($honest_answer and $honest_answer eq 'Yes. I swear I fixed it. Please continue.') { print 'Kthxbye', $/; exit 0; } } my @exe_files = map {"bin/$_"} qw(cpandb); my $goners = join ' ', qw( cpandb.sql t/dot-cpan/cpandb.sql t/dot-cpan/FTPstats.yml t/dot-cpan/CPAN/MyConfig.pm t/dot-cpan/cpan_sqlite_log.* t/dot-cpan/sources/authors/01mailrc.txt.gz t/dot-cpan/sources/modules/02packages.details.txt.gz t/dot-cpan/sources/modules/03modlist.data.gz t/cpan-t-06/* t/cpan-t-07/* t/cpan-t-08/* ); my %opts = ( 'NAME' => 'CPAN::SQLite', 'VERSION_FROM' => 'lib/CPAN/SQLite.pm', 'EXE_FILES' => \@exe_files, 'PL_FILES' => {}, 'dist' => { 'SUFFIX' => 'gz', 'COMPRESS' => 'gzip -9f', }, 'clean' => { 'FILES' => $goners }, ); my $eu_version = $ExtUtils::MakeMaker::VERSION; $eu_version =~ s/_//msgx; if ($eu_version >= 5.43) { %opts = (%opts, 'ABSTRACT_FROM' => 'lib/CPAN/SQLite.pm', 'AUTHOR' => 'Serguei Trouchelle ', ); } my $prereqs = { 'File::Spec' => 0, 'Archive::Tar' => 1.54, 'IO::Zlib' => 0, 'Compress::Zlib' => 0, 'CPAN::DistnameInfo' => 0.09, 'DBD::SQLite' => 1.27, # for REGEXP implementation 'File::HomeDir' => 0, 'HTTP::Tiny' => 0.041, 'CPAN::Index' => 1.93, # No more false negatives because of CPAN-Index 'parent' => 0, }; my $test_prereqs = { }; if ($ENV{'HARNESS_OPTIONS'}) { # Parallel testing requires Test::Harness 3.31 $prereqs->{'Test::Harness'} = 3.31; } if ($eu_version >= '6.64') { %opts = (%opts, 'PREREQ_PM' => $prereqs, 'TEST_REQUIRES' => $test_prereqs, ); } else { %opts = (%opts, 'PREREQ_PM' => { %{$prereqs}, %{$test_prereqs} }, ); } WriteMakefile( %opts ); CPAN-SQLite-0.220/META.json000644 000766 000024 00000004740 14327144611 015161 0ustar00strostaff000000 000000 { "abstract" : "maintain and search a minimal CPAN database", "author" : [ "Serguei Trouchelle " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.025, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "CPAN-SQLite", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::CPAN::Meta" : "0", "Test::CPAN::Meta::JSON" : "0.16", "Test::EOL" : "0", "Test::Kwalitee" : "1.21", "Test::MinimumVersion" : "0", "Test::More" : "0.88", "Test::NoTabs" : "0", "Test::PAUSE::Permissions" : "0", "Test::Perl::Critic" : "0", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "CPAN" : "0", "CPAN::DistnameInfo" : "0", "Compress::Zlib" : "0", "Cwd" : "0", "DBI" : "0", "English" : "0", "Exporter" : "0", "File::Basename" : "0", "File::Find" : "0", "File::HomeDir" : "0", "File::Path" : "0", "File::Spec" : "0", "File::Spec::Functions" : "0", "Getopt::Long" : "0", "HTTP::Tiny" : "0", "Safe" : "0", "Scalar::Util" : "0", "constant" : "0", "parent" : "0", "strict" : "0", "utf8" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "CPAN::HandleConfig" : "0", "CPAN::Version" : "0", "Carp" : "0", "DBD::SQLite" : "0", "ExtUtils::MakeMaker" : "0", "File::Copy" : "0", "File::Spec" : "0", "FindBin" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0.94", "base" : "0", "lib" : "0" } } }, "release_status" : "stable", "version" : "0.220", "x_generated_by_perl" : "v5.36.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.32", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } CPAN-SQLite-0.220/lib/CPAN/000755 000766 000024 00000000000 14327144611 015022 5ustar00strostaff000000 000000 CPAN-SQLite-0.220/lib/CPAN/SQLite.pm000644 000766 000024 00000024465 14327144611 016534 0ustar00strostaff000000 000000 # $Id: SQLite.pm 85 2022-10-29 05:44:36Z stro $ package CPAN::SQLite; use strict; use warnings; our $VERSION = '0.220'; use English qw/-no_match_vars/; use File::HomeDir; require File::Spec; use Cwd; require CPAN::SQLite::META; # an array ref of distributions to ignore indexing my $ignore = [qw(SpreadSheet-WriteExcel-WebPivot)]; our $db_name = 'cpandb.sql'; use constant WIN32 => $^O eq 'MSWin32'; sub new { my $class = shift; my %args = @_; my ($CPAN, $update_indices); my $db_dir = $args{db_dir}; my $urllist = []; my $keep_source_where; # for testing under Darwin, must load CPAN::MyConfig contained # in PERL5LIB, as File::HomeDir doesn't use this if ($ENV{CPAN_SQLITE_TESTING}) { eval { require CPAN::MyConfig; }; } eval { require CPAN; CPAN::HandleConfig->load; }; if (not $@ and not defined $args{CPAN}) { $CPAN = $CPAN::Config->{cpan_home}; $db_dir = $CPAN; $keep_source_where = $CPAN::Config->{keep_source_where}; $urllist = $CPAN::Config->{urllist}; # Sometimes this directory doesn't exist (like on new installations) unless (-d $CPAN) { eval { File::Path::mkpath($CPAN); }; # copied from CPAN.pm } die qq{The '$CPAN' directory doesn't exist} unless -d $CPAN; $update_indices = 0; } else { $CPAN = $args{CPAN} || ''; die qq{Please specify the CPAN location} unless defined $CPAN; die qq{The '$CPAN' directory doesn't exist} unless (-d $CPAN); $update_indices = (-f File::Spec->catfile($CPAN, 'MIRRORING.FROM')) ? 0 : 1; } push @$urllist, q{http://www.cpan.org/}; $db_dir ||= cwd; my $self = { %args, CPAN => $CPAN, update_indices => $update_indices, db_name => $db_name, urllist => $urllist, keep_source_where => $keep_source_where, db_dir => $db_dir }; return bless $self, $class; } sub index { my ($self, %args) = @_; require CPAN::SQLite::Index; my %wanted = map { $_ => $self->{$_} } qw(CPAN ignore update_indices db_name db_dir keep_source_where setup reindex urllist); my $log_dir = $self->{CPAN} || $self->{db_dir}; die qq{Please create the directory '$log_dir' first} unless -d $log_dir; my $index = CPAN::SQLite::Index->new(%wanted, %args, log_dir => $log_dir); $index->index() or do { warn qq{Indexing failed!}; return; }; return 1; } sub query { my ($self, %args) = @_; require CPAN::SQLite::Search; my %wanted = map { $_ => $self->{$_} } qw(max_results CPAN db_name db_dir meta_obj); my $query = CPAN::SQLite::Search->new(%wanted, %args); %wanted = map { $_ => $self->{$_} } qw(mode query id name); $query->query(%wanted, %args) or do { warn qq{Query failed!}; return; }; my $results = $query->{results}; return unless defined $results; $self->{results} = $query->{results}; return 1; } 1; =head1 NAME CPAN::SQLite - maintain and search a minimal CPAN database =head1 VERSION version 0.220 =head1 SYNOPSIS my $obj = CPAN::SQLite->new(CPAN => '/path/to/CPAN'); $obj->index(setup => 1); $obj->query(mode => 'dist', name => 'CPAN'); my $results = $obj->{results}; =head1 DESCRIPTION This package is used for setting up, maintaining, and searching a CPAN database consisting of the information stored in the two main CPAN indices: F<$CPAN/modules/02packages.details.txt.gz> and F<$CPAN/authors/01mailrc.txt.gz>. It should be considered at an alpha stage of development. One begins by creating the object as my $obj = CPAN::SQLite->new(%args); which accepts the following arguments: =over 3 =item * C '/path/to/CPAN'> This specifies the path to where the index files are to be stored. This could be a local CPAN mirror, defined here by the presence of a F file beneath this directory, or a local directory in which to store these files from a remote CPAN mirror. In the latter case, the index files are fetched from a remote CPAN mirror, using the same list that C uses, if this is configured, and are updated if they are more than one day old. If the C option is not given, it will default to C of L, if this is configured, with the index files found under C. A fatal error results if such a directory isn't found. Updates to these index files are assumed here to be handled by C. =item * C '/path/to/db/dir'> This specifies the path to where the database file is found. If not given, it defaults to the C directory of C, if present, or to the directory in which the script was invoked. The name of the database file is C. =back There are two main methods available. =head2 C<$obj-Eindex(%args);> This is used to set up and maintain the database. The following arguments are accepted: =over 3 =item * setup =E 1 This specifies that the database is to be created and populated from the CPAN indices; any existing database will be overwritten. Not specifying this option will assume that an existing database is to be updated. =item * reindex =E 'dist_name' This specifies that the CPAN distribution C is to be reindexed. =back =head2 C<$obj-Equery(%args);> This is used for querying the database by distribution name, module name, or CPAN author name. There are two arguments needed to specify such queries. =over 3 =item * C some_value> This specifies what type of query to perform, with C being one of C, C, or C, for searching through, respectively, CPAN distribution names, module names, or author names and CPAN ids. =item * C query_term> This specifies the query term for the search, with C being one of C, to search for an exact match, or C, for searching for partial matches. Perl regular expressions are supported in the C for the C option. =back As well, an option of C some_number> will limit the number of results returned; if not specified, the limit doesn't apply. =head1 CPAN.pm support As of CPAN.pm version 1.88_65, there is experimental support within CPAN.pm for using CPAN::SQLite to obtain information on packages, modules, and authors. One goal of this is to reduce the memory footprint of the CPAN.pm shell, as this information is no longer all preloaded into memory. This can be enabled through perl -MCPAN -e shell cpan> o conf use_sqlite 1 Use cpan> o conf commit to save this setting for future sessions. Using CPAN::SQLite, what happens is that a request for information through CPAN.pm, such as cpan> a ANDK will cause a query to the SQLite database to be made. If successful, this will place the relevant data for this request into the data structure CPAN.pm uses to store and retrieve such information. Thus, at any given time, the only information CPAN.pm stores in memory is that for packages, modules, and authors for which previous queries have been made. There are certain requests, such as cpan> r to make a list of recommended packages for which upgrades on CPAN are available, which will result in loading information on all available packages into memory; if such a query is made, the subsequent memory footprint of CPAN.pm with and without CPAN::SQLite will be essentially the same. The database itself, called F, will be stored in the location specified by C<$CPAN::Config-E{cpan_home}>. When first started, this database will be created, and afterwards, it will be updated if the database is older than one day since the last update. A log file of the creation or update process, called F, will be created in the same directory as the database file. =head1 SEE ALSO L, for setting up and maintaining the database, and L for an interface to querying the database. Some details of the interaction with L is available from L. See also the L script for a command-line interface to the indexing and querying of the database. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc CPAN::SQLite You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN::Forum: Discussion forum L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 BUGS At this time, CPAN::SQLite keeps information contained only in the latest version of a CPAN distribution. This means that modules that are provided only in older versions of a CPAN distribution will not be present in the database; for example, at this time, the latest version of the I distribution on CPAN is 5.805, but there are modules such as I contained in version 5.10 of libwww-perl that are not present in 5.805. This behaviour differs from that of L without CPAN::SQLite. This may change in the future. Please report bugs and feature requests via L. =head1 ENVIRONMENT VARIABLES Information messages from the indexing procedures are printed out to STDOUT if the environment variable CPAN_SQLITE_DEBUG is set. This is automatically set within L. If CPAN_SQLITE_NO_LOG_FILES is set, no log files will be created during the indexing procedures. Log files are deleted automatically in 30 days. To override this, set CPAN_SQLITE_LOG_FILES_CLEANUP. To stop automatic cleanup, set this variable to 0. If CPAN_SQLITE_DOWNLOAD variable are set, an already existing and up-to-date cpandb.sql file will be downloaded from http://cpansqlite.trouchelle.com/ where it's updated every hour. This greatly increases performance and decreases CPU and memory consumption during the indexing process. See L for more details, potential problems, and more configuration options. =head1 AUTHORS Randy Kobes (passed away on September 18, 2010) Serguei Trouchelle Estro@cpan.orgE =head1 COPYRIGHT Copyright 2006,2008 by Randy Kobes Er.kobes@uwinnipeg.caE. Copyright 2011-2014 by Serguei Trouchelle Estro@cpan.orgE. Use and redistribution are under the same terms as Perl itself. =cut CPAN-SQLite-0.220/lib/CPAN/SQLite/000755 000766 000024 00000000000 14327144611 016163 5ustar00strostaff000000 000000 CPAN-SQLite-0.220/lib/CPAN/SQLite/DBI.pm000644 000766 000024 00000007527 14327144611 017132 0ustar00strostaff000000 000000 # $Id: DBI.pm 85 2022-10-29 05:44:36Z stro $ package CPAN::SQLite::DBI; use strict; use warnings; our $VERSION = '0.220'; use English qw/-no_match_vars/; require File::Spec; use DBI; use parent 'Exporter'; our ($dbh, $tables, @EXPORT_OK); @EXPORT_OK = qw($dbh $tables); $tables = { 'info' => { 'primary' => { 'status' => q!INTEGER NOT NULL PRIMARY KEY!, }, 'other' => {}, 'key' => [], 'name' => 'status', 'id' => 'status', }, mods => { primary => { mod_id => q{INTEGER NOT NULL PRIMARY KEY} }, other => { mod_name => q{VARCHAR(100) NOT NULL}, dist_id => q{INTEGER NOT NULL}, mod_abs => q{TEXT}, mod_vers => q{VARCHAR(10)}, }, key => [qw/dist_id mod_name/], name => 'mod_name', id => 'mod_id', has_a => { dists => 'dist_id' }, }, dists => { primary => { dist_id => q{INTEGER NOT NULL PRIMARY KEY} }, other => { dist_name => q{VARCHAR(90) NOT NULL}, auth_id => q{INTEGER NOT NULL}, dist_file => q{VARCHAR(110) NOT NULL}, dist_vers => q{VARCHAR(20)}, dist_abs => q{TEXT}, }, key => [qw/auth_id dist_name/], name => 'dist_name', id => 'dist_id', has_a => { auths => 'auth_id' }, has_many => { mods => 'dist_id', }, }, auths => { primary => { auth_id => q{INTEGER NOT NULL PRIMARY KEY} }, other => { cpanid => q{VARCHAR(20) NOT NULL}, fullname => q{VARCHAR(40) NOT NULL}, email => q{TEXT}, }, key => [qw/cpanid/], has_many => { dists => 'dist_id' }, name => 'cpanid', id => 'auth_id', }, }; sub new { my ($class, %args) = @_; my $db_dir = $args{db_dir} || $args{CPAN}; my $db = File::Spec->catfile($db_dir, $args{db_name}); $dbh ||= DBI->connect( "DBI:SQLite:$db", '', '', { RaiseError => 1, AutoCommit => 0, sqlite_use_immediate_transaction => 0, }); die "Cannot connect to $db" unless $dbh; $dbh->{AutoCommit} = 0; my $objs; foreach my $table (keys %$tables) { my $cl = $class . '::' . $table; $objs->{$table} = $cl->make(table => $table); } for my $table (keys %$tables) { foreach my $type (qw(primary other)) { foreach my $column (keys %{ $tables->{$table}->{$type} }) { push @{ $tables->{$table}->{columns} }, $column; } } } return bless { objs => $objs }, $class; } sub make { my ($class, %args) = @_; my $table = $args{table}; die qq{No table exists corresponding to '$class'} unless $table; my $info = $tables->{$table}; die qq{No information available for table '$table'} unless $info; my $self = { table => $table, columns => $info->{columns}, id => $info->{id}, name => $info->{name}, }; foreach (qw(name has_a has_many)) { next unless defined $info->{$_}; $self->{$_} = $info->{$_}; } return bless $self, $class; } sub db_error { my ($obj, $sth) = @_; return unless $dbh; if ($sth) { $sth->finish; undef $sth; } return $obj->{error_msg} = q{Database error: } . $dbh->errstr; } 1; =head1 NAME CPAN::SQLite::DBI - DBI information for the CPAN::SQLite database =head1 VERSION version 0.220 =head1 DESCRIPTION This module is used by L and L to set up some basic database information. It exports two variables: =over 3 =item C<$tables> This is a hash reference whose keys are the table names, with corresponding values being hash references whose keys are the columns of the table and values being the associated data types. =item C<$dbh> This is a L database handle used to connect to the database. =back The main method of this module is C, which is used to make the tables of the database. =head1 SEE ALSO L and L =cut CPAN-SQLite-0.220/lib/CPAN/SQLite/Index.pm000644 000766 000024 00000023310 14327144611 017567 0ustar00strostaff000000 000000 # $Id: Index.pm 85 2022-10-29 05:44:36Z stro $ package CPAN::SQLite::Index; use strict; use warnings; our $VERSION = '0.220'; use English qw/-no_match_vars/; use CPAN::SQLite::Info; use CPAN::SQLite::State; use CPAN::SQLite::Populate; use CPAN::SQLite::DBI qw($tables); use File::Spec::Functions qw(catfile); use File::Basename; use File::Path; use HTTP::Tiny; use Scalar::Util 'weaken'; unless ($ENV{CPAN_SQLITE_NO_LOG_FILES}) { $ENV{CPAN_SQLITE_DEBUG} = 1; } our ($oldout); my $log_file = 'cpan_sqlite_log.' . time; # This is usually already defined in real life, but tests need it to be set $CPAN::FrontEnd ||= "CPAN::Shell"; sub new { my ($class, %args) = @_; if ($args{setup} and $args{reindex}) { die "Reindexing must be done on an exisiting database"; } my $self = { index => undef, state => undef, %args }; return bless $self, $class; } sub download_index { my $self = shift; if ($ENV{'CPAN_SQLITE_DOWNLOAD'}) { $ENV{'CPAN_SQLITE_DOWNLOAD_URL'} = 'http://cpansqlite.trouchelle.com/' unless $ENV{'CPAN_SQLITE_DOWNLOAD_URL'}; } return 0 unless $ENV{'CPAN_SQLITE_DOWNLOAD_URL'}; $CPAN::FrontEnd->myprint("Downloading the compiled index db ... "); if (my $response = HTTP::Tiny->new->mirror($ENV{'CPAN_SQLITE_DOWNLOAD_URL'} => catfile($self->{'db_dir'}, $self->{'db_name'}))) { if ($response->{'success'} and $response->{'status'} and $response->{'status'} eq '200') { if (my $type = $response->{'headers'}->{'content-type'}) { if ($type eq 'application/x-sqlite3') { return 1; } } } } $CPAN::FrontEnd->mywarn('Cannot download the compiled index db'); return 0; } sub index { my $self = shift; my $setup = $self->{'setup'}; if ($setup) { my $db_name = catfile($self->{'db_dir'}, $self->{db_name}); if (-f $db_name) { $CPAN::FrontEnd->myprint("Removing existing $db_name ... "); if (unlink $db_name) { $CPAN::FrontEnd->myprint("Done.\n"); } else { $CPAN::FrontEnd->mywarn("Failed: $!\n"); } } } my $log = catfile($self->{'log_dir'}, $log_file); unless ($ENV{'CPAN_SQLITE_NO_LOG_FILES'}) { $oldout = error_fh($log); } my $log_cleanup = $ENV{'CPAN_SQLITE_LOG_FILES_CLEANUP'}; $log_cleanup = 30 unless defined $log_cleanup; if ($log_cleanup and $log_cleanup =~ /^\d+$/) { if (opendir(my $DIR, $self->{'log_dir'})) { my @files = grep { /cpan_sqlite_log\./ } readdir $DIR; closedir $DIR; @files = grep { -C $_ > $log_cleanup } map { catfile($self->{'log_dir'}, $_) } @files; if (@files) { $CPAN::FrontEnd->myprint('Cleaning old log files ... '); unlink @files; $CPAN::FrontEnd->myprint("Done.\n"); } } } if ($self->download_index()) { return 1; } if ($self->{'update_indices'}) { $CPAN::FrontEnd->myprint('Fetching index files ... '); if ($self->fetch_cpan_indices()) { $CPAN::FrontEnd->myprint("Done.\n"); } else { $CPAN::FrontEnd->mywarn("Failed\n"); return; } } $CPAN::FrontEnd->myprint('Gathering information from index files ... '); if ($self->fetch_info()) { $CPAN::FrontEnd->myprint("Done.\n"); } else { $CPAN::FrontEnd->mywarn("Failed\n"); return; } unless ($setup) { $CPAN::FrontEnd->myprint('Obtaining current state of database ... '); if ($self->state()) { $CPAN::FrontEnd->myprint("Done.\n"); } else { $CPAN::FrontEnd->mywarn("Failed\n"); return; } } $CPAN::FrontEnd->myprint('Populating database tables ... '); if ($self->populate()) { $CPAN::FrontEnd->myprint("Done.\n"); } else { $CPAN::FrontEnd->mywarn("Failed\n"); return; } return 1; } sub fetch_cpan_indices { my $self = shift; my $CPAN = $self->{CPAN}; my $indices = { '01mailrc.txt.gz' => 'authors', '02packages.details.txt.gz' => 'modules', }; foreach my $index (keys %$indices) { my $file = catfile($CPAN, $indices->{$index}, $index); next if (-e $file and -M $file < 1); my $dir = dirname($file); unless (-d $dir) { mkpath($dir, 0, oct(755)) or die "Cannot mkpath $dir: $!"; } my @urllist = @{ $self->{urllist} }; foreach my $cpan (@urllist) { my $from = join '/', ($cpan, $indices->{$index}, $index); if (my $response = HTTP::Tiny->new->get($from)) { if ($response->{'success'}) { if (open(my $FILE, '>', $file)) { binmode $FILE; print $FILE $response->{'content'}; if (close($FILE)) { next; } } } } } unless (-f $file) { $CPAN::FrontEnd->mywarn("Cannot retrieve '$file'"); return; } } return 1; } sub fetch_info { my $self = shift; my %wanted = map { $_ => $self->{$_} } qw(CPAN ignore keep_source_where); my $info = CPAN::SQLite::Info->new(%wanted); $info->fetch_info() or return; my @tables = qw(dists mods auths info); my $index; foreach my $table (@tables) { my $class = __PACKAGE__ . '::' . $table; my $this = { info => $info->{$table} }; $index->{$table} = bless $this, $class; } $self->{index} = $index; return 1; } sub state { my $self = shift; my %wanted = map { $_ => $self->{$_} } qw(db_name index setup reindex db_dir); my $state = CPAN::SQLite::State->new(%wanted); $state->state() or return; $self->{state} = $state; return 1; } sub populate { my $self = shift; my %wanted = map { $_ => $self->{$_} } qw(db_name index setup state db_dir); my $db = CPAN::SQLite::Populate->new(%wanted); $db->populate() or return; return 1; } sub error_fh { my $file = shift; open(my $tmp, '>', $file) or die "Cannot open $file: $!"; close $tmp; # Should be open(my $oldout, '>&', \*STDOUT); but it fails on 5.6.2 open(my $oldout, '>&STDOUT'); open(STDOUT, '>', $file) or die "Cannot tie STDOUT to $file: $!"; select STDOUT; $| = 1; return $oldout; } sub DESTROY { unless ($ENV{CPAN_SQLITE_NO_LOG_FILES}) { close STDOUT; open(STDOUT, '>&', $oldout) if $oldout; } return; } 1; =head1 NAME CPAN::SQLite::Index - set up or update database tables. =head1 VERSION version 0.220 =head1 SYNOPSIS my $index = CPAN::SQLite::Index->new(setup => 1); $index->index(); =head1 DESCRIPTION This is the main module used to set up or update the database tables used to store information from the CPAN and ppm indices. The creation of the object my $index = CPAN::SQLite::Index->new(%args); accepts two possible arguments: =over 3 =item * setup =E 1 This (optional) argument specifies that the database is being set up. Any existing tables will be dropped. =item * reindex =E value This (optional) argument specifies distribution names that one would like to reindex in an existing database. These may be specified as either a scalar, for a single distribution, or as an array reference for a list of distributions. =back =head1 DETAILS Calling $index->index(); will start the indexing procedure. Various messages detailing the progress will written to I, which by default will be captured into a file F, where the extension is the C