Product SiteDocumentation Site

Capítulo 6. Mantenimiento y actualizaciones: las herramientas APT

6.1. Contenido del archivo sources.list
6.1.1. Sintaxis
6.1.2. Repositorios para usuarios de Stable
6.1.3. Repositorios para usuarios de Testing/Unstable
6.1.4. Using Alternate Mirrors
6.1.5. Recursos no oficiales: mentors.debian.net
6.1.6. Proxy caché para paquetes Debian
6.2. Los programas aptitude, apt-get y apt
6.2.1. Inicialización
6.2.2. Instalación y eliminación
6.2.3. Actualización del sistema
6.2.4. Opciones de configuración
6.2.5. Gestión de prioridades de los paquetes
6.2.6. Trabajo con varias distribuciones
6.2.7. Seguimiento de paquetes instalados automáticamente
6.3. La orden apt-cache
6.4. The apt-file Command
6.5. Interfaces: aptitude, synaptic
6.5.1. aptitude
6.5.2. synaptic
6.6. Comprobación de la autenticidad de un paquete
6.7. Actualización de una distribución estable a la siguiente
6.7.1. Procedimiento recomendado
6.7.2. Manejo de problemas tras una actualización
6.7.3. Cleaning Up after an Upgrade
6.8. Manutención de un sistema actualizado
6.9. Actualizaciones automáticas
6.9.1. Configuración de dpkg
6.9.2. Configuración de APT
6.9.3. Configuración de debconf
6.9.4. Manejo de interacciones de línea de órdenes
6.9.5. La combinación milagrosa
6.10. Búsqueda de paquetes
What makes Debian so popular with administrators is how easily software can be installed and how easily the whole system can be updated. This unique advantage is largely due to the APT program, which Falcot Corp administrators studied with enthusiasm.
APT is the abbreviation for Advanced Package Tool. What makes this program “advanced” is its approach to packages. It doesn't simply evaluate them individually, but it considers them as a whole and produces the best possible combination of packages depending on what is available and compatible according to dependencies.
APT needs to be given a “list of package sources (repositories)”: the file /etc/apt/sources.list will list the different repositories that publish Debian packages. APT will then import the list of packages published by each of these sources. This operation is achieved by downloading Packages.xz files or a variant such as Packages.gz or .bz2 (using a different compression method) in case of a source of binary packages and by analyzing their contents. In case of a source of source packages, APT downloads Sources.xz files or a variant using a different compression method. When an old copy of these files is already present, APT can update it by only downloading the differences (see sidebar TIP Incremental updates).

6.1. Contenido del archivo sources.list

6.1.1. Sintaxis

Each active line in the /etc/apt/sources.list file represents a package source (repository) and is made of at least three parts separated by spaces. For a complete description of the file format and the accepted entry compositions see sources.list(5).

Ejemplo 6.1. Example entry format in /etc/apt/sources.list

deb url distribution component1 component2 component3 [..] componentX
deb-src url distribution component1 component2 component3 [..] componentX
El primer campo indica el tipo de origen:
deb
package source (repository) of binary packages
deb-src
package source (repository) of source packages
The second field gives the base URL of the source. Combined with the filenames listed in the Packages.xz files, it must give a full and valid URL. This can consist in a Debian mirror or in any other package archive set up by a third party. The URL can start with file:// to indicate a local source installed in the system's file hierarchy, with http:// or https:// to indicate a source accessible from a web server server, or with ftp:// or ftps:// for a source available on an FTP server. The URL can also start with cdrom: for CD-ROM/DVD/Blu-ray disc based installations, although this is less frequent, since network-based installation methods are eventually more common.
The syntax of the last field depends on the structure of the repository. In the simplest case, you can simply indicate a subdirectory (with a required trailing slash) of the desired source. This is often a simple “./” which refers to the absence of a subdirectory. The packages are then directly at the specified URL. But in the most common case, the repositories will be structured like a Debian mirror, with multiple distributions, each having multiple components. In those cases, name the chosen distribution by its “codename” — see the list in sidebar COMUNIDAD Bruce Perens, un líder polémico — or by the corresponding “suite” oldstable, stable, testing, unstable) and then the components to enable. A typical Debian mirror provides the components main, contrib, and non-free.
Los elementos cdrom describen los CD/DVD-ROMs que posee. A diferencia de otros elementos, un CD-ROM no siempre está disponible ya que debe encontrarse en el dispositivo y sólo un disco puede leerse en un momento dado. Por estas razones, se gestionan estos elementos de una forma ligeramente diferente y necesitan ser agregados con el programa apt-cdrom, usualmente ejecutado con el parámetro add. Este programa solicitará que introduzca el disco en el dispositivo y navegará su contenido en busca de archivos Packages. Utilizará dichos achivos para actualizar su base de datos de paquetes disponibles (generalmente realizada cuando ejecuta apt update). Desde ese momento en adelante, APT puede solicitarle introducir el disco si necesita uno de sus paquetes.

6.1.2. Repositorios para usuarios de Stable

Este es un archivo sources.list estándar para un sistema que ejecuta la versión Stable de Debian:

Ejemplo 6.2. el archivo /etc/apt/sources.list para usuarios de Debian «stable»

# Security updates
deb http://security.debian.org/ buster/updates main contrib non-free
deb-src http://security.debian.org/ buster/updates main contrib non-free

## Debian mirror

# Base repository
deb https://deb.debian.org/debian buster main contrib non-free
deb-src https://deb.debian.org/debian buster main contrib non-free

# Stable updates
deb https://deb.debian.org/debian buster-updates main contrib non-free
deb-src https://deb.debian.org/debian buster-updates main contrib non-free

# Stable backports
deb https://deb.debian.org/debian buster-backports main contrib non-free
deb-src https://deb.debian.org/debian buster-backports main contrib non-free
This file lists all sources of packages associated with the Buster version of Debian (the current Stable suite as of this writing). In the example above, we opted to name “buster” explicitly instead of using the corresponding “stable“ aliases (stable, stable-updates, stable-backports) because we don't want to have the underlying distribution changed outside of our control when the next stable release comes out.
La mayoría de los paquetes provendrán del «repositorio base» que contiene todos los paquetes pero rara vez es actualizado (alrededor de una vez cada 2 meses para «versiones menores» — «point release»). Los otros repositorios son parciales (no contienen todos los paquetes) y pueden almacenar actualizaciones (paquetes con versiones más recientes) para que instale APT. Las secciones siguientes explicarán su propósito y las reglas que regulan cada uno de estos repositorios.
Sepa que cuando la versión deseada de un paquete se encuentra disponible en varios repositorios, se utilizará el que se encuentre primero en el archivo sources.list. Por esta razón, generalmente se agregan orígenes no oficiales al final del archivo.
Como nota adicional, la mayoría de lo que diga esta sección sobre Stable también es aplicable a Oldstable ya que esta última es sólo una versión Stable más antigua que se mantiene en paralelo.

6.1.2.1. Actualizaciones de seguridad

Debian takes security seriously. Known software vulnerabilities in Debian are tracked in the Security Bug Tracker and usually get fixed in a reasonable timeframe. The security updates are not hosted on the usual network of Debian mirrors but on security.debian.org, a small set of machines maintained by the Debian System Administrators. This archive contains security updates prepared by the Debian Security Team and/or by package maintainers for the Stable and Oldstable distribution.
The server can also host security updates for Testing but this doesn't happen very often since those updates tend to reach the Testing suite via the regular flow of updates coming from Unstable.
For serious issues, the security team issues a Debian Security Advisory (DSA) and announces it together with the security update on the mailing list (archive).

6.1.2.2. Actualizaciones de Stable

Las actualizaciones de stable no implican riesgos de seguridad pero son consideradas suficientemente importantes como para ser enviadas a los usuarios antes de la publicación de la siguiente versión menor de stable.
This repository will typically contain fixes for critical and serious bugs which could not be fixed before release or which have been introduced by subsequent updates. Depending on the urgency, it can also contain updates for packages that have to evolve over time, like spamassassin's spam detection rules, clamav's virus database, the daylight-saving time rules of all timezones (tzdata), the ESR version of Firefox (firefox-esr) or cryptographic keyrings like debian-archive-keyring.
In practice, this repository is a subset of the proposed-updates repository, carefully selected by the Stable Release Managers. All updates are announced on the mailing list (archive) and will be included in the next Stable point release anyway.
deb https://deb.debian.org/debian buster-updates main contrib non-free

6.1.2.3. Actualizaciones propuestas

Una vez publicada, la distribución Stable se actualiza sólo una vez cada 2 meses. El repositorio proposed-updates es donde se preparan las futuras actualizaciones (bajo la supervisión de los Gestores de la versión estable, «Stable Release Managers»).
Las actualizaciones de seguridad y de estable documentadas en las secciones anteriores siempre son parte de este repositorio, pero también habrá otras ya que los encargados de los paquetes también tienen la oportunidad de corregir errores importantes que no justifican que se publique una nueva versión inmediatamente.
Anyone can use this repository to test those updates before their official publication. The extract below uses the buster-proposed-updates alias which is both more explicit and more consistent since stretch-proposed-updates also exists (for the Oldstable updates):
deb https://deb.debian.org/debian buster-proposed-updates main contrib non-free

6.1.2.4. Retroadaptaciones para Stable

El repositorio stable-backports contiene «retroadaptaciones de paquetes». Es término hace referencia a paquetes de software reciente que fue recompilado para una distribución antigua, generalmente para Stable.
When the distribution becomes a little dated, numerous software projects have released new versions that are not integrated into the current Stable suite, which is only modified to address the most critical problems, such as security issues. Since the Testing and Unstable suites can be more risky, package maintainers sometimes voluntarily offer recompilations of recent software applications for Stable, which has the advantage to users and system administrators to limit potential instability to a small number of chosen packages. The page https://backports.debian.org provides more information.
Backports from stable-backports are only created from packages available in Testing. This ensures that all installed backports will be upgradable to the corresponding stable version once the next stable release of Debian is available.
Even though this repository provides newer versions of packages, APT will not install them unless you give explicit instructions to do so (or unless you have already done so with a former version of the given backport):
$ sudo apt-get install package/buster-backports
$ sudo apt-get install -t buster-backports package

6.1.3. Repositorios para usuarios de Testing/Unstable

Este es un archivo sources.list estándar para un sistema que ejecuta la versión Testing o Unstable de Debian:

Ejemplo 6.3. Archivo sources.list para usuarios de Debian Testing/Unstable

# Unstable
deb https://deb.debian.org/debian unstable main contrib non-free
deb-src https://deb.debian.org/debian unstable main contrib non-free

# Testing
deb https://deb.debian.org/debian testing main contrib non-free
deb-src https://deb.debian.org/debian testing main contrib non-free

# Testing security updates
deb http://security.debian.org/ testing-security main contrib non-free
deb-src http://security.debian.org/ testing-security main contrib non-free

# Stable
deb https://deb.debian.org/debian stable main contrib non-free
deb-src https://deb.debian.org/debian stable main contrib non-free

# Stable security updates
deb http://security.debian.org/ stable/updates main contrib non-free
deb-src http://security.debian.org/ stable/updates main contrib non-free
With this sources.list file APT will install packages from the Unstable suite. If that is not desired, use the APT::Default-Release setting (see Sección 6.2.3, “Actualización del sistema”) to instruct APT to pick packages from another suite (most likely Testing in this case).
Existen buenas razones para incluir todos estos repositorios, inclusive cuando sólo uno debería ser suficiente. Los usuarios de Testing apreciarán la posibilidad de seleccionar paquetes específicos de Unstable cuando la versión en Testing posee un error molesto. Por el otro lado, los usuarios de Unstable afectados por regresiones inesperadas pueden desactualizar paquetes a la versión de Testing (que supuestamente funciona).
The inclusion of Stable is more debatable but it often gives access to some packages, which have been removed from the development versions. It also ensures that you get the latest updates for packages, which have not been modified since the last stable release.

6.1.3.1. El repositorio Experimental

El compendio de paquetes Experimental se encuentra en todas las réplicas Debian y contiene paquetes que no están en Unstable aún debido a que su calidad está bajo los estándares normales — generalmente son versiones en desarrollo del software o versiones previas (alpha, beta, candidato de publicación...). Un paquete también puede ser enviado ahí luego de sufrir muchos cambios que pueden generar problemas. El desarrollador luego intentará descubrirlos con la ayuda de usuarios avanzados que pueden manejar problemas importantes. Luego de esta etapa, mueve el paquete a Unstable, donde alcanza una audiencia más grande y donde será probado en mucho más detalle.
Los usuarios que usan Experimental generalmente no les importa romper su sistema y luego repararlo. Esta distribución les da la posibilidad de importar un paquete que el usuario desea probar o usar según lo necesita. Esto es exactamente el enfoque que toma Debian ya que agregarlo en el archivo sources.list de APT no conlleva el uso sistemático de sus paquetes. La línea a agregar es:
deb https://deb.debian.org/debian experimental main contrib non-free

6.1.4. Using Alternate Mirrors

The sources.list examples in this chapter refer to package repositories hosted on deb.debian.org. Those URLs will redirect you to servers which are close to you and which are managed by Content Delivery Networks (CDN) whose main role is to store multiple copies of the files across the world, and to deliver them as fast as possible to users. The CDN companies that Debian is working with are Debian partners who are offering their services freely to Debian. While none of those servers are under direct control of Debian, the fact that the whole archive is sealed by GPG signatures makes it a non-issue.
Picky users who are not satisfied with the performance of deb.debian.org can try to find a better mirror in the official mirror list:
But when you don't know which mirror is best for you, this list is of not much use. Fortunately for you, Debian maintains DNS entries of the form ftp.country-code.debian.org (e.g. ftp.us.debian.org for the USA, ftp.fr.debian.org for France, etc.) which are covering many countries and which are pointing to one (or more) of the best mirrors available within that country.
As an alternative to deb.debian.org, there used to be httpredir.debian.org. This service would identify a mirror close to you (among the list of official mirrors, using GeoIP mainly) and would redirect APT's requests to that mirror. This service has been deprecated due to reliability concerns and now httpredir.debian.org provides the same CDN-based service as deb.debian.org.

6.1.5. Recursos no oficiales: mentors.debian.net

There are numerous non-official sources of Debian packages set up by advanced users who have recompiled some software (Ubuntu made this popular with their Personal Package Archive (PPA) service, by programmers who make their creation available to all, and even by Debian developers who offer pre-versions of their package online.
The mentors.debian.net site is interesting (although it only provides source packages), since it gathers packages created by candidates to the status of official Debian developer or by volunteers who wish to create Debian packages without going through that process of integration. These packages are made available without any guarantee regarding their quality; make sure that you check their origin and integrity and then test them before you consider using them in production.
Instalar un paquete significa dar permisos de root a su creador, porque ellos deciden el contenido de los scripts de inicialización que ejecutan bajo esa identidad. Los paquetes oficiales de Debian son creados por voluntarios que fueron cooptados y verificados y que pueden firmar sus paquetes para que se pueda revisar su origen e integridad.
In general, be wary of a package whose origin you don't know and which isn't hosted on one of the official Debian servers: evaluate the degree to which you can trust the creator, and check the integrity of the package.

6.1.6. Proxy caché para paquetes Debian

Cuando una red completa de equipos está configurada para utilizar el mismo servidor remoto para descargar los mismo paquetes actualizados, todo administrador sabe que es beneficioso tener un proxy intermedio que funcione como caché para la red local (revise el recuadro VOCABULARIO Caché).
Puede configurar APT para que utilice un proxy «estándar» (revise la Sección 6.2.4, “Opciones de configuración” para la configuración de APT y la Sección 11.6, “Proxy HTTP/FTP” para la configuración del proxy), pero el ecosistema Debian ofrece mejores opciones para solucionar este problema. Esta sección presente un software dedicado que es más inteligente que un simple proxy caché porque utiliza la estructura específica de los repositorios APT (por ejemplo, conoce cuándo archivos particulares son obsoletos o no y así modifica el tiempo durante el cual los mantendrá).
apt-cacher y apt-cacher-ng funcionan como servidores proxy caché usuales. No se modifica el archivo sources.list, pero se configura a APT para utilizarlos como proxy para pedidos salientes.
approx, por el otro lado, funciona como un servidor HTTP que «replica» cualquier cantidad de repositorios remotos en su URL más genérica. Se almacena el mapeo entre estos directorios y las URLs remotas de los repositorios en /etc/approx/approx.conf:
# <name> <repository-base-url>
debian   https://deb.debian.org/debian
security http://security.debian.org
approx runs by default on port 9999 via a systemd socket and requires the users to adjust their sources.list file to point to the approx server:
# Sample sources.list pointing to a local approx server
deb http://localhost:9999/security buster/updates main contrib non-free
deb http://localhost:9999/debian buster main contrib non-free