- CentOS6で提供されているkernelのソースコードをMacOSXで確認したい。しかしrpmのため色々とめんどくさい。rpm2cpioコマンドを使えば簡単にファイルを取り出すことが可能となる。
コマンドライン
brew install rpm2cpio
実行結果
[~]$ brew install rpm2cpio
==> Installing rpm2cpio dependency: xz
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/xz-5.0.5.mavericks.bottle.3.tar.gz
######################################################################## 100.0%
==> Pouring xz-5.0.5.mavericks.bottle.3.tar.gz
? /usr/local/Cellar/xz/5.0.5: 58 files, 1.5M
==> Installing rpm2cpio
==> Downloading http://svnweb.freebsd.org/ports/head/archivers/rpm2cpio/files/rpm2cpio?revision=259745&view=co
######################################################################## 100.0%
? /usr/local/Cellar/rpm2cpio/1.3: 2 files, 8.0K, built in 2 seconds
[~]$
実行環境/OSのバージョン
[~]$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.9.3
BuildVersion: 13D65
[~]$
rpmからファイルを取り出す
rpm2cpio foobar.rpm | cpio -id
実行結果
- rpmファイルをダウンロード
[centos6]$ wget http://ftp.riken.jp/Linux/centos/6.5/os/x86_64/Packages/kernel-devel-2.6.32-431.el6.x86_64.rpm
--2014-07-26 19:47:25-- http://ftp.riken.jp/Linux/centos/6.5/os/x86_64/Packages/kernel-devel-2.6.32-431.el6.x86_64.rpm
Resolving ftp.riken.jp... 134.160.38.1
Connecting to ftp.riken.jp|134.160.38.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9167492 (8.7M) [text/plain]
Saving to: 'kernel-devel-2.6.32-431.el6.x86_64.rpm'
100%[=================================================================================================================================================================================>] 9,167,492 711KB/s in 10s
2014-07-26 19:47:37 (865 KB/s) - 'kernel-devel-2.6.32-431.el6.x86_64.rpm' saved [9167492/9167492]
[centos6]$
- rpmファイルをからファイルを取り出す
[centos6]$ rpm2cpio.pl kernel-devel-2.6.32-431.el6.x86_64.rpm | cpio -id
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter/xt_connmark.h: File on disk is not older; skipping.
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter/xt_dscp.h: File on disk is not older; skipping.
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter/xt_mark.h: File on disk is not older; skipping.
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter/xt_rateest.h: File on disk is not older; skipping.
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter/xt_tcpmss.h: File on disk is not older; skipping.
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter_ipv4/ipt_ecn.h: File on disk is not older; skipping.
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter_ipv4/ipt_ttl.h: File on disk is not older; skipping.
./usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/netfilter_ipv6/ip6t_hl.h: File on disk is not older; skipping.
53295 blocks