Typo
[linux_from_scratch_hints.git] / OLD / apt.txt
blob3d25e871483a9bf7f2f4966facbe6e7298ee7621
1 AUTHOR: Ben Roberts <benr@wam.umd.edu>
3 DATE: 2003-09-17
5 LICENSE: GNU Free Documentation License Version 1.2
7 SYNOPSIS: Compiling apt-get and dpkg, and getting them to work
9 DESCRIPTION:
10 dpkg and apt-get are a pair of extremely powerful programs for managing
11 packages, (in)famous for their ability to easily upgrade an entire Linux
12 system.  However, since these tools are designed for installing and
13 maintaining Debian GNU/Linux, they were never meant to be installed
14 "from scratch."  This hint describes how you can fool these programs
15 into working.
17 PREREQUISITES:
18 This hint tries to aim to be as easy to understand as the LFS book
19 itself. Some of it, however, does actually require some understanding of
20 UNIX commands. While all sets of commands give an explanation as to why
21 they should be run, they do not usually include the background on how
22 they work.
24 HINT:
25 [I first attempted this process in 2001 for the purpose of installing
26 Debian on top of Red Hat without rebooting and without install CD's.  It
27 worked quite nicely, but my logs of how I did it were lost when that
28 computer's hard drive died. I have attempted to recreate the process
29 using a chrooted LFS install on my computer; I hope this works for you
30 too.]
32 First, download the dpkg and apt sources from packages.debian.org/dpkg
33 and packages.debian.org/apt (small link near bottom of the page).  The
34 versions used to write this hint are dpkg-1.9.21 and 0.5.4.
36 $ tar xzvf dpkg_1.9.21.tar.gz
37 $ cd dpkg-1.9.21
38 $ ./configure --prefix=/usr --admindir=/var/lib/dpkg
40 Note that --with-admindir has a different default setting (/usr/lib/db)
41 than what apt and the rest of Debian use, so it's wise to use the
42 configure option to make it in the default location now, or make a
43 symlink until you download the binary as a dpkg.
45 If you just type 'make,' the compile will fail unless you have jade
46 and debiandoc2html (you probably don't have either of these things).
47 The best way around this is to change doc/Makefile; this requires
48 disabling doc/Makefile:
50 $ mv doc/Makefile doc/Makefile.bak
51 $ sed 's/^all: /&# /g; s/^install: /&# /g' doc/Makefile.bak > doc/Makefile
53 (this is further reason to just install the Debian version of the
54 package once apt works)
56 $ make
57 $ su
58 # make install 
60 Next we'll install apt.
62 $ tar xzvf apt_0.5.4.tar.gz
63 $ cd apt-0.5.4
64 $ ./configure
66 There aren't any useful options here, not even --prefix is heeded.
68 $ make
70 apt doesn't have a 'make install' target, so apt must be installed
71 manually.  Fortunately, almost all the relevant files to install are
72 located in the bin subdirectory.  The exception is the dselect scripts.
74 Keep in mind apt probably will not work if these exact directories are
75 not used!  I've tried.  This is why no --prefix was given to
76 ./configure; it doesn't pay attention to what you tell it.
78 $ su
79 # cd bin
80 # cp -a libapt-* /usr/lib
81 # ldconfig
82 # cp apt-cache apt-cdrom apt-config apt-get /usr/bin
83 # mkdir /usr/lib/apt
84 # cp -R methods /usr/lib/apt
85 # cd ..
86 # cp -R scripts/dselect /usr/lib/dpkg/methods/apt
87 # mkdir -p /etc/apt /var/state/apt/lists/partial \
88         /var/cache/apt/archives/partial
90 Now, to get it working.  First we need a /etc/apt/sources.list.  Replace
91 the sites below with local mirrors, of course.  You might also want
92 things like sources and security updates, but this is just a hint, after
93 all.
95 # cat > /etc/apt/sources.list >> EOF
96 # Begin /etc/apt/sources.list
98 deb http://http.us.debian.org/debian testing main contrib non-free
99 deb http://non-us.debian.org/debian-non-US testing/non-US main contrib non-free
101 # end /etc/apt/sources.list
104 If you need to symlink /var/lib/dpkg to /usr/lib/db, do it now.
106 # ln -s /usr/lib/db /var/lib/dpkg
108 # touch /var/lib/dpkg/status
110 # dselect
112 In dselect, start with the [A]ccess menu and go down to choose apt.
113 Keep the config file that was already created above.  Then choose
114 [U]pdate.  Now dpkg's available database has been updated.  (for some
115 reason, just using apt-get update didn't work for me, if you have
116 problems, try this dselect method)
118 That's pretty much it.  A few things to watch out for: dpkg doens't like
119 installing from scratch like this.  Many of the essential packages have
120 more complicated dependencies than they list.  You may have problems
121 installing things because it thinks other things aren't installed (an
122 example is if you try to install libc6, it will complain that dpkg isn't
123 installed even though it's not a dependency)  The solution to this is to
124 hack /var/lib/dpkg/status.  To solve the example problem given with
125 libc6, put this in the database:
127 Package: dpkg
128 Essential: yes
129 Status: install ok installed
130 Priority: required
131 Section: base
132 Installed-Size: 2360
133 Maintainer: Wichert Akkerman <wakkerma@debian.org>
134 Version: 1.9.21
135 Replaces: dpkg-doc-ja
136 Pre-Depends: libc6.1 (>= 2.2.4-4), libncurses4 (>= 5.2.20020112a-1),
137 libstdc++2.10-glibc2.2 (>= 1:2.95.4-0.010810) <--- *PUT THIS ON ABOVE LINE!*
138 Description: Package maintenance system for Debian
139  This package contains the programs which handle the installation and
140  removal of packages on your system.
142  The primary interface for the dpkg suite is the `dselect' program;
143  a more low-level and less user-friendly interface is available in
144  the form of the `dpkg' command.
146  In order to unpack and build Debian source packages you will need to
147  install the developers' package `dpkg-dev' as well as this one.
149 One thing to note here is that the version on dpkg is the same as the
150 one we installed.  If you want to reinstall dpkg from a package, the
151 best thing to do here is to decrement the version number by one, so it
152 thinks version 1.9.20 is installed.  Then dpkg will automatically
153 "upgrade" itself.
155 You might even want to put all the packages installed so far by LFS into
156 this status database, and hold them all in dselect; that way, you only
157 have to worry about the binaries, and you've fooled dpkg into not
158 overwriting your pristine LFS installation.
160 That's it and good luck with your Debian From Scratch!
161 (DFS? DG/LFS perhaps?)
163 It should be noted that this procedure only works for dpkg 1.9.21
164 and apt 0.5.4, which were the versions this hint was developed against.
165 Newer versions (including dpkg 1.10 and later) have been tried and have
166 problems, including requiring as-of-yet unofficial ncurses
167 distributions. A procedure for compiling them has not been worked out,
168 so their compilations are not covered here. However, if anyone out there
169 wants to tell me how to do it I'll include the procedure here if you
170 want, but I wouldn't be surprised to find it so different that a new
171 hint would be warranted.
173 ACKNOWLEDGEMENTS:
174   * Xavier Amado <xavier@blackbloodstudios.com> for discovering that
175     dpkg 1.10 doesn't work with these directions.
177 CHANGELOG:
178 [2002-06-12]
179   * Initial hint.
180 [2003-09-17]
181   * Changed format to fit new guidelines, added disclaimer about dpkg
182     1.10.