#navi_header|技術| Debian, Ubuntu系のdpkgとaptコマンドのメモ。Ubuntu10.04 LTSにて確認。 参考: - Chapter 3. Package Management -- https://help.ubuntu.com/10.04/serverguide/C/package-management.html - Ubuntu Manpage: dpkg - package manager for Debian -- http://manpages.ubuntu.com/manpages/lucid/en/man1/dpkg.1.html - Ubuntu Manpage: apt-get - APT package handling utility -- command-line interface -- http://manpages.ubuntu.com/manpages/lucid/en/man8/apt-get.8.html - Ubuntu Manpage: apt-cache - APT package handling utility -- cache manipulator -- http://manpages.ubuntu.com/manpages/lucid/en/man8/apt-cache.8.html - APT HOWTO (Obsolete Documentation) -- http://www.debian.org/doc/manuals/apt-howto/ - apt-cache・apt-file・apt-get・gdebiの使い方 - Ubuntu Japanese Wiki -- https://wiki.ubuntulinux.jp/UbuntuTips/Application/PackageManagementSystem/Apt * dpkgコマンド ・インストール済みのパッケージ一覧。 $ dpkg -l ・あるファイルを含んでいるパッケージはどれか。 $ which python /usr/bin/python $ dpkg -S /usr/bin/python python-minimal: /usr/bin/python フルパスでなくても良い。 $ dpkg -S stdio.h libc6-dev: /usr/include/bits/stdio.h libstdc++6-4.4-dev: /usr/include/c++/4.4/tr1/stdio.h libc6-dev: /usr/include/stdio.h perl: /usr/lib/perl/5.10.1/CORE/nostdio.h ・そのパッケージの情報を表示する。 $ dpkg -s python-minimal Package: python-minimal Essential: yes Status: install ok installed ... ・そのパッケージが提供しているファイルの一覧を表示する。 $ dpkg -L python-minimal /. /usr /usr/bin /usr/bin/pycompile /usr/bin/pyclean ... ・".deb"ファイルの情報を表示する。 $ cd /var/cache/apt/archives $ dpkg -I php5-cli_5.3.2-1ubuntu4.9_i386.deb # 大文字の"I" new debian package, version 2.0. size 2817008 bytes: control archive= 1530 bytes. 1626 bytes, 26 lines control 181 bytes, 3 lines md5sums 307 bytes, 19 lines * postinst #!/bin/sh 166 bytes, 18 lines * postrm #!/bin/sh 133 bytes, 11 lines * prerm #!/bin/sh Package: php5-cli Source: php5 Version: 5.3.2-1ubuntu4.9 Architecture: i386 ... 小文字の"-l"(エル)だとインストールしたパッケージの一覧になってしまうので注意。 ・".deb"ファイルの提供するファイル一覧を表示する。 #pre||> $ dpkg -c php5-cli_5.3.2-1ubuntu4.9_i386.deb drwxr-xr-x root/root 0 2011-05-02 18:00 ./ drwxr-xr-x root/root 0 2011-05-02 17:58 ./etc/ drwxr-xr-x root/root 0 2011-05-02 17:58 ./etc/php5/ drwxr-xr-x root/root 0 2011-05-02 18:00 ./etc/php5/cli/ drwxr-xr-x root/root 0 2011-05-02 17:59 ./usr/ drwxr-xr-x root/root 0 2011-05-02 18:00 ./usr/bin/ -rwxr-xr-x root/root 7467156 2011-05-02 18:00 ./usr/bin/php5 drwxr-xr-x root/root 0 2011-05-02 17:59 ./usr/share/ drwxr-xr-x root/root 0 2011-05-02 17:58 ./usr/share/man/ drwxr-xr-x root/root 0 2011-05-02 18:00 ./usr/share/man/man1/ -rw-r--r-- root/root 3229 2011-05-02 17:59 ./usr/share/man/man1/php5.1.gz drwxr-xr-x root/root 0 2011-05-02 17:59 ./usr/share/lintian/ drwxr-xr-x root/root 0 2011-05-02 17:59 ./usr/share/lintian/overrides/ -rw-r--r-- root/root 318 2011-05-02 17:59 ./usr/share/lintian/overrides/php5-cli drwxr-xr-x root/root 0 2011-05-02 18:00 ./usr/share/doc/ drwxr-xr-x root/root 0 2011-05-02 17:59 ./usr/lib/ drwxr-xr-x root/root 0 2011-05-02 17:59 ./usr/lib/php5/ drwxr-xr-x root/root 0 2011-05-02 17:59 ./usr/lib/php5/20090626+lfs/ lrwxrwxrwx root/root 0 2011-05-02 18:00 ./etc/php5/cli/conf.d -> ../conf.d lrwxrwxrwx root/root 0 2011-05-02 18:00 ./usr/share/doc/php5-cli -> php5-common ||< ・設定ファイル、ディレクトリなど /etc/dpkg/dpkg.cfg : 設定ファイル /var/lib/dpkg/available : 利用可能なパッケージ /var/log/dpkg.log : ログファイル * apt-cache, apt-getコマンド ・利用可能なパッケージを探す。 $ apt-cache search ^php5 dwoo - PHP5 template engine libgv-php5 - Php5 bindings for graphviz php5-adodb - Extension optimising the ADOdb database abstraction library php5-auth-pam - A PHP5 extension for PAM authentication ... ・利用可能なパッケージの情報を取得する。 #pre||> $ apt-cache show php-pear Package: php-pear Priority: optional Section: php Installed-Size: 2600 Maintainer: Ubuntu Developers Original-Maintainer: Debian PHP Maintainers Architecture: all Source: php5 Version: 5.3.2-1ubuntu4.9 ... ||< ・パッケージの「仮」インストールを行なってみる("-s" or "--dry-run"オプション)。 #pre||> $ sudo apt-get install --dry-run php5-cli Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: php5-common Suggested packages: php-pear php5-suhosin The following NEW packages will be installed: php5-cli php5-common 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Inst php5-common (5.3.2-1ubuntu4.9 Ubuntu:10.04/lucid-updates) Inst php5-cli (5.3.2-1ubuntu4.9 Ubuntu:10.04/lucid-updates) Conf php5-common (5.3.2-1ubuntu4.9 Ubuntu:10.04/lucid-updates) Conf php5-cli (5.3.2-1ubuntu4.9 Ubuntu:10.04/lucid-updates) ||< ・パッケージをダウンロードするだけで、インストールはしない("-d", "--download-only")。 #pre||> $ sudo apt-get install -d php5-cli Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: php5-common Suggested packages: php-pear php5-suhosin The following NEW packages will be installed: php5-cli php5-common 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 3,363kB of archives. After this operation, 8,610kB of additional disk space will be used. Do you want to continue [Y/n]? Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main php5-common 5.3.2-1ubuntu4.9 [546kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main php5-cli 5.3.2-1ubuntu4.9 [2,817kB] Fetched 3,363kB in 7s (429kB/s) Download complete and in download only mode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- インストールまでは実行していない。 ||< デフォルトでは"/var/cache/apt/archives/"に保存される。 ・(まだインストールしていないパッケージも含めて)あるファイルを含むパッケージを探す。 事前に"apt-file"パッケージをインストールしておくこと。 #pre||> $ dpkg -l | grep -i ruby | wc -l 0 $ apt-file search /usr/bin/ruby libglade2-ruby1.8: /usr/bin/ruby-glade-create-template libruby1.8-dbg: /usr/lib/debug/usr/bin/ruby1.8 libruby1.9: /usr/lib/debug/usr/bin/ruby1.9 libruby1.9.1-dbg: /usr/lib/debug/usr/bin/ruby1.9.1 ruby: /usr/bin/ruby ruby-prof: /usr/bin/ruby-prof ruby1.8: /usr/bin/ruby1.8 ruby1.9: /usr/bin/ruby1.9 ruby1.9.1: /usr/bin/ruby1.9.1 sloccount: /usr/bin/ruby_count ||< ・ソースコードのURIを表示する。 #pre||> $ apt-get source --print-uris libpng Reading package lists... Done Building dependency tree Reading state information... Done Need to get 693kB of source archives. 'http://us.archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.42-1ubuntu2.2.dsc' \ libpng_1.2.42-1ubuntu2.2.dsc 1939 MD5Sum:77bdd4a86079d816f208d23e6a56d8e8 'http://us.archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.42.orig.tar.bz2' \ libpng_1.2.42.orig.tar.bz2 670811 MD5Sum:9a5cbe9798927fdf528f3186a8840ebe 'http://us.archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.42-1ubuntu2.2.debian.tar.bz2' \ libpng_1.2.42-1ubuntu2.2.debian.tar.bz2 20532 MD5Sum:f0eb3be297e03dd258d73c36bb3dff8d ||< ・ソースコードをカレントディレクトリにダウンロードする。 #pre||> $ apt-get source --download-only libpng Reading package lists... Done Building dependency tree Reading state information... Done Need to get 693kB of source archives. Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main libpng 1.2.42-1ubuntu2.2 (dsc) [1,939B] Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main libpng 1.2.42-1ubuntu2.2 (tar) [671kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main libpng 1.2.42-1ubuntu2.2 (diff) [20.5kB] Fetched 693kB in 5s (125kB/s) Download complete and in download only mode ||< ・設定ファイル・ディレクトリなど /etc/apt/sources.list : リポジトリのリスト /etc/apt/apt.conf : 設定ファイル /var/cache/apt/archives/ : ダウンロードしたパッケージの保存先 * apt-fileコマンド $ apt-file search xxxxx → ファイル名をもとに、そのファイルを提供しているパッケージを検索してくれる。 #navi_footer|技術|