APT-の手引き
APTとは?
APTとはAdvanced Packaging Toolの略でシステム管理者(つまりあなた)がDebianのパッケージ(debファイル)をインストールしたり、どのパッケージがインストールされているかなどを管理するためのいくつかのプログラムとスクリプトの総称です。
ソースリスト
APTシステムにはインストールまたはアップグレードできるパッケージの場所についての情報を保持するsources.listと呼ばれるファイルが必要です。
Sources are contained in a directory or folder named:
/etc/apt/sources.list.d/
このフォルダーには2つのファイルがあります:
/etc/apt/sources.list.d/debian.list と
/etc/apt/sources.list.d/sidux.list
このやり方には簡単な(自動的な)ミラー切り替えができるという利点があり、リストの交換もより安全にできます。
ここに自分のソースリストファイル /etc/apt/sources.list.d/*.list を加えることもできます。
siduxのISOは次のようなsources をデフォルトとして使っています:
#sidux # Free University Berlin/ spline (Student Project LInux NEtwork), Germany deb ftp://ftp.spline.de/pub/sidux/debian/ sid main fix.main #deb-src ftp://ftp.spline.de/pub/sidux/debian/ sid main fix.main
non-freeが必要な場合のためのsources.listand debian.list::
#Debian # Unstable deb http://ftp.us.debian.org/debian/ unstable main contrib non-free #deb-src http://ftp.us.debian.org/debian/ unstable main contrib non-free # Testing #deb http://ftp.us.debian.org/debian/ testing main contrib non-free #deb-src http://ftp.us.debian.org/debian/ testing main contrib non-free # Experimental #deb http://ftp.us.debian.org/debian/ experimental main contrib non-free #deb-src http://ftp.us.debian.org/debian/ experimental main contrib non-free
ノート: この例で使われているftp.usはドイツのレポジトリーを表します。 rootとして、このファイルを変更して、近くのレポジトリーを使うように設定できます。 たとえば ftp.us を ftp.jp または ftp.uk という具合に。 大抵の国にレポジトリーがあるのでバンドウィドスの節約になりスピードも改良されます。
List of Debian Servers and mirrors current status.
パッケージについての最新の情報を得るためにAPTはデータベースを使っています。 このデータベースにはパッケージだけでなく、そのパッケージが動くために他のどのパッケージが必要であるかの情報(依存関係と呼ばれます)も含まれています。 apt-getというプログラムはこのデータベースを見て、インストールするパッケージの依存関係をすべて解決するパッケージを選びます。 このデータベースを更新するのために apt-get update のコマンドがあります。
# apt-get update (which returns) Get:1 http://sidux.com sid Release.gpg [189B] Get:2 http://sidux.com sid Release.gpg [189B] Get:3 http://sidux.com sid Release.gpg [189B] Get:4 http://ftp.de.debian.org unstable Release.gpg [189B] Get:5 http://sidux.com sid Release [34.1kB] Get:6 http://ftp.de.debian.org unstable Release [79.6kB]
新しいパッケージのインストール
APTのデータベースが更新され、インストールしたいパッケージの名がわかっていたら、次のコマンドでそのパッケージをインストールできます。 例として qemu という名のパッケージと依存関係のあるパッケージすべてをインストールするには: (パッケージの探し方は後ほど)
# apt-get install qemu Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: bochsbios openhackware proll vgabios Recommended packages: debootstrap vde The following NEW packages will be installed: bochsbios openhackware proll qemu vgabios 0 upgraded, 5 newly installed, 0 to remove and 20 not upgraded. Need to get 4152kB of archives. After unpacking 11.9MB of additional disk space will be used. Do you want to continue [Y/n]? n
パッケージの除去
Similarly it should come as no surprise that the following will deinstall a package, however it will not remove the dependencies:
apt-get remove gaim
Reading package lists... Done Building dependency tree... Done The following packages will be REMOVED: gaim gaim-irchelper 0 upgraded, 0 newly installed, 2 to remove and 310 not upgraded. Need to get 0B of archives. After unpacking 4743kB disk space will be freed. Do you want to continue [Y/n]? (Reading database ... 174409 files and directories currently installed.) Removing gaim-irchelper ... Removing gaim ...
上記の最後のコマンドでは gaim というパッケージの設定ファイルは消去されていません。 そのため後でまた同じパッケージをインストールするとこの設定が使われることになります。
設定ファイルも一緒に消してしまいたい場合は次のコマンドを使います:
apt-get --purge remove gaim
Reading package lists... Done Building dependency tree... Done The following packages will be REMOVED: gaim* 0 upgraded, 0 newly installed, 1 to remove and 309 not upgraded. Need to get 0B of archives. After unpacking 4678kB disk space will be freed. Do you want to continue [Y/n]? Y (Reading database ... 174405 files and directories currently installed.) Removing gaim ... Purging configuration files for gaim ...
Note the * after the package name in the output of apt. The asterisk in the output of apt indicates that the configuration files will also be removed.
ダウングレードまたはパッケージの保持
時にはインストールしたばかりの最新パッケージに大きなバグがあるため前のバージョンに戻したり、インストールされている最新でないパッケージを維持する必要があるかもしれません。
ホールド(保持)
echo package hold|dpkg --set-selections
ホールドの終了
echo package install|dpkg --set-selections
ホールドになっているパッケージの表示:
dpkg --get-selections | grep hold
ダウングレード
ここでは例としてkmahjonggをダウングレードします:
/etc/apt/sources.list.d/debian.list のtesting の行を有効にする
(行の始めの#を消してコメントからはずす)。 次のようになります:
deb http://ftp.nl.debian.org/debian/ testing main contrib non-freeapt-get update
apt-get install kmahjongg/testing
- 今インストールされたパッケージをホールドにする:
echo kmahjongg hold|dpkg --set-selections
/etc/apt/sources.list.d/debian.list の testing の行をコメントに戻す
apt-get update
このパッケージを最新のものにしたくなったら:
echo kmahjongg install|dpkg --set-selections apt-get update apt-get install kmahjongg
インストールされたシステムのアップグレード - dist-upgrade - Overview
システム全体をアップグレードしたい場合は dist-upgrade を行います。 まず必ず sidux のウェッブサイトに警告がないかをチェックし、とくにシステムがアップデートしようとしているパッケージに問題がないかを確認してください。 必要があればパッケージのダウングレードとホールドの項目にしたがってパッケージをholdにします
Debian sid で upgrade のコマンドだけでアップグレードするのは推薦できません。
dist-upgradeの頻度について
dist-upgrade はなるべく定期的に行います。 理想的には一週間か二週間に一度、少なくとも一ヶ月に一度ならば安心です。 二、三カ月に一度ならまだなんとかぎりぎり大丈夫といえるかもしれません。 標準でないパッケージや自分でコンパイルしたパッケージを使っている場合はいつ互換性の問題でシステムが滅茶苦茶になってもおかしくないのでさらに注意が必要です。
データベースがアップデートされた後、新しいバージョンのあるパッケージを表示することができます。 (初めての実行前に apt-show-versions をインストールしてください)
apt-show-versions -u libpam-runtime/unstable upgradeable from 0.79-1 to 0.79-3 passwd/unstable upgradeable from 1:4.0.12-5 to 1:4.0.12-6 teclasat/unstable upgradeable from 0.7m02-1 to 0.7n01-1 libpam-modules/unstable upgradeable from 0.79-1 to 0.79-3.........
一つのパッケージを依存パッケージを含めて新しいバージョンにアップデートするには次の(gcc-4.0をアップデートする)例のようにします:
apt-get install gcc-4.0 Reading package lists... Done Building dependency tree... Done gcc-4.0 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and xxx not upgraded
ダウンロードだけする方法
あまり知られていないけれど、どのパッケージがdist-upgradeによって更新されるかを調べるのに非常に便利なオプションとして -d フラッグがあります:
apt-get update && apt-get dist-upgrade -d
この -d オプションは dist-upgrade のパッケージをインストールなしにただダウンロードするコマンドで、Xの上でもコンソールから安全に実行でき、あとで仕事が終わってからinit 3 でdist-upgradeを行うことができます。 このコマンドを使えば列記されたパッケージをチェックしたり、または下のように、実行を中止することもできます。
apt-get dist-upgrade -d
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
elinks-data
The following packages have been kept back:
git-core git-gui git-svn gitk icedove libmpich1.0ldbl
The following packages will be upgraded:
alsa-base bsdutils ceni configure-ndiswrapper debhelper
discover1-data elinks file fuse-utils gnucash.........
35 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 23.4MB of archives.
After this operation, 594kB of additional disk space will be used.
Do you want to continue [Y/n]?Y
Y を選べば現行のシステムを変更することなく新しいパッケージをダウンロードします
'dist-upgrade -d' がパッケージをダウンロードしたあとすぐ、またはしばらくたってからdist-upgradeを完了したいと思ったら、次の指示に従ってください。
dist-upgrade - The Steps
KDEをログアウト。
Ctrl+Alt+F1を押してテキストモードに
rootとしてログイン, init 3とタイプ
apt-get update
apt-get dist-upgrade
apt-get clean
init 5 && exit
init 3に行かずにアップデートする癖がつくと、今にきっとひどい目にあいますよ。 警告しましたよ!!!!!!!!!!!
dist-upgradeにapt-get以外の方法を使ってはいけない理由
adept, aptitude, synaptic, kpackageといったパッケージマネージャはSidに起こるような大きな変化 (依存関係の変更、パッケージ名の変更、メンテ用のスクリプトの変更など)に常にうまく対処できるようには作られていません。 これは別に上記のツールの開発者の過失というわけではなく、Debianのstableのために優れた道具を開発したことを讃えるべきですが、単にDebian Sidの特殊な要求に対処するのには向いていないというだけのことです。
パッケージを探すためにはどんなツールを使っても構いませんが、実際にパッケージのインストール/除去またはdist-upgradeをするときにはあくまでapt-getを使うようにしてください。
複雑な依存関係の入り組んだパッケージ選択にあたって, 少なくともadept, aptitude, synaptic, kpackageといったパッケージマネージャは決定論的に作られてはいません。 めまぐるしく変化するSidや、品質管理に疑問の残る外部レポジトリーのことも考えると, わざわざ破局を招いているようなものです。 (外部レポジトリーはsiduxに含まれていませんし、特に使用を勧めるものではありませんが、あれこれ使われているのが実際でしょう)。 もう一つ注意してほしいことはこれらGUIのパッケージマネージャはinit 5またはXウィンドウ上で実行される必要があることで、dist-upgrade (またはsiduxから推奨されていない'update')をXの上で行うのは、たとえ今日,明日は無事にすんでも、いつかきっとシステムに回復不可能なダメージを与えることになるでしょう。
それに比べてapt-getはやるべきことだけを厳密に行うプログラムです。 依存関係に問題があったら正確に指摘するので原因をデバッグ/修正できますし、もしapt-getが(ライブラリの移行などのため)現行システムの半分を消去しようとしていたら、何か変だぞとちょっと調べてみるのはそれこそアドミンの(つまりあなたの)仕事です。
そのためDebian自体の配布でも他のパッケージマネージャではなく、apt-getが使われているわけです。
apt-cacheを使ってパッケージを探す
APTシステムのもう一つとても便利なコマンドとして apt-cacheがあります。 APTのデータベースをサーチしてパッケージについての情報を表示します。 例: 名前または説明の中に"sidux"と"manual"の両方が現れるパッケージを探すには:
$ apt-cache search sidux manual ....... sidux-manual-common - the official sidux manual - common files sidux-manual-es - the official Spanish sidux manual sidux-manual-de - the official German sidux manual sidux-manual-el - the official Greek sidux manual sidux-manual - the official sidux manual - all languages sidux-manual-pt-br - the official Brazilian Portuguese sidux manual sidux-manual-en - the official English sidux manual sidux-manual-reader - sidux manual reader
特定のパッケージについてもっと知りたかったら:
$ apt-cache show sidux-manual-en Package: sidux-manual-en Priority: optional Section: doc Installed-Size: 1088 Maintainer: Kel Modderman <kel@otaku42.de> Architecture: all Source: sidux-manual Version: 01.12.2007.06.03-1 Depends: sidux-manual-common Filename: pool/main/s/sidux-manual/sidux-manual-en_01.12.2007.06.03-1_all.deb Size: 391222 MD5sum: 60f2175c3c5709745a4b4256ccc3c49d SHA1: e275a0b27628b6aa210a4ced48d3646b438e78b8 SHA256: 2792580c7a091521301064180a1d0d8901f0a4af407b90432b9f8d8b6b3603ca Description: the official en sidux manual This manual is divided into common sections, for example, .......
そのパッケージのインストールできるバージョン(sources.listの内容によって違います)を表示するには:
$ apt-cache policy sidux-manual-en
sidux-manual-en:
Installed: (none)
Candidate:01.12.2007.06.03-1
Version table:
01.12.2007.06.03-1 0
500 http://sidux.com sid/main Packages
APTシステムの詳細はAPT-HOWTO(日本語版)をご覧ください (英語版はこちらへ)
Debian Package Search GUI application
apt-get update apt-get install packagesearch
When you first start Debian Package Search you need to adjust Packagesearch>Preferences to use apt-get.
Please do not use Packagesearch to install packages, use it only as a GUI search engine.
On initial use you may be prompted to install deborphan. Please use with care.
Search can be done by
- pattern
- tags (based on the debtags system, a new way of categorizing Debian packages)
- files
- installed status
- orphaned packages
Additionally a lot of information about the packages is displayed, including the files belonging to them. Please read the Help>Contents for a full explanation on how to use the Debian Package Search GUI application. At the moment the GUI is in English only.
APTシステムの詳細はAPT-HOWTO(日本語版)をご覧ください

サーチ Online Offline