/[ddp]/manuals/trunk/apt-howto/apt-howto.en.sgml
ViewVC logotype

Contents of /manuals/trunk/apt-howto/apt-howto.en.sgml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6995 - (show annotations) (download) (as text)
Mon Nov 30 14:32:06 2009 UTC (3 years, 5 months ago) by osamu
File MIME type: text/x-sgml
File size: 62008 byte(s)
double (Obsolete Documentation) (Obsolete Documentation) fixed
1 <!doctype debiandoc system>
2 <debiandoc>
3
4 <book>
5
6 <title>APT HOWTO (Obsolete Documentation)</title>
7
8 <author>
9 <name>Gustavo Noronha Silva</name> <email>kov@debian.org</email>
10 </author>
11
12 <version>1.8.11 - August 2005</version>
13
14 <abstract>
15 This document intends to provide the user with a good understanding
16 of the workings of the Debian package management utility, APT. Its
17 goal is to make life easier for new Debian users and to help those
18 who wish to deepen their understanding of the administration of this
19 system. It was created for the Debian project in order to help
20 improve the support available for users of this distribution.
21 </abstract>
22
23 <copyright>
24 <copyrightsummary>
25 Copyright &copy; 2001, 2002, 2003, 2004 Gustavo Noronha Silva
26 </copyrightsummary>
27 <p>
28 This manual is free software; you may redistribute it and/or modify it
29 under the terms of the GNU General Public License as published by the
30 Free Software Foundation; either version 2, or (at your option) any
31 later version.
32 </p>
33
34 <p>
35 This is distributed in the hope that it will be useful, but without
36 any warranty; without even the implied warranty of merchantability or
37 fitness for a particular purpose. See the GNU General Public License
38 for more details.
39 </p>
40
41 <p>
42 A copy of the GNU General Public License is available as
43 /usr/share/common-licenses/GPL in the Debian GNU/Linux distribution or
44 on the World Wide Web at the GNU General Public Licence. You can also
45 obtain it by writing to the Free Software Foundation, Inc., 59 Temple
46 Place - Suite 330, Boston, MA 02111-1307, USA.
47 </p>
48 </copyright>
49
50 <toc>
51
52 <chapt>Introduction
53 <p>
54 In the beginning there was the .tar.gz. Users had to compile each program
55 that they wanted to use on their GNU/Linux systems. When Debian was created,
56 it was deemed necessary that the system include a method of managing the
57 packages installed on the machine. The name <prgn>dpkg</prgn> was given to
58 this system. Thus the famous `package' first came into being on GNU/Linux,
59 a while before Red Hat decided to create their own `rpm' system.
60 <p>
61 A new dilemma quickly took hold of the minds of the makers of
62 GNU/Linux. They needed a rapid, practical, and efficient way to install
63 packages that would manage dependencies automatically and take care of
64 their configuration files while upgrading. Here again, Debian led the way
65 and gave birth to APT, the Advanced Packaging Tool, which has since been
66 ported by Conectiva for use with rpm and has been adopted by some other
67 distributions.
68 <p>
69 This manual makes no attempt to address apt-rpm, as the Conectiva port of
70 APT is known, but "patches" to this document which do so would be welcome.
71 <p>
72 This manual is based on the next Debian release, <tt>Sarge</tt>.
73 </chapt>
74
75 <chapt id="basico">Basic Configuration
76
77 <sect id="sources.list">The /etc/apt/sources.list file
78 <p>
79 As part of its operation, APT uses a file that lists the 'sources' from
80 which packages can be obtained. This file is <tt>/etc/apt/sources.list</tt>.
81 <p>
82 The entries in this file normally follow this format:
83
84 <p>
85 <example>
86 deb http://host/debian distribution section1 section2 section3
87 deb-src http://host/debian distribution section1 section2 section3
88 </example>
89
90 <p>
91 Of course, the above entries are fictitious and should not be used. The
92 first word on each line, <tt>deb</tt> or <tt>deb-src</tt>, indicates the type
93 of archive: whether it contains binary packages (<tt>deb</tt>), that is, the
94 pre-compiled packages that we normally use, or source packages
95 (<tt>deb-src</tt>), which are the original program sources plus the Debian
96 control file (<tt>.dsc</tt>) and the <tt>diff.gz</tt> containing the
97 changes needed for `debianizing' the program.
98 <p>
99 We usually find the following in the default Debian sources.list:
100 <p>
101 <example>
102 # See sources.list(5) for more information, especially
103 # Remember that you can only use http, ftp or file URIs
104 # CDROMs are managed through the apt-cdrom tool.
105 deb http://http.us.debian.org/debian stable main contrib non-free
106 deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
107 deb http://security.debian.org stable/updates main contrib non-free
108
109 # Uncomment if you want the apt-get source function to work
110 #deb-src http://http.us.debian.org/debian stable main contrib non-free
111 #deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
112 </example>
113
114 <p>
115 These are the lines needed by a basic Debian install. The first <tt>deb</tt>
116 line points to the official archive, the second to the non-US archive and
117 the third to the archive of Debian security updates.
118 <p>
119 The two last lines are commented out (with a `#' in front), so apt-get will
120 ignore them. These are <tt>deb-src</tt> lines, that is, they point to
121 Debian source packages. If you often download program sources for testing or
122 recompiling, uncomment them.
123 <p>
124 The <tt>/etc/apt/sources.list</tt> file can contain several types of lines.
125 APT knows how to deal with archives of types <tt>http</tt>, <tt>ftp</tt>,
126 <tt>file</tt> (local files, e.g., a directory containing a mounted ISO9660
127 filesystem) and <tt>ssh</tt>, that I know of.
128 <p>
129 Do not forget to run <tt>apt-get update</tt> after modifying the
130 <tt>/etc/apt/sources.list</tt> file. You must do this to let
131 APT obtain the package lists from the sources you specified.
132 </sect>
133
134 <sect id="dpkg-scanpackages">How to use APT locally
135 <p>
136 Sometimes you have lots of packages .deb that you would like to use
137 APT to install so that the dependencies would be automatically
138 solved.
139 <p>
140 To do that create a directory and put the .debs you want to index
141 in it . For example:
142 <p>
143 <example>
144 # mkdir /root/debs
145 </example>
146 <p>
147 You may modify the definitions set on the package's control file
148 directly for your repository using an <tt>override</tt> file.
149 Inside this file you may want to define some options to override
150 the ones that come with the package. It looks like follows:
151 <p>
152 <example>
153 package priority section
154 </example>
155 <p>
156 package is the name of the package, priority is low, medium or
157 high and section is the section to which it belongs. The file
158 name does not matter, you'll have to pass it as an argument for
159 <prgn>dpkg-scanpackages</prgn> later. If you do not want to
160 write an <tt>override</tt> file, just use <file>/dev/null</file>.
161 when calling <prgn>dpkg-scanpackages</prgn>.
162 <p>
163 Still in the /root directory do:
164 <p>
165 <example>
166 # dpkg-scanpackages debs <var>file</var> | gzip &gt; debs/Packages.gz
167 </example>
168 <p>
169 In the above line, <var>file</var> is the <tt>override</tt> file,
170 the command generates a file <file>Packages.gz</file> that contains
171 various information about the packages, which are used by APT. To
172 use the packages, finally, add:
173 <p>
174 <example>
175 deb file:/root debs/
176 </example>
177 <p>
178 After that just use the APT commands as usual. You may also generate
179 a sources repository. To do that use the same procedure,
180 but remember that you need to have the files <tt>.orig.tar.gz</tt>,
181 <tt>.dsc</tt> and <tt>.diff.gz</tt> in the directory and you
182 have to use <tt>Sources.gz</tt> instead of <tt>Packages.gz</tt>.
183 The program used is also different. It is <prgn>dpkg-scansources</prgn>.
184 The command line will look like this:
185 <p>
186 <example>
187 # dpkg-scansources debs | gzip &gt; debs/Sources.gz
188 </example>
189 <p>
190 Notice that <prgn>dpkg-scansources</prgn> doesn't need an
191 <tt>override</tt> file. The sources.list's line is:
192 <p>
193 <example>
194 deb-src file:/root debs/
195 </example>
196 </sect>
197
198 <sect id="netselect">Deciding which mirror is the best to include in the sources.list file: netselect, netselect-apt
199 <p>
200 A very frequent doubt, mainly among the newest users is: "which Debian
201 mirror to include in <tt>sources.list</tt>?". There are many ways
202 to decide which mirror. The experts probably have a script that
203 measures the ping time through the several mirrors. But there's a
204 program that does this for us: <strong>netselect</strong>.
205 <p>
206 To install netselect, as usual:
207 <p>
208 <example>
209 # apt-get install netselect
210 </example>
211 <p>
212 Executing it without parameters shows the help. Executing it with a
213 space-separated list of hosts (mirrors), it will return a score and
214 one of the hosts. This score takes in consideration the estimated ping
215 time and the hops (hosts by which a network query will pass by to reach
216 the destination) number and is inversely proportional to the estimated
217 download speed (so, the lower, the better). The returned host is the
218 one that had the lowest score (the full list of scores can be seen adding
219 the -vv option). See this example: <p>
220 <example>
221 # netselect ftp.debian.org http.us.debian.org ftp.at.debian.org download.unesp.br ftp.debian.org.br
222 365 ftp.debian.org.br
223 #
224 </example>
225 <p>
226 This means that, from the mirrors included as parameters to netselect,
227 <tt>ftp.debian.org.br</tt> was the best, with an score of 365. (Attention!!
228 As it was done on my computer and the network topography is extremely
229 different depending on the contact point, this value is not necessarily
230 the right speed in other computers).
231 <p>
232 Now, just put the fastest mirror found by netselect in the
233 <tt>/etc/apt/sources.list</tt> file (see <ref id="sources.list">) and
234 follow the tips in <ref id="apt-get">.
235 <p> <strong>Note:</strong> the list of mirrors may always be found in the
236 file <url id="http://www.debian.org/mirror/mirrors_full"
237 name="http://www.debian.org/mirror/mirrors_full">.
238 <p>
239 Beginning with the 0.3.ds1 version, the netselect source package includes the
240 <strong>netselect-apt</strong> binary package, which makes the process
241 above automatic. Just enter the distribution tree as parameter (the
242 default is stable) and the <tt>sources.list</tt> file will be
243 generated with the best main and non-US mirrors and will be saved
244 under the current directory. The following example generates a
245 sources.list of the stable distribution:
246 <p>
247 <example>
248 # ls sources.list
249 ls: sources.list: File or directory not found
250 # netselect-apt stable
251 (...)
252 # ls -l sources.list
253 sources.list
254 #
255 </example>
256 <p>
257 <strong>Remember:</strong> the <tt>sources.list</tt> file is generated
258 under the current directory, and must be moved to the <tt>/etc/apt</tt>
259 directory.
260 <p>
261 Then, follow the tips in <ref id="apt-get">.
262 </sect>
263
264 <sect id="cdrom">Adding a CD-ROM to the sources.list file
265 <p>
266 If you'd rather use your CD-ROM for installing packages or updating
267 your system automatically with APT, you can put it in your
268 <tt>sources.list</tt>. To do so, you can use the <prgn>apt-cdrom</prgn>
269 program like this:
270
271 <p>
272 <example>
273 # apt-cdrom add
274 </example>
275
276 <p>
277 with the Debian CD-ROM in the drive. It will mount the CD-ROM, and
278 if it's a valid Debian CD it will look for package information on the
279 disk. If your CD-ROM configuration is a little unusual, you
280 can also use the following options:
281
282 <p>
283 <example>
284 -h - program help
285 -d directory - CD-ROM mount point
286 -r - Rename a recognized CD-ROM
287 -m - No mounting
288 -f - Fast mode, don't check package files
289 -a - Thorough scan mode
290 </example>
291
292 <p>
293 For example:
294
295 <p>
296 <example>
297 # apt-cdrom -d /home/kov/mycdrom add
298 </example>
299
300 <p>
301 You can also identify a CD-ROM, without adding it to your list:
302
303 <p>
304 <example>
305 # apt-cdrom ident
306 </example>
307
308 <p>
309 Note that this program only works if your CD-ROM is properly
310 configured in your system's <tt>/etc/fstab</tt>.
311 </sect>
312
313 </chapt>
314
315 <chapt id="apt-get">Managing packages
316 <sect id="update">Updating the list of available packages
317 <p>
318 The packaging system uses a private database to keep track of which
319 packages are installed, which are not installed and which are available for
320 installation. The <prgn>apt-get</prgn> program uses this database to
321 find out how to install packages requested by the user and to find out
322 which additional packages are needed in order for a selected package to
323 work properly.
324 <p>
325 To update this list, you would use the command <prgn>apt-get update</prgn>.
326 This command looks for the package lists in the archives found in
327 <tt>/etc/apt/sources.list</tt>; see <ref id="sources.list"> for more
328 information about this file.
329 <p>
330 It's a good idea to run this command regularly to keep yourself and your
331 system informed about possible package updates, particularly security
332 updates.
333 </sect>
334
335 <sect id="install">Installing packages
336 <p>
337 Finally, the process you've all been waiting for! With your sources.list
338 ready and your list of available packages up to date, all you have to do is
339 run <tt>apt-get</tt> to get your desired package installed. For example,
340 you can run:
341
342 <p>
343 <example>
344 # apt-get install xchat
345 </example>
346
347 <p>
348 APT will search it's database for the most recent version of this package and
349 will retrieve it from the corresponding archive as specified in
350 <tt>sources.list</tt>. In the event that this package depends on another --
351 as is the case here -- APT will check the dependencies and install the
352 needed packages. See this example:
353
354 <p>
355 <example>
356 # apt-get install nautilus
357 Reading Package Lists... Done
358 Building Dependency Tree... Done
359 The following extra packages will be installed:
360 bonobo libmedusa0 libnautilus0
361 The following NEW packages will be installed:
362 bonobo libmedusa0 libnautilus0 nautilus
363 0 packages upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
364 Need to get 8329kB of archives. After unpacking 17.2MB will be used.
365 Do you want to continue? [Y/n]
366 </example>
367
368 <p>
369 The package <package>nautilus</package> depends on the shared libraries cited,
370 therefore APT will get them from the archive. If you had
371 specified the names of these libraries on the <tt>apt-get</tt> command line,
372 APT would not have asked if you wanted to continue; it would automatically
373 accept that you wanted to install all of those packages.
374 <p>
375 This means that APT only asks for confirmation when it needs to install
376 packages which weren't specified on the command line.
377 <p>
378 The following options to apt-get may be useful:
379
380 <p>
381 <example>
382 -h This help text.
383 -d Download only - do NOT install or unpack archives
384 -f Attempt to continue if the integrity check fails
385 -s No-act. Perform ordering simulation
386 -y Assume Yes to all queries and do not prompt
387 -u Show a list of upgraded packages as well
388 </example>
389
390 <p>
391 Multiple packages may be selected for installation in one line.
392 Files downloaded from the network are placed in the directory
393 <tt>/var/cache/apt/archives</tt> for later installation.
394 <p>
395 You can specify packages to be removed on the same command line, as well.
396 Just put a '-' immediately after the name of the package to be removed, like
397 this:
398
399 <p>
400 <example>
401 # apt-get install nautilus gnome-panel-
402 Reading Package Lists... Done
403 Building Dependency Tree... Done
404 The following extra packages will be installed:
405 bonobo libmedusa0 libnautilus0
406 The following packages will be REMOVED:
407 gnome-applets gnome-panel gnome-panel-data gnome-session
408 The following NEW packages will be installed:
409 bonobo libmedusa0 libnautilus0 nautilus
410 0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
411 Need to get 8329kB of archives. After unpacking 2594kB will be used.
412 Do you want to continue? [Y/n]
413 </example>
414
415 <p>
416 See section <ref id="remove"> for more details on package removal.
417 <p>
418 If you somehow damage an installed package, or simply want the files of a
419 package to be reinstalled with the newest version that is available,
420 you can use the <tt>--reinstall</tt> option like so:
421
422 <p>
423 <example>
424 # apt-get --reinstall install gdm
425 Reading Package Lists... Done
426 Building Dependency Tree... Done
427 0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 1 not upgraded.
428 Need to get 0B/182kB of archives. After unpacking 0B will be used.
429 Do you want to continue? [Y/n]
430 </example>
431 </sect>
432
433 <sect id="remove">Removing packages
434 <p>
435 If you no longer want to use a package, you can remove it from your system
436 using APT. To do this just type: <tt>apt-get remove package</tt>.
437 For example:
438
439 <p>
440 <example>
441 # apt-get remove gnome-panel
442 Reading Package Lists... Done
443 Building Dependency Tree... Done
444 The following packages will be REMOVED:
445 gnome-applets gnome-panel gnome-panel-data gnome-session
446 0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
447 Need to get 0B of archives. After unpacking 14.6MB will be freed.
448 Do you want to continue? [Y/n]
449 </example>
450
451 <p>
452 As you can see in the above example, APT also takes care of removing
453 packages which depend on the package you have asked to remove. There is no
454 way to remove a package using APT without also removing those packages that
455 depend on it.
456 <p>
457 Running <prgn>apt-get</prgn> as above will cause the packages to be removed
458 but their configuration files, if any, will remain intact on the system.
459 For a complete removal of the package, run:
460
461 <p>
462 <example>
463 # apt-get --purge remove gnome-panel
464 Reading Package Lists... Done
465 Building Dependency Tree... Done
466 The following packages will be REMOVED:
467 gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
468 0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
469 Need to get 0B of archives. After unpacking 14.6MB will be freed.
470 Do you want to continue? [Y/n]
471 </example>
472
473 <p>
474 Note the '*' after the names. This indicates that the configuration
475 files for each of these packages will also be removed.
476 <p>
477 Just as in the case of the <tt>install</tt> method, you can use a symbol
478 with <tt>remove</tt> to invert the meaning for a particular package. In the
479 case of removing, if you add a <tt>'+'</tt> right after the package name,
480 the package will be installed instead of being removed.
481
482 <p>
483 <example>
484 # apt-get --purge remove gnome-panel nautilus+
485 Reading Package Lists... Done
486 Building Dependency Tree... Done
487 The following extra packages will be installed:
488 bonobo libmedusa0 libnautilus0 nautilus
489 The following packages will be REMOVED:
490 gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
491 The following NEW packages will be installed:
492 bonobo libmedusa0 libnautilus0 nautilus
493 0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
494 Need to get 8329kB of archives. After unpacking 2594kB will be used.
495 Do you want to continue? [Y/n]
496 </example>
497
498 <p>
499 Note that <prgn>apt-get</prgn> lists the extra packages which will be
500 installed (that is, the packages whose installation is needed for the proper
501 functioning of the package whose installation has been requested), those
502 which will be removed, and those which will be installed (including the
503 extra packages again).
504 </sect>
505
506 <sect id="upgrade">Upgrading packages
507 <p>
508 Package upgrades are a great success of the APT system. They can be
509 achieved with a single command: <tt>apt-get upgrade</tt>. You can use
510 this command to upgrade packages within the same distribution, as well
511 as to upgrade to a new distribution, although for the latter the command
512 <tt>apt-get dist-upgrade</tt> is preferred; see section
513 <ref id="dist-upgrade"> for more details.
514 <p>
515 It's useful to run this command with the <tt>-u</tt> option. This option
516 causes APT to show the complete list of packages which will be upgraded.
517 Without it, you'll be upgrading blindly. APT will download the latest
518 versions of each package and will install them in the proper order. It's
519 important to always run <tt>apt-get update</tt> before you try this. See
520 section <ref id="update">. Look at this example:
521
522 <p>
523 <example>
524 # apt-get -u upgrade
525 Reading Package Lists... Done
526 Building Dependency Tree... Done
527 The following packages have been kept back
528 cpp gcc lilo
529 The following packages will be upgraded
530 adduser ae apt autoconf debhelper dpkg-dev esound esound-common ftp indent
531 ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0 libesd0-dev
532 libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev liborbit0
533 libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit procps psmisc
534 29 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
535 Need to get 5055B/5055kB of archives. After unpacking 1161kB will be used.
536 Do you want to continue? [Y/n]
537 </example>
538
539 <p>
540 The process is very simple. Note that in the first few lines,
541 <tt>apt-get</tt> says that some packages were <tt>kept back</tt>. This
542 means that there are new versions of these packages which will not be
543 installed for some reason. Possible reasons are broken dependencies
544 (a package on which it depends doesn't have a version available for
545 download) or new dependencies (the package has come to depend on new
546 packages since the last version).
547 <p>
548 There's no clean solution for this first case. For the second case, it's
549 sufficient to run <tt>apt-get install</tt> for the specific package in
550 question, as this will download the dependencies. An even cleaner solution
551 is to use <tt>dist-upgrade</tt>. See section <ref id="dist-upgrade">.
552 </sect>
553
554 <sect id="dist-upgrade">Upgrading to a new release
555 <p>
556 This feature of APT allows you to upgrade an entire Debian system at once,
557 either through the Internet or from a new CD (purchased or downloaded as
558 an ISO image).
559 <p>
560 It is also used when changes are made to the relationships between installed
561 packages. With <tt>apt-get upgrade</tt>, these packages would be kept
562 untouched (<tt>kept back</tt>).
563 <p>
564 For example, suppose that you're using revision 0 of the stable version of
565 Debian and you buy a CD with revision 3. You can use APT to upgrade your
566 system from this new CD. To do this, use <prgn>apt-cdrom</prgn>
567 (see section <ref id="cdrom">) to add the CD to your
568 <tt>/etc/apt/sources.list</tt> and run <tt>apt-get dist-upgrade</tt>.
569 <p>
570 It's important to note that APT always looks for the most recent
571 versions of packages. Therefore, if your <tt>/etc/apt/sources.list</tt>
572 were to list an archive that had a more recent version of a package than
573 the version on the CD, APT would download the package from there.
574 <p>
575 In the example shown in section <ref id="upgrade">, we saw that
576 some packages were <tt>kept back</tt>. We'll solve this problem now
577 with the <tt>dist-upgrade</tt> method:
578
579 <p>
580 <example>
581 # apt-get -u dist-upgrade
582 Reading Package Lists... Done
583 Building Dependency Tree... Done
584 Calculating Upgrade... Done
585 The following NEW packages will be installed:
586 cpp-2.95 cron exim gcc-2.95 libident libopenldap-runtime libopenldap1
587 libpcre2 logrotate mailx
588 The following packages have been kept back
589 lilo
590 The following packages will be upgraded
591 adduser ae apt autoconf cpp debhelper dpkg-dev esound esound-common ftp gcc
592 indent ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0
593 libesd0-dev libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev
594 liborbit0 libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit
595 procps psmisc
596 31 packages upgraded, 10 newly installed, 0 to remove and 1 not upgraded.
597 Need to get 0B/7098kB of archives. After unpacking 3118kB will be used.
598 Do you want to continue? [Y/n]
599 </example>
600
601 <p>
602 Note now that the packages will be upgraded, and new packages will also be
603 installed (the new dependencies of the packages). Note too that lilo is
604 still being <tt>kept back</tt>. It probably has a more serious problem
605 than a new dependency. We can find out by running:
606
607 <p>
608 <example>
609 # apt-get -u install lilo
610 Reading Package Lists... Done
611 Building Dependency Tree... Done
612 The following extra packages will be installed:
613 cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
614 logrotate mailx
615 The following packages will be REMOVED:
616 debconf-tiny
617 The following NEW packages will be installed:
618 cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
619 logrotate mailx
620 The following packages will be upgraded
621 lilo
622 1 packages upgraded, 9 newly installed, 1 to remove and 31 not upgraded.
623 Need to get 225kB/1179kB of archives. After unpacking 2659kB will be used.
624 Do you want to continue? [Y/n]
625 </example>
626
627 <p>
628 As noted in the above, lilo has a new conflict with the package
629 <package>debconf-tiny</package>, which means it couldn't be installed
630 (or upgraded) without removing debconf-tiny.
631 <p>
632 To know what's keeping or removing a package you may use:
633
634 <p>
635 <example>
636 # apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
637 Reading Package Lists... Done
638 Building Dependency Tree... Done
639 Calculating Upgrade... Starting
640 Starting 2
641 Investigating python1.5
642 Package python1.5 has broken dep on python1.5-base
643 Considering python1.5-base 0 as a solution to python1.5 0
644 Holding Back python1.5 rather than change python1.5-base
645 Investigating python1.5-dev
646 Package python1.5-dev has broken dep on python1.5
647 Considering python1.5 0 as a solution to python1.5-dev 0
648 Holding Back python1.5-dev rather than change python1.5
649 Try to Re-Instate python1.5-dev
650 Done
651 Done
652 The following packages have been kept back
653 gs python1.5-dev
654 0 packages upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
655 </example>
656
657 <p>
658 This way, it's easy to notice that the python1.5-dev package cannot
659 be installed because of an unsatisfied dependency: python1.5.
660
661 </sect>
662
663 <sect id="clean">Removing unused package files: apt-get clean and autoclean
664 <p>
665 When you install a package APT retrieves the needed files from the hosts
666 listed in /etc/apt/sources.list, stores them in a local repository
667 (<file>/var/cache/apt/archives/</file>), and then proceeds with
668 installation, see <ref id="install">.
669 <p>
670 In time the local repository can grow and occupy a lot of disk space.
671 Fortunately, APT provides tools for managing its local repository:
672 <prgn>apt-get</prgn>'s <tt>clean</tt> and <tt>autoclean</tt> methods.
673 <p>
674 <prgn>apt-get clean</prgn> removes everything except lock files from
675 <file>/var/cache/apt/archives/</file> and
676 <file>/var/cache/apt/archives/partial/</file>. Thus, if you need to
677 reinstall a package APT should retrieve it again.
678 <p>
679 <prgn>apt-get autoclean</prgn> removes only package files that can
680 no longer be downloaded.
681 <p>
682 The following example show how apt-get autoclean works:
683
684 <p>
685 <example>
686 # ls /var/cache/apt/archives/logrotate* /var/cache/apt/archives/gpm*
687 logrotate_3.5.9-7_i386.deb
688 logrotate_3.5.9-8_i386.deb
689 gpm_1.19.6-11_i386.deb
690 </example>
691
692 <p>
693 In /var/cache/apt/archives there are two files for the
694 package <package>logrotate</package> and one for the package
695 <package>gpm</package>.
696
697 <p>
698 <example>
699 # apt-show-versions -p logrotate
700 logrotate/stable uptodate 3.5.9-8
701 # apt-show-versions -p gpm
702 gpm/stable upgradeable from 1.19.6-11 to 1.19.6-12
703 </example>
704
705 <p>
706 <prgn>apt-show-versions</prgn> shows that
707 <file>logrotate_3.5.9-8_i386.deb</file> provides the up to date version
708 of <package>logrotate</package>, so
709 <file>logrotate_3.5.9-7_i386.deb</file> is useless. Also
710 <file>gpm_1.19.6-11_i386.deb</file> is useless because a more recent
711 version of the package can be retrieved.
712
713 <p>
714 <example>
715 # apt-get autoclean
716 Reading Package Lists... Done
717 Building Dependency Tree... Done
718 Del gpm 1.19.6-11 [145kB]
719 Del logrotate 3.5.9-7 [26.5kB]
720 </example>
721
722 <p>Finally, <tt>apt-get autoclean</tt> removes only the old files.
723 See <ref id="apt-show-versions"> for more information on
724 apt-show-versions.
725 </sect>
726
727 <sect id="dselect-upgrade">Using APT with dselect
728 <p>
729 <prgn>dselect</prgn> is a program that helps users select Debian packages
730 for installation. It's considered somewhat complicated and rather boring,
731 but with practice you can get the hang of its console-based ncurses
732 interface.
733 <p>
734 One feature of dselect is that it knows how to make use of the capacity
735 Debian packages have for "recommending" and "suggesting" other packages
736 for installation. To use the program, run <tt>`dselect'</tt> as root.
737 Choose 'apt' as your access method. This isn't truly necessary, but if
738 you're not using a CD ROM and you want to download packages from the
739 Internet, it's the best way to use dselect.
740 <p>
741 To gain a better understanding of dselect's usage, read the dselect
742 documentation found on the Debian page
743 <url id="http://www.debian.org/doc/ddp" name="http://www.debian.org/doc/ddp">.
744 <p>
745 After making your selections with dselect, use:
746
747 <p>
748 <example>
749 # apt-get -u dselect-upgrade
750 </example>
751
752 <p>
753 as in the example below:
754
755 <p>
756 <example>
757 # apt-get -u dselect-upgrade
758 Reading Package Lists... Done
759 Building Dependency Tree... Done
760 The following packages will be REMOVED:
761 lbxproxy
762 The following NEW packages will be installed:
763 bonobo console-tools-libs cpp-3.0 enscript expat fingerd gcc-3.0
764 gcc-3.0-base icepref klogd libdigest-md5-perl libfnlib0 libft-perl
765 libgc5-dev libgcc300 libhtml-clean-perl libltdl0-dev libsasl-modules
766 libstdc++3.0 metamail nethack proftpd-doc psfontmgr python-newt talk tidy
767 util-linux-locales vacation xbill xplanet-images
768 The following packages will be upgraded
769 debian-policy
770 1 packages upgraded, 30 newly installed, 1 to remove and 0 not upgraded.
771 Need to get 7140kB of archives. After unpacking 16.3MB will be used.
772 Do you want to continue? [Y/n]
773 </example>
774
775 <p>
776 Compare with what we see when running apt-get dist-upgrade on the same
777 system:
778
779 <p>
780 <example>
781 # apt-get -u dist-upgrade
782 Reading Package Lists... Done
783 Building Dependency Tree... Done
784 Calculating Upgrade... Done
785 The following packages will be upgraded
786 debian-policy
787 1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
788 Need to get 421kB of archives. After unpacking 25.6kB will be freed.
789 Do you want to continue? [Y/n]
790 </example>
791
792 <p>
793 Note that many of the packages from above are being installed because other
794 packages "suggested" or "recommended" them. Others are being installed or
795 removed (in the case of lbxproxy, for example) per the choices we made
796 while navigating through dselect's package listing. Dselect can be a powerful
797 tool when used in conjunction with APT.
798 </sect>
799
800 <sect id="default-version">How to keep a mixed system
801 <p>
802 People are sometimes interested in using one of the Debian
803 versions as its main system distribution and one or more packages
804 from another branch.
805 <p>
806 To set up what is your main version of Debian you should edit the
807 <file>/etc/apt/apt.conf</file> (it does not usually exist, create it
808 if you don't have one) to contain the following line:
809 <p>
810 <example>
811 APT::Default-Release "<var>version</var>";
812 </example>
813 <p>
814 Where <var>version</var> is the version of Debian you want to
815 use as the main distribution. The versions you can use are
816 <tt>stable</tt>, <tt>testing</tt> and <tt>unstable</tt>.
817 To install packages from another version, then, you must
818 use APT in the following way:
819
820 <p>
821 <example>
822 # apt-get -t <var>distribution</var> install <var>package</var>
823 </example>
824 <p>
825
826 For that to work, though, you need at least one APT source line
827 in your <file>/etc/apt/sources.list</file> for the distribution
828 you want the package from, and the package must exist on that
829 source.
830 <p>
831 You can also request a specific version of a package using the
832 following sintax:
833
834 <example>
835 # apt-get install <var>package</var>=<var>version</var>
836 </example>
837
838 For example, the line below will install version <tt>2.2.4-1</tt>
839 of the <package>nautilus</package> package.:
840
841 <example>
842 # apt-get install nautilus=2.2.4-1
843 </example>
844
845 <p>
846 <em>IMPORTANT</em>: the `unstable' version of Debian is the version to
847 which the newest versions of Debian packages are uploaded first. This
848 distribution sees all of the changes that packages go through, both
849 small ones and more drastic ones which affect many packages or the whole
850 system. For this reason, this version of the distribution should
851 <em>not</em> be used by inexperienced users or by those who need proven
852 stability.
853 <p>
854 The `testing' distribution is not necessarily better than `unstable',
855 because it does not receive security updates quickly. For servers
856 and other production systems stable should always be used.
857 </sect>
858
859 <sect id="apt-show-versions">How to upgrade packages from specific versions of Debian
860 <p>
861 <prgn>apt-show-versions</prgn> provides a safe way for users of mixed
862 distributions to upgrade their systems without getting more of the
863 less-stable distribution than they had in mind. For instance, it is
864 possible to upgrade just your unstable packages by running after
865 having installed the <package>apt-show-versions</package> package:
866 <p>
867 <example>
868 # apt-get install `apt-show-versions -u -b | grep unstable | cut -d ' ' -f 1`
869 </example>
870 </sect>
871
872 <sect id="pin">How to keep specific versions of packages installed (complex)
873 <p>
874 You may have occasion to modify something in a package and don't have
875 time or don't want to port those changes to a new version of the
876 program. Or, for instance, you may have just upgraded your Debian
877 distribution to 3.0, but want to continue with the version of a certain
878 package from Debian 2.2. You can "pin" the version you have installed
879 so that it will not be upgraded.
880 <p>
881 Using this resource is simple. You just need to edit the file
882 <tt>/etc/apt/preferences</tt>.
883 <p>
884 The format is simple:
885 <p>
886 <example>
887 Package: &lt;package&gt;
888 Pin: &lt;pin definition&gt;
889 Pin-Priority: &lt;pin's priority&gt;
890 </example>
891 <p>
892 Each entry must be separated from any other entries by a blank
893 line. For example, to keep package <package>sylpheed</package> that I
894 have modified to use "reply-to-list" at version 0.4.99, I add:
895 <p>
896 <example>
897 Package: sylpheed
898 Pin: version 0.4.99*
899 </example>
900 <p>
901 Note that I used an <tt>*</tt> (asterisk). This is a "wildcard"; it say
902 that I want that this "pin" to be valid for all versions beginning with
903 0.4.99. This is because Debian versions its packages with a "Debian
904 revision" and I don't want to avoid the installation of these revisions.
905 So, for instance, versions 0.4.99-1 and 0.4.99-10 will be installed as
906 soon as they are made available. Note that if you modified the package
907 you won't want to do things this way.
908 <p>
909 The pin priority helps determine whether a package matching the "Packages:"
910 and "Pin:" lines will be installed, with higher priorities making it more
911 likely that a matching package will be installed. You can read
912 <manref name="apt_preferences" section="7"> for a thorough discussion of
913 priorities, but a few examples should give the basic idea. The following
914 describes the effect of setting the priority field to different values in
915 the sylpheed example above.
916 </p>
917 <p>
918 <taglist>
919 <tag>1001</tag>
920 <item>
921 Sylpheed version 0.4.99 will never be replaced by apt. If available,
922 apt will install version 0.4.99 even if it would replace an installed
923 package with a higher version. Only packages of priority greater than
924 1000 will ever downgrade an existing package.
925 </item>
926 <tag>1000</tag>
927 <item>
928 The effect is the same as priority 1001, except that apt will refuse
929 to downgrade an installed version to 0.4.99
930 </item>
931 <tag>990</tag>
932 <item>
933 Version 0.4.99 will be replaced only by a higher version available
934 from a release designated as preferred using the
935 "APT::Default-Release" variable (see <ref id="default-version">,
936 above).
937 </item>
938 <tag>500</tag>
939 <item>
940 Any version higher than 0.4.99 of sylpheed which is available from any
941 release will take preference over version 0.4.99, but 0.4.99 will
942 still be preferred to a lower version.
943 </item>
944 <tag>100</tag>
945 <item>
946 Higher versions of sylpheed available from any release will take
947 preference over version 0.4.99, as will any installed higher version
948 of slypheed; so 0.4.99 will be installed only if no version is
949 installed already. This is the priority of installed packages.
950 </item>
951 <tag>-1</tag>
952 <item>
953 Negative priorities are allowed as well, and prevent 0.4.99 from ever
954 being installed.
955 </item>
956 </taglist>
957 <p>
958 A pin can be specified on a package's <tt>version</tt>, <tt>release</tt>
959 or <tt>origin</tt>.
960 <p>
961 Pinning on a <tt>version</tt>, as we have seen, supports literal
962 version numbers as well as wildcards to specify several
963 versions at one time.
964 <!-- what's available? standard shell globs? ?*[] or more? -->
965 <p>
966 Option <tt>release</tt> depends on the Release file from an APT
967 repository or from a CD. This option may be of no use at all if you're
968 using package repositories that don't provide this file. You may see
969 the contents of the Release files that you have on
970 <tt>/var/lib/apt/lists/</tt>. The parameters for a release are:
971 <tt>a</tt> (archive), <tt>c</tt> (components), <tt>v</tt> (version),
972 <tt>o</tt> (origin) and <tt>l</tt> (label).
973 <p>
974 An example:
975 <p>
976 <example>
977 Package: *
978 Pin: release v=2.2*,a=stable,c=main,o=Debian,l=Debian
979 Pin-Priority: 1001
980 </example>
981 <p>
982 In this example, we chose version 2.2* of Debian (which can be 2.2r2,
983 2.2r3 -- this accommodates "point releases" that typically include
984 security fixes and other very important updates), the <tt>stable</tt>
985 repository, section <tt>main</tt> (as opposed to <tt>contrib</tt> or
986 <tt>non-free</tt>) and origin and label Debian. Origin (o=) defines who
987 produced that Release file, the label (l=) defines the name of the
988 distribution: Debian for Debian itself and Progeny for Progeny, for
989 example. A sample Release file:
990 <p>
991 <example>
992 $ cat /var/lib/apt/lists/ftp.debian.org.br_debian_dists_potato_main_binary-i386_Release
993 Archive: stable
994 Version: 2.2r3
995 Component: main
996 Origin: Debian
997 Label: Debian
998 Architecture: i386
999 </example>
1000 </sect>
1001 </chapt>
1002
1003 <chapt id="helpers">Very useful helpers
1004 <sect id="equivs">How to install locally compiled packages: equivs
1005 <p>
1006 Sometimes, people want to use a specific version of a program
1007 available only on source code, with no Debian package. But the
1008 packaging system can be a trouble when doing this. Suppose
1009 you want to compile a new version of your email server. All
1010 is fine, but many packages in Debian depend on an MTA (Mail
1011 Transport Agent). Since you installed something you compiled
1012 by yourself, the packaging system doesn't know about it.
1013 <p>
1014 That's where <package>equivs</package> enters the scene. To use it,
1015 install the package with that name. Equivs creates an empty package
1016 that fullfills dependencies, making the package system believe that
1017 the dependencies are satisfied.
1018 <p>
1019 Before we begin, it is good to remind you that there are safer
1020 ways of compiling a program which is already packaged for Debian
1021 with different options, and that one should not use equivs to
1022 replace dependencies if you don't know what you are doing.
1023 See section <ref id="sourcehandling"> for more information.
1024 <p>
1025 Let's continue with the MTA example, you just installed your
1026 new compiled <prgn>postfix</prgn> and goes on for installing
1027 <package>mutt</package>. Suddenly you discover that
1028 <package>mutt</package> wants to install another MTA. But you
1029 already have yours.
1030 <p>
1031 Go to some directory (<file>/tmp</file>, for example) and run:
1032
1033 <p>
1034 <example>
1035 # equivs-control <var>name</var>
1036 </example>
1037
1038 <p>
1039 Replace <var>name</var> for the name of the control file you
1040 want to create. The file will be created as follows:
1041
1042 <p>
1043 <example>
1044 Section: misc
1045 Priority: optional
1046 Standards-Version: 3.0.1
1047
1048 Package: &lt;enter package name; defaults to equivs-dummy&gt;
1049 Version: &lt;enter version here; defaults to 1.0&gt;
1050 Maintainer: &lt;your name and email address; defaults to username&gt;
1051 Pre-Depends: &lt;packages&gt;
1052 Depends: &lt;packages&gt;
1053 Recommends: &lt;packages&gt;
1054 Suggests: &lt;package&gt;
1055 Provides: &lt;(virtual)package&gt;
1056 Architecture: all
1057 Copyright: &lt;copyright file; defaults to GPL2&gt;
1058 Changelog: &lt;changelog file; defaults to a generic changelog&gt;
1059 Readme: &lt;README.Debian file; defaults to a generic one&gt;
1060 Extra-Files: &lt;additional files for the doc directory, comma-separated&gt;
1061 Description: &lt;short description; defaults to some wise words&gt;
1062 long description and info
1063 .
1064 second paragraph
1065 </example>
1066
1067 <p>
1068 We just need modify this to do what we want. Have a look at
1069 the field's format and to their descriptions, there's no need
1070 to explain each one here, let's do what's required:
1071
1072 <p>
1073 <example>
1074 Section: misc
1075 Priority: optional
1076 Standards-Version: 3.0.1
1077
1078 Package: mta-local
1079 Provides: mail-transport-agent
1080 </example>
1081
1082 <p>
1083 Yes, that's all. <package>mutt</package> depends on
1084 <package>mail-transport-agent</package>, that is a virtual
1085 package provided by all MTAs, I could simply name
1086 the package <package>mail-transport-agent</package>, but I preferred
1087 to use the virtual package's schema, using Provides.
1088 <p>
1089 Now you only need to build the package:
1090
1091 <p>
1092 <example>
1093 # equivs-build <var>name</var>
1094 dh_testdir
1095 touch build-stamp
1096 dh_testdir
1097 dh_testroot
1098 dh_clean -k
1099 # Add here commands to install the package into debian/tmp.
1100 touch install-stamp
1101 dh_testdir
1102 dh_testroot
1103 dh_installdocs
1104 dh_installchangelogs
1105 dh_compress
1106 dh_fixperms
1107 dh_installdeb
1108 dh_gencontrol
1109 dh_md5sums
1110 dh_builddeb
1111 dpkg-deb: building package `<var>name</var>' in `../<var>name</var>_1.0_all.deb'.
1112
1113 The package has been created.
1114 Attention, the package has been created in the current directory,
1115 </example>
1116
1117 <p>
1118 And install the resulting <tt>.deb</tt>.
1119 <p>
1120 As one can see, there are several uses for <prgn>equivs</prgn>. One
1121 can even crate a <tt>my-favorites</tt> package, which depends on
1122 the programs you usually installs, for example. Just free your imagination,
1123 but be careful.
1124 <p>
1125 It is important to note that there are example control files in
1126 <file>/usr/share/doc/equivs/examples</file>. Check them out.
1127 </sect>
1128
1129 <sect id="localepurge">Removing unused locale files: localepurge
1130 <p>
1131 Many Debian users use only one locale. A Brazilian Debian user,
1132 for example, usually uses the <tt>pt_BR</tt> locale all the time
1133 and doesn't care about the <tt>es</tt> one.
1134 <p>
1135 <package>localepurge</package> is a very useful tool for these users.
1136 You can free lots of space by having only the locales that you
1137 really use. Just <tt>apt-get install localepurge</tt>.
1138 <p>
1139 It is very easy to configure it, debconf questions guide the
1140 user in a step-by-step configuration. Be very careful on answering
1141 the first question though, wrong answers may remove all the locales
1142 files, even the ones you use. The only way to recover these files
1143 is reinstalling all the packages that provide them.
1144 </sect>
1145
1146 <sect id="helper-show-versions">How to know what packages may be upgraded
1147 <p>
1148 <prgn>apt-show-versions</prgn> is a program that shows what packages
1149 in the system may be updated and several useful information.
1150 The <tt>-u</tt> option displays a list of upgradeable packages:
1151
1152 <p>
1153 <example>
1154 $ apt-show-versions -u
1155 libeel0/unstable upgradeable from 1.0.2-5 to 1.0.2-7
1156 libeel-data/unstable upgradeable from 1.0.2-5 to 1.0.2-7
1157 </example>
1158 </sect>
1159
1160 </chapt>
1161
1162 <chapt id="search">Getting information about packages.
1163 <p>
1164 There are some front-end programs for the APT system that make it
1165 significantly easier to get listings of packages that are available
1166 for installation or are already installed, as well as to find out what
1167 section a package is in, what its priority is, what its description is, etc.
1168 <p>
1169 But... our goal here is to learn how to use pure APT. So how can you find
1170 out the name of a package that you want to install?
1171 <p>
1172 We have a number of resources for such a task. We'll begin with
1173 <tt>apt-cache</tt>. This program is used by the APT system for maintaining
1174 its database. We'll take just a brief look at some of its more practical
1175 applications.
1176
1177 <sect id="cache">Discovering package names
1178 <p>
1179 For example, suppose that you want to reminisce about the good old days of
1180 the Atari 2600. You want to use APT to install an Atari emulator, and then
1181 download some games. You can do:
1182
1183 <p>
1184 <example>
1185 # apt-cache search atari
1186 atari-fdisk-cross - Partition editor for Atari (running on non-Atari)
1187 circuslinux - The clowns are trying to pop balloons to score points!
1188 madbomber - A Kaboom! clone
1189 tcs - Character set translator.
1190 atari800 - Atari emulator for svgalib/X/curses
1191 stella - Atari 2600 Emulator for X windows
1192 xmess-x - X binaries for Multi-Emulator Super System
1193 </example>
1194
1195 <p>
1196 We find several packages related to what we're looking for, together with
1197 brief descriptions. To get more information about a specific package, I can
1198 then use:
1199
1200 <p>
1201 <example>
1202 # apt-cache show stella
1203 Package: stella
1204 Priority: extra
1205 Section: non-free/otherosfs
1206 Installed-Size: 830
1207 Maintainer: Tom Lear &lt;tom@trap.mtview.ca.us&gt;
1208 Architecture: i386
1209 Version: 1.1-2
1210 Depends: libc6 (&gt;= 2.1), libstdc++2.10, xlib6g (&gt;= 3.3.5-1)
1211 Filename: dists/potato/non-free/binary-i386/otherosfs/stella_1.1-2.deb
1212 Size: 483430
1213 MD5sum: 11b3e86a41a60fa1c4b334dd96c1d4b5
1214 Description: Atari 2600 Emulator for X windows
1215 Stella is a portable emulator of the old Atari 2600 video-game console
1216 written in C++. You can play most Atari 2600 games with it. The latest
1217 news, code and binaries for Stella can be found at:
1218 http://www4.ncsu.edu/~bwmott/2600
1219 </example>
1220
1221 <p>
1222 In this output you have many details about the package that you want (or
1223 don't want) to install, together with the full description of the package.
1224 If the package is already installed on your system and there is a newer
1225 version, you'll see information about both versions. For example:
1226
1227 <p>
1228 <example>
1229 # apt-cache show lilo
1230 Package: lilo
1231 Priority: important
1232 Section: base
1233 Installed-Size: 271
1234 Maintainer: Russell Coker &lt;russell@coker.com.au&gt;
1235 Architecture: i386
1236 Version: 1:21.7-3
1237 Depends: libc6 (&gt;= 2.2.1-2), debconf (&gt;=0.2.26), logrotate
1238 Suggests: lilo-doc
1239 Conflicts: manpages (&lt;&lt;1.29-3)
1240 Filename: pool/main/l/lilo/lilo_21.7-3_i386.deb
1241 Size: 143052
1242 MD5sum: 63fe29b5317fe34ed8ec3ae955f8270e
1243 Description: LInux LOader - The Classic OS loader can load Linux and others
1244 This Package contains lilo (the installer) and boot-record-images to
1245 install Linux, OS/2, DOS and generic Boot Sectors of other OSes.
1246 .
1247 You can use Lilo to manage your Master Boot Record (with a simple text screen)
1248 or call Lilo from other Boot-Loaders to jump-start the Linux kernel.
1249
1250 Package: lilo
1251 Status: install ok installed
1252 Priority: important
1253 Section: base
1254 Installed-Size: 190
1255 Maintainer: Vincent Renardias &lt;vincent@debian.org&gt;
1256 Version: 1:21.4.3-2
1257 Depends: libc6 (&gt;= 2.1.2)
1258 Recommends: mbr
1259 Suggests: lilo-doc
1260 Description: LInux LOader - The Classic OS loader can load Linux and others
1261 This Package contains lilo (the installer) and boot-record-images to
1262 install Linux, OS/2, DOS and generic Boot Sectors of other OSes.
1263 .
1264 You can use Lilo to manage your Master Boot Record (with a simple text screen)
1265 or call Lilo from other Boot-Loaders to jump-start the Linux kernel.
1266 </example>
1267
1268 <p>
1269 Note that the first in the list is the available package and the second is
1270 the one already installed. For more general information about a package,
1271 you can use:
1272
1273 <p>
1274 <example>
1275 # apt-cache showpkg penguin-command
1276 Package: penguin-command
1277 Versions:
1278 1.4.5-1(/var/lib/apt/lists/download.sourceforge.net_debian_dists_unstable_main_binary-i386_Packages)(/var/lib/dpkg/status)
1279
1280 Reverse Depends:
1281 Dependencies:
1282 1.4.5-1 - libc6 (2 2.2.1-2) libpng2 (0 (null)) libsdl-mixer1.1 (2 1.1.0) libsdl1.1 (0 (null)) zlib1g (2 1:1.1.3)
1283 Provides:
1284 1.4.5-1 -
1285 Reverse Provides:
1286 </example>
1287
1288 <p>
1289 And to just find out what packages it depends on:
1290
1291 <p>
1292 <example>
1293 # apt-cache depends penguin-command
1294 penguin-command
1295 Depends: libc6
1296 Depends: libpng2
1297 Depends: libsdl-mixer1.1
1298 Depends: libsdl1.1
1299 Depends: zlib1g
1300 </example>
1301
1302 <p>
1303 In summary, we have a range of weapons we can use to find out the name of
1304 a package we want.
1305 </sect>
1306
1307 <sect id="dpkg-search">Using dpkg to find package names
1308 <p>
1309 One of the ways to locate the name of a package is to know the name of an
1310 important file found within the package. For example, to find the package
1311 that provides a particular <tt>".h"</tt> file you need for compilation you
1312 can run:
1313
1314 <p>
1315 <example>
1316 # dpkg -S stdio.h
1317 libc6-dev: /usr/include/stdio.h
1318 libc6-dev: /usr/include/bits/stdio.h
1319 perl: /usr/lib/perl/5.6.0/CORE/nostdio.h
1320 </example>
1321
1322 <p>
1323 or:
1324
1325 <p>
1326 <example>
1327 # dpkg -S /usr/include/stdio.h
1328 libc6-dev: /usr/include/stdio.h
1329 </example>
1330
1331 <p>
1332 To find out the names of packages installed on your system, which is useful,
1333 for example, if you plan to clean up your hard drive, you can run:
1334
1335 <p>
1336 <example>
1337 # dpkg -l | grep mozilla
1338 ii mozilla-browse 0.9.6-7 Mozilla Web Browser
1339 </example>
1340 <p>
1341 The problem with this command is that it can "break" the package name. In
1342 the example above, the full name of the package is <tt>mozilla-browser</tt>.
1343 To fix this, you can use the <tt>COLUMNS</tt> environment variable this way:
1344
1345 <p>
1346 <example>
1347 [kov]@[couve] $ COLUMNS=132 dpkg -l | grep mozilla
1348 ii mozilla-browser 0.9.6-7 Mozilla Web Browser - core and browser
1349 </example>
1350
1351 <p>
1352 or the description or part of it this way:
1353
1354 <p>
1355 <example>
1356 # apt-cache search "Mozilla Web Browser"
1357 mozilla-browser - Mozilla Web Browser
1358 </example>
1359 </sect>
1360
1361 <sect id="auto-apt">How to install packages "on demand"
1362 <p>
1363 You're compiling a program and, all of a sudden, boom! There's an error
1364 because it needs a <tt>.h</tt> file you don't have. The program
1365 <prgn>auto-apt</prgn> can save you from such scenarios. It asks you to
1366 install packages if they're needed, stopping the relevant process and
1367 continuing once the package is installed.
1368 <p>
1369 What you do, basically, is run:
1370
1371 <p>
1372 <example>
1373 # auto-apt run command
1374 </example>
1375
1376 <p>
1377 Where `command' is the command to be executed that may need some
1378 unavailable file. For example:
1379
1380 <p>
1381 <example>
1382 # auto-apt run ./configure
1383 </example>
1384
1385 <p>
1386 It will then ask to install the needed packages and call apt-get
1387 automatically. If you're running X, a graphical interface will
1388 replace the default text interface.
1389 <p>
1390 Auto-apt keeps databases which need to be kept up-to-date in order for
1391 it to be effective. This is achieved by calling the commands
1392 <tt>auto-apt update</tt>, <tt>auto-apt updatedb</tt> and
1393 <tt>auto-apt update-local</tt>.
1394 </sect>
1395
1396 <sect id="apt-file">How to discover to which package a file belongs
1397 <p>
1398 If you want to install a package, and you can't find out what it is
1399 called by searching with <prgn>apt-cache</prgn>, but know the filename
1400 of the program itself, or some other filename that belongs to the package,
1401 then you can use <prgn>apt-file</prgn> to find the package name. This
1402 is done like this:
1403
1404 <p>
1405 <example>
1406 $ apt-file search <var>filename</var>
1407 </example>
1408
1409 <p>
1410 It works just like <tt>dpkg -S</tt>, but will also show you uninstalled
1411 packages that contain the file. It could also be used to find what
1412 packages contain necessary include files that are missing when
1413 compiling programs, although <prgn>auto-apt</prgn> is a much better
1414 method of solving such issues, see <ref id="auto-apt">.
1415 <p>
1416 You can also list the contents of a package, by running:
1417
1418 <p>
1419 <example>
1420 $ apt-file list <var>packagename</var>
1421 </example>
1422
1423 <p>
1424 <prgn>apt-file</prgn> keeps a database of which files all packages
1425 contain, just like auto-apt does and it needs to be up-to-date.
1426 This is done by running:
1427
1428 <p>
1429 <example>
1430 # apt-file update
1431 </example>
1432
1433 <p>
1434 By default, <prgn>apt-file</prgn> uses the same database
1435 <prgn>auto-apt</prgn> is using, see <ref id="auto-apt">.
1436
1437 </sect>
1438
1439 <sect id="apt-listchanges">How to keep informed about the changes in the packages.
1440 <p>
1441 Every package installs in its documentation directory (<tt>/usr/share/doc/packagename</tt>)
1442 a file called <tt>changelog.Debian.gz</tt> which contains the list of changes
1443 made to the package since the last version. You can read these files with
1444 <tt>zless</tt>' help, for example, but it is something not so easy, after an
1445 complete system upgrade, to start searching changelogs for every upgraded
1446 package.
1447 <p>
1448 There's a way to automatize this task by means of a tool called
1449 <prgn>apt-listchanges</prgn>. To begin with one needs to install
1450 the <package>apt-listchanges</package> package. During the package
1451 installation, Debconf will configure it. Some questions may not be
1452 shown to you depending on the priority you set up Debconf to use.
1453 Answer to the questions as you want.
1454 <p>
1455 The first question asks how you want the changes to be showed by
1456 apt-listchanges. You can have them mailed to you, which is good for
1457 automatic upgrades, or you can ask them in a pager
1458 like <prgn>less</prgn>, so you can inspect the changes before
1459 leting the upgrade continue. If you don't
1460 want <prgn>apt-listchanges</prgn> running automaticaly during
1461 upgrades you can answer <tt>none</tt>.
1462 <p>
1463 After apt-listchanges is installed, as soon as packages are downloaded
1464 (or gotten from a CD or mounted disk) by apt it will show the lists
1465 of changes made to those packages before installing them.
1466 </sect>
1467 </chapt>
1468
1469 <chapt id="sourcehandling">Working with source packages
1470 <sect id="source">Downloading source packages
1471 <p>
1472 It's common in the world of free software to study source code or
1473 even make corrections to buggy code. To do this, you would need to
1474 download the source of the program. The APT system provides an easy way
1475 to obtain source code to the many programs contained in the
1476 distribution, including all the files needed to create a .deb for the
1477 program.
1478 <p>
1479 Another common use of Debian sources is to adapt a more recent version
1480 of a program, from the unstable distribution, for example, for use with
1481 the stable distribution. Compiling a package against stable will
1482 generate .debs with dependencies adjusted to match the packages
1483 available in this distribution.
1484 <p>
1485 To accomplish this, the <tt>deb-src</tt> entry in your
1486 <tt>/etc/apt/sources.list</tt> should be pointed at unstable. It should
1487 also be enabled (uncommented). See section <ref id="sources.list">.
1488 <p>
1489 To download a source package, you would use the following command:
1490
1491 <p>
1492 <example>
1493 $ apt-get source packagename
1494 </example>
1495 <p>
1496 This will download three files: a <tt>.orig.tar.gz</tt>, a
1497 <tt>.dsc</tt> and a <tt>.diff.gz</tt>. In the case of packages
1498 made specifically for Debian, the last of these is not downloaded
1499 and the first usually won't have <tt>"orig"</tt> in the name.
1500 <p>
1501 The <tt>.dsc</tt> file is used by dpkg-source for unpacking the source
1502 package into the directory <var>packagename-version</var>. Within each
1503 downloaded source package there is a <tt>debian/</tt> directory that
1504 contains the files needed for creating the .deb package.
1505 <p>
1506 To auto-build the package when it's been downloaded, just add
1507 <tt>-b</tt> to the command line, like this:
1508
1509 <p>
1510 <example>
1511 $ apt-get -b source packagename
1512 </example>
1513
1514 <p>
1515 If you decide not to create the .deb at the time of the download, you
1516 can create it later by running:
1517
1518 <p>
1519 <example>
1520 $ dpkg-buildpackage -rfakeroot -uc -b
1521 </example>
1522
1523 <p>
1524 from within the directory that was created for the package after
1525 downloading. To install the package built by the commands above
1526 one must use the package manager directly, like this:
1527
1528 <p>
1529 <example>
1530 # dpkg -i <var>file.deb</var>
1531 </example>
1532
1533 <p>
1534 There's a difference between <prgn>apt-get</prgn>'s <tt>source</tt>
1535 method and its other methods. The <tt>source</tt> method can be used by
1536 normal users, without needing special root powers. The files are
1537 downloaded to the directory from which the <tt>apt-get source package</tt>
1538 command was called.
1539 </sect>
1540
1541 <sect id="build-dep">Packages needed for compiling a source package
1542 <p>
1543 Normally, specific headers and shared libraries need to be present in
1544 order for a source package to be compiled. All source packages have a
1545 field in their control files called 'Build-Depends:' that indicates
1546 which additional packages are needed for the package to be built from
1547 source.
1548 <p>
1549 APT has a simple way of downloading these packages. Just run
1550 <tt>apt-get build-dep package</tt>, where `package' is the name of the
1551 package you're going to build. For example:
1552
1553 <p>
1554 <example>
1555 # apt-get build-dep gmc
1556 Reading Package Lists... Done
1557 Building Dependency Tree... Done
1558 The following NEW packages will be installed:
1559 comerr-dev e2fslibs-dev gdk-imlib-dev imlib-progs libgnome-dev libgnorba-dev
1560 libgpmg1-dev
1561 0 packages upgraded, 7 newly installed, 0 to remove and 1 not upgraded.
1562 Need to get 1069kB of archives. After unpacking 3514kB will be used.
1563 Do you want to continue? [Y/n]
1564 </example>
1565
1566 <p>
1567 The packages that will be installed are the packages needed in order for
1568 <package>gmc</package> to be built correctly. It's important to note
1569 that this command doesn't look for the source package of the program to
1570 be compiled. You will therefore need to run <tt>apt-get source</tt>
1571 separately to get it.
1572
1573 <p>
1574 If all you want is checking what packages are needed to build a
1575 given package, there's a variant of the <tt>apt-cache show</tt>
1576 command (see <ref id="search">, which will show, among other
1577 informations, the <tt>Build-Depends</tt> line that lists those
1578 information, the <tt>Build-Depends</tt> line that lists those
1579
1580 <p>
1581 <example>
1582 # apt-cache showsrc <var>package</var>
1583 </example>
1584
1585 </sect>
1586 </chapt>
1587
1588 <chapt id="erros">How to deal with errors
1589 <sect id="erros-comuns">Common errors
1590 <p>
1591 Errors will always happen, many of them caused by users not paying
1592 attention. The following is a list of some of the most frequently reported errors and
1593 how to deal with them.
1594 <p>
1595 If you receive a message that looks like the one below when trying to
1596 run <tt>apt-get install package</tt>...
1597
1598 <p>
1599 <example>
1600 Reading Package Lists... Done
1601 Building Dependency Tree... Done
1602 W: Couldn't stat source package list 'http://people.debian.org unstable/ Packages' (/var/state/apt/lists/people.debian.org_%7ekov_debian_unstable_Packages) - stat (2 No such file or directory)
1603 W: You may want to run apt-get update to correct these missing files
1604 E: Couldn't find package penguineyes
1605 </example>
1606
1607 <p>
1608 you forgot to run <tt>apt-get update</tt> after your last change to the
1609 <tt>/etc/apt/sources.list</tt> file.
1610 <p>
1611 If the error looked like:
1612
1613 <p>
1614 <example>
1615 E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)
1616 E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
1617 </example>
1618
1619 <p>
1620 when trying any <prgn>apt-get</prgn> method other than <tt>source</tt>,
1621 you don't have root permission, that is, you're running as a normal
1622 user.
1623 <p>
1624 There's an error similar to the above which happens when you run two
1625 copies of <prgn>apt-get</prgn> at the same time, or even if you try to
1626 run <prgn>apt-get</prgn> while a <prgn>dpkg</prgn> process is active.
1627 The only method that can be used simultaneously with others is the
1628 <tt>source</tt> method.
1629 <p>
1630 If an installation breaks in the middle of the process and you find that
1631 it's no longer possible to install or remove packages, try running these
1632 two commands:
1633
1634 <p>
1635 <example>
1636 # apt-get -f install
1637 # dpkg --configure -a
1638 </example>
1639
1640 <p>
1641 And then try again. It may be necessary to run the second of the above
1642 commands more than once. This is an important lesson for those
1643 adventurers who use `unstable'.
1644
1645 <p>
1646 If you receive the error "E: Dynamic MMap ran out of room" when running
1647 <tt>apt-get update</tt>, add the following line to
1648 <file>/etc/apt/apt.conf</file>:
1649
1650 <example>
1651 APT::Cache-Limit 10000000;
1652 </example>
1653
1654 </sect>
1655
1656 <sect id="help">Where can I find help?
1657 <p>
1658 If you find yourself plagued by doubts, consult the extensive
1659 documentation available for the Debian packaging system.
1660 <tt>--help</tt>'s and manpages can be an enormous help to you, as can
1661 the documentation contained in the <tt>/usr/share/doc</tt> directories
1662 such as <tt>/usr/share/doc/apt</tt>.
1663 <p>
1664 If this documentation fails to drive your fears away, try looking for
1665 the answer on the Debian mailing lists. You can find more information
1666 about specific user lists on the Debian website: <url
1667 id="http://www.debian.org" name="http://www.debian.org">.
1668 <p>
1669 Remember that these lists and resources should be used only by Debian
1670 users; users of other systems will find better support from the
1671 community resources of their own distributions.
1672 </sect>
1673 </chapt>
1674
1675 <chapt id="distros">What distributions support APT?
1676 <p>
1677 Here are the names of some of the distributions that use APT:
1678 <p>
1679 Debian GNU/Linux (<url id="http://www.debian.org" name="http://www.debian.org">)
1680 - it was for this distribution that APT was developed
1681 <p>
1682 Conectiva (<url id="http://www.conectiva.com.br" name="http://www.conectiva.com.br">)
1683 - this was the first distribution to port APT for use with rpm
1684 <p>
1685 Libranet (<url id="http://www.libranet.com" name="http://www.libranet.com">)
1686 <p>
1687 Mandrake (<url id="http://www.mandrake.com" name="http://www.mandrake.com">)
1688 <p>
1689 PLD (<url id="http://www.pld.org.pl" name="http://www.pld.org.pl">)
1690 <p>
1691 Vine (<url id="http://www.vinelinux.org" name="http://www.vinelinux.org">)
1692 <p>
1693 APT4RPM (<url id="http://apt4rpm.sf.net" name="http://apt4rpm.sf.net">)
1694 <p>
1695 Alt Linux (<url id="http://www.altlinux.ru/" name="http://www.altlinux.ru/">)
1696 <p>
1697 Red Hat (<url id="http://www.redhat.com/" name="http://www.redhat.com/">)
1698 <p>
1699 Sun Solaris (<url id="http://www.sun.com/" name="http://www.sun.com/">)
1700 <p>
1701 SuSE (<url id="http://www.suse.de/" name="http://www.suse.de/">)
1702 <p>
1703 Yellow Dog Linux (<url id="http://www.yellowdoglinux.com/"
1704 name="http://www.yellowdoglinux.com/">)
1705 </chapt>
1706
1707 <chapt id="agradecimentos">Credits
1708 <p>
1709 A big thank you goes out to my great friends in the Debian-BR project,
1710 and in Debian itself, who are a constant help to me and always give me
1711 the strength to continue working for humanity's benefit, as well as
1712 helping me with my goal of saving the world. :)
1713 <p>
1714 I also want to thank the CIPSGA for the enormous help it has given to
1715 our project and to all the free projects that spring from great ideas.
1716 <p>
1717
1718 And special thanks to:
1719 <p>
1720 Yooseong Yang &lt;yooseong@debian.org&gt;
1721 <p>
1722 Michael Bramer &lt;grisu@debian.org&gt;
1723 <p>
1724 Bryan Stillwell &lt;bryan@bokeoa.com&gt;
1725 <p>
1726 Pawel Tecza &lt;pawel.tecza@poczta.fm&gt;
1727 <p>
1728 Hugo Mora &lt;h.mora@melix.com.mx&gt;
1729 <p>
1730 Luca Monducci &lt;luca.mo@tiscali.it&gt;
1731 <p>
1732 Tomohiro KUBOTA &lt;kubota@debian.org&gt;
1733 <p>
1734 Pablo Lorenzzoni &lt;spectra@debian.org&gt;
1735 <p>
1736 Steve Langasek &lt;vorlon@netexpress.net&gt;
1737 <p>
1738 Arnaldo Carvalho de Melo &lt;acme@conectiva.com.br&gt;
1739 <p>
1740 Erik Rossen &lt;rossen@freesurf.ch&gt;
1741 <p>
1742 Ross Boylan &lt;RossBoylan@stanfordalumni.org&gt;
1743 <p>
1744 Matt Kraai &lt;kraai@debian.org&gt;
1745 <p>
1746 Aaron M. Ucko &lt;ucko@debian.org&gt;
1747 <p>
1748 Jon &Aring;slund &lt;d98-jas@nada.kth.se&gt;
1749 </chapt>
1750
1751 <chapt id="novas">New versions of this tutorial
1752 <p>
1753 This manual was created by the <url id="http://www.debian-br.org"
1754 name="Debian-BR"> project, with the goal of aiding everyday use of
1755 Debian.
1756 <p>
1757 New versions of this document will be made available in the Debian
1758 Documentation Project's
1759 page, at
1760 <url id="http://www.debian.org/doc/ddp"
1761 name="http://www.debian.org/doc/ddp">.
1762 <p>
1763 Comments and criticisms can be sent to me directly by email at
1764 <email>kov@debian.org</email>.
1765 </chapt>
1766
1767 </book>
1768
1769 </debiandoc>

  ViewVC Help
Powered by ViewVC 1.1.5