http://www.perlmonks.org?node_id=840420

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

Hi Monks.

I have an embedded system (I make an image of the filesystem beforehand) with Perl 5.8.8. My host system is Perl 5.10.0. The arch is different as well, but I'm only worried about pure Perl modules right now.

The filesystem for the embedded system is built from, say, /path/to/root

I want to install a pure Perl module to the correct location under /path/to/root , such that when my embedded system boots, the module will be found in @INC. Currently, if I run perl Makefile.PL PREFIX=/path/to/root/usr , it installs under /path/to/root/usr/share/perl/5.10.0/ , which of course doesn't work:

Can't locate TheModule.pm in @INC (@INC contains: /usr/lib/perl5/site_ +perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/5.8.8 .) at ./test +_script line 6.

If I manually copy the files to one of the directories in @INC, it works fine, but I have many such modules to install, so would very much like to be able to run Makefile.PL and make install in my system build script to stick the modules into the right location, rather than hacking together my own install script or hacking @INC.

(Running Makefile.PL on the embedded system is not an option; I would need to do that every time the system boots, and that would require putting MakeMaker, make(1), etc., on the embedded system, which I don't have the space for.)

Is this easily accomplished by MakeMaker, or am I on my own here?

Replies are listed 'Best First'.
Re: Installing a Perl module to an embedded target with different Perl version
by ikegami (Patriarch) on May 17, 2010 at 22:16 UTC

    I believe you can specify the installation directory specifically through LIB instead of having it derived from PREFIX.

    Note that your approach won't work for distros that have machine-specific or version-specific components, such as distros with XS components.

      Thanks for this. It works.

      Note that I had to specify both LIB and PREFIX to install libraries and scripts from the same package. E.g.:

      perl Makefile.PL LIB=/path/to/root/usr/lib/perl5/5.8.8 PREFIX=/path/to/root/usr/local
Re: Installing a Perl module to an embedded target with different Perl version
by JavaFan (Canon) on May 18, 2010 at 01:30 UTC
    How are you transferring stuff to the embedded system? Can't you just do something like:
    $ scp -r /path/to/root/user/share/perl/5.10.0 remote:/usr/lib/perl5/si +te_perl/5.8.8
    ? Alternatively, do something like this on your build system:
    $ mkdir -p /usr/lib/perl5/site_perl/5.8.8 $ ln -s /usr/lib/perl5/site_perl/5.8.8 /path/to/root/usr/share/perl/5. +10.0
    Or build a perl5.8.8 on your build system, which has the same @INC as the one on the embedded system, and use that to build your modules. Then you can deal with non-pure Perl modules as well.
      How are you transferring stuff to the embedded system? Can't you just do something like: (scp to the box)

      No. Remember the system boots from a filesystem image. It's created beforehand and installed on many, many units in production, and, thanks to the fact that it's in RAM, FS changes are destroyed on every reboot (and that's a good thing).

      Or build a perl5.8.8 on your build system, which has the same @INC as the one on the embedded system, and use that to build your modules. Then you can deal with non-pure Perl modules as well.

      I also mentioned that the host and target architectures differ, so this wouldn't gain anything. However, I'm really only worried about pure Perl modules. ikegami hit the solution on the head, though, so fortunately nothing like this is necessary, which is what I'd hoped.

      Thanks!

        Remember the system boots from a filesystem image.
        So, where is this filesystem image coming from? I've created images for embedded systems as well (but they didn't have the resources to be able to run perl); putting files there was a matter of copying - it wasn't "scp to box" but "cp to mounted image".