Apt Howto.en

Embed Size (px)

Citation preview

  • 8/2/2019 Apt Howto.en

    1/53

    APT HOWTOGustavo Noronha Silva

    2.0.2 - October 2006

    Abstract

    This document intends to provide the user with a good understanding of the workings of theDebian package management utility, APT. Its goal is to make life easier for new Debian usersand to help those who wish to deepen their understanding of the administration of this system.It was created for the Debian project in order to help improve the support available for usersof this distribution.

  • 8/2/2019 Apt Howto.en

    2/53

    Copyright Notice

    Copyright 2001, 2002, 2003, 2004, 2005 Gustavo Noronha Silva

    This manual is free software; you may redistribute it and/or modify it under the terms of theGNU General Public License as published by the Free Software Foundation; either version 2,or (at your option) any later version.

    This is distributed in the hope that it will be useful, but without any warranty; without even theimplied warranty of merchantability or fitness for a particular purpose. See the GNU GeneralPublic License for more details.

    A copy of the GNU General Public License is available as /usr/share/common-licenses/GPLin the Debian GNU/Linux distribution or on the World Wide Web at the GNU General PublicLicence. You can also obtain it by writing to the Free Software Foundation, Inc., 51 Franklin St,Fifth Floor, Boston, MA 02110-1301, USA.

  • 8/2/2019 Apt Howto.en

    3/53

    i

    Contents

    1 Introduction 1

    1.1 Basic terminology and concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    2 Introduction to the Debian archive 3

    2.1 Introduction to Debian suites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2.2 Debian sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2.3 APTs chain of trust . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    3 Basic Configuration 5

    3.1 The /etc/apt/sources.list file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.2 Authenticating packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    3.3 Adding a CD-ROM to the sources.list file . . . . . . . . . . . . . . . . . . . . . . . 7

    3.4 The APT configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    3.5 Adjusting APT priority for packages . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    3.6 Using APT through a proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    4 Managing packages 11

    4.1 Using the Debian Package Manager: aptitude . . . . . . . . . . . . . . . . . . . . . 114.2 Updating the list of available packages . . . . . . . . . . . . . . . . . . . . . . . . . 13

    4.3 Searching for packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    4.4 Installing and reinstalling packages . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    4.5 Installing manually downloaded or locally created debian packages . . . . . . . . 17

    4.6 Removing packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    4.7 Upgrading packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    4.8 Upgrading to a new release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

  • 8/2/2019 Apt Howto.en

    4/53

    CONTENTS ii

    4.9 Keeping packages on hold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    4.10 Removing unused package files: clean and autoclean . . . . . . . . . . . . . . . . 20

    5 Building from source 21

    5.1 Downloading source packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    5.2 Packages needed for compiling a source package . . . . . . . . . . . . . . . . . . . 22

    5.3 Building a debuging package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    5.4 Customizing package build options . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    5.5 But hey, I do not want to use the Debian stuff! . . . . . . . . . . . . . . . . . . . . 24

    6 Getting information about packages. 27

    6.1 Discovering package names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    6.2 Using dpkg to find package names . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    6.3 How to discover to which package a file belongs . . . . . . . . . . . . . . . . . . . 30

    6.4 Information about packages on the Web . . . . . . . . . . . . . . . . . . . . . . . . 31

    7 Tricks and Techniques 33

    7.1 How to install packages on demand . . . . . . . . . . . . . . . . . . . . . . . . . 33

    7.2 Caching packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    7.3 Deciding which mirror is the best to include in the sources.list file: netselect,netselect-apt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    7.4 Removing unused locale files: localepurge . . . . . . . . . . . . . . . . . . . . . . . 36

    7.5 How to keep informed about the changes in the packages. . . . . . . . . . . . . . 36

    8 Being at the other side: creating a repository 37

    9 Alternative User Interfaces for managing packages 39

    9.1 Synaptic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    9.2 GNOME-APT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    10 How to deal with errors 41

    10.1 Common errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    10.2 Where can I find help? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    11 What distributions support APT? 43

  • 8/2/2019 Apt Howto.en

    5/53

    CONTENTS iii

    12 Credits 45

    13 New versions of this tutorial 47

  • 8/2/2019 Apt Howto.en

    6/53

    CONTENTS iv

  • 8/2/2019 Apt Howto.en

    7/53

    1

    Chapter 1

    Introduction

    In the beginning there was the .tar.gz. Users had to compile each program that they wanted touse on their GNU/Linux systems. When Debian was created, it was deemed necessary that thesystem include a method of managing the packages installed on the machine. The name dpkgwas given to this system. Thus the famous package first came into being on GNU/Linux, awhile before Red Hat decided to create their own rpm system.

    A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They neededa rapid, practical, and efficient way to install packages that would manage dependencies au-tomatically and take care of their configuration files while upgrading. Here again, Debian led

    the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported byConectiva for use with rpm and has been adopted by some other distributions.

    This manual makes no attempt to address apt-rpm, as the Conectiva port of APT is known, butpatches to this document which do so would be welcome.

    This manual is based on the next Debian release, Etch, as of 31th of August, 2005.

    1.1 Basic terminology and concepts

    Here you can find some basic terminology and concepts used on this manual:

    APT source: an APT source is a location (often on the internet, or possibly on aCDROM or other location) which functions as a repository of Debian packages, see The/etc/apt/sources.list file on page 5.

    APT source line: an APT source line is a line you add to a configuration file to tell APT aboutthe Apt sources you want to use, see The /etc/apt/sources.list file on page 5.

    binary package: a binary package is a .deb file prepared to be installed by the package man-ager (dpkg), it may include binary files but may also carry just architecture-independent data its called binary package either way.

    debian-native: package created specifically for Debian, this kind of package usually has the

  • 8/2/2019 Apt Howto.en

    8/53

    Chapter 1. Introduction 2

    debian control files inside the original source and every new version of the package is also anew version of the original program or data.

    debianize: verb usually used to mean prepare for use with Debian or, more simply put,packaged in .deb format.

    source package: a source package is really an abstract definition to a set of two or three fileswhich are part of the deb source format: a .dsc file, which contains information about thepackage, also called source control file; a .orig.tar.gz file, which contains the original up-stream source for that package you may also find this being called .tar.gz, simply, withno .orig, meaning this is a debian-native package; a .diff.gz file, which carries the modifi-cations made to the original source to debianize the package you will not find this kind offile on a debian-native package.

    upstream: this word usually means something that comes from the original developer of thesoftware or data, or the developer himself.

    virtual packages: virtual packages are packages that do not really exist, but that aregeneric services provided by some specific packages the most common example is themail-transport-agent package, to which packages that need an MTA1 can specify a de-pendency while keeping the user choice as to which MTA to use.

    1MTA means Mail Transfer Agent its usually a server to send and receive mail

  • 8/2/2019 Apt Howto.en

    9/53

    3

    Chapter 2

    Introduction to the Debian archive

    2.1 Introduction to Debian suites

    Debian development happens in a model where we have three main trees which we callsuites: the stable suite is the last released version of Debian; the testing suite contains the-oretically a always-ready-to-release version, packages come from the unstable branch afterbeing there for 10 days with no critical problems reported and after being built on all releasearchitectures; the unstable suite is where development happens: all new packages go to unsta-ble to be tested for releasability and, then, end up in testing.

    The stable suite never receives new versions of packages, just new revisions to fix security orcritical problems. It is supposed to remain stable, meaning that the admin need not expectchanges in configuration or behavior of the software they administer.

    There is another suite which is treated differently from the usual ones by many tools: the ex-perimental suite. First of all, it is not a self-contained suite, meaning you cannot have a systeminstalled simply from it, you usually need to use it together with one of the ones mentionedearlier: most times the unstable one is chosen.

    Its treated differently because it is indeed highly experimental in nature. Packages whichmaintainers think are broken or not really ready to go in unstable come to experimental forwider testing by fearless maintainers. Please do not use experimental if youre not actuallywilling to help in development, taking care of the burden it might bring to you yourself.

    2.2 Debian sections

    Each suite of a Debian repository is usually composed of one or more sections; their names andpurposes may vary from one distributor to the other. Debian itself has three sections: main,contrib and non-free.

    The main section is what Debian actually is, officially. All the software that conformsto the Debian Free Software Guidelines (http://www.debian.org/social_contract#

    http://www.debian.org/social_contract#guidelineshttp://www.debian.org/social_contract#guidelineshttp://www.debian.org/social_contract#guidelines
  • 8/2/2019 Apt Howto.en

    10/53

    Chapter 2. Introduction to the Debian archive 4

    guidelines) (DFSG) and only depends on DFSG-conformant software come to this sectionof the archive, complying with the Social Contract (http://www.debian.org/social_contract). Through these documents, and by promising to only allow software that com-plies with them to enter the main section, Debian provides a reasonably clear basic standardof freedom which users can rely on when installing software from main.

    The contrib section is composed of DFSG-compliant software which depend on non-DFSG-compliant software or data to work. The non-free section is composed of software which donot conform to the DFSG but may be distributed. You should check the license of each softwarefrom non-free you want to install to evaluate if theyre good enough for you to accept.

    2.3 APTs chain of trust

    APT comes equipped with a cryptographic chain-of-trust that extends from the debian devel-opers to the end users.

    The chain starts with the package maintainers who sign and upload their packages. Eachsignature is checked against the packagers key which was uploaded when they became anofficial Debian developer. This key was itself verified personally by other Debian developers.

    Once the uploaded package is verified as having been signed by the maintainer, an MD5 sumof the package is computed and put in the Packages file. The MD5 sums of all of the Packagesfiles are then computed and put into the Release file. The Release file is then signed by thearchive key which is created once a year and distributed by the FTP server. This key is also onthe Debian keyring.

    Therefore, the end user, having added the archive key to his keyring , can check that theRelease file was signed by the proper key, the MD5 sums of all the Packages files, andthe MD5 sums of all the Debian packages. APT automates this process:

    During update (see Updating the list of available packages on page 13), APT checks the sig-nature of the Release files by using its keyring (see Authenticating packages on page 6 forinformation on this) and the MD5 sums of the Packages files (which are recorded in the Re-lease files).

    During upgrade or installation of a package (see Upgrading packages on page 18 and In-

    stalling and reinstalling packages on page 14 respectively) APT checks the MD5 sums of thepackages (which are stored in the Packages files).

    If any of these steps fails, the user is warned, and the process halts.

    http://www.debian.org/social_contract#guidelineshttp://www.debian.org/social_contract#guidelineshttp://www.debian.org/social_contracthttp://www.debian.org/social_contracthttp://www.debian.org/social_contracthttp://www.debian.org/social_contracthttp://www.debian.org/social_contract#guidelineshttp://www.debian.org/social_contract#guidelines
  • 8/2/2019 Apt Howto.en

    11/53

    5

    Chapter 3

    Basic Configuration

    3.1 The /etc/apt/sources.list file

    As part of its operation, APT uses a file that lists the APT sources from which packages canbe obtained. This file is /etc/apt/sources.list.

    The entries in this file normally follow this format:

    deb http://host/debian distribution section1 section2 section3

    deb-src http://host/debian distribution section1 section2 section3

    Of course, the above entries are fictitious and should not be used. The first word on each line,deb or deb-src, indicates the type of archive: whether it contains binary packages (deb), thatis, the pre-compiled packages that we normally use, or source packages (deb-src), which arethe original program sources plus the Debian control file (.dsc) and the diff.gz containingthe changes needed for debianizing the program, check Building from source on page 21.

    The word that goes where we read distribution in the above example defines what is theDebian suite were targeting. They can be generic names, like stable, testing, or specificnames like sarge and etch. Lets say the current testing is called etch and you wantto keep tracking etch even when it becomes stable; in this case you should use etch fordistribution. In case you want to keep tracking testing you should use testing instead.So, if you want to always have the latest stable distribution, and upgrade as soon as a newrelease is made, you should be using stable as distribution. This may not be a goodidea, for you may want to plan the upgrade for stable releases, which sometimes involvesmore than simply answering a few new questions, besides doing some testing and backupingbefore proceeding, so I recommend you always use the codenames.

    We usually find the following in the default Debian sources.list:

    deb http://http.us.debian.org/debian stable main

    deb http://security.debian.org stable/updates main

  • 8/2/2019 Apt Howto.en

    12/53

    Chapter 3. Basic Configuration 6

    #deb-src http://http.us.debian.org/debian stable

    #deb-src http://security.debian.org stable/updates main

    These are the lines needed by a basic Debian install. The first deb line points to the officialarchive, the second to the archive of Debian security updates.

    The two last lines are commented out (with a # in front), so APT will ignore them. These aredeb-src lines, that is, they point to Debian source packages. If you often download programsources for testing or recompiling, uncomment them.

    The /etc/apt/sources.list file can contain several types of lines. APT knows how todeal with archives of types http, ftp, file (local files, e.g., a directory containing a mounted

    ISO9660 filesystem) and ssh, that I know of.Remember: everytime you want to add a source for APT to grab packages from this is the fileyoure going to edit.

    Do not forget to update the list of packages after modifying the /etc/apt/sources.listfile, see Updating the list of available packages on page 13. You must do this to let APT knowwhat packages are available from the sources you specified.

    3.2 Authenticating packages

    As of APT version 0.6, packages are authenticated to ensure that they originate from the sourcethat they claim to originate from. This is an optional security feature. If the system cantauthenticate the package upon installation, itll ask you whether or not you want to abort theinstallation.

    Since this authentication is based on cryptographic methods, APT maintains its own keyring.Each of the entries in your sources.list file will have a corresponding key. However, ifyoure using unofficial APT sources, its possible that a source youre using wont be authen-ticated. If this is the case, you should encourage the maintainer of that source to implementauthentication on their site.

    To take advantage of this security feature, you need to add a key to APTs keyring for eachauthenticated source. This can be done with GPG, but APT provides a tool, apt-key, whichis a simplified wrapper to GPG.

    apt-key is easy to use. The tricky part of this process is getting a key for each of your sources,and making sure that you can trust that key.

    Debians archive key will be installed in /usr/share/apt/debian-archive.gpg, so youcan simply use that file to add the official archives key to your APT keyring by doing this:

    # apt-key add /usr/share/apt/debian-archive.gpg

  • 8/2/2019 Apt Howto.en

    13/53

    Chapter 3. Basic Configuration 7

    For external, unofficial sources youll need to find out where did they provide their public keyso that you can import it into your APT keyring.

    If you choose to disable the cryptographic checking of Release files for some reason you canadd the following to APTs configuration (see The APT configuration file on the followingpage):

    APT::Get::AllowUnauthenticated "true";

    3.3 Adding a CD-ROM to the sources.list file

    If youd rather use your CD-ROM for installing packages or updating your system automati-cally with APT, you can put it in your sources.list. To do so, you can use the apt-cdromprogram like this:

    # apt-cdrom add

    with the Debian CD-ROM in the drive. It will mount the CD-ROM, and if its a valid DebianCD it will look for package information on the disk. If your CD-ROM configuration is a littleunusual, you can also use the following options:

    -h - program help

    -d directory - CD-ROM mount point

    -r - Rename a recognized CD-ROM

    -m - No mounting

    -f - Fast mode, dont check package files

    -a - Thorough scan mode

    For example:

    # apt-cdrom -d /home/kov/mycdrom add

    You can also identify a CD-ROM, without adding it to your list:

    # apt-cdrom ident

    Note that this program only works if your CD-ROM is properly configured in your systems/etc/fstab.

  • 8/2/2019 Apt Howto.en

    14/53

    Chapter 3. Basic Configuration 8

    3.4 The APT configuration file

    APT uses /etc/apt/apt.conf as its main configuration file. Although, as you will find out,theres no file named like that in a default install, you can safely create one and add your editsthere. If you prefer, theres a more modular way of handling configuration: you can placeindividual files with whatever names you choose into /etc/apt/apt.conf.d/.

    Beware of two facts when you choose the modular way: some Debian packages will droptheir configuration stuff into that directory, so you have to try to prevent name clashes by, forexample, adding a -local suffix to the name. Also, the configuration is read ordered by thefile name, so you can add a number at the very beginning of your filename to position it onthe sequence. For example, you can name it 00000myconf-local if you want to make sureit will be the first configuration to be considered.

    To know the syntax and options accepted by those configuration files, check out theapt.conf(5) manpage.

    3.5 Adjusting APT priority for packages

    APT uses a prioritization algorythm to decide what repository it should grab a given packagefrom. Heres a simple example:

    $ apt-cache policy apt-howto

    apt-howto:

    Installed: 1.8.10.3-1

    Candidate: 1.8.11-1

    Version table:

    1.8.11-1 0

    500 http://ftp.nl.debian.org sid/main Packages

    *** 1.8.10.3-1 0

    500 http://ftp.nl.debian.org sarge/main Packages

    100 /var/lib/dpkg/status

    I have two sources here: a sid and a sarge one, and thats all.

    The installed version is marked with ***. We can see its installed because of the mention ofthe /var/lib/dpkg/status file, too, which holds the information about the current state ofthe system. We can also see that the package comes from sarge. The sid version is also listedas available.

    APT gives priority 100 for installed packages, as we can see, and 500 for all other sources witha single exception: the experimental suite, which, as we already said, is treated in a specialway by many tool. APTs algorythm will prefer to install packages from sources with higherpriority. If priorities are the same, then it will prefer the highest version. You can see that bylooking at the Candidate field, which lists the newer version, from unstable, as candidate forinstalation: it wants to upgrade it.

  • 8/2/2019 Apt Howto.en

    15/53

    Chapter 3. Basic Configuration 9

    If you want to have the sid source only to install selected packages and dont want APT toautomaticaly consider packages from that source as candidates for upgrades, then you musttweak its priorities. You do that using the Archive field of the Release file of the source youwant to give priority to. You can find that information out by looking at the Release file whichthe update process downloaded:

    # grep ^Archive /var/lib/apt/lists/ftp.nl.debian.org_debian_dists_sarge_main_

    Archive: stable

    Notice that the filename changes depending on your source line. To make APT keep yourpackages at the stable suite, then, you add a file with the following contents to /etc/apt/apt.conf.d/:

    APT::Default-Release "stable";

    Then, APT policy will have changed:

    $ apt-cache policy apt-howto

    apt-howto:

    Installed: 1.8.10.3-1

    Candidate: 1.8.10.3-1

    Version table:

    1.8.11-1 0

    500 http://ftp.nl.debian.org sid/main Packages

    *** 1.8.10.3-1 0

    990 http://ftp.nl.debian.org sarge/main Packages

    100 /var/lib/dpkg/status

    APT will give priority 990 for its default source for any package, the other sources remain justlike before. Packages from other sources which are installed will have their priority raisedfrom 100 to 500. Why is APT not going to downgrade them? Because APT will only considera downgrade in case something is given a priority above 1000. That means, though, that APTwill not automaticaly upgrade the versions from the non-default sources unless the tool youreusing wants to try to to help you there, which is the case for aptitude.

    Defining priority for groups of packages based on many other criteria is also possible by usingthe /etc/apt/preferences configuration file. You can even convince APT to try to down-grade your whole system, althought thats not supported and should not be tried by the faintof heart. You can have more information about that by reading the apt_preferences(5)manpage..

    3.6 Using APT through a proxy

    If you are using APT in a network in which all http and ftp connections are made through aproxy, then youll have to setup APT to use that proxy. You can do this by editing the /etc

  • 8/2/2019 Apt Howto.en

    16/53

    Chapter 3. Basic Configuration 10

    /apt/apt.conf configuration file or by placing a configuration file inside the /etc/apt/apt.conf.d/ directory, which makes it is easier to organize the configuration stuff (take alook at The APT configuration file on page 8).

    If that file does not exist, then create it and add lines like these:

    Acquire::http::proxy "http://proxy:port";

    Acquire::ftp::proxy "http://proxy:port";

    Replace proxy and port for those given by your network administrator. You can also specifyuser and password if the proxy requires like this:

    Acquire::http::proxy "http://user:password@proxy:port";

    There are many other useful options you can set for APT on the /etc/apt/apt.conf con-figuration file, see The APT configuration file on page 8.

  • 8/2/2019 Apt Howto.en

    17/53

    11

    Chapter 4

    Managing packages

    4.1 Using the Debian Package Manager: aptitude

    Debian has long lived with a package manager which was known to be difficult to understandand use, called dselect. The Debian system is now moving towards a new default managercalled aptitude, which is also based on the APT library.

    If you installed Sarge you will have aptitude installed by default on the base system, other-wise install the aptitude package by running, for example, this command before continuing:

    # apt-get install aptitude

    Try to avoid using apt-get and use aptitude instead, as it knows much more about whatAPT is able to do and have some unique features like marking packages that were automati-cally installed to satisfy dependencies and ask to remove them automatically when they are nolonger needed.

    aptitude has two main modes: a ncurses-based UI in which you can navigate through a listof packages much like dselect and a command line-based UI, much like apt-get. Mostexamples in this document use the command line-based UI, giving tips on which command isused to achieve the same results in the aptitude dselect-like UI.

    TofireupthisUI,type aptitude in a terminal theres no need to be root at this time, aptitudewill request root powers when it needs them automatically. Lets check out the basics: to accessthe menubar at the top of the screen you need to press F10, as the second line suggests. Thissecond line has a summary of the most commonly used features like getting help, quiting,updating list of packages and proceeding.

    Do take a look at the User Manual which is located at the help menu to understand how thething works.

    Notice that aptitude works in a way similar to other package managers: you make all yourselections and then commits the changes. Almost all actions done in managing the instalationof a package will require pressing the g key two times to be effective. The first time you press

  • 8/2/2019 Apt Howto.en

    18/53

    Chapter 4. Managing packages 12

    g youll be presented with the list of changes being done, then you press g again to confirm thechanges or q to go back.

    Similarly, you can press the Enter key to get more details about a package or group of pack-ages for example, you can press Enter when the selection is on New Packages to see thea list of sections. By pressing Enter on a section you will see the list of new packages in thatsection and you can see more details on a package by pressing Enter on it. Notice that enter-ing a packages details will change aptitudes view context, so youll need to press q to goback.

    The packages are categorized by default based on their installation status and some other spe-cial categories. Youll be seing this when you first enter aptitude

    --- New Packages--- Upgradable Packages

    --- Installed Packages

    --- Not Installed Packages

    --- Obsolete and Locally Created Packages

    --- Virtual Packages

    --- Tasks

    New Packages has the packages that entered Debian since the last time you cleared your list ofnew packages using the Forget new packages option in the Actions menu, or the f key.

    Upgradable Packages are installed packages that have new versions available. Installed Pack-ages are the installed packages proper, Not Installed Packages are the ones you did not installbut are available from one of the APT sources. Obsolete and Locally Created Packages arethose packages that are no longer available from at least one APT source or the ones you cre-ated yourself. Virtual Packages are packages defining a service rather than a particular soft-ware and that are provided by several specific packages. Finally, Tasks are the collections ofpackages which serve a specific purpose, also used by the tasksel program.

    Pressing Enter on any of those will expand the tree to something like this:

    --\ Not Installed Packages

    --- admin - Administrative utilities (install software, manage users, etc)

    --- base - The Debian base system

    [...]

    Going even deeper well have:

    --\ games - Games, toys, and fun programs

    --- contrib - Programs which depend on software not in Debian

    --\ main - The main Debian archive

    p 3dchess 0.8.1-

  • 8/2/2019 Apt Howto.en

    19/53

    Chapter 4. Managing packages 13

    This shows us one package which is a not installed one, that is a game and that is availablefrom the main Debian repository, which is what the Debian distribution is officially.

    On the center of the screen theres a marked line that is filled with some text when you select apackage. That is what we call the short description of the package. Below it theres a textbox containing more detailed information on the package. Thats the long description.Some times the long description is too big to fit the rectangle reserved for it, so you can pressthe z key to scroll it down and a to scroll it up again.

    Check Installing and reinstalling packages on the next page for more information on the datashown here.

    4.2 Updating the list of available packages

    The packaging system uses a private database to keep track of which packages are installed,which are not installed and which are available for installation. The aptitude program usesthis database to find out how to install packages requested by the user and to find out whichadditional packages are needed in order for a selected package to work properly.

    To update this list, you would use the command aptitude update. This commandlooks for the package lists in the archives found in /etc/apt/sources.list; see The/etc/apt/sources.list file on page 5 for more information about this file. You can also usethe u key inside the ncurses interface of aptitude to have it update the packages lists.

    One of the steps that APT takes in updating your database is to verify that the list of packagesand their MD5 sums is secure. It does this by verifying a cryptographic signature, and checkingsome MD5 sums; see APTs chain of trust on page 4 for more information. If APT finds thatthe signature is incorrect, or that the MD5 sums do not match, you may get an error whileupdating your package database. This is to prevent trojaned packages from being installed onyour computer. If this occurs, there may be a configuration problem (such as an out-of-datekey) which you can solve. Failing this, you should contact the administrator of the apt sourcethat failed.

    Its a good idea to update the lists of available packages regularly to keep yourself and your

    system informed about possible package updates, particularly security updates.

    4.3 Searching for packages

    Aptitude provides a very flexible and powerful search feature. You can access it by pressingthe / (slash) key. That will open a small dialog on the center of the screen.

    You can then type the name of a package. Aptitude will search as you type. If the packageit finds is not exactly the one you want you can press enter for the dialog to vanish and thenpress the n key to repeat the search for the same string.

  • 8/2/2019 Apt Howto.en

    20/53

    Chapter 4. Managing packages 14

    You can use regular expressions1 on the search dialog, just beware that aptitude has its ownsearch language which sometimes overlaps with the regular expressions one. Lets move on toan example, then: if you want to have an exact match to the string gnome type ^gnome$on the search dialog.

    Notice that when searching like this you are simply searching for the package names. If youwant to search for descriptions you need to use ~d right before the search term. So, ifyou want to search for all packages mentioning isolinux on their descriptions youd write~disolinux at the search dialog.

    You can also search for all packages which are currently broken by searching for ~b, searchfor all the packages which were removed but which configuration files have ben kept searchingfor ~c.

    For more advanced searching on aptitude take a look at Aptitudes User Manual, whichyou can find inside the Help menu.

    You can also use the command line to search for packages like this:

    $ aptitude search ~c

    c A abiword-common - WYSIWYG word processor based on GTK2

    c A acme - Enables the "multimedia buttons" found

    (...)

    As you can see, you can use any aptitude search string when using the command line too, andaptitude provides you some information on the state of the packages that we are going todiscuss through this manual.

    4.4 Installing and reinstalling packages

    Finally, the process youve all been waiting for! With your sources.list ready, your keys addedto APTs keyring, and your list of available packages up to date, all you have to do is runaptitude to get your desired package installed.

    When you enter aptitude you can have it install one or more packages by pressing the +key while the package in question is selected. You can use the / key to search for the pack-

    age you want, see Searching for packages on the preceding page. When you request theinstallation of a package it will be marked with a green color and the line will look like in thisexample:

    pi celestia-gnome 1.3.0-

    This means that the package is not installed (p) and is marked for installation. The word means no version is installed and the version number after it is the one that is beingmarked for installation.

    1regular expressions are special strings to match sentences based on some conditions, take a look at the regex(7)manpage

  • 8/2/2019 Apt Howto.en

    21/53

  • 8/2/2019 Apt Howto.en

    22/53

    Chapter 4. Managing packages 16

    --\ Versions

    p A 4.3.0-0pre1v4

    i A 4.2.1-14

    Those versions which are trusted will not have the U letter at the forth column, so you justpick the one you want and tell aptitude to install. Our example above has different versionscoming from trusted sources.

    Notice that almost always, when you see three or more dashes you can press Enter to have itexpand. It will then become something like --\. You now have plenty of information on thispackage, like what packages it depends on and which it conflicts2, for example.

    Also notice that at the end of the screen (you can go down using the arrow keys or page down)youll find the different Versions available for that package. The xterm package has two

    available versions for me, because I have more than one APT source providing it at differentversions.

    You can install the version you want by pressing + on it. Remeber that you need to askaptitude to proceed with the marks you have made. You do that by pressing g. Aptitudewill then show a list of actions its going to perform where you can see if it is doing what youwant:

    --\ Packages being automatically installed to satisfy dependencies

    ciA calctool 4.3.16

    --\ Packages being held back

    ih libgnomeprintui2.2-0 2.4.0-1 2.4.2---\ Packages to be installed

    pi gwget2 0.7-3

    --\ Packages to be removed

    ip qvwm 1:1.1.12-1 1:1.1.

    The entries should be easily understandable. The new thing here is a package being held back.You can read more about that in Keeping packages on hold on page 19. After checking thechanges are the ones you wish confirm the selections by pressing the g key again.

    aptitude will now start the process of downloading and installing the packages you haveselected. APT may also start upgrading any packages that need to be upgraded at this time

    (see Upgrading packages on page 18). If you have selected packages from untrusted sourcesaptitude will show you a list of those packages and prompt you before starting to obtain thepackages whether you really want to install them. See APTs chain of trust on page 4 for moreinformation on secure sources.

    If you want to reinstall a package, say, to have files you removed by accident recovered orsomething you can press the L key to mark it for reinstallation. Youll then go through thesame process as if you were installing it.

    You can also use aptitude without the interactive UI to install or reinstall packages like this:2a package which conflicts with another one or with a specific version of another package cannot be installed

    at the same time as that package or package version

  • 8/2/2019 Apt Howto.en

    23/53

    Chapter 4. Managing packages 17

    # aptitude install package1 package2 ...

    # aptitude --reinstall install package1 package2 ...

    4.5 Installing manually downloaded or locally created debian pack-

    ages

    If you have downloaded a .deb file manually from the internet or has got a .deb from anysource other than using APT you will not be able to use aptitude or any other APT-basedprogram to install it.

    Youll then need to use the underlying package management tool, which is the onethat actually

    does the hard work of installing packages even aptitude calls this tool for installing:dpkg

    .You can install a package by doing:

    # dpkg -i file.deb

    If you want to use the unstable branch of Debian or wishes to create Debian packages youbetter learn more about dpkg! Its a very powerful tool and has many useful options.

    4.6 Removing packages

    If you no longer want to use a package, you can remove it from your system using APT. To dothis just type - while having the package selected on aptitude. That will mark the packagefor removal with a purple-colored line, like this:

    id celestia-gnome 1.3.0-1 1.3.0-

    Notice that this will result in a line that looks like this, after the package is removed:

    c ocaml-base 3.07.2

    Theres a c atthebeginningoftheline,insteadofap. This means that, in my system, the ocaml-base package was removed but the configuration files are still hanging around. To remove thepackage with its configuration files you have to use the _ key3, instead thats called purge.

    One important note: if you try to remove a package which is a dependency of an installedpackage youll end up having broken packages, as the top of the aptitude screen shows:

    aptitude 0.2.13 #Broken: 1 Will free 208MB of disk space

    3The underscore key, usually found together with the dash, typeable by pressing shift while pressing the dashkey.

  • 8/2/2019 Apt Howto.en

    24/53

    Chapter 4. Managing packages 18

    The broken packages will be marked like this:

    iBA openoffice.org 1.1.0-3 1.1.0-

    You can try to solve the brokeness for yourself, by having the ofending packages removed aswell, so that no broken depends are left or ask aptitude to proceed, pressing the g key. Itwill then try to fix all the brokeness. If the solution taken by the program does not satisfy yourwishes you can manually fix it before confirming with g.

    You can search for broken packages typing / and using ~b as search string and press-ing Enter, you can then search for the next match using the \ key. You can search brokenpackages by simply pressing the b key, also; pressing it again will show you the next bro-

    ken package. See Getting information about packages. on page 27 for more information onfinding packages.

    As usual, you can have packages removed or purged through the command line interface likethis:

    # aptitude remove package1 package2 ...

    # aptitude purge package1 package2 ...

    4.7 Upgrading packages

    Package upgrades are a great success of the APT system. Aptitude will automatically markthe packages that have newer versions for upgrade so all you have to do to upgrade yoursystem is, usually, update the lists of packages (see Updating the list of available packages onpage 13) and then ask aptitude to proceed, by typing g and, after reviewing the changes,confirming with g, again. If aptitude is not marking the upgrades automaticaly you canpress the U (upper u) key to ask it to. This is a configuration option which lives on theOptions->Misc menu.

    You can check the list of packages that have new versions available looking at the UpgradablePackages category:

    --\ Upgradable Packages

    --\ libs - Collections of software routines

    --\ main - The main Debian archive

    iu libgnomeprintui2.2-0 2.4.0-1 2.4.2-

    Packages marked for upgrade have their lines cyan-colored and have the character u as theaction that is going to be performed. If you want to upgrade to a new release, then take a lookat the next section, Upgrading to a new release on the next page.

  • 8/2/2019 Apt Howto.en

    25/53

    Chapter 4. Managing packages 19

    4.8 Upgrading to a new release

    APT allows you to upgrade an entire Debian system at once, either through the Internet orfrom a new CD (purchased or downloaded as an ISO image).

    For example, suppose that youre using revision 0 of the stable version of Debian and you buya CD with revision 3. You can use APT to upgrade your system from this new CD. To do this,use apt-cdrom (see section Adding a CD-ROM to the sources.list file on page 7) to add theCD to your /etc/apt/sources.list and run aptitude to proceed with the instalation,as described above.

    Its important to note that APT always looks for the most recent versions of packages, but onlyafter considering the sources priorities as weve seen on Adjusting APT priority for packages

    on page 8. Consider that and, if your/etc/apt/sources.list

    lists an archive that hasa more recent version of a package than the version on the CD, APT would download thepackage from there, if both sources have the same priority or the other archive has a higherpriority than the one on CD.

    If you want to update your system from the Internet you only need to setup the /etc/apt/sources.list file accordingly. Upgrading to a new stable release is usually just a matter ofrunning the normal upgrade process on aptitude. If your /etc/apt/sources.list usesthe release codename4 youll need to update it to the new name or change it to stable.

    So, for example, this line:

    deb http://http.us.debian.org/debian sarge main

    Would have to read like one of the following as soon as Etch is released as stable for the com-puter to be kept up-to-date with the current stable system:

    deb http://http.us.debian.org/debian etch main

    deb http://http.us.debian.org/debian stable main

    The difference here is that the first one will keep you at etch as long as you wish, even if a newstable comes out. This may be useful if you want to decide when to upgrade to the new stable.The second example will automatically update your box to the new stable when it is released.

    4.9 Keeping packages on hold

    As we saw on the previous section, aptitude will automatically mark packages for upgrade.If you want to keep the current version installed, though, you can ask it to put the package onhold.

    This is achieved by pressing the = key. Packages being held from upgrades will look likethis:

    4For example, Debian 3.0 was called woody, Debian 3.1 is sarge

  • 8/2/2019 Apt Howto.en

    26/53

    Chapter 4. Managing packages 20

    ih alien 8.41 8.41

    In this example, the alien package will be kept at version 8.41 even if a new version appearson an APT source notice the h character at the left. To have it upgraded/upgradable againjust mark it for installation.

    You can put packages on hold using the command line interface, too, by running:

    # aptitude hold package1 package2 ...

    4.10 Removing unused package files: clean and autoclean

    When you install a package APT retrieves the needed files from the hosts listed in/etc/apt/sources.list, stores them in a local repository (/var/cache/apt/archives/), andthen proceeds with installation; see Installing and reinstalling packages on page 14.

    In time the local repository can grow and occupy a lot of disk space. Fortunately, APT providestools for managing its local repository: APTs clean and autoclean methods.

    The clean method is invoked through the Clean package cache menu item in the Actionsmenu. It is used to delete all the .deb files downloaded. The autoclean method is invokedthrough the Clean obsolete files option, also in the Actions menu.

    The autoclean method is to be used by those who like to keep a local copy of the packagescurrently installed, mostly. It only deletes those .deb files which are no longer provided byany APT source and are, thus, obsoleted by a newer version.

  • 8/2/2019 Apt Howto.en

    27/53

    21

    Chapter 5

    Building from source

    5.1 Downloading source packages

    Its common in the world of free software to study source code or even make corrections tobuggy code. Building from source may also be useful if you want to enable features that aredisabled in the official package, or disable some which is enabled. To do this, you would needto download the source of the program. The APT system provides an easy way to obtainsource code to the many programs contained in the distribution, including all the files neededto create a .deb for the program.

    Another common use of Debian sources is to adapt a more recent version of a program, fromthe unstable distribution, for example, for use with the stable distribution. Compiling a pack-age against stable will generate .debs with dependencies adjusted to match the packages avail-able in this distribution.

    To accomplish this, the deb-src entry in your /etc/apt/sources.list should be pointedat unstable. It should also be enabled (uncommented). See section The /etc/apt/sources.listfile on page 5.

    Aptitude, the Debian Package Manager is mainly targeted at binary packages. To use sourcepackages well need to use apt-get instead. To download a source package, you would usethe following command:

    $ apt-get source packagename

    This will download three files: a .orig.tar.gz, a .dsc and a .diff.gz. In the case ofdebian-native packages, the last of these is not downloaded and the first usually wont haveorig in the name.

    The .dsc file is used by dpkg-source for unpacking the source package into the directorypackagename-version. Within each downloaded source package there is a debian/ directorythat contains the files needed for creating the .deb package.

    To auto-build the package when its been downloaded, just add -b to the command line, likethis:

  • 8/2/2019 Apt Howto.en

    28/53

    Chapter 5. Building from source 22

    $ apt-get -b source packagename

    If you decide not to create the .deb at the time of the download, you can create it later byrunning the following command from within the directory that was created for the packageafter downloading:

    $ dpkg-buildpackage -rfakeroot -uc -b

    Notice that to build most packages youll need at least the following packages: devscripts,dpkg-dev, debhelper, fakeroot, take a look at Installing and reinstalling packages onpage 14 and install them before proceeding. Most packages will also depend on compilationtools, so it may be useful to install the build-essential package as well. Other packages

    may be needed, take a look at Packages needed for compiling a source package on the currentpage for more information.

    To install the package built by the commands above one must use the package manager di-rectly. Take a look at Installing manually downloaded or locally created debian packages onpage 17. A useful tool is provided by the devscripts package: debi. If you run debi frominside the source package directory it will look for the .changes file at the parent directory todiscover what are the binary packages the package produces and will run dpkg to install allof them. While this is not very useful if your source package produces conflicting packages, itmight be in most circunstances. Of course you need root powers in order to perform this.

    Theres a difference between apt-gets source method and its other methods. The source

    method can be used by normal users, without needing special root powers. The files are down-loaded to the directory from which the apt-get source package command was called.

    5.2 Packages needed for compiling a source package

    Normally, specific headers and shared libraries need to be present in order for a source packageto be compiled. All source packages have a field in their control files called Build-Depends:that indicates which additional packages are needed for the package to be built from source.Some basic packages are also needed, check Downloading source packages on the previous

    page before continuing.APT has a simple way of downloading these packages. Just run apt-get build-deppackage, where package is the name of the package youre going to build. For example:

    # apt-get build-dep gmc

    Reading Package Lists... Done

    Building Dependency Tree... Done

    The following NEW packages will be installed:

    comerr-dev e2fslibs-dev gdk-imlib-dev imlib-progs libgnome-dev libgnorba-de

    libgpmg1-dev

    0 packages upgraded, 7 newly installed, 0 to remove and 1 not upgraded.

  • 8/2/2019 Apt Howto.en

    29/53

    Chapter 5. Building from source 23

    Need to get 1069kB of archives. After unpacking 3514kB will be used.

    Do you want to continue? [Y/n]

    The packages that will be installed are the packages needed in order for gmc to be built cor-rectly. Its important to note that this command doesnt download the source package of theprogram to be compiled. You will therefore need to run apt-get source separately to getit.

    If all you want is checking what packages are needed to build a given package, theres ashowpkg method for apt-cache command (see Getting information about packages. onpage 27, which will show, among other informations, the Build-Depends line that lists thosepackages.

    # apt-cache showsrc package

    5.3 Building a debuging package

    If you want to build a package for debuging purposes to, for example, report a bug or fixone, you can use simple environment variables that are supported by most Debian packages.

    To build a package which contains unstriped binaries1 all you need to do is prefix it withDEB_BUILD_OPTIONS=nostrip. Optimizations can also make debuging harder, so you candisable them by adding the noopt string to the DEB_BUILD_OPTIONS variable too. Example:

    $ DEB_BUILD_OPTIONS="nostrip noopt" dpkg-buildpackage -rfakeroot -uc -b

    5.4 Customizing package build options

    If what you want is to customize the way the package is built youll have to go about editing thedebian/rules file. This means: inside the main directory created when the source package isextracted there will be a debian directory, which contains many files. One of them is special:the rules file.

    This file is usually a Makefile that has targets to configure, build, install and create the package.For example, if I want to have the luola2 built without sound I can, after downloading andextracting its source edit the debian/rules file that looks like this:

    [...]

    configure: configure-stamp

    configure-stamp:

    dh_testdir

    1Debian usually strips all thebinaries andlibraries it ships. That means that all the debug symbols are removed.2A very nice ship-fighting game that lacks network play. Any takers? =)

  • 8/2/2019 Apt Howto.en

    30/53

    Chapter 5. Building from source 24

    # Add here commands to configure the package.

    ./configure $(confflags) \

    --prefix=/usr \

    --mandir=share/man \

    --infodir=share/info \

    --datadir=share/games \

    --bindir=games \

    --enable-sound

    # --enable-sdl-gfx

    touch configure-stamp

    [...]

    See the --enable-sound switch? If I remove it or replace it with --disable-sound andthen rebuild the package using the technique described on Downloading source packages onpage 21 Ill have a luola package that is built with no sound.

    If you really want to work with source packages on a daily basis I would suggest read-ing the Debian New Maintainers Guide (http://www.debian.org/doc/maint-guide/)and the Debian Policy (http://www.debian.org/doc/debian-policy/), mainly. Otherdocumentation available from the Debian Developers Corner (http://www.debian.org/devel/) may be useful too.

    5.5 But hey, I do not want to use the Debian stuff!

    Sometimes, people want to use a specific version of a program available only on source code,with no Debian package. But the packaging system can be a trouble when doing this. Supposeyou want to compile a new version of your email server. All is fine, but many packages inDebian depend on an MTA (Mail Transfer Agent). Since you installed something you compiledby yourself, the packaging system doesnt know about it.

    Thats where equivs enters the scene. To use it, install the package with that name. Equivscreates an empty package that fullfills dependencies, making the package system believe thatthe dependencies are satisfied.

    Before we begin, it is good to remind you that there are safer ways of compiling a programwhich is already packaged for Debian with different options, and that one should not useequivs to replace dependencies if she doesnt know what she is doing. See Downloadingsource packages on page 21 for more information.

    Lets continue with the MTA example, you just installed your new compiled postfix andgoes on for installing mutt. Suddenly you discover that mutt wants to install another MTA.But you already have yours.

    Go to some directory (/tmp, for example) and run:

    # equivs-control name

    http://www.debian.org/doc/maint-guide/http://www.debian.org/doc/debian-policy/http://www.debian.org/devel/http://www.debian.org/devel/http://www.debian.org/devel/http://www.debian.org/devel/http://www.debian.org/devel/http://www.debian.org/doc/debian-policy/http://www.debian.org/doc/maint-guide/
  • 8/2/2019 Apt Howto.en

    31/53

    Chapter 5. Building from source 25

    Replace name for the name of the control file you want to create. The file will be created as thefollowing:

    Section: misc

    Priority: optional

    Standards-Version: 3.5.10

    Package:

    Version:

    Maintainer: Your Name

    Pre-Depends:

    Depends:

    Recommends: Suggests:

    Provides:

    Architecture: all

    Copyright:

    Changelog:

    Readme:

    Extra-Files:

    Description:

    long description and info

    .

    second paragraph

    We just need modify this to do what we want. Have a look at the fields format and at theirdescriptions, theres no need to explain each one here, lets look at an example instead:

    Section: misc

    Priority: optional

    Standards-Version: 3.0.1

    Package: mta-local

    Conflicts: mail-transport-agentReplaces: mail-transport-agent

    Provides: mail-transport-agent

    Yes, thats all. mutt depends on mail-transport-agent, that is a virtual package providedby all MTAs, mta-local registers itself as an mail-transport-agent using the Provides field.

    The Conflicts and Replaces fields are needed, too, so that APT and dpkg will understandthey should remove the currently installed MTA package in favour of the new one youreinstalling.

    Now you only need to build the package:

  • 8/2/2019 Apt Howto.en

    32/53

    Chapter 5. Building from source 26

    # equivs-build name

    dh_testdir

    touch build-stamp

    dh_testdir

    dh_testroot

    dh_clean -k

    # Add here commands to install the package into debian/tmp.

    touch install-stamp

    dh_testdir

    dh_testroot

    dh_installdocs

    dh_installchangelogs

    dh_compress

    dh_fixperms

    dh_installdeb

    dh_gencontrol

    dh_md5sums

    dh_builddeb

    dpkg-deb: building package name in ../name_1.0_all.deb.

    The package has been created.

    Attention, the package has been created in the current directory,

    And install the resulting .deb. See Installing manually downloaded or locally created debianpackages on page 17.

    As one can see, there are several uses for equivs. One can even create a my-favoritespackage, which depends on the programs you usually installs, for example. Just free yourimagination, although being carefull.

    It is important to note that there are example control files in /usr/share/doc/equivs/examples. Check them out.

  • 8/2/2019 Apt Howto.en

    33/53

    27

    Chapter 6

    Getting information about packages.

    There are some front-end programs for the APT system that make it significantly easier to getlistings of packages that are available for installation or are already installed, as well as to findout what section a package is in, what its priority is, what its description is, etc.

    But. . . our goal here is to learn how to use pure APT. So how can you find out the name of apackage that you want to install?

    Thats what this chapter intends to answer. Lets check out our options.

    6.1 Discovering package names

    For example, suppose that you want to reminisce about the good old days of the Atari 2600.You want to use APT to install an Atari emulator, and then download some games. You cando:

    $ aptitude search atari

    p atari-fdisk-cross - Partition editor for Atari (running on

    p atari800 - Atari emulator for X/curses/SDL

    p console-keymaps-atari - Keymaps for Atari keyboards.

    We find several packages related to what were looking for, together with brief descriptions.The p letter at the begining of the line is similar to the notation used inside the curses UIaptitude uses. It means, thus, that the package is not installed. Important to notice that ap-titude only searches package names by default. You can use all the search options providedby aptitude, which you can discover by reading the aptitudes User Manual. To search thedescriptions, for example, you could use:

    $ aptitude search ~datari

    p aranym - Atari Running on Any Machine

    p atari-fdisk-cross - Partition editor for Atari (running on

  • 8/2/2019 Apt Howto.en

    34/53

    Chapter 6. Getting information about packages. 28

    p atari800 - Atari emulator for X/curses/SDL

    p circuslinux - The clowns are trying to pop balloons t

    p circuslinux-data - Data files for circuslinux

    p console-keymaps-atari - Keymaps for Atari keyboards.

    [...]

    p stella - Atari 2600 Emulator for SDL & X windows

    [...]

    Now, that returned many more packages, as we can see. Now that we found a list of possiblesolutions to our problem, lets go deeper into them:

    $ aptitude show stella

    Package: atari-fdisk-crossVersion: 0.7.1-5

    Priority: extra

    Section: otherosfs

    Maintainer: Roman Hodek = 0.6.4), libatk1.0-0 (>= 1.4.1), libbonobo2-0 (>=

    Architecture: i386

    Filename: ./pool/main/m/muine/muine_0.5.0-1_i386.deb

    Size: 164314

    Installed-Size: 692

    MD5sum: 9885f13e5ef4f76b3bf6fe7bb3ea8634

    Description: Simple music player

    Muine is an innovative music player. It has a simple interface designed to

    allow the user to easily construct playlists from albums and/or single songs

    Its goal is to be simply a music player, not to become a robust music

  • 8/2/2019 Apt Howto.en

    35/53

    Chapter 6. Getting information about packages. 29

    management application.

    Package: muine

    Priority: optional

    Section: gnome

    Installed-Size: 492

    Maintainer: Link Dupont

    Architecture: i386

    Version: 0.4.0-8

    Depends: gstreamer-gconf (>= 0.6.4), libatk1.0-0 (>= 1.4.1), libbonobo2-0 (>=

    Filename: pool/main/m/muine/muine_0.4.0-8_i386.deb

    Size: 139864

    MD5sum: e746709ad6a6fcc1e9c46b46b3d6e5b2

    Description: Simple music player

    Muine is an innovative music player. It has a simple interface designed to

    allow the user to easily construct playlists from albums and/or single songs

    Its goal is to be simply a music player, not to become a robust music

    management application.

    For more general information about a package, you can use:

    # apt-cache showpkg penguin-command

    Package: penguin-command

    Versions:1.4.5-1(/var/lib/apt/lists/download.sourceforge.net_debian_dists_unstable_mai

    Reverse Depends:

    Dependencies:

    1.4.5-1 - libc6 (2 2.2.1-2) libpng2 (0 (null)) libsdl-mixer1.1 (2 1.1.0) libs

    Provides:

    1.4.5-1 -

    Reverse Provides:

    And to just find out what packages it depends on:

    # apt-cache depends penguin-command

    penguin-command

    Depends: libc6

    Depends: libpng2

    Depends: libsdl-mixer1.1

    Depends: libsdl1.1

    Depends: zlib1g

    In summary, we have a range of weapons we can use to find out the name of a package wewant.

  • 8/2/2019 Apt Howto.en

    36/53

    Chapter 6. Getting information about packages. 30

    6.2 Using dpkg to find package names

    One of the ways to locate the name of a package is to know the name of an important file foundwithin the package. For example, to find the package that provides a particular .h file youneed for compilation you can run:

    $ dpkg -S stdio.h

    libc6-dev: /usr/include/stdio.h

    libc6-dev: /usr/include/bits/stdio.h

    perl: /usr/lib/perl/5.6.0/CORE/nostdio.h

    or:

    $ dpkg -S /usr/include/stdio.h

    libc6-dev: /usr/include/stdio.h

    Notice that this method only works to find package names of packages that are installed inyour system. Youll have to use auto-apt (see How to install packages on demand onpage 33) or apt-file (see How to discover to which package a file belongs on the currentpage) to search for files on packages which are not installed. You can also take a look at thehttp://packages.debian.org/ website. To list the names of packages installed on yoursystem, which is useful, for example, if you plan to clean up your hard drive, you can run:

    $ dpkg -l | grep mozilla

    ii mozilla-browse 0.9.6-7 Mozilla Web Browser

    The problem with this command is that it can break the package name. In the example above,the full name of the package is mozilla-browser. To fix this, you can use the COLUMNSenvironment variable this way:

    $ COLUMNS=132 dpkg -l | grep mozilla

    ii mozilla-browser 0.9.6-7 Mozilla Web Brows

    6.3 How to discover to which package a file belongs

    If you want to install a package, and you cant find out what it is called by searching withapt-cache, but know the filename of the program itself, or some other filename that belongsto the package, then you can use apt-file, which is included in the package of same nameto find the package name. This is done like this:

    $ apt-file search filename

    http://packages.debian.org/http://packages.debian.org/
  • 8/2/2019 Apt Howto.en

    37/53

    Chapter 6. Getting information about packages. 31

    It works just like dpkg -S, but will also show you uninstalled packages that contain the file. Itcould also be used to find what packages contain necessary include files that are missing whencompiling programs, although auto-apt is a much better method of solving such issues, seeHow to install packages on demand on page 33.

    You can also list the contents of a package, by running:

    $ apt-file list packagename

    apt-file keeps a database of which files all packages contain, just like auto-apt does and itneeds to be up-to-date. This is done by running:

    # apt-file update

    By default, apt-file uses the same database auto-apt is using, see How to install packageson demand on page 33.

    6.4 Information about packages on the Web

    There are lots of web resources with informations about the packages available in the Debiandistribution, most of them directed mainly towards Debian Developers, but many of them maybe useful for users, too.

    The Debian Packages Pages (http://packages.debian.org/) lets you search for pack-ages that are available on the various architectures Debian supports and, also, searchfor the contents of all the Debian packages. There are information regarding depen-dencies and other relationships with packages. There are also links to download thesource package and the binary package for all architectures. You can use a shortcut likehttp://packages.debian.org/packagename to have quick access links to a package.

    The Package Tracking System (http://packages.qa.debian.org/) provides informationabout what happened to the package recently, what are the TODO itens, from a Debian main-tainers point of view, provides a summary of bugs reported and some more very useful infor-mation. One of the nice things about the Package Tracking System is that it lets you subscribe

    to a package to follow all the emails that the maintainer usually receives about the package.This way you can follow the development of packages that are crucial for your work or play.The http://packages.qa.debian.org/packagename shortcut works here, as well.

    Finally, the Bug Tracking System (http://bugs.debian.org/) provides information aboutknown bugs in the packages distributed by Debian. This may be useful for you to find outwhy something does not work the way you expected and even find solutions or work-aroundsthrough the bug logs. Also, read these pages and its documentation to be able to fill goodbug reports for Debian. The http://bugs.debian.org/packagename shortcut also workshere, as expected, but the BTS (Bug Tracking System) also accepts other very useful shortcutslike, for example, http://bugs.debian.org/src:packagename to show all bug reportson all binary packages provided by a given source package.

    http://packages.debian.org/http://packages.qa.debian.org/http://bugs.debian.org/http://bugs.debian.org/http://bugs.debian.org/http://packages.qa.debian.org/http://packages.debian.org/
  • 8/2/2019 Apt Howto.en

    38/53

    Chapter 6. Getting information about packages. 32

  • 8/2/2019 Apt Howto.en

    39/53

    33

    Chapter 7

    Tricks and Techniques

    7.1 How to install packages on demand

    Youre compiling a program and, all of a sudden, boom! Theres an error because it needs a .hfile you dont have. The program auto-apt can save you from such scenarios, it is availablein the package of the same name. It asks you to install packages if theyre needed, stoppingthe relevant process and continuing once the package is installed.

    What you do, basically, is run:

    # auto-apt run command

    Where command is the command to be executed that may need some unavailable file. Forexample:

    # auto-apt run ./configure

    It will then ask to install the needed packages and call apt-get automatically. If youre runningX, a graphical interface will replace the default text interface.

    Auto-apt keeps databases which need to be kept up-to-date in order for it to be effective.This is achieved by calling the commands auto-apt update, auto-apt updatedb andauto-apt update-local.

    7.2 Caching packages

    If you are dealing with several machines in a network it might be useful to have a packagecaching system, so that you will not have to download the packages for each machine. Thismanual will focus on the apt-proxy package, which does exactly that. Other solutions exist,

  • 8/2/2019 Apt Howto.en

    40/53

    Chapter 7. Tricks and Techniques 34

    like apt-cacher, though. You may want to try each one to choose the one that best fits yourneeds.

    First of all, install the apt-proxy package. It will register itself on inetd to listen for requestson port 9999, you may need to restart the inetd service.

    Next youll want to edit the /etc/apt-proxy/apt-proxy.conffile. It lists the real serversapt-proxy will use to download the package lists and packages from. You can use http, ftp andrsync as transfer methods. The file comes with a default backend that looks like this:

    add_backend /debian/ \

    $APT_PROXY_CACHE/debian/ \

    http://ftp.us.debian.org/debian/ \

    http://ftp.de.debian.org/debian/ \

    http://ftp.uk.debian.org/debian/ \

    +ftp.us.debian.org::debian/

    This means that whenever a client tries to get something from /debian/ apt-proxy will useits cache, the listed Debian http mirrors and one rsync server, which is preferred for download-ing the package lists (the + sign means prefered for control files).

    How, then, a client will use this backend? By adding the following line at the /etc/apt/sources.list file at the clients (including the box in which apt-proxy is installed):

    deb http://server:9999/debian/ stable main

    The line looks much like a normal line. The difference here is you put your apt-proxy serverwhere you would normally put an http or ftp mirror, uses a port value (9999) and then selectthe backend (/debian/). After having done all this initial setup update the list of packages atone of the machines and upgrade it first, so that it will only download a package one time.After the first machine is up-to-date update the others.

    You can use the apt-proxy-import command to import the packages that are insideyour current APT cache (/var/cache/apt/archives/) by running apt-proxy-import/var/cache/apt/archives. Notice that you must have run the update process in at leastone client to initiate the apt-proxys cache before using apt-proxy-import.

    You can learn more about apt-proxy by reading the comments that populate the /etc/apt-proxy/apt-proxy.conf file. To setup http and ftp proxies for apt-proxy to use,for example, you will find example configurations at the end of the file.

    7.3 Deciding which mirror is the best to include in the sources.list

    file: netselect, netselect-apt

    A very frequent question, mainly among the newest users, is: which Debian mirror to includein sources.list?. There are many ways to decide which mirror. The experts probably have

  • 8/2/2019 Apt Howto.en

    41/53

  • 8/2/2019 Apt Howto.en

    42/53

    Chapter 7. Tricks and Techniques 36

    7.4 Removing unused locale files: localepurge

    Many Debian users use only one locale. A Brazilian Debian user, for example, usually uses thept_BR locale all the time and doesnt care about the es one.

    localepurge is a very useful tool for these users. You can free lots of space by having onlythe locales that you really use. Just apt-get install localepurge.

    It is very easy to configure it, debconf questions guide the user in a step-by-step configuration.Be very careful on answering the first question though, wrong answers may remove all thelocales files, even the ones you use. The only way to recover these files is reinstalling all thepackages that provide them.

    7.5 How to keep informed about the changes in the packages.

    Every package installs in its documentation directory (/usr/share/doc/packagename) afile called changelog.Debian.gz which contains the list of changes made to the packagesince the last version. You can read these files with zless help, for example, but it is some-thing not so easy, after an complete system upgrade, to start searching changelogs for everyupgraded package.

    Theres a way to automatize this task by means of a tool called apt-listchanges. To beginwith one needs to install the apt-listchanges package. During the package installation,

    Debconf will configure it. Answer to the questions as you want.The option Should apt-listchanges be automatically run by apt? is very useful cause it showsa list of changes made to each package thats being installed by apt during an upgrade and letsyou analyze them before continuing. The option Should apt-listchanges prompt for confir-mation after displaying changes? is useful because it asks you wether you want to continueinstallation after reading the list of changes. If you say that you dont want to continue apt-listchanges will return an error and apt will abort installation.

    After apt-listchanges is installed, as soon as packages are downloaded (or gotten from a CD ormounted disk) by apt it will show the lists of changes made to those packages before installingthem.

  • 8/2/2019 Apt Howto.en

    43/53

    37

    Chapter 8

    Being at the other side: creating a

    repository

    To create a repository you mainly need a set of packages (source and/or binary) to generatePackages.gz and Sources.gz files from them. You may have binary-only packages in somecases, but be careful not to violate licenses. A GPLed software, for example, needs to have itssource distributed along with the binaries.

    To do that you need to use the apt-ftparchive program which is installed by theapt-utils package. First of all you collect all your packages in a directory. Lets say, for

    example, ~/public_html/debian; using that were going to be exposing the repositorythrough our http server, already!

    I can go to that directory and do the following:

    $ apt-ftparchive sources . > Sources

    $ apt-ftparchive packages . > Packages

    $ gzip -c Packages > Packages.gz

    $ gzip -c Sources > Sources.gz

    The first two commands scan the directory and its subdirectories of the directory you specified

    (., in this case) and prints the resulting packages list to the standard output, which wereredirecting to the Sources and Packages files.

    If youre using the file method to access this repository the first two lines are enough. Ifyoure using a remote method like ftp or http, then you need the compressed versions, astheyre what APT will look for when updating the packages lists.

    Here are the source lines you could add to your /etc/apt/sources.list to make APTaware of your repository now:

    # This will only work with local access to the filesystem

    deb file:/home/user/public_html/debian/ ./

  • 8/2/2019 Apt Howto.en

    44/53

    Chapter 8. Being at the other side: creating a repository 38

    # This will be useable by people that can access your machine

    # with a network connection if you have your http server properly

    # configured

    deb http://host/~user/debian/ ./

    You get the idea. As we called apt-ftparchive at the same directory the packages were on wecan simply provide the full path to where the packages are and add a ./ at the end. You cando things differently, by calling apt-ftparchive with different relative paths instead of callingit on the same directory in which the packages are. You can also separate groups of packagesas sections like Debian does. Read the apt-ftparchive(1) manpage for more informationand play with the possibilities.

  • 8/2/2019 Apt Howto.en

    45/53

    39

    Chapter 9

    Alternative User Interfaces for

    managing packages

    Aptitude is what this howto recommends as the main user interface for managing packagesfor your Debian system. This is because, as we stated through the document, aptitude has aset of features that makes the administrators life easier.

    There are, though, other user interfaces, even graphical ones, like Synaptic or GNOME-APT.In this chapter were going to go through them.

    9.1 Synaptic

    Synaptic was originaly written by Alfredo Kojima for Conectiva. Today its maintained bypeople from both Conectiva and Debian. It was originaly written in wing, Window Makersgraphical toolkit, but was rewritten in GTK+.

    To use Synaptic you have to install the synaptic package.

    Synaptic is probably the most usable of all the graphical user interfaces for APT, the one theend users will most likely have less problems with.

    9.2 GNOME-APT

    GNOME-APT was first written by Havoc Pennington and Diego Lages for the Debian system.It was unmaintained for some time but people managed to keep it alive for Woody. For Sargethe package gained a new maintainer that took it forward. As oposed to Synaptic, GNOME-APT is for those people who, while enjoying a nice Gtk+ interface, like flexibility over usability.

    You can use GNOME-APT by installing the gnome-apt package.

  • 8/2/2019 Apt Howto.en

    46/53

    Chapter 9. Alternative User Interfaces for managing packages 40

  • 8/2/2019 Apt Howto.en

    47/53

    41

    Chapter 10

    How to deal with errors

    10.1 Common errors

    Errors will always happen, many of them caused by users not paying attention. The followingis a list of some of the most frequently reported errors and how to deal with them.

    If you receive a message that looks like the one below when trying to run apt-get installpackage. . .

    Reading Package Lists... DoneBuilding Dependency Tree... Done

    W: Couldnt stat source package list http://people.debian.org unstable/ Pack

    W: You may want to run apt-get update to correct these missing files

    E: Couldnt find package penguineyes

    you forgot to run apt-get update after your last change to the /etc/apt/sources.listfile.

    If the error looked like:

    E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)E: Unable to lock the administration directory (/var/lib/dpkg/), are you root

    when trying any apt-get method other than source, you dont have root permission, thatis, youre running as a normal user.

    Theres an error similar to the above which happens when you run two copies ofapt-get atthe same time, or even if you try to run apt-get while a dpkg process is active. The onlymethod that can be used simultaneously with others is the source method.

    If an installation breaks in the middle of the process and you find that its no longer possibleto install or remove packages, try running these two commands:

  • 8/2/2019 Apt Howto.en

    48/53

    Chapter 10. How to deal with errors 42

    # apt-get -f install

    # dpkg --configure -a

    And then try again. It may be necessary to run the second of the above commands more thanonce. This is an important lesson for those adventurers who use unstable.

    If you receive the error E: Dynamic MMap ran out of room when running apt-getupdate, add the following line to /etc/apt/apt.conf:

    APT::Cache-Limit 10000000;

    10.2 Where can I find help?

    If you find yourself plagued by doubts, consult the extensive documentation availablefor the Debian packaging system. --helps and manpages can be an enormous helpto you, as can the documentation contained in the /usr/share/doc directories such as/usr/share/doc/apt.

    If this documentation fails to drive your fears away, try looking for the answer on the Debianmailing lists. You can find more information about specific user lists on the Debian website:http://www.debian.org.

    Remember that these lists and resources should be used only by Debian users; users of other

    systems will find better support from the community resources of their own distributions.

    http://www.debian.org/http://www.debian.org/http://www.debian.org/
  • 8/2/2019 Apt Howto.en

    49/53

    43

    Chapter 11

    What distributions support APT?

    Here are the names of some of the distributions that use APT:

    Debian GNU/Linux (http://www.debian.org/) - it was for this distribution that APT wasdeveloped

    Mandriva Conectiva (http://www.conectiva.com.br) - this was the first distribution toport APT for use with rpm

    Libranet (http://www.libranet.com)

    Mandriva (http://www.mandriva.com/)

    PLD (http://www.pld.org.pl)

    Vine (http://www.vinelinux.org)

    APT4RPM (http://apt4rpm.sf.net)

    Alt Linux (http://www.altlinux.ru/)

    Red Hat (http://www.redhat.com/)

    Sun Solaris (http://www.sun.com/)

    SuSE (http://www.suse.de/)

    Ubuntu (http://www.ubuntulinux.com/)Yellow Dog Linux (http://www.yellowdoglinux.com/)

    http://www.debian.org/http://www.debian.org/http://www.conectiva.com.br/http://www.libranet.com/http://www.mandriva.com/http://www.pld.org.pl/http://www.vinelinux.org/http://apt4rpm.sf.net/http://www.altlinux.ru/http://www.redhat.com/http://www.sun.com/http://www.suse.de/http://www.ubuntulinux.com/http://www.ubuntulinux.com/http://www.yellowdoglinux.com/http://www.yellowdoglinux.com/http://www.ubuntulinux.com/http://www.suse.de/http://www.sun.com/http://www.redhat.com/http://www.altlinux.ru/http://apt4rpm.sf.net/http://www.vinelinux.org/http://www.pld.org.pl/http://www.mandriva.com/http://www.libranet.com/http://www.conectiva.com.br/http://www.debian.org/
  • 8/2/2019 Apt Howto.en

    50/53

  • 8/2/2019 Apt Howto.en

    51/53

    45

    Chapter 12

    Credits

    A big thank you goes out to my great friends in the Debian-BR project, and in Debian itself, whoare a constant help to me and always give me the strength to continue working for humanitysbenefit, as well as helping me with my goal of saving the world. :)

    I also want to thank the CIPSGA for the enormous help it has given to our project and to allthe free projects that spring from great ideas.

    And special thanks to:

    Yooseong Yang

    Michael Bramer Bryan Stillwell

    Pawel Tecza

    Hugo Mora

    Luca Monducci

    Tomohiro KUBOTA

    Pablo Lorenzzoni

    Steve Langasek

    Arnaldo Carvalho de Melo

    Erik Rossen

    Ross Boylan

    Matt Kraai

    Aaron M. Ucko

    Jon slund

    Isaac Jones

  • 8/2/2019 Apt Howto.en

    52/53

  • 8/2/2019 Apt Howto.en

    53/53