LFS - DESTDIR Style

Bryan Kadzban bryan at kadzban.is-a-geek.net
Mon Mar 31 15:12:40 PDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

taipan wrote:
> It still has me wondering if this proposed branch would require or 
> benefit from the inclusion of the 'fakeroot' package, as used by 
> diy-linux? I've never built either, & am uncertain of it's precise 
> function - so this is pure speculation on my part...

fakeroot lets you run programs that normally require root access (e.g.
programs that use the mknod(2) system call) without actually running
them as root.  Normally mknod(2) requires the caller to be root (if it
didn't, then any user could create a device for the partition containing
the root filesystem, change it, and wait for the next restart).

The way it works is, it first loads a library that takes over the glibc
mknod() function.  Instead of having mknod() call into the kernel (into
the system call that will fail), it creates a marker file, and stores
away (1) the fact that the program called mknod() on that filename, and
(2) the details of the mknod() call (permissions, major/minor/type,
etc.).  Of course it also wraps calls like chmod(), chown(), etc.

The library also takes over stat(), to return the information that it
originally stored away.  This way, if you run a program like tar or cpio
under the same fakeroot session, the archive that you create will have
records in it for the real devices (and the proper permissions on other
files, etc., etc.), not the marker files.

So what you do is, you put "make install DESTDIR=x" under a fakeroot
session, and tar up the "x" directory under the same session.  Then you
can extract the tarball later under your root directory, as root, and
get the proper device files, permissions, owner/group, set-uid/set-gid
bits, etc.

But really the only thing it lets you do is build an archive as a
non-root user, with enough information in it to be able to extract the
proper files out when you install the package as root.  The package-user
hint doesn't really require it, because when using that hint, you
install the packages as a non-root user anyway (and you manually work
around the inability to chown/mknod/etc.).  But any kind of DESTDIR type
setup would require it, if the package's "make install" is run as a
non-root user.

(Of course, a by-the-book LFS run builds all of chapter 6 as root.  That
might -- possibly -- be something that could be changed, though.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH8WHXS5vET1Wea5wRAwt+AJ4/5LhwPvovyYpW3MMPB3bzetltugCfdXhU
DwVSlRufgjPivNUjgOB1cJc=
=jK+6
-----END PGP SIGNATURE-----



More information about the lfs-dev mailing list