Skip Menu |
 

This queue is for tickets about the Module-Install CPAN distribution.

Report information
The Basics
Id: 56531
Status: resolved
Priority: 0/
Queue: Module-Install

People
Owner: Nobody in particular
Requestors: florent.angly [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: New patches for M::I::Bundle
Download (untitled) / with headers
text/plain 1.8k
Patches for SVN revision 11912. They cover: Module::Install::Makefile.pm • Prevented duplicate distributions in the DIR entry of the Makefile. • Changed some confusing variable names. • Corrected from which variable module names are removed from. It was erroneous and led to them not being deleted from the Makefile PREREQ_PM entry. • Converted module location from inc/BUNDLES/Foo to ./Foo (following change in M::I::Bundle). Module::Install::Bundle.pm • Removed an extraneous call to $self->bundle() in auto_bundle_deps($name) because a call to $self->bundle_deps($name) already takes care of bundling $name. • Added some comments and renamed a few variables for clarity. • Rephrased a warning message when missing module from the package: issue has to be reported by package user to package author • Recorded the inc/BUNDLES/Foo location of distributions in META.yml, not the location where the module will be built (./Foo) because this built location does not exist if the user already has this module installed. • Added the build directories in the list of files to be remove upon running "make clean" • Added the build directories in the list of files to not include in MANIFEST. • Fix bundle_deps() so that regular users get the module dependencies by reading META.yml Module::Install::Admin::Bundle.pm • Added a check during CPAN search: package admin gets a warning if module is not found. After these changes, it is possible to bundle some dependencies with 'perl Makefile.PL', have a correct 'make clean', correct 'make manifest, and correct 'make dist'. When trying to deploy the package on another machine, it looks like it's mostly working but I got some messages saying that I am missing some dependencies. Maybe some dependencies were not picked up during packaging? I'll have to try to find a test case for this. Cheers, Florent
Subject: bundle_patches.diff
Download bundle_patches.diff
text/x-diff 5.5k
Index: lib/Module/Install/Bundle.pm =================================================================== --- lib/Module/Install/Bundle.pm (revision 11912) +++ lib/Module/Install/Bundle.pm (working copy) @@ -25,28 +25,35 @@ sub bundle { my $self = shift; + + # As admin, fetch these distributions in CPAN and put them in inc/BUNDLES $self->admin->bundle(@_) if $self->is_admin; + # Distribution names and directory my $cwd = Cwd::cwd(); my $bundles = $self->read_bundles; my $bundle_dir = $self->_top->{bundle}; $bundle_dir =~ s/\W+/\\W+/g; - while (my ($name, $version) = splice(@_, 0, 2)) { + # + while (my ($mod_name, $version) = splice(@_, 0, 2)) { $version ||= 0; - my $source = $bundles->{$name}; - if (not $source) { - warn "Warning: Could not find package for module $name. Bundle it manually\n"; + my $dist_source_dir = $bundles->{$mod_name}; + if (not $dist_source_dir) { + warn "Warning: It appears that the module $mod_name is missing. Report the issue to the author of this package.\n"; next; } - my $target = File::Basename::basename($source); - $self->bundles($name, $target); - next if eval "use $name $version (); 1"; - mkdir( $target, 0777 ) or die $! unless -d $target; + # State in META.yml that this module is bundled in the package + $self->bundles($mod_name, $dist_source_dir); - # XXX - clean those directories upon "make clean"? + # Skip to next module if module is already installed + next if eval "use $mod_name $version (); 1"; + + # Move distribution to package root for deployment by make + my $dist_target_dir = File::Basename::basename($dist_source_dir); + mkdir( $dist_target_dir, 0777 ) or die $! unless -d $dist_target_dir; File::Find::find({ wanted => sub { my $out = $_; @@ -55,9 +62,25 @@ File::Copy::copy($_ => $out) unless -d; }, no_chdir => 1, - }, $source); + }, $dist_source_dir); + + # Delete this build directory upon "make clean" + $self->clean_files( $dist_target_dir ); + + # Append the build dir in MANIFEST.SKIP to avoid having it in MANIFEST + # XXX - need to actually read the content of the file to prevent adding an entry that already exists + # XXX - ideally, we should read this file once and write in it only once too... + # XXX - having a dedicated method for this somewhere would be convenient + my $file = 'MANIFEST.SKIP'; + open my $fh, '>>', $file or die "Error: could not write file $file\n$!\n"; + print $fh "$dist_target_dir\n"; + print $fh "$file\n"; + close $fh; + } + + chdir $cwd; } @@ -84,15 +107,17 @@ my @core = map @$_, map @$_, grep ref, $self->requires; while (my ($name, $version) = splice(@core, 0, 2)) { next unless $name; - $self->bundle_deps($name, $version); - $self->bundle($name, $version); + $self->bundle_deps($name, $version); } } sub bundle_deps { my ($self, $pkg, $version) = @_; - my $deps = $self->admin->scan_dependencies($pkg) or return; - + my $deps = $self->admin->scan_dependencies($pkg); + if (scalar keys %$deps == 0) { + # Probably a user trying to install the package, read the dependencies from META.yml + %$deps = ( map { $$_[0] => undef } (@{$self->requires()}) ); + } foreach my $key (sort keys %$deps) { $self->bundle($key, ($key eq $pkg) ? $version : 0); } Index: lib/Module/Install/Admin/Bundle.pm =================================================================== --- lib/Module/Install/Admin/Bundle.pm (revision 11912) +++ lib/Module/Install/Admin/Bundle.pm (working copy) @@ -39,7 +39,11 @@ while ( my ( $name, $version ) = splice( @_, 0, 2 ) ) { my $mod = $cp->module_tree($name); - next unless $mod; + if (not $mod) { + warn "Warning: Could not find distribution for module $name on CPAN. Bundle it manually.\n"; + next; + } + if ( $mod->package_is_perl_core or $self->{already_bundled}{$mod->package} ) { next; } @@ -63,6 +67,7 @@ } else { $location = $extract_result; } + for my $submod ($mod->contains) { $bundles{$submod->name} = $location; } Index: lib/Module/Install/Makefile.pm =================================================================== --- lib/Module/Install/Makefile.pm (revision 11912) +++ lib/Module/Install/Makefile.pm (working copy) @@ -298,13 +298,22 @@ # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; - # Delete bundled dists from prereq_pm + # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} ||= []); if ($self->bundles) { + my %processed; foreach my $bundle (@{ $self->bundles }) { - my ($file, $dir) = @$bundle; - push @$subdirs, $dir if -d $dir; - delete $build_prereq->{$file}; #Delete from build prereqs only + my ($mod_name, $dist_dir) = @$bundle; + delete $prereq->{$mod_name}; + $dist_dir = File::Basename::basename($dist_dir); # dir for building this module + if (not exists $processed{$dist_dir}) { + if (-d $dist_dir) { + # List as sub-directory to be processed by make + push @$subdirs, $dist_dir; + } + # Else do nothing: the module is already present on the system + $processed{$dist_dir} = undef; + } } }
Hi. Applied in the trunk. Thanks. On 2010-4-12 Mon 13:04:22, FANGLY wrote: Show quoted text
> Patches for SVN revision 11912. They cover: > > Module::Install::Makefile.pm > • Prevented duplicate distributions in the DIR entry of the Makefile. > • Changed some confusing variable names. > • Corrected from which variable module names are removed from. It was > erroneous and led to them not being deleted from the Makefile
PREREQ_PM Show quoted text
> entry. > • Converted module location from inc/BUNDLES/Foo to ./Foo (following > change in M::I::Bundle). > > Module::Install::Bundle.pm > • Removed an extraneous call to $self->bundle() in > auto_bundle_deps($name) because a call to $self->bundle_deps($name) > already takes care of bundling $name. > • Added some comments and renamed a few variables for clarity. > • Rephrased a warning message when missing module from the package: > issue has to be reported by package user to package author > • Recorded the inc/BUNDLES/Foo location of distributions in META.yml, > not the location where the module will be built (./Foo) because this > built location does not exist if the user already has this module
installed. Show quoted text
> • Added the build directories in the list of files to be remove upon > running "make clean" > • Added the build directories in the list of files to not include in > MANIFEST. > • Fix bundle_deps() so that regular users get the module dependencies
by Show quoted text
> reading META.yml > > Module::Install::Admin::Bundle.pm > • Added a check during CPAN search: package admin gets a warning if > module is not found. > > > After these changes, it is possible to bundle some dependencies with > 'perl Makefile.PL', have a correct 'make clean', correct 'make
manifest, Show quoted text
> and correct 'make dist'. When trying to deploy the package on another > machine, it looks like it's mostly working but I got some messages > saying that I am missing some dependencies. Maybe some dependencies
were Show quoted text
> not picked up during packaging? I'll have to try to find a test case
for Show quoted text
> this. > > Cheers, > > Florent
Hi. Closed this ticket as fixed, too. Thanks.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.