Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Building perl in chroot

by moot (Chaplain)
on May 05, 2005 at 17:51 UTC ( [id://454447]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks.

Well I was hoping to complete this task without bothering SoPW, but both google and super-search have not been my friends.

I'm building a newer version of perl (5.8.6) on a platform which is no longer supported and therefore has no package later than 5.6.1. It's being built on a system where I can't overwrite the existing perl (for various reasons) and will be deployed as a package to identical systems that lack for a compiler.

Sounds like a job for chroot, I thought - build new perl, install it in a chroot environment, and then package up from there.

However, the gods are not smiling. I receive the following error:

# make install make install.perl install.man STRIPFLAGS= DESTDIR="" AutoSplitting perl library ./miniperl -Ilib -e 'use AutoSplit; autosplit_lib_modules(@ARGV)' lib +/*.pm Can't open perl script "-e": No such file or directory *** Error code 9 Stop in /perl-5.8.6 (line 371 of makefile). *** Error code 1 Stop in /perl-5.8.6 (line 440 of makefile).
..this indicates to me that something is missing from the chroot environment (the same command launched from the same directory but without chrootiness works fine), but what? Attempts to run miniperl -Ilib -e with other code meets the 'Can't open perl script "-e"' error, but miniperl functions just fine as a stand-alone perl, i.e. when run without -e.

Any ideas what could be missing? Has anymonk ever successfully installed perl in a chroot environment?

Replies are listed 'Best First'.
Re: Building perl in chroot
by salva (Canon) on May 05, 2005 at 18:26 UTC
    you don't need a chroot environment for that. Just install perl in an alternative path, say /apps/perl-5.8.6.

    When running Configure, pay attention to its questions, because at some point it will ask you where you want perl installed!. Modules will also become installed under the same location by default later.

    And if you want to move to a chroot environment anyway, then, once your new perl is installed on a different path, fool your scripts to use it, while monitoring them with some tracing tool (truss, strace, etc.). to see which files are being accessed. Those are the ones you have to copy inside the jail.

      Hmm.. perhaps I wasn't clear. I don't want to overwrite the existing perl on the build system, but I do on the deployment targets, which is the same perl in the same location (because it's using the packaged perl 5.6.1). I have no need to keep 5.6 on the deployed machines.

      If I build perl to live in, say, /apps/perl-5.8.6, it also wants to install its libraries there, no? At least, that's what I can figure from Configure..and that will break the package, because the paths will not reflect those in deployment.

      I used the Config.pm from the 5.6 installation to configure 5.8.6, but it's confusing to say the least - particularly this is unclear:

      In some special cases, particularly when building $package for distrib +ution, it is convenient to distinguish the directory in which files s +hould be installed from the directory ($prefix) in which they will ev +entually reside.
      I'll try your chroot idea, although it looks like that means I'll have to configure & build perl twice..
        you can use a soft link to make /apps/perl-5.8.6 point to the old directory where perl was installed on production machines.

        You can also use Configure -Dinstallprefix=/foo/bar option to tell perl that it should install itself in some place and then expect to reside in a different one when executed. But this feature will not allow you to test the new perl on the development machine.

Re: Building perl in chroot
by jasonk (Parson) on May 05, 2005 at 19:17 UTC

    You don't need a chroot to do what you are trying to do, all you need to do is when running configure, include some flags to tell it where to build it, and what to build it as...

    # for example... sh Configure -des ...other flags... -Dinstallprefix=/tmp/buildperlhere +/usr/ -Dprefix=/usr

    By setting a different installprefix and prefix, you are telling the build system that when perl is built, you want it built as though it were going to be installed under /usr (i.e. binaries in /usr/bin, libraries in /usr/lib), but the installprefix tells it when you run 'make install' to actually put it under /tmp/buildperlhere/usr, so you will end up with binaries in /tmp/buildperlhere/usr/bin and libraries in /tmp/buildperlhere/usr/lib). You don't say what kind of packaging you are going to do, but for the sake of argument if you were just going to build tar-files, you could do cd /tmp/buildperlhere; tar cvfz perl.tgz usr and this would give you a tar file that could be untarred under / on the target machines, and you would have perl there as though it had been built under /usr.

    One of the best ways to figure all this stuff out is to get a spec file that is used to build RPMs for RPM-based linux systems, and take a look at the %build and %install sections, they do basically exactly what you are trying to do, build and install perl in a temporary directory, but built so that the RPM will put things in the right places in the system directories.


    We're not surrounded, we're in a target-rich environment!
      Thanks, that's exactly what I was looking for. I thought chroot might be a sledgehammer/ nut approach.
Re: Building perl in chroot
by polettix (Vicar) on May 05, 2005 at 19:51 UTC
    At the risk of being repetitive (with respect to the previous answers)... you don't need to chroot for that :) Jokes apart, have you considered to use a Live CD distro, like Knoppix? This shouldn't spoil anything (hopefully).

    I once compiled Perl 5.8.6 in a chrooted environment, that of Linux From Scratch - try to see there if there's something that can help you. In your particular case, try to

    prompt$ ldd miniperl
    and try to see if it requires some lib that's not included in your chroot environment.

    Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

    Don't fool yourself.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://454447]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-28 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found