I'm writing a build process using a Perl script thats primary function is to create a chroot() jail before running "make install" so that a package can install itself into what it *thinks* is the root filesystem but is actually another location altogether (later I can tar up the results and release the tarball onto other machines for release).
e.g. I create a directory /tmp/install, and have my source in /tmp/build. My script does the following:
- chdir() into /tmp/build. Run configure and make
- runs mount of /bin, /usr/bin, /lib, and /tmp/build into /tmp/install/bin, /tmp/install/usr/bin, /tmp/install/lib, and /tmp/install/tmp/build respectively using the --bind mount option
- chroot() into /tmp/install
- run make install inside the chroot jail
- umount the bin, usr/bin, lib, and tmp/build directories
I can tar up the contents of /tmp/install and have a clean build that can be applied to the root file system of similar machines.
My problem is that I want to build mod_perl and this a)needs Perl and b)wants to install things into the Perl library directories. A simple mount of the Perl directory is not sufficient because the Perl modules installed will go straight into my system (and I don't want that).
So I want to copy all of /usr/local/perl into /tmp/install/usr/local/perl, run my chroot(), do the make install, remove all the copied files from /tmp/install/usr/local/perl, and then be left with the Perl modules that were created in /tmp/install/usr/local/perl/lib/....
I thought about maybe using File::Find and File::Copy along with File::Path to automatically create directories, and storing each copied file into an array for subsequent deletion. Is this the best approach? How have other people applied a directory copy then removal (leaving any new artifacts in place).
update: corrected spelling.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.