5.4. Dpkg-1.18.0 - Pass 1

Approximate build time: 0.9 SBU
Required disk space: 99 MB

5.4.1. Installation of Initial Dpkg

[Note]

Note

Go back and re-read the notes in the previous section. Understanding the notes labeled important will save you a lot of problems later.

Fix a bug which prevents dpkg-deb from being able to build .deb files when compiled without zlib support:

sed -i -e '/control_compress_params\.level = / s/-1/9/' dpkg-deb/build.c

Prepare Dpkg for compilation:

./configure --prefix=/tools \
    --disable-dselect       \
    --without-zlib          \
    --without-bz2           \
    --without-liblzma       \
    --without-selinux       \
    PERL_LIBDIR=/tools/lib/perl/5.20.2

The meaning of the configure options:

--prefix=/tools

This tells the configure script to prepare to install the Dpkg programs in the /tools directory.

--disable-dselect

This disables building of the dselect utility, which is obsolete and also useless for an LFS system.

--without-zlib, --without-bz2, --without-liblzma, --without-selinux

These parameters disable building against various libraries which might be present on the build host. In the case of the first three libraries, dpkg-deb will instead call the corresponding compression binaries.

PERL_LIBDIR=/tools/lib/perl/5.20.2

This tells the configure script where to install the Dpkg perl modules.

Continue with compiling the package:

make

Compilation is now complete. As discussed earlier, running the test suite is not mandatory for the temporary tools here in this chapter. To run the Dpkg test sute anyway, issue the following command:

make check

Install the package:

make install

In preparation for creating a package archive, also install into a temporary staging directory:

make install DESTDIR=$(pwd)/debian/tmp

The meaning of the make parameters:

DESTDIR=$(pwd)/debian/tmp

This tells the build system to create an install image in debian/tmp instead of installing directly to the filesystem. The DESTDIR variable is supported by most packages using autotools or CMake, and by quite a few packages besides.

Create a package metadata file:

mkdir -v debian/tmp/DEBIAN
cat > debian/tmp/DEBIAN/control << EOF
Package: dpkg-pass1
Version: 1.18.0
Maintainer: Linux From Scratch
Architecture: `dpkg --print-architecture`
Description: LFS dpkg-pass1
EOF

(Note: the command above is correct. Even though the usual file creation process puts quotes around "EOF", in this case the quotes would cause the backquote substitution to be skipped.)

Optionally, strip the binaries to be placed in the package. This will reduce the required disk space:

strip --strip-debug debian/tmp/tools/lib/*
strip --strip-unneeded debian/tmp/tools/{,s}bin/*

These commands will skip a number of files, reporting that it does not recognize their file format. Most of these are scripts or directories instead of binaries.

Take care not to use --strip-unneeded on the libraries. The static ones would be destroyed.

To save more disk space, remove the documentation:

rm -rf debian/tmp/tools/share/man
rm -rf /tools/share/man

Build the package archive:

dpkg-deb --build debian/tmp ..

Initialize Dpkg's package status file and triggers directory:

touch /tools/var/lib/dpkg/status
mkdir -v /tools/var/lib/dpkg/triggers

Reinstall Dpkg using the newly built package archive, in order to register its contents with Dpkg:

dpkg -i --force-not-root --force-bad-path ../dpkg-pass1_1.18.0_*.deb

The meaning of the dpkg parameters:

--force-not-root

This tells dpkg to install the package even though it is not being run as root.

--force-bad-path

This tells dpkg to install the package even though ldconfig is not yet on the LFS user's PATH.

Now set these options as the default for future dpkg runs:

cat > /tools/etc/dpkg/dpkg.cfg << "EOF"
force-not-root
force-bad-path
EOF