Allo, all. I'm not really sure how to write this, so I'm just going to try to get it out.

Currently, a bundle is just a lot of metadata. CPAN.pm knows what to do with the metadata: it gets the modules that the bundle consists of (hereafter referred to as submodules), and builds them.

However, this doesn't work very well if you aren't using CPAN.pm. You try to get the module by hand, do the perl Makefile.PL, make, make test, make install dance, and it happily installs the placeholder pod.

So I wrote a Makefile.PL that simply distributes actions across all of the subdirectories. To make a bundle this way, you just untar all the submodules into one directory, add extra files (README, META.yml, etc) in as you wish, and tar it up.

The biggest limitation is that there's no obvious method to install things that are part of the bundle itself and not one of the submodules. But that's OK, just add another subdirectory for that. The other limitation is that there can be no extra directores that are not submodules.

The code follows. Note that I'd love a better way to get a "real" $^X, that is, a full path by which we can call the current perl intrepter. I don't consider Config.pm to be a better way, though.

#!/usr/bin/perl use IO::File; use File::Spec 'catfile'; use warnings; use strict; # Alternative: Use Config's idea of the path to perl. # IMHO, it's entirely too easy to move the perl executable without upd +ating # Config.pm. We assume the user knew what they were doing when they s +pecified what # perl to run to the shell, and simply attempt to interpret it the sam +e way as the # shell did, when it's not absolute. my ($myperl)=(scalar(()=File::Spec->splitdir($^X)) > 1 # If the path h +as any "slash"es... # Assume it's rel to the current directory, or absolute ? File::Spec->rel2abs($^X) # Otherwise, we have very little to go on. Get the # first executable file Of this name in the path. : ( grep { -x $_ } # On unix, empty=. let this go for other OSes too, as # there's no other useful meaning. map { File::Spec->catfile($_, $^X) } (File::Spec->rel2a +bs($^X)), File::Spec->path ) ); print "Running with perl $myperl\n"; my $returnval=0; my @dirs = grep {-d $_} glob('*'); foreach (@dirs) { print "$_\n"; chdir $_ or do {print "Couldn't change directory to $_: $!"; next} +; system($^X, 'Makefile.PL', @ARGV); if ($?==-1) { print "Error running Makefile.PL: $!\n"; } elsif ($?) { print "While running Makefile.PL in subdir $_, it failed with +\$?=$?. Continuing anyway.\n"; print "(Signal ", $?>>8, ")\n" if $?>>8 ; print "(Return ", $?&127, ")\n" if $?&127; print "(Core dumped)\n" if $?&128; if ($?>>8 > $returnval) { $returnval = $?>>8; } } chdir '..' or die "Couldn't chdir back to main directory: $!"; } print "Writing Makefile in this directory.\n"; my @targets = qw(FORCE all ci clean config dist distcheck distclean di +stdir disttest dynamic help install linkext makemakerdflt manifest manifypods met +afile ppd realclean shdist skipcheck static subdirs tardist test testdb unin +stall uutardist veryclean zipdist); my $makefile = IO::File->new('>Makefile') or die "Cannot open Makefile +: $!"; print $makefile <<"END_OF_MAKEFILE"; # This makefile generated by Build::Bundle::Really @targets: END_OF_MAKEFILE foreach (@dirs) { print $makefile "\tcd $_; make $@"; print $makefile "\n"; } exit $returnval;


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Replies are listed 'Best First'.
Re: Real bundles?
by Koschei (Monk) on Dec 20, 2003 at 23:04 UTC

    You may want to check out Module::Install and its auto_bundle function.

    fwiw, if you already have a directory with a bunch of dists unpacked inside it, a fairly blank Makefile.PL will automatically recurse. (ExtUtils::MakeMaker will recurse, but Module::Build won't.)

Re: Real bundles?
by castaway (Parson) on Dec 21, 2003 at 18:09 UTC
    Theres a slight problem here.. It doesn't account for dependencies.. (ie running in a dir with DBD-* and DBI* as sub dirs will compile the DBDs first, and DBI after, which doesn't make a lot of sense..)

    I guess fixing this will make it significantly more compilcated though.

    C.

      Unfornatly, I don't see how to fix that without breaking the paradime of perl Makefile.PL; make; make test; make install.


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Real bundles?
by adrianh (Chancellor) on Dec 21, 2003 at 22:16 UTC