Is there a chroot build script somewhere?
I am about to develop a little script to gather information for a chroot-jail.
In my case this looks (at the first glance) pretty simple: The application has a clean rpm-install and did install almost all files into a sub-directory of /opt.
My idea is:
- Do a find of all binaries
- Check their library-dependencies
- Record the results into a list
- Do a rsync of that list into the chroot-target-directory before startup of the application
Now I wonder - ist there any script around that already does such a job (perl/bash/python)?
So far I found only specialized solutions for single applications (like sftp-chroot).
Although is does not matter (imho) - OS is CentOS 5 x86_64 current minor release and patch-level.
rpm -ql
is IMHO not generic enough, since it will only cover rpm-based distributions. The mention of the "clean install" above was just to mention that the files of the software are not distributed across the whole file-system. So my starting point is - at the moment - a find /opt/directory/
... that should work on almost any system (even not Linux).
I would suggest creating a template chroot and installing all the packages you want just like it was a normal OS. After that you can manage the chroot using your typical tools (update scripts, package manager, etc.) and rsync the updates into each chroot built using that template.
There are a few advantages to this approach. The two big ones are you can manage the template using familiar tools (no strange hoops to jump through to upgrade your chroot), and if you have one chroot which can't be updated for some reason (say it needs a particular version of some package) you can exclude it from the rsync
upgrade process and manage it independently as though it were a standalone machine, marking the package as "held" or equivalent so it doesn't get stomped on.
Your mileage (and implementation requirements) may vary...