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

I know that this is do-able, and almost certainly done very often. What I am looking for is the best practice for a non-trivial Makefile.PL - one that needs to save some config information used by the module test scripts. An example would be a server, database, username and password.

I would be looking to have the Makefile.PL prompt the user with some questions, whose answers get saved somewhere. If the Makefile.PL script gets rerun, the previously saved values are presented as defaults.

I know there are a number of modules that can save config information (Config::Tiny, Config::Simple, AppConfig, even YAML), I just wonder whether the user interaction part has been turned into a module. I also am looking for something that plays properly with automated installs, such as CPANPLUS or the CPAN shell.

For my particular instance, I don't want to go down the Module::Build route.

--
I'm Not Just Another Perl Hacker

  • Comment on Saving the testing config in Makefile.PL

Replies are listed 'Best First'.
Re: Saving the testing config in Makefile.PL
by Joost (Canon) on Mar 23, 2005 at 17:42 UTC
Re: Saving the testing config in Makefile.PL
by brian_d_foy (Abbot) on Mar 23, 2005 at 18:32 UTC

    The Makefile.PL is just a Perl script, so you can do Perl scripting things in it.

    There are some things to consider:

    • Remove the cache file on a `make clean` or `make realclean`. In WriteMakefile you can list additional things to remove in the "clean" key.
    • Don't leave a file with sensitive information lying around in a build directory.
    • You don't have to do everything when you run Makefile.PL. For instance, you can add a MY::test_harness function which will override Makemaker's. In that, you can prompt for a password, then set the enviroment before you call the real test_harness.
    • You can also filter files during a `make` with the PL_FILES key in WriteMakefile().

    One of our clients is very sensitive about some of the security issues, so we don't test a "live" connection for the module installation. We have another set of script to do that, and they grab the right credentials but do not save them anywhere outside the program. That same script can then be used to verify a set-up later, even when the module distro is gone.

    Beyond that, I've had a few requests to add a "config shell" to ConfigReader::Simple, but I haven't had time to do it. Basically, it would load a configuration file then go through it an prompt the user for values. You'd have to start with a config file, but it can be a dummy file.

    --
    brian d foy <bdfoy@cpan.org>
Re: Saving the testing config in Makefile.PL
by chromatic (Archbishop) on Mar 24, 2005 at 01:10 UTC

    The current versions of SDL_perl do this to create SDL::Config. I used Module::Build because trying to customize MakeMaker to do anything sensible seemed like even less fun than eating broken glass which is only physically harmful, if it doesn't kill you.