Build.PL100644000765000024 45514233174424 16741 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33# ========================================================================= # THIS FILE IS AUTOMATICALLY GENERATED BY MINILLA. # DO NOT EDIT DIRECTLY. # ========================================================================= use 5.008_001; use strict; use Module::Build::Tiny 0.035; Build_PL(); Changes100644000765000024 657014233174424 16764 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33Revision history for Perl extension App::pmuninstall 0.33 2022-04-30T08:53:39Z - Fixed #11 Win32 local_lib path problem (zmughal++) 0.31 2022-04-24T13:02:35Z - Fixed #6 local_lib path problem (perlpunk++) - Fixed #7 Did not work on multiple paths in PERL5LIB (zmughal++) - Fixed #8 Using ExtUtils::Packlist (zmughal++) - Feature #9 Add GitHub Actions workflow (zmughal++) - Changed unnecessary catfile to cannonpath. (zmughal++) 0.30 2013-06-03T14:42:38Z - minil migrate 0.29 Wed Feb 8 17:23:05 2012 - Copy and wording fixes (finn++) 0.28 Wed Dec 7 01:11:32 2011 - fixed issue: https://github.com/xaicron/pm-uninstall/issues/2 (finn++) 0.27 Wed Nov 30 12:55:13 2011 - changed cpanmetadb URL 0.26 Wed Nov 30 02:45:19 2011 - fixed not CPAN module problem (reported by gfx++) - if did not fetch vname then skip check desp. 0.25 Thu Oct 13 16:03:48 2011 - maybe support install.json (from cpanm 1.5000 / miyagawa++) 0.24 Tue Oct 4 15:10:39 2011 - fix is_local_lib() (But, it's called after the setup_local_lib(), no problem) 0.23 Tue Oct 4 01:57:32 2011 - fix broken -l and -L option (rt:71417) - fix doc 0.22 Sat Sep 17 17:10:26 2011 - shorten startup time - fix checking core module logic - fix was gone version option - coloring for Success or Failed message. 0.21 Sun Aug 28 03:01:03 2011 - maybe fixed: cannot be find a XS path problem. (reported by Ben Bullock++) - added --quiet option 0.20 Wed Aug 24 02:19:56 2011 - is_core_module was broken (win32) 0.19 Thu Aug 4 02:52:38 2011 - removed dependency on local::lib (did not work, because latest local::lib had been changed interface.) 0.18 Sun Jun 26 13:20:05 2011 - modularization 0.17 Sat Jun 25 15:06:12 2011 - fixed the dependencies check problem 0.16 Wed Feb 23 01:19:12 2011 - fixe couldn't remove core-modules installed from 'local::lib' or etc... issue (suggested by masartz) 0.15 Fri Dec 3 00:16:50 2010 - suppress warnings for no CPAN module 0.14 Tue Nov 23 01:06:22 2010 - workaround for Windows 0.13 Mon Nov 22 19:25:16 2010 - fixed `-L` option problem (suggested by tokuhirom++) - fixed wrong show dependencies issue (previous version was not corrected) 0.12 Sun Nov 21 16:00:27 2010 - fixed wrong show dependencies issue (report by tokuhirom++) - fixed `-L` option was not working - fixed core-module check issue 0.11 Sun Nov 14 22:39:02 2010 - fixed wrong message issue. (report by punytan++) 0.10 Mon Oct 25 22:10:28 2010 - wrote `-n` about the document 0.09 Mon Oct 25 02:19:36 2010 - fixed syntax error for pod 0.08 Mon Oct 25 00:25:53 2010 - small changes to the document. 0.07 Sun Oct 24 17:56:47 2010 - suppressed uninstall for core-module - show mandb message 0.06 Sun Oct 17 23:16:31 2010 - --checkdeps option default - check core module 0.05 Fri Oct 8 00:36:10 2010 - supported local::lib - rmdir for empty dir 0.04 Fri Aug 6 14:19:52 2010 - wrote document 0.03 Tue Aug 3 01:01:22 2010 - thanks miyagawa-san! 0.01 Wed Mar 10 23:26:16 2010 - original version LICENSE100644000765000024 4365214233174424 16520 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33This software is copyright (c) 2013 by Yuji Shimada. 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) 2013 by Yuji Shimada. 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, Suite 500, Boston, MA 02110-1335 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) 2013 by Yuji Shimada. 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End META.json100644000765000024 446314233174424 17111 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33{ "abstract" : "Uninstall modules", "author" : [ "Yuji Shimada" ], "dynamic_config" : 0, "generated_by" : "Minilla/v3.1.16", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "App-pmuninstall", "no_index" : { "directory" : [ "t", "xt", "inc", "share", "eg", "examples", "author", "builder" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "Module::Build::Tiny" : "0.035" } }, "develop" : { "requires" : { "Test::CPAN::Meta" : "0", "Test::MinimumVersion::Fast" : "0.04", "Test::PAUSE::Permissions" : "0.07", "Test::Perl::Critic" : "0", "Test::Pod" : "1.41", "Test::Spellunker" : "v0.2.7" } }, "runtime" : { "requires" : { "CPAN::DistnameInfo" : "0", "ExtUtils::Install" : "1.43", "ExtUtils::MakeMaker" : "6.3", "HTTP::Tiny" : "0.012", "JSON::PP" : "2.01", "Module::CoreList" : "0", "YAML" : "0", "version" : "0" } } }, "provides" : { "App::pmuninstall" : { "file" : "lib/App/pmuninstall.pm", "version" : "0.33" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/xaicron/pm-uninstall/issues" }, "homepage" : "https://github.com/xaicron/pm-uninstall", "repository" : { "type" : "git", "url" : "https://github.com/xaicron/pm-uninstall.git", "web" : "https://github.com/xaicron/pm-uninstall" } }, "version" : "0.33", "x_contributors" : [ "Finn Smith ", "Finn Smith ", "Tina Mueller ", "Yuji Shimada ", "Yuji Shimada ", "Zakariyya Mughal " ], "x_serialization_backend" : "JSON::PP version 4.06", "x_static_install" : 1 } README.md100644000765000024 257114233174424 16745 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33# NAME App::pmuninstall - Uninstall modules # DESCRIPTION App::pmuninstall is a fast module uninstaller. delete files from **.packlist**. [App::cpanminus](https://metacpan.org/pod/App%3A%3Acpanminus) and, [App::cpanoutdated](https://metacpan.org/pod/App%3A%3Acpanoutdated) with a high affinity. # SYNOPSIS uninstall MODULE $ pm-uninstall App::pmuninstall # OPTIONS - -f, --force Uninstalls without prompts $ pm-uninstall -f App::pmuninstall - -v, --verbose Turns on chatty output $ pm-uninstall -v App::cpnaminus - -c, --checkdeps Check dependencies ( default on ) $ pm-uninstall -c Plack - -n, --no-checkdeps Don't check dependencies $ pm-uninstall -n LWP - -q, --quiet Suppress some messages $ pm-uninstall -q Furl - -h, --help Show help message $ pm-uninstall -h - -V, --version Show version $ pm-uninstall -V - -l, --local-lib Additional module path $ pm-uninstall -l extlib App::pmuninstall - -L, --local-lib-contained Additional module path (don't include non-core modules) $ pm-uninstall -L extlib App::pmuninstall # AUTHOR Yuji Shimada Tatsuhiko Miyagawa # SEE ALSO [pm-uninstall](https://metacpan.org/pod/pm-uninstall) # LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. cpanfile100644000765000024 54014233174424 17144 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33requires 'CPAN::DistnameInfo'; requires 'ExtUtils::Install', '1.43'; requires 'ExtUtils::MakeMaker', '6.3'; requires 'HTTP::Tiny', '0.012'; requires 'JSON::PP', '2.01'; requires 'Module::CoreList'; requires 'YAML'; requires 'version'; on build => sub { requires 'ExtUtils::MakeMaker'; }; on develop => sub { requires 'Test::Perl::Critic'; }; pmuninstall.pm100644000765000024 3377114233174424 21706 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33/lib/Apppackage App::pmuninstall; use strict; use warnings; use File::Spec; use File::Basename qw(dirname); use ExtUtils::Packlist; use Getopt::Long qw(GetOptions :config bundling); use Config; use YAML (); use CPAN::DistnameInfo; use version; use HTTP::Tiny; use Term::ANSIColor qw(colored); use Cwd (); use JSON::PP qw(decode_json); our $VERSION = "0.33"; my $perl_version = version->new($])->numify; my $depended_on_by = 'http://deps.cpantesters.org/depended-on-by.pl?dist='; my $cpanmetadb = 'http://cpanmetadb.plackperl.org/v1.0/package'; my @core_modules_dir = do { my %h; grep !$h{$_}++, @Config{qw/archlib archlibexp privlib privlibexp/} }; $ENV{ANSI_COLORS_DISABLED} = 1 if $^O eq 'MSWin32'; our $OUTPUT_INDENT_LEVEL = 0; sub new { my ($class, $inc) = @_; $inc = [@INC] unless ref $inc eq 'ARRAY'; bless { check_deps => 1, verbose => 0, inc => $class->prepare_include_paths($inc), }, $class; } sub run { my ($self, @args) = @_; local @ARGV = @args; GetOptions( 'f|force' => \$self->{force}, 'v|verbose!' => sub { ++$self->{verbose} }, 'c|checkdeps!' => \$self->{check_deps}, 'n|no-checkdeps!' => sub { $self->{check_deps} = 0 }, 'q|quiet!' => \$self->{quiet}, 'h|help!' => sub { $self->usage }, 'V|version!' => \$self->{version}, 'l|local-lib=s' => \$self->{local_lib}, 'L|local-lib-contained=s' => sub { $self->{local_lib} = $_[1]; $self->{self_contained} = 1; }, ) or $self->usage; if ($self->{version}) { $self->puts("pm-uninstall (App::pmuninstall) version $App::pmuninstall::VERSION"); exit; } $self->short_usage unless @ARGV; $self->uninstall(@ARGV); } sub uninstall { my ($self, @modules) = @_; $self->setup_local_lib; my $uninstalled = 0; for my $module (@modules) { $self->puts("--> Working on $module") unless $self->{quiet}; my ($packlist, $dist, $vname) = $self->find_packlist($module); $packlist = File::Spec->canonpath($packlist); if ($self->is_core_module($module, $packlist)) { $self->puts(colored ['red'], "! $module is a core module!! Can't be uninstalled."); $self->puts unless $self->{quiet}; next; } unless ($dist) { $self->puts(colored ['red'], "! $module not found."); $self->puts unless $self->{quiet}; next; } unless ($packlist) { $self->puts(colored ['red'], "! $module is not installed."); $self->puts unless $self->{quiet}; next; } if ($self->ask_permission($module, $dist, $vname, $packlist)) { if ($self->uninstall_from_packlist($packlist)) { $self->puts(colored ['green'], "Successfully uninstalled $module"); ++$uninstalled; } else { $self->puts(colored ['red'], "! Failed to uninstall $module"); } $self->puts unless $self->{quiet}; } } if ($uninstalled) { $self->puts if $self->{quiet}; $self->puts("You may want to rebuild man(1) entries. Try `mandb -c` if needed"); } return $uninstalled; } sub uninstall_from_packlist { my ($self, $packlist) = @_; my $inc = { map { File::Spec->canonpath($_) => 1 } @{$self->{inc}} }; my $failed; for my $file ($self->fixup_packlist($packlist)) { chomp $file; $self->puts(-f $file ? 'unlink ' : 'not found', " : $file") if $self->{verbose}; unlink $file or $self->puts("$file: $!") and $failed++; $self->rm_empty_dir_from_file($file, $inc); } $self->puts("unlink : $packlist") if $self->{verbose}; unlink $packlist or $self->puts("$packlist: $!") and $failed++; $self->rm_empty_dir_from_file($packlist, $inc); if (my $install_json = $self->{install_json}) { $self->puts("unlink : $install_json") if $self->{verbose}; unlink $install_json or $self->puts("$install_json: $!") and $failed++; $self->rm_empty_dir_from_file($install_json); } $self->puts unless $self->{quiet} || $self->{force}; return !$failed; } sub rm_empty_dir_from_file { my ($self, $file, $inc) = @_; my $dir = dirname $file; return unless -d $dir; return if $inc->{+File::Spec->canonpath($dir)}; my $failed; if ($self->is_empty_dir($dir)) { $self->puts("rmdir : $dir") if $self->{verbose}; rmdir $dir or $self->puts("$dir: $!") and $failed++; $self->rm_empty_dir_from_file($dir, $inc); } return !$failed; } sub is_empty_dir { my ($self, $dir) = @_; opendir my $dh, $dir or die "$dir: $!"; my @dir = grep !/^\.{1,2}$/, readdir $dh; closedir $dh; return @dir ? 0 : 1; } sub find_packlist { my ($self, $module) = @_; $self->puts("Finding $module in your \@INC") if $self->{verbose}; # find with the given name first (my $try_dist = $module) =~ s!::!-!g; if (my $pl = $self->locate_pack($try_dist)) { $self->puts("-> Found $pl") if $self->{verbose}; return ($pl, $try_dist); } $self->puts("Looking up $module on cpanmetadb") if $self->{verbose}; # map module -> dist and retry my $yaml = $self->fetch("$cpanmetadb/$module") or return; my $meta = YAML::Load($yaml); my $info = CPAN::DistnameInfo->new($meta->{distfile}); my $name = $self->find_meta($info->distvname) || $info->dist; if (my $pl = $self->locate_pack($name)) { $self->puts("-> Found $pl") if $self->{verbose}; return ($pl, $info->dist, $info->distvname); } } sub find_meta { my ($self, $distvname) = @_; my $name; for my $lib (@{$self->{inc}}) { next unless $lib =~ /$Config{archname}/; my $install_json = "$lib/.meta/$distvname/install.json"; next unless -f $install_json && -r _; my $data = decode_json +$self->slurp($install_json); $name = $data->{name} || next; $self->puts("-> Found $install_json") if $self->{verbose}; $self->{meta} = $install_json; last; } return $name; } sub locate_pack { my ($self, $dist) = @_; $dist =~ s!-!/!g; for my $lib (@{$self->{inc}}) { my $packlist = "$lib/auto/$dist/.packlist"; $self->puts("-> Finding .packlist $packlist") if $self->{verbose} > 1; return $packlist if -f $packlist && -r _; } return; } sub is_core_module { my ($self, $dist, $packlist) = @_; require Module::CoreList; return unless exists $Module::CoreList::version{$perl_version}{$dist}; return 1 unless $packlist; my $is_core = 0; for my $dir (@core_modules_dir) { my $safe_dir = quotemeta $dir; # workaround for MSWin32 if ($packlist =~ /^$safe_dir/) { $is_core = 1; last; } } return $is_core; } sub ask_permission { my($self, $module, $dist, $vname, $packlist) = @_; my @deps = $self->find_deps($vname, $module); $self->puts if $self->{verbose}; $self->puts("$module is included in the distribution $dist and contains:\n") unless $self->{quiet}; for my $file ($self->fixup_packlist($packlist)) { chomp $file; $self->puts(" $file") unless $self->{quiet}; } $self->puts unless $self->{quiet}; return 'force uninstall' if $self->{force}; my $default = 'y'; if (@deps) { $self->puts("Also, they're depended on by the following installed dists:\n"); for my $dep (@deps) { $self->puts(" $dep"); } $self->puts; $default = 'n'; } return lc($self->prompt("Are you sure you want to uninstall $dist?", $default)) eq 'y'; } sub find_deps { my ($self, $vname, $module) = @_; return unless $self->{check_deps} && !$self->{force}; $vname ||= $self->vname_for($module) or return; $self->puts("Checking modules depending on $vname") if $self->{verbose}; my $content = $self->fetch("$depended_on_by$vname") or return; my (@deps, %seen); for my $dep ($content =~ m|
  • ]+>([a-zA-Z0-9_:-]+)|smg) { $dep =~ s/^\s+|\s+$//smg; # trim next if $seen{$dep}++; local $OUTPUT_INDENT_LEVEL = $OUTPUT_INDENT_LEVEL + 1; $self->puts("Finding $dep in your \@INC (dependencies)") if $self->{verbose}; push @deps, $dep if $self->locate_pack($dep); } return @deps; } sub prompt { my ($self, $msg, $default) = @_; require ExtUtils::MakeMaker; ExtUtils::MakeMaker::prompt($msg, $default); } sub fixup_packlist { my ($self, $packlist) = @_; my @target_list; my $is_local_lib = $self->is_local_lib($packlist); my $plist = ExtUtils::Packlist->new($packlist); while (my $file = each %$plist) { if ($is_local_lib) { next unless $self->is_local_lib($file); } push @target_list, $file; } return @target_list; } # NOTE only use this for comparing paths sub _canon_path_compare { my ($self, $path) = @_; $path = Cwd::realpath($path); if( $^O eq 'MSWin32' ) { require Win32; $path = Win32::GetLongPathName($path); } return $path; } sub is_local_lib { my ($self, $file) = @_; return unless $self->{local_lib}; my $local_lib_base = quotemeta $self->_canon_path_compare($self->{local_lib}); $file = $self->_canon_path_compare($file); return $file =~ /^$local_lib_base(?:\/|\z)/ ? 1 : 0; } sub vname_for { my ($self, $module) = @_; $self->puts("Fetching $module vname on cpanmetadb") if $self->{verbose}; my $yaml = $self->fetch("$cpanmetadb/$module") or return; my $meta = YAML::Load($yaml); my $info = CPAN::DistnameInfo->new($meta->{distfile}) or return; return $info->distvname; } # taken from cpan-outdated sub setup_local_lib { my $self = shift; return unless $self->{local_lib}; unless (-d $self->{local_lib}) { $self->puts(colored ['red'], "! $self->{local_lib} : no such directory"); exit 1; } local $SIG{__WARN__} = sub { }; # catch 'Attempting to write ...' $self->{inc} = [ grep { defined } map { Cwd::realpath($_) } @{$self->build_active_perl5lib($self->{local_lib}, $self->{self_contained})} ]; push @{$self->{inc}}, @INC unless $self->{self_contained}; } sub build_active_perl5lib { my ($self, $path, $interpolate) = @_; my $perl5libs = [ $self->install_base_arch_path($path), $self->install_base_perl_path($path), $interpolate && $ENV{PERL5LIB} ? split(/\Q$Config{path_sep}\E/, $ENV{PERL5LIB}) : (), ]; return $perl5libs; } sub install_base_perl_path { my ($self, $path) = @_; File::Spec->catdir($path, 'lib', 'perl5'); } sub install_base_arch_path { my ($self, $path) = @_; File::Spec->catdir($self->install_base_perl_path($path), $Config{archname}); } sub fetch { my ($self, $url) = @_; $self->puts("-> Fetching from $url") if $self->{verbose}; my $res = HTTP::Tiny->new->get($url); return if $res->{status} == 404; die "[$res->{status}] fetch $url failed!!\n" if !$res->{success}; return $res->{content}; } sub slurp { my ($self, $file) = @_; open my $fh, '<', $file or die "$file $!"; do { local $/; <$fh> }; } sub puts { my ($self, @msg) = @_; push @msg, '' unless @msg; print ' ' x $OUTPUT_INDENT_LEVEL if $OUTPUT_INDENT_LEVEL; print @msg, "\n"; } sub usage { my $self = shift; $self->puts(<< 'USAGE'); Usage: pm-uninstall [options] Module [...] options: -v,--verbose Turns on chatty output -f,--force Uninstalls without prompts -c,--checkdeps Check dependencies (defaults to on) -n,--no-checkdeps Don't check dependencies -q,--quiet Suppress some messages -h,--help This help message -V,--version Show version -l,--local-lib Additional module path -L,--local-lib-contained Additional module path (don't include non-core modules) USAGE exit 1; } sub short_usage { my $self = shift; $self->puts(<< 'USAGE'); Usage: pm-uninstall [options] Module [...] Try `pm-uninstall --help` or `man pm-uninstall` for more options. USAGE exit 1; } sub prepare_include_paths { my ($class, $inc) = @_; my $new_inc = []; my $archname = quotemeta $Config{archname}; for my $path (@$inc) { push @$new_inc, $path; next if $path eq '.' or $path =~ /$archname/; push @$new_inc, File::Spec->catdir($path, $Config{archname}); } return [do { my %h; grep !$h{$_}++, @$new_inc }]; } 1; __END__ =head1 NAME App::pmuninstall - Uninstall modules =head1 DESCRIPTION App::pmuninstall is a fast module uninstaller. delete files from B<.packlist>. L and, L with a high affinity. =head1 SYNOPSIS uninstall MODULE $ pm-uninstall App::pmuninstall =head1 OPTIONS =over =item -f, --force Uninstalls without prompts $ pm-uninstall -f App::pmuninstall =item -v, --verbose Turns on chatty output $ pm-uninstall -v App::cpnaminus =item -c, --checkdeps Check dependencies ( default on ) $ pm-uninstall -c Plack =item -n, --no-checkdeps Don't check dependencies $ pm-uninstall -n LWP =item -q, --quiet Suppress some messages $ pm-uninstall -q Furl =item -h, --help Show help message $ pm-uninstall -h =item -V, --version Show version $ pm-uninstall -V =item -l, --local-lib Additional module path $ pm-uninstall -l extlib App::pmuninstall =item -L, --local-lib-contained Additional module path (don't include non-core modules) $ pm-uninstall -L extlib App::pmuninstall =back =head1 AUTHOR Yuji Shimada Tatsuhiko Miyagawa =head1 SEE ALSO L =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut minil.toml100644000765000024 3114233174424 17420 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33name = "App-pmuninstall" pm-uninstall100755000765000024 142614233174424 21341 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33/script#!perl use strict; use warnings; use App::pmuninstall; App::pmuninstall->new->run(@ARGV); __END__ =head1 NAME pm-uninstall - Uninstall modules =head1 SYNOPSIS pm-uninstall [options] Module ... options: -v,--verbose Turns on chatty output -f,--force Uninstalls without prompts -c,--checkdeps Check dependencies (defaults to on) -n,--no-checkdeps Don't check dependencies -q,--quiet Suppress some messages -h,--help This help message -V,--version Show version -l,--local-lib Additional module path -L,--local-lib-contained Additional module path (don't include non-core modules) =cut happy_cpantesters.t100644000765000024 22514233174424 21624 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33/tuse strict; use warnings; use Test::More tests => 1; BEGIN { require_ok 'App::pmuninstall' } diag("App::pmuninstall/$App::pmuninstall::VERSION"); 02_perlcritic.t100644000765000024 33314233174424 20721 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33/xtuse strict; use Test::More; eval { require Test::Perl::Critic; Test::Perl::Critic->import( -profile => 'xt/perlcriticrc'); }; plan skip_all => "Test::Perl::Critic is not installed." if $@; all_critic_ok('lib'); perlcriticrc100644000765000024 6314233174424 20463 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33/xt[TestingAndDebugging::ProhibitNoStrict] allow=refs META.yml100644000765000024 242114233174424 16731 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33--- abstract: 'Uninstall modules' author: - 'Yuji Shimada' build_requires: ExtUtils::MakeMaker: '0' configure_requires: Module::Build::Tiny: '0.035' dynamic_config: 0 generated_by: 'Minilla/v3.1.16, 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: App-pmuninstall no_index: directory: - t - xt - inc - share - eg - examples - author - builder provides: App::pmuninstall: file: lib/App/pmuninstall.pm version: '0.33' requires: CPAN::DistnameInfo: '0' ExtUtils::Install: '1.43' ExtUtils::MakeMaker: '6.3' HTTP::Tiny: '0.012' JSON::PP: '2.01' Module::CoreList: '0' YAML: '0' version: '0' resources: bugtracker: https://github.com/xaicron/pm-uninstall/issues homepage: https://github.com/xaicron/pm-uninstall repository: https://github.com/xaicron/pm-uninstall.git version: '0.33' x_contributors: - 'Finn Smith ' - 'Finn Smith ' - 'Tina Mueller ' - 'Yuji Shimada ' - 'Yuji Shimada ' - 'Zakariyya Mughal ' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' x_static_install: 1 MANIFEST100644000765000024 26614233174424 16576 0ustar00shimada.yujistaff000000000000App-pmuninstall-0.33Build.PL Changes LICENSE META.json README.md cpanfile lib/App/pmuninstall.pm minil.toml script/pm-uninstall t/happy_cpantesters.t xt/02_perlcritic.t xt/perlcriticrc META.yml MANIFEST