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

Esteemed Monks

I am about to embark on a project, using Catalyst, where I know that the project will eventually be installed on many machines. The project is reliant on a database, which won't necessarily exist before the installation of the Catalyst project. Within the project, I would like to place both: a set of SQL creation/upgrade scripts; and a program that runs at "make install" time to either install, upgrade, or skip, the database installation, as defined by human response. I know how to do everything except add this install-upgrade-skip program to the install section of the make file, after running "perl Makefile.PL"

There are a number of possibilities:

Please could some generous monk point me in the right direction?

Thank you for your time!

  • Comment on [SOLVED] Where should one place support scripts and resources within a Catalyst project?

Replies are listed 'Best First'.
Re: Where should one place support scripts and resources within a Catalyst project?
by Anonymous Monk on Aug 24, 2011 at 12:51 UTC

    My understanding of the configuration of Module::Install is limited and I am incapable of understanding the documentation

    This.

    Drop distname_any-file.pl you wish to install into script subdirectory and install_script glob('script/*.pl'); in Makefile.PL takes care of installing it

    Its a good idea to follow the catalyst naming convention

      A very excellent suggestion and certainly part of the story, thank you :)

      My understanding is that install_script will perform all of the necessary work to install the various additional scripts.

      Is there a way to additionally include the execution of distname_any-file.pl as part of the make install procedure?

      Perhaps it's easier with a working example to explain what I am doing (disclaimer: I have substituted my project name for the standard Catalyst tutorial myapp):

      Leaning on the advice of another reply to my original post (and to keep this explanation as simple as possible), I have created a database directory called database in the root directory of the project (so it's a sibling of script, root, lib, etc.), with the database update-upgrade script myapp_database.pl, and a directory called sql containing the necessary SQL files. The relevant part of the output of tree -fi is:

      ./database ./database/myapp_database.pl ./database/sql ./database/sql/create-tables.sql ./database/sql/create-data.sql

      My Makefile.PL now also includes:

      install_script glob('database/myapp_database.pl'); install_share ( 'dist', 'database/sql');

      This nicely places the script and the SQL files in sensible places within the blib directory (genuinely impressed at how easy this was!)

      What I would like to do at this point is add something like:

      post_install_execute 'myapp_database.pl';

      Is this, or something equivalent, possible?

      Thank you again!

Re: Where should one place support scripts and resources within a Catalyst project?
by Your Mother (Archbishop) on Aug 24, 2011 at 13:54 UTC

    The previous advice regarding install_script is good. I recommend however not putting your scripts into myapp/script but instead something like myapp/bin or myapp/tool. This is a logical separation because of the many Catalyst Helper packages that automatically create or upgrade stuff in script. If you have them separated, programmatic v in-house, you will never have mysteries or in-line "forks" to solve.

Re: Where should one place support scripts and resources within a Catalyst project?
by chromatic (Archbishop) on Aug 24, 2011 at 14:31 UTC

      Great recommendation, thank you!

      DBIx::Class::DeploymentHandler is now my reading this morning :) Looks good!