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

I am about to take on the task of creating an installation script, to make it easier when setting up my applications on client systems. It is a web based (cgi) application so my install will be as well. So far I have determined the script must:
check if needed Modules are installed and throw a warning if not,
add tables to a DBI compatible SQL database,
determine where the script lives,
determine the OS,
create additional directories
drop the files from a compressed file into their proper places,
adjust the config file to reflect all this information.

I will be satisfied if it will handle the boring 80% and if I just have to tweak a little here and there. Am I missing anything in my list? Is there an installation kit builder already out there that I missed? Any tricks, traps, or other issues I should be aware of? Thanks for your input.

Greg White

Replies are listed 'Best First'.
Re: Installation script
by andreychek (Parson) on Jun 08, 2001 at 17:18 UTC
    As much criticism as it often gets, I personally have found the
    Slash code to be a good example, particularly in this area.

    Slashcode has to download required modules, create directories,
    modify permissions, creates DB tables, and I believe it may even change a config script somewhere,
    but don't quote me on that.

    In the root directory of the distribution, they have a typical
    Makefile that you might see in say, a C program. It begins copying some
    files into place, modifying permissions, and that sort of thing.
    But then it recurses through all the Perl directories, and runs the Makefile.PL
    files in those directories, which each use ExtUtils::MakeMaker.

    I don't remember how slash does it, but MakeMaker is often what is used to
    create dependencies for your application. If it doesn't do what
    you need, you can also use the CPAN module and just do something like:
    use CPAN; my @required_modules = qw(CGI XML::Parser HTML::Template); foreach my $module ( @required_modules ) { print "Checking for $module"; eval "require $module"; if($@) { print "failed\n"; print "$module does not seem to be present! I'll install it now +.\n"; CPAN::Shell->install($module); } }
    You can just put those lines in your Makefile.PL. HTH
    -Eric
Re: Installation script
by perigeeV (Hermit) on Jun 08, 2001 at 16:56 UTC
    Don't forget to adjust/set permissions, check effective and real UIDs, and check disk space requirements/availability.

    update
    Also, if on a Unix set the umask before doing any creation. Another idea: have your install script write itself a log of each step. Then write an uninstall script that will do the right thing based on that site's particulars.