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

Hello Monks

I have a couple of executable helper scripts that I would like for the installer to install in the bin directory of the target machine.

Is there a "standard" way to distribute them and get them to install in the correct directories? What about portability issues? For example, I could simply hack the Makefile procedure (I used h2xs for the base of my distro) and have these files copied to /usr/local/bin but this would not be portable to other non-unix platforms. The question is to know if there is a standard module or best practice to deploy these helper scripts?
  • Comment on Distributing executable helper scripts with CPAN Distro

Replies are listed 'Best First'.
Re: Distributing executable helper scripts with CPAN Distro
by jettero (Monsignor) on Jan 11, 2008 at 17:51 UTC
    What I usually do in a situation like this is think of someone else's module that does what I want.

    In the LWP Makefile.PL, I believe you'll find your answers...

    if (@request_aliases) { require File::Copy; for (@request_aliases) { File::Copy::copy("bin/lwp-request", "bin/$_") || die "Can't co +py bin/$_"; chmod(0755, "bin/$_"); push(@programs_to_install, $_); } } # ... WriteMakefile( NAME => 'LWP', EXE_FILES => [ map "bin/$_", @programs_to_install ], 'clean' => { FILES => join(" ", map "bin/$_", @request_aliase +s) }, );

    The rest of the answer is in ExtUtils::MakeMaker and or Module::Build (which I've never read myself).

    -Paul

Re: Distributing executable helper scripts with CPAN Distro
by jplindstrom (Monsignor) on Jan 11, 2008 at 20:42 UTC
    If you use EUMM, add this to the config chunk in Makefile.PL :

    'EXE_FILES' => [ 'path/to/your_script' ],

    If you use MB, add this to the config chunk in Build.PL:

    script_files => [ "path/to/your_script", ],

    /J

      Wow, this was precisely the answer I was waiting for! I felt that Makefile.PL must have had some standard way of doing this but did not find any examples in the perl libs on my machine. I obviously did not do an extensive search however.

      If I could, I would vote several times on your node, although all the responses have been great!

      Wow, this was precisely the answer I was waiting for! I felt that Makefile.PL must have had some standard way of doing this but did not find any examples in the perl libs on my machine. I obviously did not do an extensive search however.

      If I could, I would vote several times on your node, although all the responses have been great also!

Re: Distributing executable helper scripts with CPAN Distro
by EvanCarroll (Chaplain) on Jan 11, 2008 at 19:10 UTC
    Use Module::Install like a real man. All other build systems are deprecated... M::I is both easier and more powerful and the new version of module-starter, supports it to. There is no reason to not use it. Check out Module::Install::Scripts, which is part of M::I and offers
    prompt_script()
    Opt-in installer
    install_script()
    installs the script


    Evan Carroll
    www.EvanCarroll.com

      Use Module::Install like a real man. All other build systems are deprecated...

      That's a bold statement. I think there's probably a lot of E::U and E::B users that would disagree. Personally, I have no intention of switching any time soon.

      I think it's safe to say that M::I is easier, possibly even better, but "deprecated?" I doubt that.

      -Paul