1 AUTHOR: Chris Wheeler <topher.wheeler at yahoo dot com>
5 LICENSE: GNU Free Documentation License Version 1.2
7 SYNOPSIS: Use dpkg (.deb) package management on LFS 6.3.
10 This is how to compile and install dpkg - The Debian Package Manager - for LFS
11 6.3. This will allow pre-compiled (.deb) packages or custom compiled BLFS
12 packages to be installed/uninstalled through a package manager.
15 * http://www.linuxfromscratch.org/hints/downloads/files/ATTACHMENTS/dpkg/status
18 This hint requires that you have sufficient knowledge of LinuxFromScratch.
19 Some previous knowledge of debian/dpkg would also help (a lot).
22 This applies specifically to LFS 6.3 but could be adopted to other systems as
23 well. Installing more than one package manager on a system is not recommended.
24 I'll start by setting up dpkg, then move on to showing you how to setup apt for
25 those interested in prebuilt (including source) packages. And finally I will
26 show you how to create your own binary .deb packages from dhcpcd and lynx in the
29 There have been many half-baked attempts at similar documents but this one is
30 the real deal. I know because I am typing this in Kate - in KDE - in X11 , and
31 everything beyond my LinuxFromScratch base setup was installed through
32 dpkg (except for dpkg itself and a few dependencies). So buckle up; this will
33 save you the 24 solid hours it took me to figure out how to do this.
35 First of all you need dpkg-1.13.25.tar.gz and po4a_0.29.orig.tar.gz from
36 http://www.debian.org/distrib/packages get em! I strongly suggest using the
37 packages from Debian 4.0 [etch] (currently the stable branch) because, not only
38 is it considered stable, but the package versions are slightly older than the
39 LFS 6.3 equivalents, for the most part, which means easy dependency handling if
40 you decide to merge in other packages from their repository.
42 To compile "dpkg" you need to first compile and install "po4a" which needs
43 "Module::Build-0.2808" from the perl modules in BeyondLinuxFromScratch 6.3. So
44 go get "Module::Build" from BLFS. You will have to compile all of its
45 dependencies in reverse order. Just install the ones that are not optional.
46 Don't bother with the check part of the compiles either; that will just create
47 more dependencies for you to deal with. Compile and install "Module::Build".
49 Now would be a good time to make sure you properly setup LC* and LANG*
50 environment variables according to LFS 6.3 chap 7.9 "Bash Shell Startup Files".
51 Compile and install "po4a". Run "gcc --print-libgcc-file-name" without quotes.
52 This will give a clue to your architecture type (i686 etc need to use i386).
53 Compile "dpkg" with the command line:
55 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
56 --build=i386-gnu-linux
58 * you can omit --prefix=/usr to use /usr/local; I believe this also determines
59 where your .deb packages will be installed.
60 * I also include "--without-dselect" because I still have nightmares about that
62 * --build=CPU-COMPANY-SYSTEM ;what I provided above is for all x86 setups
63 (except amd64 I suppose). You can still optimize the packages you create (ie.
64 CFLAGS="-O3 -march=i686").
66 ..then do "make" and as root "make install" as usual.
67 while you are root do:
68 touch /var/dpkg/status
69 touch /var/dpkg/available
71 That's all there is to it! Well unless you actually want to do something with
74 - Phase [2] - INSTALLING APT -
75 - you can skip to phase [3] if you just want to create your own packages.
77 This section is for people who may want to use packages created by others.
78 First of all you need to create some dummy entries in /var/dpkg/status to make
79 dpkg think that some basic GNU programs and libraries are installed (because
80 they are). I have attached my working (but needs working) "status" file at the
81 top of this document. It seems one can get away with just the package name,
82 version, architecture, and status. A proper mock-up of a real status file with
83 all the resulting debian packages would be nicer though. There might be a
84 clean way to do this with the "equivs" program.
86 You can ignore the messages:
87 dpkg: serious warning: files list ...
89 Those are a result of the crude, but effective status file.
90 I achieved the "status" file by running each LFS source package name through
91 debian's package search tool with the search source packages option selected -
92 which then showed me what .deb's are created from the source tarball. I didn't
93 bother to include the <package>-doc.deb's though.
95 For the installation of "apt" on LFS 6.3 I only cover installing with the
96 binary: apt_0.6.46.4-0.1_i386.deb (the i386 part will differ for other cpu's)
97 So get it from http://www.debian.org/distrib/packages and also get the
98 "sysv-rc" package: sysv-rc_2.86.ds1-38+etchnhalf.1_all.deb
101 ar xv sysv-rc_*_all.deb
104 cp ./usr/sbin/update-rc.d /usr/sbin/
105 dpkg -i apt_*_i386.deb
107 You should now have "apt" installed, but not fully configured. To finish the
111 cp /usr/share/doc/apt/examples/configure-index.gz ./apt.conf.gz
114 Edit the "apt.conf" file with "vi" or some other editor if you have one
115 installed. Use // to comment out any lines you are unsure of. Specifically:
117 // any lines with "Pre-Invoke" "Post-Invoke" for auto re-mounting.
118 // any lines with "pre-configure"
119 // ftp & http proxy stuff or edit it at least.
120 // the Dl-Limit "7" in the http section! (and I thought the us mirror was
122 - Remove the last three lines of "junk" at bottom of file
123 - edit /var/lib/dpkg/status to just be /var/dpkg/status
124 - edit Cache-Limit to be "33554432" or maybe just comment it out.
125 - edit mount "/cdrom"; to be: mount "/media/cdrom"; or whatever you use.
129 (run this for debian repository):
130 cp /usr/share/doc/apt/examples/sources.list /etc/apt/
134 There you gots it. apt
136 Phase [3] - BUILD YOUR OWN PACKAGES! -
138 First we'll start with "dhcpcd" from bLFS as an example (it seems to work
139 better than debian's version). So download "dhcpcd-3.0.19.tar.bz2" from the
140 BLFS 6.3 book and un-pack it. Run the "make" command inside the source
141 directory like the book suggests, then instead of going straight to "make
146 make DESTDIR=./debian/ install
148 Now if you look in the "debian" directory that you created inside your package
149 source directory, it should have the files installed in the "sbin" , "usr" ,
150 and "etc" folders just like it would if you installed it to / . Most packages
151 that use the automake/autoconf setup (most GNU programs) allow for the
152 "DESTDIR=" flag for "make install". If unsure, check the Makefile and look for
153 $(DESTDIR). This diverts the package install at the last minute, but the
154 --prefix=/usr or whatever is still hard-coded into the program. So the program
155 should work properly when dpkg expands the <package>.deb file to the root folder
158 Next get and un-pack the blfs-bootscripts-20080816 like BLFS
159 recommends. Run "make DESTDIR=/path/to/dhcpcd/debian/ install-service-dhcpcd"
160 without the quotes. This should install the dhcpcd bootscript somewhere down
161 the etc/sysconfig/... branch of the same ./debian tree.
163 This next part is very easy but pay attention. The config files in the BLFS
164 book need to be slightly modified. The first two lines need a ./path/to instead
165 of just /path/to ;that's "dot slash path" instead of just "slash path". And you
166 need to run the install & cat command code blocks from inside the ./debian dir.
168 So the first two original lines:
170 install -v -d /etc/sysconfig/network-devices/ifconfig.eth0 &&
171 cat > /etc/sysconfig/network-devices/ifconfig.eth0/dhcpcd << "EOF"
175 install -v -d ./etc/sysconfig/network-devices/ifconfig.eth0 &&
176 cat > ./etc/sysconfig/network-devices/ifconfig.eth0/dhcpcd << "EOF"
178 ...then you can hit enter (inside the ./debian directory) and continue pasting
179 the rest of the file. Note: It may be a good idea to edit the dhcpcd config
180 file that is now in the ./debian/etc/.../ifconfig.eth0/ folder and remove the:
181 "<insert appropriate start options here>" lines. I just left "" and "-k" for
182 mine and everything works fine.
184 Finally make it a .deb package file. The Debian Binary Package Building HOWTO
185 is a great source for info on making binary .deb's (especially section 4). Now
186 let's make a "control" file for our package. It should have at least:
188 Package: <package name>
189 Version: <package version>
191 Maintainer: Your Name <your.name@somewhere.com>
192 Description: Your package description goes here. There can be no blank lines
193 in the control file. So if you need a blank line in the description do this
195 yep, just a single dot will work, and it will show as a blank line.
197 The Debian New Maintainer's Guide and The Debian Policy Manual are also good
198 sources on how to create and manage .deb files. You may also put a "Depends: "
199 line in the middle of your control file to include mandatory dependencies. I
200 prefer not to append the debian revision to my package versions (x.y.z instead
201 of x.y.z-1) that way it seems debian will ignore packages of the same version
202 even if they have a high revision like -13 and it's less conflict with existing
205 You can use the "ldd <filename>" command to find out which shared libraries
206 your program uses and include those as depends:
209 linux-gate.so.1 => (0xb7f27000)
210 libc.so.6 => /lib/libc.so.6 (0xb7df4000)
211 /lib/ld-linux.so.2 (0xb7f28000)
213 You can then run the library names in debian.org's package search engine with
214 "search package contents" selected to find out which official package they come
215 from and even trace that back to the source package. However you want to
216 handle dependencies is up to you; just ignore them if you want/dare. Either
217 way I definitely suggest further reading on at least that subject in the above
220 Go to the ./debian folder for your package and :
224 Then edit/save your "control" file so that it's : ./debian/DEBIAN/control
226 From the folder just below ./debian (your package source dir) run :
228 find ./debian -type d | xargs chmod 755
232 dpkg-deb --build debian
234 Always use dpkg-deb for manipulating .deb files (it's part of dpkg). Rename
235 the resulting debian.deb package to whatever you like dot deb. The official way
236 is packagename_x.y.z-#_arch.deb . It's probably a good idea to use i686 or
237 pentium3 or whatever for the arch part if you use -march=cpu flags with gcc.
238 That way you will know which packages are optimized. Or at least list your
239 optimizations in the description part of the control file.
241 To install your new package run (as root):
243 dpkg -i packagename.deb
245 To uninstall your package run (as root):
248 ... -r leaves configuration files in place
250 dpkg --purge packagename
251 ... --purge removes entire program and config files
253 SECOND PACKAGE EXAMPLE - Lynx -
255 Get Lynx-2.8.6rel.5 and open BLFS 6.3 page for it in chap 15. After you
256 unpack the source tarball to a directory do not change to it. Instead, in the
257 directory you just unpacked from (just under the source tree):
261 ../lynx2-8-6/configure --prefix=/usr \
262 --sysconfdir=/etc/lynx \
263 --datadir=/usr/share/doc/lynx-2.8.6rel.5 \
266 --with-screen=ncursesw \
267 --enable-locale-charset &&
270 This causes new files created by the compilation to be place in ./build
271 instead of the ./lynx2-8-6 dir. It's just good practice so I thought I'd
272 include this method. Now as root (from inside build dir):
275 make DESTDIR=./debian/ install
277 Now like before, change to the ./debian dir and (as BLFS recommends) run:
280 chgrp -v -R root ./usr/share/doc/lynx-2.8.6rel.5/lynx_doc
282 Don't forget to add the dot in front of /usr/share/.... ./usr/share/....!
283 You can then run the sed commands in the same manner; from inside the ./debian
284 dir and place a dot in front of all those path names (./etc/....). The "dot"
285 refers to the current directory instead of the top level / . So the ./debian
286 dir acts as a faked root dir.
288 Finally create your control file in ./debian/DEBIAN/control (control is a file
289 not a dir). Then make your .deb the same way as with dhcpcd. The chmod
290 command changes the permissions to the proper settings. Take note that
291 whatever user you compile with will have ownership of the resulting program
292 files. You may want to run (from inside ./debian dir) something like:
295 as root, of course right before you make your .deb
301 * Aptitude, Synaptic, and Kpackage are all great interfaces for
302 adding/removing .deb's on your system.
304 * If you install apt and plan to use packages from a public repository, you
305 may want to place all the packages that represent your base LFS system on
308 * If you use Aptitude, I recommend unchecking the first three options under
309 Options -> Dependency handling.
311 * The debian style for rc startup scripts is a little different than LFS.
312 This can be a good thing since debian likes to bog down the start-up. If you
313 install official debian packages you will need to mkdir rcS.d , rc0.d ... rc6.d
314 and init.d under /etc and "touch /etc/default/rcS". Or create symlinks to the
315 proper /etc/rc.d/... dirs and init.d (recommended). Install the official
316 "adduser-ng" package. The "apt-utils" and "libdb4.4" will be necessary as well
317 for an xorg install. The last big issue with official .deb packages is
318 "debconf"... To install this package you first have to unpack it manually:
320 ar xv debconf_1.5.11etch2_all.deb
322 cp -r ./usr/share/perl5/Debconf /usr/share/perl5/.
324 Only then can you install "debconf" because of its circular dependency on
327 That's all for now. I wrote this based on memory (or lack of) and a couple
328 pages of scribbled notes I used to document my progress. So I could have
329 missed a step somewhere. Comments, questions, and suggestions are more than
330 welcome; send them to my email address at the top of this document.
334 * Ben Roberts <benr@wam.umd.edu> for previous attempt at this.
335 * Chr. Clemens Lee for The Debian Binary Package HOWTO.
336 * BLFS Development Team for dhcpcd and lynx walkthrough.
337 * Gerard Beekmans for LFS.
338 * Your personal Savior.