Permalink
Browse files

remove old, experimental bundling code

git-svn-id: http://svn.perl.org/modules/Module-Build/branches/inc-bundling@13322 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information...
1 parent d845856 commit d0f46a3f5ce74560c6768fa8f287f56b336892cc @xdg xdg committed Sep 13, 2009
Showing with 1 addition and 155 deletions.
  1. +0 −53 contrib/bundle.pl
  2. +0 −101 inc/latest.pm
  3. +1 −1 lib/Module/Build/Base.pm
View
53 contrib/bundle.pl
@@ -1,53 +0,0 @@
-#!/usr/bin/perl
-
-# this is just a first crack and it uses File::Fu because I'm lazy.
-
-=head1 using
-
-This installs from a fresh Module::Build to your inc/inc_Module-Build
-directory. Use it from within your dist:
-
- perl /path/to/Module-Build/contrib/bundle.pl
-
-You still need to manually add the following to your Build.PL
-
- use lib 'inc';
- use latest 'Module::Build';
-
-You also need to regen your manifest.
-
- perl Build.PL
- ./Build distmeta; >MANIFEST; ./Build manifest; svn diff MANIFEST
-
-=cut
-
-use warnings;
-use strict;
-
-use File::Fu;
-use File::Copy ();
-
-my $inc_dir = shift(@ARGV);
-$inc_dir = File::Fu->dir($inc_dir || 'inc/inc_Module-Build');
-$inc_dir->create unless($inc_dir->e);
-$inc_dir = $inc_dir->absolutely;
-
-
-my $mb_dir = File::Fu->program_dir->dirname;
-
-$mb_dir->chdir_for(sub {
- my $temp = File::Fu->temp_dir('mb_bundle');
- local @INC = @INC;
- unshift(@INC, 'lib', 'inc');
- require Module::Build;
- my $builder = Module::Build->new_from_context;
- $builder->dispatch(install =>
- install_base => $temp,
- install_path => {lib => $inc_dir},
- );
-});
-
-my $latest = $mb_dir/'inc'+'latest.pm';
-File::Copy::copy($latest, 'inc');
-
-# vim:ts=2:sw=2:et:sta
View
101 inc/latest.pm
@@ -1,101 +0,0 @@
-package latest;
-
-use strict;
-use File::Spec;
-use IO::File;
-
-my $mypath;
-
-
-sub import {
- my ($pack, $mod, @args) = @_;
- my $file = $pack->_mod2path($mod);
-
- if ($INC{$file}) {
- # Already loaded
- return $pack->_load($mod, @args);
- }
-
- # A bundled copy must be present
- my ($bundled, $bundled_dir) = $pack->_search_bundled($file)
- or die "No bundled copy of $mod found";
-
- my $from_inc = $pack->_search_INC($file);
- unless ($from_inc) {
- # Only bundled is available
- unshift(@INC, $bundled_dir);
- return $pack->_load($mod, @args);
- }
-
- if (_version($from_inc) > _version($bundled)) {
- # Ignore the bundled copy
- return $pack->_load($mod, @args);
- }
-
- # Load the bundled copy
- unshift(@INC, $bundled_dir);
- return $pack->_load($mod, @args);
-}
-
-sub _version {
- # TODO: So far this only handles the extremely easy cases
- my ($file) = @_;
- my $fh = IO::File->new($file) or die "Can't read $file: $!";
- while (<$fh>) {
- # This regex has been tested to work against all versions of M::B
- # up through at least 0.2808. No guarantees for other modules.
- return (eval $2) if /^\s*\$VERSION\s*=\s*(['"]?)([\d._]+)\1/;
- }
- return;
-}
-
-sub _load {
- my ($self, $mod, @args) = @_;
- eval "require $mod";
- die $@ if $@;
- $mod->import(@args);
- return;
-}
-
-sub _search_bundled {
- my ($self, $file) = @_;
-
- $mypath ||= (File::Spec->splitpath( $INC{ __PACKAGE__ . '.pm' } ))[1];
-
- local *DH; # Maintain 5.005 compatibility
- opendir DH, $mypath or die "Can't open directory $mypath: $!";
-
- while (defined(my $e = readdir DH)) {
- next unless $e =~ /^inc_/;
- my $try = File::Spec->catfile($mypath, $e, $file);
-
- return($try, File::Spec->catdir($mypath, $e)) if -e $try;
- }
- return;
-}
-
-# Look for the given path in @INC.
-sub _search_INC {
- # TODO: doesn't handle coderefs or arrayrefs or objects in @INC, but
- # it probably should
- my ($self, $file) = @_;
-
- foreach my $dir (@INC) {
- next if ref $dir;
- my $try = File::Spec->catfile($dir, $file);
- return $try if -e $try;
- }
-
- return;
-}
-
-# Translate a module name into a directory/file.pm to search for in @INC
-sub _mod2path {
- my ($self, $mod) = @_;
- my @parts = split /::/, $mod;
- $parts[-1] .= '.pm';
- return $parts[0] if @parts == 1;
- return File::Spec->catfile(@parts);
-}
-
-1;
View
2 lib/Module/Build/Base.pm
@@ -3602,7 +3602,7 @@ sub ACTION_distdir {
my $new = $self->copy_if_modified(from => $file, to_dir => $dist_dir, verbose => 0);
}
- $self->do_create_bundle_inc if $self->bundle_inc;
+ $self->do_create_bundle_inc if @{$self->bundle_inc};
$self->_sign_dir($dist_dir) if $self->{properties}{sign};
}

0 comments on commit d0f46a3

Please sign in to comment.