From: Subject: Debian reference - Debian package management Date: Mon, 29 Apr 2002 17:49:24 +0200 MIME-Version: 1.0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Location: http://qref.sourceforge.net/quick/ch-package.en.html X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Debian reference - Debian package management
[ previous = ] [=20 Content= s=20 ] [ 1 ] [ = 2 ] [ = 3 ] [ = 4 ] [ = 5 ] [ 6 = ] [ 7 ] [ = 8 ] [ 9 ] [ 10 ] [ = 11 ] [ 12 ] [ 13 ] [ = 14 ] [ = 15 ] [ = A ] [ = next ]=20

Debian reference
Chapter 6 - Debian package management


Make sure to set up a local HTTP proxy using squid for = packages=20 downloaded by APT. This greatly improves the performance of network = upgrades,=20 especially with multiple Debian boxes on the LAN. This document is based = on a=20 Woody system but most information also applies to a Potato system = (except for=20 apt_preferences(5) and topics related to=20 /etc/preferences)).=20


6.1 Introduction

If reading all the developer documentation is too much for you, read = this=20 chapter first and start enjoying the full power of Debian with = testing/unstable=20 :-)=20


6.1.1 Main tools

     dselect     - menu-driven package =
management tool (top level)
     apt-get     - install package (package-archive centric, APT)
     dpkg        - install package (package-file centric)
     aptitude & deity - Future replacements for dselect (GUI APT)

These are not equal-level tools. dselect runs on the top = of APT=20 (the command-line command is apt-get) and = dpkg. When=20 using dselect, make sure to update the status file (using = [U]pdate)=20 before selection if you have installed packages via = apt-get.=20

As for package dependencies, apt-get automatically pulls = in=20 packages with recommends but leaves packages with = suggests=20 while dselect offers fine grained control over choices of = these=20 packages. See Pa= ckage=20 dependencies, Section 2.2.8.=20


6.1.2 Convenience tools

     apt-cache         - check =
package archive in local cache
     dpkg-reconfigure  - reconfigure an already installed package
     dpkg-source       - manage source package file
     dpkg-buildpackage - automate the building of a package file
     ...

6.2 Debian survival commands

With this knowledge, one can live a life of eternal "upgrade" :-)=20

Also refer to Debian = System=20 installation hints, Chapter 3 and Upgrading=20 distribution, Chapter 5.=20


6.2.1 Install task with tasksel

tasksel is the Debian Task Installer, which is = offered=20 as the "simple" option during system installation.=20

When one needs to install a common function which requires multiple = packages,=20 this is the best way. Make sure to run as follows:

     # dselect =
update
     # tasksel

6.2.2 Install system with APT

You can selectively install packages from different archives using = newer=20 versions of apt-get (>Woody). This enables selective = upgrade to=20 "unstable" and selective downgrade to "stable" while tracking "testing". =

     # apt-cache policy libc6 libc6-dev locales         # check =
status
     # apt-get install libc6=3D2.2.4-1 libc6-dev=3D2.2.4-1 =
locales=3D2.2.4-1
     # apt-get install libc6/unstable libc6-dev/unstable =
locales/unstable
     # apt-get install -t unstable libc6 libc6-dev locales
     # apt-get -u install interesting-new-package remove-package-
     # apt-get remove useless-old-package
     # apt-get remove --purge really-useless-old-package

To downgrade all packages to stable, edit = /etc/apt/preferences=20 as follows:

     Package: *
     Pin: release a=3Dstable
     Pin-Priority: 1001

and run apt-get upgrade, which forces downgrade due to=20 Pin-priority > 1000.=20


6.2.3 Upgrade system with APT

Upgrade system with APT:

     # apt-get update
     ... then do one of the following:
     # apt-get -u upgrade         # pull all recommends
     # apt-get -u dist-upgrade    # pull all recommends and check =
dependency
     # apt-get -u dselect-upgrade # follow selection by dselect

Use the -s option to simulate upgrade without actual = upgrade.=20

dselect offers a menu-driven interface over APT.=20 deity and aptitude will offer alternatives to=20 dselect.=20


6.2.4 Check bugs in Debian and seek help

Usually most problems have been already recognized. Check the = following first=20 (links and w3m works as good):

     $ lynx http://bugs.debian.org/
     $ lynx http://bugs.debian.org/<package-name>   # if you know =
package name
     $ lynx http://bugs.debian.org/<bug-number>    # if you know =
bug number

Search Google (www.google.com) with search words including = "site:debian.org".=20

When in doubt, read the fine manual. Set CDPATH as = follows:

     export CDPATH=3D.:/usr/local:/usr/share/doc

and type

     $ cd <packagename>
     $ mc

More support resources are listed at Support = for Debian,=20 Chapter 15.=20


6.2.5 APT upgrade troubleshooting

Package dependency problems may occur when upgrading in = unstable/testing.=20 Most of the time, this is because a package that will be upgraded has a = new=20 dependency that isn't met. These problems are fixed by using

     # =
apt-get dist-upgrade

If this does not work, then repeat one of the following until the = problem=20 resolves itself:

     # apt-get upgrade -f         # continue =
upgrade even after error
     ... or
     # apt-get dist-upgrade -f    # continue dist-upgrade even after =
error

Some really broken upgrade scripts may cause persistent trouble. It = is=20 usually better to resolve this type of situation by inspecting the=20 /var/lib/dpkg/info/packagename.{post-,pre-}{install,removal}=20 scripts of the offending package and then running:

     # dpkg =
--configure -a    # configures all partially installed packages

If a script complains about a missing configuration file, look in=20 /etc for the corresponding configuration file. If one = exists with=20 an extension of .new (or something similar), change=20 (mv) it to remove the suffix.=20

Package dependency problems may occur when installing in = unstable/testing.=20 There are ways to circumvent dependency.

     # apt-get install -f =
package # override broken dependencies

An alternative method to fix these situations is to use the=20 equivs package. See equivs=20 package, Section 6.4.2.=20


6.2.6 Rescue using dpkg

Ad hoc recovery of a crashed dselect (APT) can be done = on a=20 really broken system by just using dpkg without APT:

  =
   # cd /var/cache/apt/archives
     # dpkg -i libc6* libdb2* perl*
     # dpkg -i apt* dpkg* debconf*
     # dpkg -i *  (until no error occurs)

If a package is missing, get it by:

     # mc            # use =
"FTP link" pointing to Debian FTP server

As of recently, actual packages on the HTTP/FTP server may not be = located=20 under the classic /dist directory but rather under the new=20 /pool directory.=20

Then install by:

     # dpkg -i =
/var/cache/apt/archives/packagefile.deb

For a broken dependency, fix it or use:

     # dpkg =
--ignore-depends=3Dpackage1,... -i packagefile.deb
     # dpkg --force-depends -i packagefile.deb
     # dpkg --force-depends --purge package

6.2.7 Install package into an unbootable system

Boot into Linux using a Debian rescue floppy/CD or an alternative = partition=20 in a multi-boot Linux system. Mount the unbootable system on=20 /target and use the chroot install mode of = dpkg.

     # dpkg --root /target -i packagefile.deb

Then configure and fix problems.=20

By the way, if a broken lilo is all that prevents = booting, you=20 can boot using a standard Debian rescue disk. At boot prompt, assuming = the root=20 partition of your Linux installation is in /dev/hda12 and = you want=20 runlevel 3, enter:

     boot: rescue root=3D/dev/hda12 3

Then you are booted into an almost fully functional system with the = kernel on=20 floppy disk. (There may be minor glitches due to lack of kernel features = or=20 modules.)=20


6.3 Debian nirvana commands

Enlightment with these commands will save a person from the eternal = karmic=20 struggle of upgrade hell and let him reach Debian nirvana. :-)=20


6.3.1 Information on a file

To find the package to which a particular file belongs:

     $ =
dpkg {-S|--search} pattern # search for pattern in installed packages
     $ zgrep -e pattern /local/copy/of/debian/woody/Contents-i386.gz
                  # find filename-pattern of files in the debian archive

Or use specialized package commands:

     # apt-get install =
dlocate =20
                      # conflicts with slocate (secure version of =
locate)
     $ dlocate filename         # fast alternative to dpkg -L and dpkg =
-S
     ...
     # apt-get install auto-apt # on-demand package installation tool
     # auto-apt update          # create db file for auto-apt
     $ auto-apt search pattern =20
                     # search for pattern in all packages, installed or =
not

6.3.2 Information on a package

Search and display information from package archives. Make sure to = point apt=20 to the proper archive(s) by editing /etc/apt/sources.list. = If you=20 want to see how packages in testing/unstable do against the currently = installed=20 one, use apt-cache policy=97quite nice.

     # apt-get =
  check         # update cache and check for broken packages
     $ apt-cache search  pattern # search package from text description
     $ apt-cache policy  package # package priority/dists information
     $ apt-cache show -a package # show description of package in all =
dists
     $ apt-cache showpkg package # package information for debugging
     # dpkg  --audit|-C          # search for partially installed =
packages
     $ dpkg {-s|--status} package ... # description of installed package
     $ dpkg -l package ...       # status of installed package (1 line =
each)
     $ dpkg -L package ...       # list file names installed by the =
package

You can also find package information in (I use mc to = browse=20 these):

     /var/lib/apt/lists/*
     /var/lib/dpkg/{available|status}

6.3.3 Reconfigure installed packages

Use the following to reconfigure any already-installed package.

 =
    # dpkg-reconfigure --priority=3Dmedium package [...]
     # dpkg-reconfigure --all  # reconfigure all packages

Do this for debconf if you need to change the=20 debconf dialog mode permanently.=20

Some programs come with special configuration scripts.

     =
apt-setup     - create /etc/sources.list
     install-mbr   - install a Master Boot Record manager
     tzconfig      - set the local timezone
     gpmconfig     - set gpm mouse daemon
     smbconfig     - configure Samba
     eximconfig    - configure Exim (MTA)
     texconfig     - configure teTeX
     apacheconfig  - configure Apache (httpd)
     cvsconfig     - configure CVS
     sndconfig     - configure sound system
     ...
     update-alternatives - set default command, e.g., vim as vi
     update-rc.d         - System-V init script management
     update-menus        - Debian menu system
     ...

6.3.4 Remove and purge packages

Remove a package while maintaining its configuration:

     # =
apt-get remove package ...
     # dpkg  --remove package ...

Remove a package and all configuration:

     # apt-get remove =
--purge package ...
     # dpkg    --purge        package ...

6.3.5 Holding older packages

For example, holding of libc6 and libc6-dev = for=20 dselect and apt-get -u upgrade package can be = done as=20 follows:

     # echo -e "libc6 hold\nlibc6-dev hold" | dpkg =
--set-selections

apt-get -u install package will not be hindered by this = "hold".=20 To hold a package through forcing automatic downgrade for apt-get = -u=20 upgrade package or apt-get -u dist-upgrade, add the=20 following to /etc/apt/preferences:

     Package: =
libc6*
     Pin: release a=3Dstable
     Pin-Priority: 2000

The following will list packages on hold:

     dpkg =
--get-selections "*"|grep -e "hold$"

6.3.6 dselect =96 global configuration

Add a line with "expert" in /etc/dpkg/dselect.cfg to = reduce=20 noise.=20

When started, dselect automatically selects all = "Required",=20 "Important", and "Standard" packages. Some packages, such as = teTEX=20 and emacs, are large and may not be needed when you first = install a=20 system. So be careful.=20

dselect has a somewhat strange user interface. There are = 4=20 ambiguous commands (Capital means CAPITAL!):

     Key-stroke  =
Action
     Q           Quit. Confirm current selection and quit anyway.=20
                 (override dependencies)
     R           Revert! I did not mean it.
     D           Damn it! I do not care what dselect thinks.  Just Do =
it!
     U           Set all to sUggested state

With D and Q, you can select conflicting = selections=20 at your own risk. Handle these commands with care. For a slower machine, = run=20 dselect on another fast machine to find packages and use=20 apt-get install to install them. apt-get=20 dselect-upgrade best honors dselect selection.=20


6.3.7 Reduce cached package files

Package install with APT leaves cached package files in=20 /var/cache/apt/archives and these need to be cleaned.

 =
    # apt-get autoclean # removes only useless package files
     # apt-get clean     # removes all cache package files

6.3.8 Record/copy system configuration

To make a local copy of the package selection states:

     $ =
dpkg --get-selections "*" >myselections   # or use \*

"*" makes myselections include package = entries for=20 "purge" too.=20

You transfer this file to another computer, and install it there = with:

     # apt-get update
     # dpkg --set-selections <myselections
     # apt-get -u dselect-upgrade

6.3.9 Port a package to the "stable" system

For partial upgrades of the stable system, rebuilding a package = within its=20 environment using the source package is desirable. This avoids massive = package=20 upgrades due to their dependencies. First, add the following entries to=20 /etc/apt/sources.list:

     deb-src =
http://http.us.debian.org/debian testing main contrib non-free
     deb-src http://non-us.debian.org/debian-non-US testing/non-US main =
contrib non-free
     deb-src http://http.us.debian.org/debian unstable main contrib =
non-free
     deb-src http://non-us.debian.org/debian-non-US unstable/non-US main =
contrib non-free

Then get the source and make a local package:

     $ apt-get =
source package/unstable
     $ dpkg-source -x package.dsc
     $ cd package-version
       ... inspect required packages (Build-depends in .dsc file) and
           install them too.  You need fakeroot too.
    =20
     $ dpkg-buildpackage -rfakeroot=20
    =20
       ...or (no sig)
     $ dpkg-buildpackage -rfakeroot -us -uc # use "debsign" later if =
needed
    =20
       ...or (no sig)
     # ./debian/rules binary
     # ./debian/rules clean
     # cd ..
     # dpkg-source -b package-version
    =20
       ...Then to install
     # dpkg -i packagefile.deb

Usually, one needs to install a few packages with the "-dev" suffix = to=20 satisfy package dependencies. debsign is in the=20 devscripts package. auto-apt may ease = satisfying these=20 dependencies.=20

In Woody, these dependency issues can be simplified. For example, to = compile=20 a source-only pine package:

     # apt-get build-dep =
pine
     # apt-get source -b pine

6.3.10 Convert or install an alien binary package

alien enables to convert binary packages provided in = Redhat rpm,=20 Stampede slp, Slackware tgz, and Solaris pkg file formats into Debian = deb=20 package. If you want to use a package from another linux distribution = than the=20 one you have installed on your system, you can use alien to convert it = to your=20 preferred package format and install it. It also supports LSB packages.=20


6.4 Other Debian peculiarities


6.4.1 dpkg-divert command

dpkg-divert forces dpkg not to install a = file into=20 its location, but to a diverted location.=20

System administrators or maintenance scripts can use this to override = some=20 package's configuration file, or whenever some files (which aren't = marked as=20 conffiles) need to be preserved by dpkg, when=20 installing a newer version of a package which contains those files. =

     # dpkg-divert [--add]  filename # add "divert"
     # dpkg-divert --remove filename # remove "divert"

6.4.2 equivs package

If you compile a program from source, it is best to make it into a = real local=20 debianized package (*.deb). Use equivs as a = last=20 resort.

     Package: equivs
     Priority: extra
     Section: admin
     Description: Circumventing Debian package dependencies
      This is a dummy package which can be used to create Debian
      packages, which only contain dependency information.

6.4.3 Alternative commands

To make the command vi run vim, use=20 update-alternatives:

     # update-alternatives =
--display vi
     ...
     # update-alternatives --config vi
       Selection    Command
     -----------------------------------------------
           1        /usr/bin/elvis-tiny
           2        /usr/bin/vim
     *+    3        /usr/bin/nvi
    =20
     Enter to keep the default[*], or type selection number: 2

Items in the Debian alternatives system are kept in=20 /etc/alternatives as symlinks.=20

To set your favorite X window manager, use = x-window-manager=20 instead.=20

/bin/sh is a direct symlink to /bin/bash or = /bin/ash. It's safer to use /bin/bash to be = compatible=20 with old bashism-contaminated scripts but better discipline to use=20 /bin/ash to enforce POSIX compliance. Upgrade to 2.4 Linux = kernel=20 tends to set this to /bin/ash=20


6.4.4 System-V init and runlevels

The default runlevel to boot into can be set in = /etc/inittab.=20

Unlike other distributions, Debian makes the management of runlevel=20 completely the sysadmin's responsibility. Management of System-V style=20 init on Debian is intended to be performed through=20 update-rc.d scripts.=20

Starting /etc/init.d/name in runlevel 1,2,3 = and=20 stopping in 4,5 with sequencing priority number 20 (normal) can be done = by:

     # update-rc.d name start 20 1 2 3 . stop 20 4 5 .

Removing symbolic links while the script in init.d still = exists=20 can be done by:

     # update-rc.d -f name remove

For editing runlevels, I cheat. I edit entries manually using the=20 mv command at the shell prompt of mc while = copying=20 link entries using Alt-Enter. I even disable a daemon by = inserting=20 exit 0 at the start of an init.d script as a = quick=20 hack. These are conffiles after all.=20


6.4.5 Disabled daemon services

Debian distribution cares system security seriously and expects the = system=20 administrator to be really a competent one. Thus, sometimes ease of use = becomes=20 secondary concern and many daemon services come with the highest = security level=20 with the least or no service available as their default install state.=20

Check ps aux or contents of /etc/init.d/* = and=20 /etc/inetd.conf, if you have doubt (exim, dhcp, ...). Also = check=20 /etc/hosts.deny as Lo= gin=20 control, Section 8.6.1.=20

X11 doesn't allow TCP/IP (remote) connections as default in the = recent=20 versions of Debian. See TCP/IP = connection to X, Section 9.4.3.=20


[ previous = ] [=20 Content= s=20 ] [ 1 ] [ = 2 ] [ = 3 ] [ = 4 ] [ = 5 ] [ 6 = ] [ 7 ] [ = 8 ] [ 9 ] [ 10 ] [ = 11 ] [ 12 ] [ 13 ] [ = 14 ] [ = 15 ] [ = A ] [ = next ]=20

Debian reference=20

Version: 2.10p00, 2002.04.28-21:10
Osamu Aoki debian@aokiconsulting.com
= Authors,=20 Section A.1