1 package Module::Install::Bundle;
8 use Module::Install::Base ();
10 use vars qw{$VERSION @ISA $ISCORE};
13 @ISA = 'Module::Install::Base';
20 # Flatten array of arrays into a single array
21 my @core = map @$_, map @$_, grep ref, $self->requires;
28 $self->admin->bundle(@_) if $self->is_admin;
31 my $bundles = $self->read_bundles;
32 my $bundle_dir = $self->_top->{bundle};
33 $bundle_dir =~ s/\W+/\\W+/g;
35 while (my ($name, $version) = splice(@_, 0, 2)) {
38 my $source = $bundles->{$name} or die "Cannot find bundle source for $name";
39 my $target = File::Basename::basename($source);
40 $self->bundles($name, $target);
42 next if eval "use $name $version; 1";
43 mkdir $target or die $! unless -d $target;
45 # XXX - clean those directories upon "make clean"?
49 $out =~ s/$bundle_dir/./i;
51 File::Copy::copy($_ => $out) unless -d;
65 open FH, $self->_top->{bundle} . ".yml" or return {};
67 /^(.*?): (['"])?(.*?)\2$/ or next;
76 sub auto_bundle_deps {
79 # Flatten array of arrays into a single array
80 my @core = map @$_, map @$_, grep ref, $self->requires;
81 while (my ($name, $version) = splice(@core, 0, 2)) {
83 $self->bundle_deps($name, $version);
84 $self->bundle($name, $version);
89 my ($self, $pkg, $version) = @_;
90 my $deps = $self->admin->scan_dependencies($pkg) or return;
92 foreach my $key (sort keys %$deps) {
93 $self->bundle($key, ($key eq $pkg) ? $version : 0);
105 Module::Install::Bundle - Bundle distributions along with your distribution
109 Have your Makefile.PL read as follows:
111 use inc::Module::Install;
114 all_from 'lib/Foo/Bar.pm';
115 requires 'Baz' => '1.60';
118 bundle 'Baz' => '1.60';
126 Module::Install::Bundle allows you to bundle a CPAN distribution within your
127 distribution. When your end-users install your distribution, the bundled
128 distribution will be installed along with yours, unless a newer version of
129 the bundled distribution already exists on their local filesystem.
131 While bundling will increase the size of your distribution, it has several
134 Allows installation of bundled distributions when CPAN is unavailable
135 Allows installation of bundled distributions when networking is unavailable
136 Allows everything your distribution needs to be packaged in one place
138 Bundling differs from auto-installation in that when it comes time to
139 install, a bundled distribution will be installed based on the distribution
140 bundled with your distribution, whereas with auto-installation the distibution
141 to be installed will be acquired from CPAN and then installed.
147 =item * auto_bundle()
149 Takes no arguments, will bundle every distribution specified by a C<requires()>.
150 When you, as a module author, do a C<perl Makefile.PL> the latest versions of
151 the distributions to be bundled will be acquired from CPAN and placed in
154 =item * bundle($name, $version)
156 Takes a list of key/value pairs specifying a distribution name and version
157 number. When you, as a module author, do a perl Makefile.PL the distributions
158 that you specified with C<bundle()> will be acquired from CPAN and placed in
161 =item * bundle_deps($name, $version)
163 Same as C<bundle>, except that all dependencies of the bundled modules are
164 also detected and bundled. To use this function, you need to declare the
165 minimum supported perl version first, like this:
167 requires( perl => 5.005 );
169 =item * auto_bundle_deps
171 Same as C<auto_bundle>, except that all dependencies of the bundled
172 modules are also detected and bundled. This function has the same constraints as bundle_deps.
178 Please report any bugs to (patches welcome):
180 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Install
184 Audrey Tang E<lt>autrijus@autrijus.orgE<gt>
186 Documentation by Adam Foxson E<lt>afoxson@pobox.comE<gt>
190 Copyright 2003, 2004, 2005 by Audrey Tang E<lt>autrijus@autrijus.orgE<gt>.
192 This program is free software; you can redistribute it and/or modify it under
193 the same terms as Perl itself.