Chapter 4. The Interface

Table of Contents

4.1. Startup
4.2. The Status Report
4.3. The Status Display
4.4. Dpkg

Both that APT dselect method and apt-get share the same interface. It is a simple system that generally tells you what it will do and then goes and does it. [2] After printing out a summary of what will happen APT then will print out some informative status messages so that you can estimate how far along it is and how much is left to do.

Before all operations except update, APT performs a number of actions to prepare its internal state. It also does some checks of the system's state. At any time these operations can be performed by running apt-get check.

# apt-get check
Reading Package Lists... Done
Building Dependency Tree... Done

The first thing it does is read all the package files into memory. APT uses a caching scheme so this operation will be faster the second time it is run. If some of the package files are not found then they will be ignored and a warning will be printed when apt-get exits.

The final operation performs a detailed analysis of the system's dependencies. It checks every dependency of every installed or unpacked package and considers if it is OK. Should this find a problem then a report will be printed out and apt-get will refuse to run.

# apt-get check
Reading Package Lists... Done
Building Dependency Tree... Done
You might want to run 'apt --fix-broken install' to correct these.
Sorry, but the following packages have unmet dependencies:
  9fonts: Depends: xlib6g but it is not installed
  uucp: Depends: mailx but it is not installed
  blast: Depends: xlib6g (>= 3.3-5) but it is not installed
  adduser: Depends: perl-base but it is not installed
  aumix: Depends: libgpmg1 but it is not installed
  debiandoc-sgml: Depends: sgml-base but it is not installed
  bash-builtins: Depends: bash (>= 2.01) but 2.0-3 is installed
  cthugha: Depends: svgalibg1 but it is not installed
           Depends: xlib6g (>= 3.3-5) but it is not installed
  libreadlineg2: Conflicts:libreadline2 (<< 2.1-2.1)

In this example the system has many problems, including a serious problem with libreadlineg2. For each package that has unmet dependencies a line is printed out indicating the package with the problem and the dependencies that are unmet. A short explanation of why the package has a dependency problem is also included.

There are two ways a system can get into a broken state like this. The first is caused by dpkg missing some subtle relationships between packages when performing upgrades. [3]. The second is if a package installation fails during an operation. In this situation a package may have been unpacked without its dependents being installed.

The second situation is much less serious than the first because APT places certain constraints on the order that packages are installed. In both cases supplying the -f option to apt-get will cause APT to deduce a possible solution to the problem and then continue on. The APT dselect method always supplies the -f option to allow for easy continuation of failed maintainer scripts.

However, if the -f option is used to correct a seriously broken system caused by the first case then it is possible that it will either fail immediately or the installation sequence will fail. In either case it is necessary to manually use dpkg (possibly with forcing options) to correct the situation enough to allow APT to proceed.

Before proceeding apt-get will present a report on what will happen. Generally the report reflects the type of operation being performed but there are several common elements. In all cases the lists reflect the final state of things, taking into account the -f option and any other relevant activities to the command being executed.

During the download of archives and package files APT prints out a series of status messages.

# apt-get update
Get:1 http://ftp.de.debian.org/debian-non-US/ stable/non-US/ Packages
Get:2 http://llug.sep.bnl.gov/debian/ testing/contrib Packages
Hit http://llug.sep.bnl.gov/debian/ testing/main Packages
Get:4 http://ftp.de.debian.org/debian-non-US/ unstable/binary-i386/ Packages
Get:5 http://llug.sep.bnl.gov/debian/ testing/non-free Packages
11% [5 testing/non-free `Waiting for file' 0/32.1k 0%] 2203b/s 1m52s

The lines starting with Get are printed out when APT begins to fetch a file while the last line indicates the progress of the download. The first percent value on the progress line indicates the total percent done of all files. Unfortunately since the size of the Package files is unknown apt-get update estimates the percent done which causes some inaccuracies.

The next section of the status line is repeated once for each download thread and indicates the operation being performed and some useful information about what is happening. Sometimes this section will simply read Forking which means the OS is loading the download module. The first word after the [ is the fetch number as shown on the history lines. The next word is the short form name of the object being downloaded. For archives it will contain the name of the package that is being fetched.

Inside of the single quote is an informative string indicating the progress of the negotiation phase of the download. Typically it progresses from Connecting to Waiting for file to Downloading or Resuming. The final value is the number of bytes downloaded from the remote site. Once the download begins this is represented as 102/10.2k indicating that 102 bytes have been fetched and 10.2 kilobytes is expected. The total size is always shown in 4 figure notation to preserve space. After the size display is a percent meter for the file itself. The second last element is the instantaneous average speed. This values is updated every 5 seconds and reflects the rate of data transfer for that period. Finally is shown the estimated transfer time. This is updated regularly and reflects the time to complete everything at the shown transfer rate.

The status display updates every half second to provide a constant feedback on the download progress while the Get lines scroll back whenever a new file is started. Since the status display is constantly updated it is unsuitable for logging to a file, use the -q option to remove the status display.

APT uses dpkg for installing the archives and will switch over to the dpkg interface once downloading is completed. dpkg will also ask a number of questions as it processes the packages and the packages themselves may also ask several questions. Before each question there is usually a description of what it is asking and the questions are too varied to discuss completely here.



[2] The dselect method actually is a set of wrapper scripts to apt-get. The method actually provides more functionality than is present in apt-get alone.

[3] APT however considers all known dependencies and attempts to prevent broken packages