Module-Build-CleanInstall-0.05000755001750001750 012050615063 15332 5ustar00joeljoel000000000000Module-Build-CleanInstall-0.05/README.pod000444001750001750 275712050615063 17143 0ustar00joeljoel000000000000=head1 NAME Module::Build::CleanInstall - Subclass of Module::Build which removes the old module before installing the new one =head1 SYNOPSIS use strict; use warnings; use Module::Build::CleanInstall; my $builder = Module::Build::CleanInstall->new( ... # same as Module::Build ); $builder->create_build_script; =head1 DESCRIPTION L is a subclass of L with one additional feature, before upgrading the module from and old version to a new one, it first removes the files installed by the previous version. This is useful especially when the new version will not contain some files that the old one did, and it is necessary that those files do not remain in place. Since it is a subclass of L it is used exactly like that module. This module does provide an additional action C, but it need not be called separately; the action C will call it when invoked. The uninstalling is done by removing the files in the installed module's L which is created when the module is first installed. =head1 SEE ALSO =over =item L =item L =back =head1 SOURCE REPOSITORY L =head1 AUTHOR Joel Berger, Ejoel.a.berger@gmail.comE =head1 COPYRIGHT AND LICENSE Copyright (C) 2012 by Joel Berger This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Module-Build-CleanInstall-0.05/META.json000444001750001750 275612050615063 17122 0ustar00joeljoel000000000000{ "abstract" : "Subclass of Module::Build which removes the old module before installing the new one", "author" : [ "Joel A. Berger " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Module-Build-CleanInstall", "no_index" : { "directory" : [ "examples", "t" ], "file" : [ "README.pod" ] }, "prereqs" : { "build" : { "requires" : { "List::MoreUtils" : "0" } }, "configure" : { "requires" : { "Module::Build" : "0.36" } }, "runtime" : { "requires" : { "Module::Build" : "0.36", "parent" : "0", "perl" : "v5.8.1" } } }, "provides" : { "Module::Build::CleanInstall" : { "file" : "lib/Module/Build/CleanInstall.pm", "version" : "0.05" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "http://github.com/jberger/Module-Build-CleanInstall/issues" }, "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://github.com/jberger/Module-Build-CleanInstall" } }, "version" : "0.05" } Module-Build-CleanInstall-0.05/Build.PL000444001750001750 147612050615063 16773 0ustar00joeljoel000000000000use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'Module::Build::CleanInstall', dist_author => 'Joel A. Berger ', license => 'perl', configure_requires => { 'Module::Build' => 0.36, }, requires => { 'perl' => '5.8.1', 'parent' => 0, 'Module::Build' => 0.36, }, build_requires => { 'List::MoreUtils' => 0, # used as target for testing packlists }, meta_merge => { resources => { repository => "http://github.com/jberger/Module-Build-CleanInstall", bugtracker => "http://github.com/jberger/Module-Build-CleanInstall/issues", }, no_index => { file => [ 'README.pod' ], directory => [ 'examples', 't' ], }, }, ); $builder->create_build_script; Module-Build-CleanInstall-0.05/Changes000444001750001750 51612050615063 16744 0ustar00joeljoel000000000000Revision history for Perl module Module::Build::CleanInstall. 0.05 November 13, 2012 - MANIFEST issues on last release 0.04 November 13, 2012 - Prevent false negatives by some CPANtesters 0.03 November 3, 2012 - Include this Changes file 0.02 November 3, 2012 - Various bugfixes 0.01 November 3, 2012 - Initial release Module-Build-CleanInstall-0.05/MANIFEST000444001750001750 20612050615063 16576 0ustar00joeljoel000000000000Build.PL Changes lib/Module/Build/CleanInstall.pm MANIFEST This list of files META.json META.yml README.pod t/00-use.t t/packlist.t Module-Build-CleanInstall-0.05/META.yml000444001750001750 161312050615063 16741 0ustar00joeljoel000000000000--- abstract: 'Subclass of Module::Build which removes the old module before installing the new one' author: - 'Joel A. Berger ' build_requires: List::MoreUtils: 0 configure_requires: Module::Build: 0.36 dynamic_config: 1 generated_by: 'Module::Build version 0.4, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Module-Build-CleanInstall no_index: directory: - examples - t file: - README.pod provides: Module::Build::CleanInstall: file: lib/Module/Build/CleanInstall.pm version: 0.05 requires: Module::Build: 0.36 parent: 0 perl: v5.8.1 resources: bugtracker: http://github.com/jberger/Module-Build-CleanInstall/issues license: http://dev.perl.org/licenses/ repository: http://github.com/jberger/Module-Build-CleanInstall version: 0.05 Module-Build-CleanInstall-0.05/lib000755001750001750 012050615063 16100 5ustar00joeljoel000000000000Module-Build-CleanInstall-0.05/lib/Module000755001750001750 012050615063 17325 5ustar00joeljoel000000000000Module-Build-CleanInstall-0.05/lib/Module/Build000755001750001750 012050615063 20364 5ustar00joeljoel000000000000Module-Build-CleanInstall-0.05/lib/Module/Build/CleanInstall.pm000444001750001750 455012050615063 23434 0ustar00joeljoel000000000000package Module::Build::CleanInstall; use strict; use warnings; our $VERSION = '0.05'; $VERSION = eval $VERSION; use parent 'Module::Build'; use ExtUtils::Installed; sub ACTION_uninstall { my $self = shift; my $module = $self->module_name; if ( my $packlist = $self->_get_packlist($module) ) { print "Removing old copy of $module\n"; $self->_uninstall($packlist); } } sub ACTION_install { my $self = shift; $self->depends_on('uninstall'); $self->SUPER::ACTION_install; } sub _get_packlist { my $self = shift; my ($module) = @_; my $installed = ExtUtils::Installed->new; my $packlist = eval { $installed->packlist($module)->packlist_file }; return $packlist || ''; } sub _uninstall { my $self = shift; my ($packlist, $dont_execute) = @_; require ExtUtils::Install; ExtUtils::Install::uninstall( $packlist, 1, !!$dont_execute ); } 1; =head1 NAME Module::Build::CleanInstall - Subclass of Module::Build which removes the old module before installing the new one =head1 SYNOPSIS use strict; use warnings; use Module::Build::CleanInstall; my $builder = Module::Build::CleanInstall->new( ... # same as Module::Build ); $builder->create_build_script; =head1 DESCRIPTION L is a subclass of L with one additional feature, before upgrading the module from and old version to a new one, it first removes the files installed by the previous version. This is useful especially when the new version will not contain some files that the old one did, and it is necessary that those files do not remain in place. Since it is a subclass of L it is used exactly like that module. This module does provide an additional action C, but it need not be called separately; the action C will call it when invoked. The uninstalling is done by removing the files in the installed module's L which is created when the module is first installed. =head1 SEE ALSO =over =item L =item L =back =head1 SOURCE REPOSITORY L =head1 AUTHOR Joel Berger, Ejoel.a.berger@gmail.comE =head1 COPYRIGHT AND LICENSE Copyright (C) 2012 by Joel Berger This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Module-Build-CleanInstall-0.05/t000755001750001750 012050615063 15575 5ustar00joeljoel000000000000Module-Build-CleanInstall-0.05/t/packlist.t000444001750001750 227612050615063 17740 0ustar00joeljoel000000000000use strict; use warnings; use Test::More; use Module::Build::CleanInstall; # some CPANtesters use a fresh and not installed version of all dependent modules if (grep { m#List-MoreUtils.*?blib# } @INC) { plan skip_all => "Test irrelevant when not using an installed version of List::MoreUtils"; } my $packlist = Module::Build::CleanInstall->_get_packlist('List::MoreUtils'); ok ($packlist, 'Found packlist for List::MoreUtils'); ok( ! Module::Build::CleanInstall->_get_packlist('SoMe::ThiNg::NOT::insTalled'), 'Returns false on not installed' ); # ExtUtils::Install::uninstall prints its actions, so create a handle which # tests from the printed actions my $unlink_attempted = 0; { package My::Test::Handle; use parent 'Tie::Handle'; sub TIEHANDLE { return bless {}, shift }; sub PRINT { my $self = shift; my ($print) = @_; $unlink_attempted++ if $print =~ /unlink (.*)/; print STDOUT $print; } } tie *TESTHANDLE, 'My::Test::Handle'; my $stdout = select *TESTHANDLE; Module::Build::CleanInstall->_uninstall( $packlist, 1 ); # 1 prevents actual removal select $stdout; ok( $unlink_attempted, 'At least one simulated unlink attempt was detected' ); done_testing(); Module-Build-CleanInstall-0.05/t/00-use.t000444001750001750 15512050615063 17111 0ustar00joeljoel000000000000use strict; use warnings; use Test::More tests => 1; use Module::Build::CleanInstall; ok( 1, "Loaded" );