Product SiteDocumentation Site

第 6 章 メンテナンスと更新、APT ツール

6.1. sources.list ファイルの内容
6.1.1. 構文
6.1.2. 安定版 ユーザ用リポジトリ
6.1.3. テスト版/不安定版ユーザ向けリポジトリ
6.1.4. 代替ミラーの利用
6.1.5. 非公式リソース、mentors.debian.net
6.1.6. Debian パッケージのキャッシュプロキシ
6.2. aptitudeapt-getapt コマンド
6.2.1. 初期設定
6.2.2. インストールと削除
6.2.3. システムのアップグレード
6.2.4. 設定オプション
6.2.5. パッケージ優先度の管理
6.2.6. 複数ディストリビューションの利用
6.2.7. 自動的にインストールされたパッケージの追跡
6.2.8. APT Patterns
6.3. apt-cache コマンド
6.3.1. The apt-cache policy Command
6.4. The apt-file Command
6.5. フロントエンド、aptitudesynaptic
6.5.1. aptitude
6.5.2. synaptic
6.6. パッケージ信頼性の確認
6.7. 安定版から次のディストリビューションへのアップグレード
6.7.1. 推奨手順
6.7.2. アップグレードの後から問題を取り扱う
6.7.3. Cleaning Up after an Upgrade
6.8. システムを最新の状態に保つ
6.9. 自動アップグレード
6.9.1. dpkg の設定
6.9.2. APT の設定
6.9.3. debconf の設定
6.9.4. コマンドラインインターフェースの制御
6.9.5. 奇跡の組み合わせ
6.10. パッケージの検索
Debian が管理者に人気がある理由は、ソフトウェアのインストールが簡単で、システム全体の更新が簡単だからです。この比類なき長所は、主として APT プログラムが担っており、Falcot Corp の管理者がこれについて熱心に学びました。
APT は Advanced Package Tool の略称です。APT を「先進的」たらしめているものとは、パッケージの取り扱い方です。APT はパッケージを独立なものとして単純に評価するのではなく、パッケージ全体を考慮し、(依存関係に従って) 利用できて相性の良いパッケージを選び出すことで、実現できる最適なパッケージの組み合わせを作り出します。
APT には「パッケージソースのリスト(リポジトリ)」が必要です。つまり /etc/apt/sources.list には Debian パッケージを公開しているさまざまなリポジトリが記載されています。APT はそれぞれのソースで公開されているパッケージのリストを取り込みます。具体的に言うと、バイナリパッケージソースの場合は Packages.xz ファイルまたは Packages.gzPackages.bz2 (別の方法で圧縮されたファイル)、ソースパッケージソースの場合は Sources.xz ファイルまたは別の方法で圧縮されたファイルをダウンロードして、内容を解析して、パッケージのリストを取り込みます。これらのファイルの古いコピーが既にあるのなら、APT は差分だけをダウンロードしてファイルを更新することも可能です (補注TIP Incremental updates」を参照してください)。

6.1. sources.list ファイルの内容

6.1.1. 構文

/etc/apt/sources.list にある有効な行はパッケージのソースで、一行は3つ以上にスペースで区切られています。この書式の解説、利用方法等は sources.list(5) にあります。

例 6.1 /etc/apt/sources.list の記述例

deb url リリース名 コンポーネント1 コンポーネント2 コンポーネント3 [..] コンポーネントX
deb-src url リリース名 コンポーネント1 コンポーネント2 コンポーネント3 [..] コンポーネントX
1 番目のフィールドはソースタイプです。
deb
バイナリパッケージのパッケージソース(リポジトリ)
deb-src
ソースパッケージのパッケージソース(リポジトリ)
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, 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. More methods like ssh:// or tor+http(s):// are supported and are either described in sources.list(5) or their respective apt-transport-method package documentation.
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 COMMUNITY Bruce Perens、賛否の分かれるリーダー」 — or by the corresponding “suite” (oldoldstable, oldstable, stable, testing, unstable) and then the components to enable. A typical Debian mirror provides the components main, contrib, and non-free.
cdrom エントリはあなたの持っている CD/DVD-ROM を表しています。他のエントリと異なり、CD-ROM は常に利用できるわけではありません。なぜなら、ディスクをドライブに挿入しなければいけませんし、一度に 1 つのディスクしか読めないからです。このような理由で、CD-ROM ソースは少し違う方法で管理されます。ソースを追加するには通常 apt-cdrom プログラムに add パラメータを付けて実行します。このようにプログラムを実行すると、ドライブにディスクを挿入するよう要求されます。apt-cdrom プログラムはディスクの内容を閲覧して Packages ファイルを探します。Packages ファイルは利用できるパッケージに関する APT のデータベースを更新するために利用されます (更新作業は apt update コマンドで実行されます)。そして、APT はディスクに含まれるパッケージが必要になったらディスクを挿入するように要求します。

6.1.2. 安定版 ユーザ用リポジトリ

下に示すのは、Debian の安定版を動かしているシステムで標準的な sources.list です。

例 6.2 Debian 安定版ユーザ向けの /etc/apt/sources.list ファイル

# セキュリティ更新
deb http://security.debian.org/ bullseye/updates main contrib non-free
deb-src http://security.debian.org/ bullseye/updates main contrib non-free

## Debian ミラー

# ベースリポジトリ
deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free

# 安定版更新
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free

# 安定版バックポート
deb http://deb.debian.org/debian bullseye-backports main contrib non-free
deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free
このファイルは Debian Bullseye (これを書いている時点の 安定版) に関連するパッケージの全ソースをリストしています。ここでディストリビューション名に「bullseye」を使い、対応する「stable」(stablestable-updatesstable-backports) という別名を使わなかったのには理由があります。それは、新しい安定版が公開されることにより自動的にディストリビューションのバージョンが変わることを避けるためです。
多くのパッケージは「ベースリポジトリ」から取得されます。「ベースリポジトリ」にはすべてのパッケージが収録されていますが、安定版の「ベースリポジトリ」はめったに更新されません (約 2 カ月に 1 度の「ポイントリリース」で更新されます)。「ベースリポジトリ」以外のリポジトリには一部のパッケージだけが収録されており (すべてパッケージが収録されているわけではありません)、「ベースリポジトリ」以外のリポジトリに更新 (「ベースリポジトリ」に含まれるパッケージの新しいバージョン) が収録されていた場合、APT は更新をインストールします。以下の節ではそれぞれのリポジトリの目的とリポジトリの運営ルールについて説明します。
あるパッケージの希望したバージョンが複数のリポジトリから取得できる場合、sources.list ファイルにリストされた最初のリポジトリから取得されることに注意してください。この理由から、非公式ソースは通常最後に追加されます。
ちなみに、この節で安定版に関して述べていることのほとんどは旧安定版に関しても同じことが言えます。なぜなら、旧安定版とは並行してメンテナンスされている古い安定版に過ぎないからです。

6.1.2.1. セキュリティ更新

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 that 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. 安定版更新

安定版更新リポジトリにはセキュリティに影響をおよぼすパッケージは含まれませんが、その重要性により次回の安定版ポイントリリースよりも前にユーザに提供するだけの価値があるとみなされた更新が含まれています。
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.

6.1.2.3. 提案された更新

安定版 ディストリビューションはひとたび公開されたら、約 2 カ月に 1 回だけ更新されます。proposed-updates リポジトリとは (安定版リリースマネージャの指揮の下で) 今後予定されている更新を準備するためのリポジトリです。
前の節で説明したセキュリティ更新と安定版更新は、常に proposed-updates リポジトリに加えられますが、更新は他にもあります。なぜなら、パッケージメンテナは素早くリリースすることもないけれど重要と思われるバグを修正する機会があるからです。
正式公開前に更新をテストするためには proposed-updates リポジトリを使います。以下で引用した例は bullseye-proposed-updates という別名を使っています。このような、より明白でより一貫性のある別名を使っている理由は、(旧安定版 に対する更新用のリポジトリとして) buster-proposed-updates という別名が存在するからです。
deb https://deb.debian.org/debian bullseye-proposed-updates main contrib non-free

6.1.2.4. 安定版バックポート

stable-backports リポジトリは「パッケージのバックポート」をホストしています。「パッケージのバックポート」という用語は古いディストリビューション (通常は安定版) 用に再コンパイルした最新ソフトウェアのパッケージを指す言葉です。
安定版ディストリビューションの公開から少し時間が経っただけで、多くのソフトウェアプロジェクトが新バージョンをリリースします。しかしながら、ソフトウェアの新バージョンは現在の安定版に組み込まれません (安定版に組み込まれるのはセキュリティ問題などの最も重要な問題に対する修正に限られています)。安定性の観点からテスト版不安定版ディストリビューションを使うのは危険過ぎると考える安定版のユーザ向けに、パッケージメンテナはしばしば安定版向けに最新のソフトウェアアプリケーションを再コンパイルして提供することがあります。バックポートされたパッケージを使うことにより、安定版のユーザとシステム管理者はシステムの不安定性をバックポートされたパッケージに起因する不安定性だけに制限することが可能です。 に詳細があります。
stable-backports に収録されているバックポートはテスト版で利用できるパッケージのみから作成されます。このおかげで、次の Debian 安定版リリースが利用できるようになったら、すべてのインストール済みバックポートパッケージはそれに対応する安定版から提供されたパッケージにアップグレードできることが保証されています。
リポジトリはパッケージの新しいバージョンを提供しますが、APT は以下に示すように明確な指示を出さない限り (または以前に同じバックポートの古いバージョンをインストールしていない限り) バックポートパッケージをインストールしません。
$ sudo apt-get install package/bullseye-backports
$ sudo apt-get install -t bullseye-backports package

6.1.3. テスト版/不安定版ユーザ向けリポジトリ

以下に示すのは、Debian のテスト版不安定版を動かしているシステムで標準的な sources.list です。

例 6.3 Debian テスト版/不安定版ユーザ向けの /etc/apt/sources.list ファイル

# 不安定版
deb https://deb.debian.org/debian unstable main contrib non-free
deb-src https://deb.debian.org/debian unstable main contrib non-free

# テスト版
deb https://deb.debian.org/debian testing main contrib non-free
deb-src https://deb.debian.org/debian testing main contrib non-free

# テスト版セキュリティ更新
deb http://security.debian.org/ testing-security main contrib non-free
deb-src http://security.debian.org/ testing-security main contrib non-free

# 安定版
deb https://deb.debian.org/debian stable main contrib non-free
deb-src https://deb.debian.org/debian stable main contrib non-free

# 安定版セキュリティ更新
deb http://security.debian.org/ stable-security main contrib non-free
deb-src http://security.debian.org/ stable-security 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 第 6.2.3 節「システムのアップグレード」) to instruct APT to pick packages from another suite (most likely Testing in this case).
There are good reasons to include all those repositories, even though a single one should be enough. Testing users will appreciate the possibility to cherry-pick a fixed package from Unstable when the version in Testing is affected by an annoying bug. On the other hand, Unstable users bitten by unexpected regressions have the possibility to downgrade packages to their (supposedly working) Testing version.
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. 実験版リポジトリ

実験版パッケージのアーカイブはすべての Debian アーカイブミラーに存在し、品質基準を満たしていないためにまだ不安定版に収録されていないパッケージを含んでいます。すなわち、実験版に含まれるパッケージはソフトウェアの開発版バージョンか先行バージョン (アルファ、ベータ、リリース候補など) であることが多いです。パッケージに対する一連の修正によって問題が引き起こされる可能性がある場合も、パッケージは実験版に送られます。メンテナは、重要な問題を取り扱う能力を持つ熟練ユーザの助けを借りて、その問題を明らかにしようとします。この最初のステージの後、パッケージは不安定版に移動されます。不安定版に移動されたパッケージはより多くのユーザに配布され、より詳細にテストされます。
実験版リポジトリを使うのは通常、システムを破壊したり修復することを気にしないユーザです。実験版リポジトリを使うユーザは必要に応じて試してみたいか使ってみたいと思ったパッケージを実験版からシステムに取り込むことができます。これはまさに Debian が実験版を活用する時の方法です。なぜなら、実験版リポジトリを APT の sources.list ファイルに追加しても、実験版パッケージを体系的に利用することにはならないからです。実験版リポジトリを追加するには以下を sources.list ファイルに追加します。
deb https://deb.debian.org/debian experimental main contrib non-free

6.1.4. 代替ミラーの利用

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.
あなたがこだわるタイプで deb.debian.org の性能に満足できないなら、以下の公式ミラーリストからさらに良いミラーを探してみてください:
どのミラーを選べばよいかわからないなら、公式のミラーリストは役に立ちません。そんな人のために、Debian は ftp.country-code.debian.org という (例: USA 用に ftp.us.debian.org、フランス用に ftp.fr.debian.org など) DNS エントリを整備しています。数多くの国に対するエントリが用意されていますし、その国の中で最良のミラー (複数個の場合もあります) に転送されます。
deb.debian.org の代替として、過去に httpredir.debian.org がありました。このサービスはユーザに近いミラーを見極め (主に GeoIP を使って公式ミラーから選び)、APT リクエストをそのミラーに転送するものでした。このサービスは信頼性の懸念が原因で既に停止しており、httpredir.debian.org では deb.debian.org と同じ CDN に基づくサービスが提供されています。

6.1.5. 非公式リソース、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.
あるパッケージをインストールすることは、パッケージの作者に root 権限を与えることを意味しています。なぜなら、パッケージ作者は root 権限で実行される初期化スクリプトの内容を決定するからです。公式 Debian パッケージは、パッケージの起源と整合性が確認できるように、選出され審査を受けたボランティアとパッケージの内容の責任を請け負うことができるボランティアによって作成されます。
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. Debian パッケージのキャッシュプロキシ

マシンのネットワーク全体で、同じ更新済みパッケージをダウンロードするために同じリモートサーバを使うよう設定されている場合、管理者はネットワークのローカルキャッシュとして振る舞う中間プロキシを用意するのは有益なことであると知っています (補注VOCABULARY キャッシュ」を参照してください)。
APT が「標準的な」プロキシを使うように設定することも可能です (APT 側は第 6.2.4 節「設定オプション」、プロキシ側は第 11.6 節「HTTP/FTP プロキシ」を参照してください)。しかしながら、Debian にはこの問題に対するより優れた選択肢が準備されています。この節で取り上げる専用ソフトウェアは単純なプロキシキャッシュよりも賢いです。なぜなら、このソフトウェアは APT リポジトリの特定の構造を頼りにできるからです (たとえば、個々のファイルが時代遅れになるタイミングがわかるので、ファイルを保存しておく時間を調整できます)。
apt-cacherapt-cacher-ng は普通のプロキシキャッシュサーバのように振る舞います。APT の sources.list を変更する必要はありませんが、APT の外部リクエスト用のプロキシ設定をこれらのプロキシキャッシュサーバに変更する必要があります。
これに対して、approx は基点 URL の下にある複数のリモートリポジトリを「ミラー」する HTTP サーバのように振る舞います。最上位ディレクトリの名前とリモート側リポジトリの基点 URL の対応関係は /etc/approx/approx.conf に保存されています。
# <最上位ディレクトリの名前> <リモート側リポジトリの基点 URL>
debian   https://deb.debian.org/debian
security http://security.debian.org/debian-security
approx のデフォルト設定では、systemd ソケット経由でポート 9999 番を使います。ユーザは基点 URL が approx サーバを指すように sources.list ファイルを書き換えなければいけません。
# ローカル approx サーバを利用する設定を施した sources.list の見本
deb http://localhost:9999/security bullseye-secutiry main contrib non-free
deb http://localhost:9999/debian bullseye main contrib non-free