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

Hi Monks, I am working on a small linux distro for use on compact flash cards. I want have a full working perl interpreter in it so that I can script the distro easily. So I took a gentoo linux machine, installed perl and the modules that I need. I then copied the perl5.8.5 binary into my distro's root filesystem, and also the entire contents of /usr/lib/perl5 to the /usr/lib/perl5 directory of my distro. When I boot it (or chroot into for that matter), everything seems to work just fine, except for one thing. It seems that when I use the IO::Socket modules, or POE::Component::Server::TCP for that matter, it doesnt work when I use the following line of code:
$server = IO::Socket::INET->new(LocalPort=>$config{'port'}, Type=>SOCK_STREAM, Proto=>'tcp', Reuse=>1, Listen=>1) or die "Fatal Error opening the socket! $! : $@\n";

it errors, telling me this:

Fatal Error opening the socket! No such file or directory : IO::Socket::INET: Bad protocol 'tcp'

This only happens when I am chroot'ed into the root filesystem of my distro, not the gentoo distro that it originated from. Wierd huh? To reword my question, how can I take an existing perl interpreter, along with all of the modules installed, and transfer it from one system to another? Also, what libraries are needed for the whole thing to work? I did "ldd perl5.8.5" and made sure that my distro included all of the libs that it reported. Thanks in advance.

holli - added code tags

Replies are listed 'Best First'.
Re: Embedding Perl
by salva (Canon) on May 19, 2005 at 16:19 UTC
    when things doesn't work as expected on chroot environments, you can use strace to monitor your scripts at the OS level and see what they are missing!
Re: Embedding Perl
by dave_the_m (Monsignor) on May 19, 2005 at 16:11 UTC
    Your embedded system is probably lacking /etc/protocols or a similar method for mapping protocol names (like "tcp") onto numbers.

    Dave.

Re: Embedding Perl
by derby (Abbot) on May 19, 2005 at 16:18 UTC
    Sounds like there's no /etc/protocols in either the chroot environment nor your distro.
    -derby
Re: Embedding Perl
by smellis (Initiate) on May 21, 2005 at 05:55 UTC
    Strace turned out to be extremely useful. I noticed that perl was trying to use some functions in /lib/libnss_nis.so.2 and /lib/libnss_files.so.2 plus it needed to get the protocol numbers from /etc/protocols. I put those files in the rootfs of my little distro, and it works like a champ now. Thanks dudes! -stephan