Debianパッケージ関連の操作の覚書。
公式パッケージ検索
- Debian -- パッケージ
- 最新ディストリビューションのパッケージの情報を探したいとき
- Debian -- Debian パッケージ検索
- 古いディストリビューションのパッケージの情報を探したいとき
パッケージのインストール先
apt-get
/aptitude
でインストールしたパッケージのインストール先のパスは
dpkg -L <package name>
を実行すると出てくる。
コマンドが含まれるパッケージを調べる
あのコマンドが含まれるDebianパッケージが知りたい、というときに調べる方法。
dpkg -S <path to the binary file>
コマンドを実行する。
mand dpkgより、-S
についてオプションの説明抜粋。
-S, --search filename-search-pattern...
Search for a filename from installed packages.
Example
Q: dpkg-buildpackageコマンドは、どのパッケージに含まれる?
$ type dpkg-buildpackage
dpkg-buildpackage is /usr/bin/dpkg-buildpackage
$ dpkg -S /usr/bin/dpkg-buildpackage
dpkg-dev: /usr/bin/dpkg-buildpackage
A: dpkg-buildpackageコマンドはdpkg-devパッケージに含まれる。
パッケージ取得
リポジトリ設定
apt-get
/aptitude
用の初期設定。
Debianバージョン毎の/etc/apt/sources.list
への記載テンプレート。
記載後にapg-get update
を実行する。
参考
debian 8 (jessie)
deb http://ftp.jp.debian.org/debian jessie main contrib non-fre
deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://ftp.jp.debian.org/debian jessie main contrib non-free
debian 7 (wheezy)
deb http://ftp.jp.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ wheezy main contrib non-free
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free
deb http://ftp.jp.debian.org/debian/ wheezy-updates main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ wheezy-updates main contrib non-free
debian 6 (squeeze)
deb http://ftp.jp.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ squeeze main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free
deb-src http://security.debian.org/ squeeze/updates main contrib non-free
deb http://ftp.jp.debian.org/debian/ squeeze-updates main contrib non-free
deb-src http://ftp.jp.debian.org/debian/ squeeze-updates main contrib non-free
debian 5 (lenny)
deb http://archive.debian.org/debian/ lenny main contrib non-free
deb-src http://archive.debian.org/debian/ lenny main contrib non-free
ソースパッケージの取得
apt-get source <package name>
を実行する。
$ apt-get source dpkg
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
注意: 'dpkg' パッケージは以下の場所の 'Git' バージョン制御システムで保守されています:
git://anonscm.debian.org/dpkg/dpkg.git
4,413 kB のソースアーカイブを取得する必要があります。
取得:1 http://security.debian.org/ jessie/updates/main dpkg 1.17.26 (dsc) [2,018 B]
取得:2 http://security.debian.org/ jessie/updates/main dpkg 1.17.26 (tar) [4,411 kB]
4,413 kB を 10秒 で取得しました (406 kB/s)
dpkg-source: info: extracting dpkg in dpkg-1.17.26
dpkg-source: info: unpacking dpkg_1.17.26.tar.xz
$ ls
dpkg-1.17.26 dpkg_1.17.26.dsc dpkg_1.17.26.tar.xz
$
トラブルシューティング
keyblock resource
現象
apt-get
実行時に
gpgv: keyblock resource '/home/<user name>/.gnupg/trustedkeys.gpg': ファイルのオープン・エラー
というメッセージが表示される。
$ apt-get source dpkg
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
注意: 'dpkg' パッケージは以下の場所の 'Git' バージョン制御システムで保守されています:
git://anonscm.debian.org/dpkg/dpkg.git
4,413 kB のソースアーカイブを取得する必要があります。
取得:1 http://security.debian.org/ jessie/updates/main dpkg 1.17.26 (dsc) [2,018 B]
取得:2 http://security.debian.org/ jessie/updates/main dpkg 1.17.26 (tar) [4,411 kB]
4,413 kB を 12秒 で取得しました (355 kB/s)
gpgv: keyblock resource `/home/toor/.gnupg/trustedkeys.gpg': ファイルのオープン・エラー
gpgv: 2015年11月26日 19時00分54秒 JSTにRSA鍵ID A4AE57A3で施された署名
gpgv: 署名を検査できません: 公開鍵が見つかりません
dpkg-source: warning: failed to verify signature on ./dpkg_1.17.26.dsc
dpkg-source: info: extracting dpkg in dpkg-1.17.26
dpkg-source: info: unpacking dpkg_1.17.26.tar.xz
$
対策
debian-keyring
パッケージをインストールする。
$ sudo aptitude install debian-keyring
以下の新規パッケージがインストールされます:
debian-keyring
更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
52.4 M バイトのアーカイブを取得する必要があります。展開後に 58.0 M バイトのディスク領域が新たに消費されます。
取得: 1 http://ftp.jp.debian.org/debian/ jessie/main debian-keyring all 2015.04.10 [52.4 MB]
73% [1 debian-keyring 38.5 MB/52.4 MB 73%] 99.2 kB/s 2分 20秒
52.4 MB を 10分 2秒 秒で取得しました (86.9 kB/s)
以前に未選択のパッケージ debian-keyring を選択しています。
(データベースを読み込んでいます ... 現在 39128 個のファイルとディレクトリがインストールされています。)
.../debian-keyring_2015.04.10_all.deb を展開する準備をしています ...
debian-keyring (2015.04.10) を展開しています...
debian-keyring (2015.04.10) を設定しています ...
$
インストール済みパッケージ一覧表示
dpkg -l
パッケージの依存関係を調べる。
apt-cache depends <package name>
を実行する。
以下、実行例
$ apt-cache depends auditd
auditd
依存: lsb-base
|依存: mawk
依存: gawk
依存: init-system-helpers
依存: libaudit1
依存: libauparse0
依存: libc6
依存: libgssapi-krb5-2
依存: libkrb5-3
依存: libwrap0
提案: audispd-plugins
$
apt-cache showpkg auditd
でもわかる。
以下、実行例
$ apt-cache showpkg auditd
Package: auditd
Versions:
1:1.7.18-1.1 (/var/lib/apt/lists/ftp.jp.debian.org_debian_dists_unstable_main_binary-amd64_Packages) (/var/lib/dpkg/status)
Description Language:
File: /var/lib/apt/lists/ftp.jp.debian.org_debian_dists_unstable_main_binary-amd64_Packages
MD5: 77aaff86394a1a8da0659fa99413f455
Description Language: en
File: /var/lib/apt/lists/ftp.jp.debian.org_debian_dists_unstable_main_i18n_Translation-en
MD5: 77aaff86394a1a8da0659fa99413f455
Reverse Depends:
libvirt-bin,auditd
audispd-plugins,auditd
Dependencies:
1:1.7.18-1.1 - lsb-base (2 3.0-6) libpam-runtime (2 1.0.1-6) libaudit0 (2 1.7.13) libc6 (2 2.7) libgssapi-krb5-2 (2 1.10+dfsg~) libkrb5-3 (2 1.6.dfsg.2) libwrap0 (2 7.6-4~) audispd-plugins (0 (null))
Provides:
1:1.7.18-1.1 -
Reverse Provides:
resolvconfパッケージ
最近は名前解決設定/etc/resolv.conf
は直接書き込まず、
resolvconfパッケージにやってもらうのがベストプラクティスらしい。
aptitude install resolvconf
allow-hotplug eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
network xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
dns-nameservers AAA.AAA.AAA.AAA BBB.BBB.BBB.BBB
dns-search hoge.local
と書いて networking を再起動するとresolvconfが /etc/resolv.conf
を自動的に書き換える。
$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver AAA.AAA.AAA.AAA
nameserver BBB.BBB.BBB.BBB
search hoge.local
最初の注意書きも自動出力される。
デバッグシンボル付パッケージ作成
DebugPackage - Debian Wiki
http://wiki.debian.org/DebugPackage
ビルド時にデバッグシンボル情報を残す設定
export DEB_BUILD_OPTIONS="noopt nostrip"
noopt # 最適化しない
nostrip # デバッグシンボルを消さない
※指定しても debian/rules で無視していると意味がない
debian/control
ソースパッケージの下記に記述を追加
Package: auditd
Section: admin
Architecture: any
Depends: ${shlibs:Depends}, lsb-base (>= 3.0-6)
Description: User space tools for security auditing ---
Package: auditd-dbg ★追加
Architecture: any
Section: debug
Priority: extra
Depends: auditd (= ${binary:Version}), ${misc:Depends}
Description: debugging symbols for auditd
configureオプション: debian/rules
configure: configure-stamp
configure-stamp: $(QUILT_STAMPFN)
dh_testdir
-test -r /usr/share/misc/config.sub && \
cp -f /usr/share/misc/config.sub config.sub && \
cp -f /usr/share/misc/config.sub system-config-audit/admin/config.sub
-test -r /usr/share/misc/config.guess && \
cp -f /usr/share/misc/config.guess config.guess && \
cp -f /usr/share/misc/config.guess system-config-audit/admin/config.guess
autoreconf -fv --install
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--sbindir=/sbin \
--libdir='$${exec_prefix}'/lib \
--libexecdir=/lib \
--mandir=/usr/share/man \
--enable-shared=audit \
--with-apparmor \
--with-prelude \
--with-debug \ ★追加
$(confflags)
touch $@
gdbに入力
GDBデバッギング覚え書き - しばそんノート
http://d.hatena.ne.jp/shibason/20090624/1245840061