![]() |
IHLFS: a utility which is aimed to aid the user with installing programs |
|
Chapter Introduction and Contents |
As a 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. One of them is Paco (see: paco.sf.net). Jhalfs, the most recent tool to automate the proces of building a LFS system, has the ability to use Paco.
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
make install
does on my system. I've found this sollution, 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. 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.
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.
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.
Unionfs
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.
Chroot
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.
(Re)Mounting
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 and the directory you're building the software in.
Software
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.
Finally, IHLFS uses commands which should be on any Linux system (like tar, chroot, modprobe, mount, bash, find, grep and bzip2).
The cache partition
Futher a partition with sufficient space to mount the cache to. At this moment this is a seperate partition.
I've been experimenting with a virtual drive (by creating a partition from a file), and it works fine.
Create a special file with:
dd if=/dev/zero of=/mnt/cache.img bs=1M count=500 mkreiserfs /mnt/cache.img mkdir /mnt/cache mount /mnt/cache.img /mnt/cache -o loop
(note: the loopback device has to be supported in your kernel. Kernels of most distributions do.)
Change the option IHLFS_CACHE to this directory.
This website is not complete yet. The things that belong here are:
features like:
- preview of everything you are about install: where in the directory tree gets your software? when not happy you do not have to continue.
- testing the software before installing: with most packages you're able to try the software before you install it
- make backups of the files which will be modified, overwritten or deleted through the install process. For example installing a new version of your Apache server, a backup will be made of the files of the old Apache installation.
- create a backup of every file you install
- interactive mode: user has full control over the installation proces
idea's:
- commandline mode: usefull in scripts
- check libraries and executables they are stripped
- warning when important files will be deleted or modified
- automatic maintaining a database with information about packages installed
- if extended file attributes are supported, write information to it like:
. name and version of package
. builddate
what it is not:
- dependencie resolver
- packagefinder and/or downloader
-
| Index |