Herkum has asked for the wisdom of the Perl Monks concerning the following question:

Howdy,

I have been bundling up my perl applications and one of the things I wanted to do was use CPAN to install not only application modules but also my cgi scripts and templates. For example,

I know that Makemaker can support something similiar (example is the Template Toolkit) but it looks like it writes a custom script to do the install.

App::Build is supposed to do this but the documentation for this module is lacking.

Does anyone have any suggestions about how to go about this?

Replies are listed 'Best First'.
Re: CPAN to install Applications
by philcrow (Priest) on Mar 10, 2006 at 16:56 UTC
    We use Module::Build, with a small bit of code it handles templates, style sheets, or anything else we think of. It handles executables natively (as does MakeMaker).

    This combined with our own CPAN::Mini leads to clean deployment on many boxes.

    Phil

      Where would declare your code for calling the executable?

      I can write a script to install the templates to a location but I cannot found in the documentation where you set a script to that is run during the ./Build install process.

        There are two types of things to install: executables and other things. For executables simply add a scripts key to your hash:
        use Module::Build; my $build = Module::Build->new( module_name => 'YourName', # ... script_files => [ qw( your scripts here ) ], #... ); $build->create_build_script;
        To do other things takes a bit more work:
        my $subclass = Module::Build->subclass( class => 'My::Builder', code => &_custom_code(), ); my $build = $subclass->new( module_name => 'YourName', script_files => [ qw( same as above ) ], #... ); $build->create_build_script; sub _custom_code { return <<'EO_CODE'; sub ACTION_install { # do whatever you want at the end of install } EO_CODE }
        Note that shelling out to other scripts is probably not ideal (but is legal). Rather, we code all the file copying, etc in the Build.PL using pure Perl.

        Phil