試験運用中なLinux備忘録・旧記事

はてなダイアリーで公開していた2007年5月-2015年3月の記事を保存しています。

RPM/Debパッケージの中身にアクセスする

RPMDebパッケージはシステムへインストールするパッケージファイルだが、その中にあるファイルの一覧を見たり個別のファイルを取り出したりしたいこともある。

RPMパッケージ

GUIで取り出す場合

GNOMEFile RollerRPMファイルを開くと、通常の書庫ファイルと同様に中のファイルやディレクトリを一覧し、取り出すこともできる。

コマンドで取り出す場合

色々なところに書かれているが、RPMパッケージはrpm2cpiocpioにより、現在の作業ディレクトリに全てのファイルを展開することができる。

(詳細出力なし)
$ rpm2cpio [.rpmファイルの場所] | cpio -id
(詳細出力あり)
$ rpm2cpio [.rpmファイルの場所] | cpio -idv
コマンドで中身の一覧が見たいだけの場合

Mandriva Linux 2009.0の時点ではlessコマンド*1で.rpmファイルを開いたときに次のような一覧が表示される。RPMをパッケージ管理システムとして使用していないディストリでは、上の各種情報を見るためには別途「rpm」パッケージが必要?

$ less /var/cache/urpmi/rpms/bind-utils-9.5.0-6.1mdv2009.0.x86_64.rpm 
==> use RPM_file:contained_file to view a file in the RPM
Name        : bind-utils                   Relocations: (not relocatable)
Version     : 9.5.0                             Vendor: Mandriva
Release     : 6.1mdv2009.0                  Build Date: 2009年01月10日 02時07分38秒
Install Date: (not installed)               Build Host: titan.mandriva.com
Group       : Networking/Other              Source RPM: bind-9.5.0-6.1mdv2009.0.src.rpm
Size        : 7546051                          License: Distributable
Signature   : DSA/SHA1, 2009年01月10日 02時29分18秒, Key ID 9aa8d0d022458a98
Packager    : Mandriva Linux Security Team <security AT mandriva DOT com>
URL         : http://www.isc.org/products/BIND/
Summary     : Utilities for querying DNS name servers
Description :
Bind-utils contains a collection of utilities for querying DNS (Domain
(中略)
servers.
================================= Content ======================================
-rwxr-xr-x   1 root     root      1526664 Jan 10 02:06 ./usr/bin/dig
-rwxr-xr-x   1 root     root      1481928 Jan 10 02:06 ./usr/bin/host
-rwxr-xr-x   1 root     root        12248 Jan 10 02:06 ./usr/bin/ldap2zone
-rwxr-xr-x   1 root     root      1514480 Jan 10 02:06 ./usr/bin/nslookup
-rwxr-xr-x   1 root     root      1477632 Jan 10 02:06 ./usr/bin/nsupdate
(以下略)

Debian(.deb)パッケージ

GUIで取り出す場合

File Rollerで開くことはできるが

データそのものはdata.tar.gzに固められているため、「展開」からファイルに書き出してから再びこれを同アプリケーションから開くことによりアクセスできるようになる。

コマンドで取り出す場合

以前「Gentoo LinuxでDebian系ツールを使用」でも書いている。

$ dpkg -X [.debファイルの場所] [展開先]
コマンドで中身の一覧が見たいだけの場合

やはりlessが楽だが、Mandriva Linux 2009.0では上の各種情報はdpkgのパッケージをインストールしないと表示されなかった。

$ less AdobeReader_jpn-8.1.3-1.i386.deb
==> use Deb_file:contained_file to view a file in the Deb
 新形式 debian パッケージ、バージョン 2.0。
 サイズ 60463458 バイト: コントロールアーカイブ = 2779 バイト。
     439 バイト,    10 行      control              
      22 バイト,     1 行      copyright            
    7421 バイト,   175 行   *  postinst             #!/bin/sh
    5125 バイト,   172 行   *  prerm                #!/bin/sh
 Package: adobereader-jpn
 Version: 8.1.3
 Section: publishing
 Priority: extra
 Architecture: i386
 Source: adobereader-jpn
 Depends: libgtk2.0-0 (>= 2.4)
 Maintainer: Adobe Systems, Incorporated
 Description: Adobe Reader allows you to view navigate and print PDF files. This version adds advanced forms support (save), better integration with Adobe Acrobat workflows, customizable toolbars and better overall performance.
 Installed-Size: 138636
drwxr-xr-x acrorel/named     0 2008-10-08 13:55 ./
drwxr-xr-x acrorel/named     0 2008-10-08 13:55 ./opt/
drwxr-xr-x acrorel/named     0 2008-10-08 13:51 ./opt/Adobe/
drwxr-xr-x acrorel/named     0 2008-10-08 13:51 ./opt/Adobe/Help/
drwxr-xr-x acrorel/named     0 2008-10-08 13:50 ./opt/Adobe/Help/en_US/
drwxr-xr-x acrorel/named     0 2008-10-08 13:50 ./opt/Adobe/Help/en_US/Adobe Reader/
drwxr-xr-x acrorel/named     0 2008-10-08 13:51 ./opt/Adobe/Help/en_US/Adobe Reader/8.0/
-r--r--r-- acrorel/named  1583 2008-10-08 13:50 ./opt/Adobe/Help/en_US/Adobe Reader/8.0/ACROBATPROFESSIONAL_8.0_HOMEPAGE.html
-r--r--r-- acrorel/named  4166 2008-10-08 13:50 ./opt/Adobe/Help/en_US/Adobe Reader/8.0/Forms1.html
(以下略)

関連記事:

使用したバージョン:

  • File Roller 2.24.0
  • less 418

*1:後述のDebianパッケージでも同様だが、lessで開くことができるのはlesspipe.shというスクリプトのおかげのようだ