如何从RPM包中提取单个文件
时间:2019-08-20 17:58:10 来源:igfitidea点击:
我们可以使用rpm2cpio和cpio从RPM包中提取单个文件。
列出RPM包中的文件
rpm2cpio package-name.rpm |cpio -t
从RPM包中提取单个文件
rpm2cpio package-name.rpm |cpio -ivdm filename1
从RPM包中提取多个选中的文件
rpm2cpio package-name.rpm |cpio -ivdm filename1 filename2 filename3 filename-N
示例
[root@localhost ~]# mkdir extract [root@localhost ~]# cp -p epel-release-6-8.noarch.rpm extract/ [root@localhost ~]# cd extract/ [root@localhost extract]# ls epel-release-6-8.noarch.rpm [root@localhost extract]# [root@localhost extract]# [root@localhost extract]# rpm2cpio epel-release-6-8.noarch.rpm |cpio -t ./etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 ./etc/rpm/macros.ghc-srpm ./etc/yum.repos.d/epel-testing.repo ./etc/yum.repos.d/epel.repo ./usr/share/doc/epel-release-6 ./usr/share/doc/epel-release-6/GPL 46 blocks [root@localhost extract]# [root@localhost extract]# [root@localhost extract]# rpm2cpio epel-release-6-8.noarch.rpm |cpio -ivdm ./etc/rpm/macros.ghc-srpm ./etc/rpm/macros.ghc-srpm 46 blocks [root@localhost extract]# [root@localhost extract]# ls -l total 20 -rw-r--r--. 1 root root 14540 Nov 5 2012 epel-release-6-8.noarch.rpm drwxr-xr-x. 3 root root 4096 Mar 26 17:48 etc [root@localhost extract]# ls etc/rpm/macros.ghc-srpm etc/rpm/macros.ghc-srpm [root@localhost extract]# rm -fr e epel-release-6-8.noarch.rpm etc/ [root@localhost extract]# rm -fr etc/ [root@localhost extract]# [root@localhost extract]# rpm2cpio epel-release-6-8.noarch.rpm |cpio -t ./etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 ./etc/rpm/macros.ghc-srpm ./etc/yum.repos.d/epel-testing.repo ./etc/yum.repos.d/epel.repo ./usr/share/doc/epel-release-6 ./usr/share/doc/epel-release-6/GPL 46 blocks [root@localhost extract]# rpm2cpio epel-release-6-8.noarch.rpm |cpio -ivdm ./etc/yum.repos.d/epel.repo ./usr/share/doc/epel-release-6 ./etc/yum.repos.d/epel.repo ./usr/share/doc/epel-release-6 46 blocks [root@localhost extract]# ls -l total 24 -rw-r--r--. 1 root root 14540 Nov 5 2012 epel-release-6-8.noarch.rpm drwxr-xr-x. 3 root root 4096 Mar 26 17:49 etc drwxr-xr-x. 3 root root 4096 Mar 26 17:49 usr [root@localhost extract]# ls etc/yum.repos.d/epel.repo etc/yum.repos.d/epel.repo [root@localhost extract]# ls usr/share/doc/epel-release-6/ [root@localhost extract]# ls -ld usr/share/doc/epel-release-6/ drwxr-xr-x. 2 root root 4096 Nov 5 2012 usr/share/doc/epel-release-6/ [root@localhost extract]# [root@localhost extract]#