IHLFS: Check What You're Installing (And More)
As an LFS (see: Linux From Scratch) user I'm interested in what packages are installed on my system.
A short introduction about LFS: LFS is not an distribution like Suse or RedHat, the LFS community aims to provide a guide to setup your own Linux system. On the website is described very detailed how you can build your own Linux system from scratch. Every package is installed by compiling and installing the source.
In the LFS community there has been investigations on how to keep track of the packages installed. There is at this moment no such tool yet.
Jhalfs, the most recent tool to automate the proces of building a LFS system, has the ability to use Paco, (see: paco.sf.net)..
Paco is based on the LD_PRELOAD mechanism, the same technique is used in for example Gentoo. This technique looks promising, but has some serious drawbacks.
I've been looking for another way of keeping track of what a command like
does on my system. I've found this solution, thanks to the excellent idea of Pierre Hebert. He describes in a howto on the "Hints" section of the LFS website or a mirror (see: Read Hints Online, "TRIP, a TRIvial Packager for LFS (and other linux systems)") how you can achieve full control of what an arbitrary install command does. With it you can track every file added, every modification and file or directory deleted. It does not only work with the "make install" command mentioned above, but it can also track everything a command like RMP does.
The tool IHLFS I've developed is very basic and is based on the same technique as TRIP is . It enables you to have a preview of how your system will look like after you've installed files or a whole package or whatever you want to add to your system. When not happy with the way things look - for example you want parts to be installed on different places - you can always go back.
The name IHLFS stands for:
Install Helper Linux From Scratch
This is done by creating a exact copy of your system (a sort of virtual system). In this copy you are completely free in what you're doing, with absolutely no effect for the original system. Anytime the user has a choice to "move" or "flush" the modifications from the virtual system into the real one.
Another use for this technique is to create an environment for a user, who thinks he is in a real system, and acts this way. But in the meantime he can do what he/she likes, without doing anything harmfull for the realsystem.
This may sound like magic, but is in reality just possible by combining some techniques from all those available for Linux.
By using the filesystem Unionfs, a chroot and some well chosen remounted directories, you can set up this virtual system.
The most important part is the use of unionfs. Unionfs gives you the possibility to create a filesystem, which is the union of at least two others. See www.unionfs.org for more info. Now by letting the new filesystem be the union of our original filesytem (the root) in only read mode, and of a temporary filesystem (the cache) in readwrite mode, you'll have a filesystem which looks exactly like your original filesystem, but in which you can modify, delete and/or add files without doing anything to your original system. This is not possible, because the root is mounted readonly. Every modification is by the unionfs stored in the cache.
The only difference between the original and the newly created system is the path: in the new system it always starts with the path of the mountpoint of the union. This is why the next step is necessary.
By chrooting to this mountpoint, you enter an environment which is absolutely a copy of your system. You can do whatever you like, even remove crucial directories and files. Test it! Look how far you can go before your system gets stuck.
One extra thing you'll have to do is (re)mounting several crucial directories like /dev, /proc and /sys. This is because the union filesystem does not preserve existing mount points.
It's also recommended to remount some special directories like /tmp. This directory is used by the configure script and the make command to store temporary inbetween results. You don't want the ihlfs program to register these as serious changes. That also counts for the directory where teh source is build.
Of course you'll need a recent Linux version. Look for the website for the kernels which are supported and the version of Unionfs you need. A different kernel means a different version of unionfs.
Your kernel has to support the loading of modules.
Futher a partition with sufficient space to mount the cache to. At this moment this is a seperate partition.
I've compared the performance of a build in my normal system and in the virtual system, I've seen no significant difference
Finally, IHLFS uses commands which should be on any Linux system (like tar, chroot, modprobe, mount, bash, find, grep and bzip2).
Download the package from my website:
Unpack the archive in a suitable directory:
tar -xjf ihlfs-1.0.tar.bz2
Installation of ihlfs goes via the
script. It simply creates some directories and copies some files.
How does it work
Before you can start make sure the filesystem where the cache will go, is mounted. And check the settings in the configurationfile /etc/ihlfs/ihlfs.conf. When everything is ok, start the program with:
You'll get some messages, and when everything is ok it will show an prompt:
Now you can enter any command you like. Note that the union does not support the preserving of mountpoints. This may cause effects like sourcedirectories which are mounted where you normally build your software are not available.
When you want to see the changes so far, type:
This shows a summary of changes.
When you want to move all teh changes from the cache to the root, enter:
This command also creates a backup of the files and directories which will be overwritten, modified or deleted and a backup of everything which will be installed.
Removing all changes goes via:
Finally, stopping the session goes with:
quit or exit
Some simple examples here. Add a file:
gives in the viewer mcview:
Summary. -------- There are no added, deleted, modified or overwritten files and/or directories found!
This is to be expected, the /tmp directory is bypassing the union.
Now create a file somewhere else:
Summary. -------- Added files. ------------ /var/tmp/test4ihlfs
If you find bugs or have an idea how things could be done in a better way, please let me know! My emailaddress is stef at bononline dot nl. But before you go futher, I would like to say that I know that the way I've programmed things may not always be the most effective. I've done this deliberately. When it comes to programstyle I prefer easy readable over effectiveness.
This package is not finished yet. Anyone who knows something about packagemanagers can point them:
- put choice of editor in the configurationfile
- now ihlfs has only one mode: interactive. It creates an environment for the user. A command line mode like:
ihlfs --command "make install"
should also be possible.
- add flags to identify the packagename and version installing.
- add some examples with various commands