Debian-Linux


Debianなページ

  • とはいえaptぐらいでしょう

まず最初にやるべき My apt-line の設定

近くの ring サーバを探す (簡易な方法)

http://www.t.ring.gr.jp/ を Mozilla などで表示すれば、TENBIN が自動的に近いサーバを探してくれる。また、http://www.dnsbalance.ring.gr.jp/ を表示すれば、空いているサーバを探してくれる。

近くの ring サーバを探す

# apt-get install netselect

して以下を実行 (ターミナルエミュレータに貼り付ければ OK)。

$ netselect -vv \
http://aist.ring.gr.jp/ \
http://ring.asahi-net.or.jp/ \
http://ring.crl.go.jp/ \
http://ring.astem.or.jp/ \
http://ring.jah.ne.jp/ \
http://ring.fujixerox.co.jp/ \
http://ring.so-net.ne.jp/ \
http://ring.ip-kyoto.ad.jp/ \
http://ring.iwate-pu.ac.jp/ \
http://ring.shibaura-it.ac.jp/ \
http://ring.ocn.ad.jp/ \
http://ring.htcn.ne.jp/ \
http://ring.pwd.ne.jp/ \
http://ring.tains.tohoku.ac.jp/ \
http://ring.toyama-ix.net/ \
http://ring.toyama-u.ac.jp/ \
http://ring.data-hotel.net/ \
http://ring.yamanashi.ac.jp/ \
http://ring.nihon-u.ac.jp/ \
http://ring.hosei.ac.jp/ \
http://ring.riken.go.jp/ \
http://ring.dcs.pref.mie.jp/ \
http://ring.qgpop.net/ \
http://ring.csi.ad.jp/ \
http://ring.atr.co.jp/ \
http://ring.shizuoka.ac.jp/ \
http://ring.airnet.ne.jp/ \
http://ring.k-opti.com/ \
http://ring.sbp-shimane.net/

結果の最後に http://近くのringサーバ (の候補) が表示される。
詳しくは近くのミラーサイトを探すにはを読みましょう。
この結果を元に /etc/apt/sources.list へ apt-line を書く。書式については下記を参考に。
もしくは apt-spy という一連の作業を自動で設定してくれるパッケージもあります。
適切な apt-line を設定する事が apt/dpkg を快適に使うための第一歩。

sources.list に書く apt-line の書式

woody (stable) 用 /etc/apt/sources.list

deb http://近くのringサーバ/pub/linux/debian/debian stable main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-non-US stable/non-US main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-jp stable-jp main contrib non-free

deb http://security.debian.org/ stable/updates main contrib non-free


sarge (testing) 用 /etc/apt/sources.list

deb http://近くのringサーバ/pub/linux/debian/debian sarge main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-non-US sarge/non-US main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-jp sarge-jp main contrib non-free

deb http://security.debian.org/ sarge/updates main contrib non-free

sid (unstable) 用 /etc/apt/sources.list

deb http://近くのringサーバ/pub/linux/debian/debian sid main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-non-US sid/non-US main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-jp sid-jp main contrib non-free

マイナーリリースのために修正がされたパッケージの利用法

proposed-updates は、リリース後に行われた Fix が取り込まれたパッケージを置く所で、次のマイナーリリース時には本体に取り込まれる。
ここに入るのは主にセキュリティ Fix などだけど、あくまで暫定的なものなので突然パッケージがなくなったりする。
また依存関係などに細かい問題が出る事もあるので本人のポリシー次第ってことで。

woody (stable) 用 /etc/apt/sources.list

deb http://近くのringサーバ/pub/linux/debian/debian proposed-updates main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-non-US proposed-updates/non-US main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-jp dists/proposed-updates-jp/

sarge (testing) 用 /etc/apt/sources.list

deb http://近くのringサーバ/pub/linux/debian/debian sarge-proposed-updates main contrib non-free

deb http://近くのringサーバ/pub/linux/debian/debian-non-US sarge-proposed-updates/non-US main contrib non-free


古いバージョンのパッケージファイルの利用法

http://snapshot.debian.net/

2002/6/4からの Debian の古いバージョンのパッケージが置いてあります。
アップグレードして不具合があればここから参照できます。
使い方はリンク先参照。

パッケージの説明が翻訳されたパッケージファイルの利用法

/etc/apt/sources.list の "先頭" に以下の行のいずれかを、 使用しているディストリビューション (woody/sarge/sid) に合わせて追加する。 翻訳作業に参加する人は、3行とも記述してね。

deb http://ftp.jp.debian.org/debian-ddtp ja/woody main

deb http://ftp.jp.debian.org/debian-ddtp ja/sarge main

deb http://ftp.jp.debian.org/debian-ddtp ja/sid main

その後 'apt-get update' すれば、全てのツール (dselect, gnome-apt, deity, ...) で翻訳済の説明文を使用することができる。

デフォルトの挙動の設定

これは設定しなくても問題ありません。
もし必要あれば /etc/apt/apt.conf あたりに書いておきましょう。
書式は

例1)
APT::Clean-Installed "true";
APT::Get::Assume-Yes "true";
例2)
APT
{
  Clean-Installed "true";
  Get
  {
     Assume-Yes "true";
  };

};

詳しくは man apt.conf を参照。
指定できる主な項目は

古いパッケージのキャッシュを自動で削除する

APT::Clean-Installed "true"

すべての質問に自動で YES と答える

APT::Get::Assume-Yes "true"

すべての質問に自動で NO と答える

APT::Get::Trivial-Only "true"

存在しないパッケージが指定されていても処理を続行する

APT::Get::Fix-Missing "true"

アンインストール時に設定ファイルも削除する

APT::Get::Purge "true"

処理の対象になっているパッケージのバージョンも表示する

APT::Get::Show-Versions "true"

ダウンロードのみでインストールしない

APT::Get::Download-Only "true"

処理の途中で失敗しても処理を続行する

APT::Get::Fix-Broken "true"

パッケージを削除できなくする

APT::Get::No-Remove "true"

詳しくは man apt-get を参照。


Debian のパッケージングシステムの FAQ

apt の使い方を知りたい

  • APT HOWTO という素敵なドキュメントがあります

インストール済のすべてのパッケージの一覧が見たい (rpm で言うところの rpm -qa)

dpkg コマンドでわかります。

$ dpkg -l

ページャなどに出力すると読み易いです

$ dpkg -l | pager

インストール済のパッケージに含まれているファイルの一覧を見たい (rpm で言うところの rpm -ql)

$ dpkg -L (パッケージ名)

インストール済のコマンドやファイルがどのパッケージに入ってるか探したい (rpm で言うところの rpm -qf)

$ which (コマンド名)
$ dpkg -S (コマンド名) | grep -w (コマンドのフルパス) 

例: ls の場合

$ which ls
/bin/ls
$ dpkg -S ls | grep -w /bin/ls
fileutils: /bin/ls

で fileutils だとわかる。

また dlocate を使う事でもできます。

# apt-get install dlocate
$ dlocate (コマンド名やファイル名)

必要であれば grep 等を併用する
パッケージをインストールして即 dlocate のデータベースに反映させたい場合や、cron での一日一回のアップデートに反映されていない場合

# update-dlocatedb

をする。

インストールしてないコマンドやファイルがどのパッケージに入ってるか探したい

  • 方法1: auto-apt コマンドをインストールして使う
    # apt-get install auto-apt
    # auto-apt update
    $ auto-apt search (コマンドやファイル名)
    $ auto-apt search (コマンド名) | grep -w (コマンドのフルパスの頭から"/"を取ったもの)

パッケージファイルの中身が見たい (rpm で言うところの rpm -qpl)

$ dpkg -c (パッケージファイル名)

パッケージファイルの中身を取り出したい

アプリやライブラリなどのファイルを取り出したい場合は

$ dpkg -x (パッケージファイル名) (展開するディレクトリ)

postinst や postrm などの制御ファイルを取り出したい場合は

$ dpkg -e (パッケージファイル名) (展開するディレクトリ)

もしくは (binutils が必要)

$ ar x (パッケージファイル名)
$ tar xvfz data.tar.gz

パッケージのバージョンを指定してインストール

# apt-get install (パッケージ名)=(バージョン)

例:

# apt-get install apache=1.3.26-0woody3

もしくは

# apt-get -t (リリースバージョン) (パッケージ名)

例:

# apt-get -t unstable apache

特定のパッケージを自動アップグレードの対象から外したい

# echo (パッケージ名) hold | dpkg --set-selections

# echo jnethack hold | dpkg --set-selections

オススメは pin を使った方法。 /etc/apt/preferences に留めておきたいパッケージ名とバージョンを

Package: (パッケージ名)
Pin: version (バージョン)
Pin-Priority: (プライオリティ)

Package: jnethack
Pin: version 1.1.5-11
Pin-Priority: 1001

のように書いておく。

sarge や sid のパッケージを借りるには

99target 篇

 /etc/apt/apt.conf.d/99target に

APT::Default-Release "stable";

と書く。(デフォルトで sarge を使う場合は testing;sid なら unstable)
 /etc/apt/sources.list には sarge や sid の apt-line も入れておく。

$ sudo apt-get install (パッケージ名)

で woody のパッケージが入る。sarge/sid から借りる場合はそれぞれ

$ sudo apt-get install (パッケージ名)/testing
$ sudo apt-get install (パッケージ名)/unstable

ただし stable な環境などで libc6 のパッケージも依存関係でアップデートされる場合、 安易に (Y) を選ぶと大変なことになるのでよく考えてから。 いつの間にかなんちゃって unstable な環境とかになってしまいます。


preferences 篇

上記の /etc/apt/apt.conf.d/99target を作るかわりに、/etc/apt/preferences へ

Package: *
Pin: release a=testing
Pin-Priority: 105
 
Package: *
Pin: release a=testing-proposed-updates
Pin-Priority: 110

Package: *
Pin: release a=unstable
Pin-Priority: 90

と書く。リリース間は空行で分離する。こちらを用いることの利点は、

  • unofficial なパッケージもバージョンナンバーが大きければちゃんとインストールされる。
  • pin を使って入れた testing または unstable パッケージはそれ以降 testing の最新版が入るようになる。
  • もちろん、特にいじらないパッケージは stable のまま。
  • Pin-Priority の値の意味
    • 0 : インストールしない
    • 1-99 : 指定すればインストールできるが、アップグレードの対象にはならない
    • 100 : 現在インストールされているパッケージの priority
    • 101-989 : 指定してインストールしたものも、アップグレードの対象になる
    • (500) : 現在インストールされてないパッケージの priority
    • (989) : apt-pin の default priority
    • 990 : apt-get の --target-releast option で指定した際に利用される priority
    • 1000以上 : ダウングレードしてでもそのパッケージをインストールさせる

参考
http://debian.dtdns.net/2ch-debian/1033049225/52.html
man 5 apt_preferences

rebuild 篇

sid や sarge のソースパッケージの apt-line (deb-src で始まるやつ )を sources.list に書いて apt-get update しておく。そしてパッケージ生成に必要な、fakeroot、devscripts パッケージを入れておく。 murasaki の sid 版を使いたい場合は、

$ mkdir ~/src/murasaki      ←作業ディレクトリを掘る
$ ^mkdir^cd                 ←そのディレクトリに移動
$ apt-get source murasaki   ←ソースパッケージを取得

これで勝手にソースが展開されるので、展開されたディレクトリに移動する。

$ cd ./murasaki-X.X.X

そしてリビルドを開始する。

$ debuild -rfakeroot -uc -us

何々がねーぞとエラーがでる場合は、apt-get build-dep murasaki してから debuild を実行する。 終ったら 一つ上のディレクトリにパッケージが出来てるので、dpkg -iでインストールする。

どのパッケージをtestingやunstableから借りてるか知りたい

例えば testing を使っているけど一部 sid から借りている場合

$ apt-show-versions | grep unstable

apt-get でインストールできるオフィシャルパッケージのバージョンを知りたい

apt-show-versions を使うと便利です。たとえば stable 環境で apache のバージョンを知りたければ

$ apt-show-versions -p apache
apache/stable uptodate 1.3.26-0woody3

といった感じに出力されます。testing/unstable のバージョンも知りたければ、

$ apt-show-versions -a -p apache
apache  1.3.26-0woody3  install ok installed
apache  1.3.26-0woody3  stable
No proposed-updates version
apache  1.3.26-1.1      testing
apache  1.3.27-0.1      unstable
apache/stable uptodate 1.3.26-0woody3

のように出力されます。

あるパッケージがどのパッケージに依存している/されているのか知りたい

どのパッケージに依存しているのか調べるには

$ apt-cache depends (パッケージ名)

どのパッケージに依存されているのか調べるには

$ apt-cache showpkg (パッケージ名)

dpkg -l でパッケージ名とかバージョンが途中までしか表示されない

環境変数 COLUMNS を大きな値 (200 とか) に設定してみてください。

例:
COLUMNS=200 dpkg -l

alias に登録しておくという手もあります。

alias dpkg='COLUMNS=${COLUMNS:-80} dpkg' 

apt-get update したら "E: Dynamic MMap ran out of room" とエラーが出た

sources.list にたくさん書きすぎです。apt-line を減らすか、/etc/apt/apt.conf に

APT::Cache-Limit "100000000";

などと書いておくといい。

man apt.conf 参照。

apt-get upgradeで400 Bad Requestが返る

おそらくHTTP 1.1を解さないproxyのせいです。debian-user@Orgでの Jason Gunthorpe氏の投稿 を要約すると

  1. 診断くん等を利用して、proxyを利用していることを確認したのち、ISPにゴルァ電。ISPがソフトウェアをアップグレードしてくれるまで続ける。「(ベンダ名)逝ってよし!」と叫ぶのも忘れない。ftpを使うと少しはましな結果になるかもしれない。
  2. acquire::http::pipeline-depth=0を設定する(see "man apt.conf")

の2通りの方法があるようです。

ローカルにあるパッケージを apt-get でインストールしたい

deb を置いたディレクトリで dpkg-scanpackages

$ dpkg-scanpackages ./ /dev/null | gzip -c9 > Packages.gz 

でもいいけど

$ apt-ftparchive packages . | gzip -c9 > Packages.gz
$ apt-ftparchive sources . | gzip -c9 > Sources.gz

の方がムトゥ神推奨。apt-ftparchive は apt-utils パッケージに入っている。
次に sources.list に

deb file:(ディレクトリ) ./
例:
deb file:/usr/src/ ./

を追加して、apt-get update して apt-get install (パッケージ) で完了。

参考: /usr/share/doc/apt/offline.html

apt の GUI フロントエンドはありますか?

synaptic や gnome-apt、kpackage などがあります。

自動で upgrade したいんですけど

cron-apt を使いましょう。
ただしデフォルトではダウンロードのみされるように設定されてます。
/etc/cron-apt/action.d/3-download の upgrade から "-d" オプションを取り除けば upgrade されます。
本当に知らぬ間に自動で upgrade されるので結構危険です。
stable でセキュリティ fix のみするような用途以外にはオススメしません。

apt-get upgradeしたときのパッケージの変更点を知りたい

apt-listchangesを入れましょう。 アップグレードされるパッケージの変更点を表示してくれます。

人気の5件

最新の6件

2021-05-17 2011-10-17 2011-12-07 2011-12-02

統計情報

counter: 7172, today: 1, yesterday: 0