免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 6287 | 回复: 10
打印 上一主题 下一主题

如何提取rpm包里的文件到指定位置? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-10 00:08 |只看该作者 |倒序浏览
5可用积分
如何提取rpm包里的文件到指定位置?谢谢!

最佳答案

论坛徽章:
0
2 [报告]
发表于 2007-09-10 00:08 |只看该作者

  1. [bob@mail ~]$ mkdir tempdir
  2. [bob@mail ~]$ cd tempdir/
  3. [bob@mail tempdir]$ rpm2cpio ../zebra-0.93b-4.9.i386.rpm |cpio -id
  4. 6750 blocks
  5. [bob@mail tempdir]$ ll
  6. total 12
  7. drwx------  6 bob bob 4096 Sep 11 23:50 etc
  8. drwx------  5 bob bob 4096 Sep 11 23:50 usr
  9. drwx------  3 bob bob 4096 Sep 11 23:50 var
  10. [bob@mail tempdir]$
复制代码

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
3 [报告]
发表于 2007-09-10 00:22 |只看该作者
以前有个命令叫rpm2cpio, 然后再用cpio 就解开rpm了.

论坛徽章:
0
4 [报告]
发表于 2007-09-10 13:39 |只看该作者
试一试....

论坛徽章:
0
5 [报告]
发表于 2007-09-10 22:48 |只看该作者
原帖由 q1208c 于 2007-9-10 00:22 发表
以前有个命令叫rpm2cpio, 然后再用cpio 就解开rpm了.

知道这个命令,但怎么把指定文件提取到指定位置,而不是默认的安装位置?

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
6 [报告]
发表于 2007-09-10 23:12 |只看该作者
man rpm
--prefix NEWPATH

论坛徽章:
0
7 [报告]
发表于 2007-09-11 00:12 |只看该作者
原帖由 寂寞烈火 于 2007-9-10 23:12 发表
man rpm
--prefix NEWPATH

谢谢!

--prefix NEWPATH
              For relocatable binary packages, translate all file  paths  that
              start  with  the  installation  prefix in the package relocation
              hint(s) to NEWPATH.
[tyc@TYC StarDict]$ rpm2cpio stardict-gaojihanyudacidian-2.4.2-1.noarch.rpm | cpio -t
./usr/share/stardict/dic
./usr/share/stardict/dic/stardict-gaojihanyudacidian-2.4.2
./usr/share/stardict/dic/stardict-gaojihanyudacidian-2.4.2/gaojihanyudacidian.dict.dz
./usr/share/stardict/dic/stardict-gaojihanyudacidian-2.4.2/gaojihanyudacidian.idx
./usr/share/stardict/dic/stardict-gaojihanyudacidian-2.4.2/gaojihanyudacidian.ifo
12995 blocks
[tyc@TYC StarDict]$ rpm -i --prefix /home/tyc/tmp stardict-gaojihanyudacidian-2.4.2-1.noarch.rpm
error: package stardict-gaojihanyudacidian is not relocatable

有没有其它方法?

论坛徽章:
0
8 [报告]
发表于 2007-09-11 22:58 |只看该作者
再顶顶

论坛徽章:
0
9 [报告]
发表于 2007-09-11 23:51 |只看该作者

  1. [bob@mail tempdir]$ rpm -qlp ../zebra-0.93b-4.9.i386.rpm
  2. warning: ../zebra-0.93b-4.9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
  3. /etc/logrotate.d/zebra
  4. /etc/pam.d/zebra
  5. /etc/rc.d/init.d/bgpd
  6. /etc/rc.d/init.d/ospf6d
  7. /etc/rc.d/init.d/ospfd
  8. /etc/rc.d/init.d/ripd
  9. /etc/rc.d/init.d/ripngd
  10. /etc/rc.d/init.d/zebra
  11. /etc/zebra
  12. /usr/bin/vtysh
  13. /usr/sbin/bgpd
  14. /usr/sbin/ospf6d
  15. /usr/sbin/ospfd
  16. /usr/sbin/ripd
  17. /usr/sbin/ripngd
  18. /usr/sbin/zebra
  19. /usr/share/doc/zebra-0.93b
  20. /usr/share/doc/zebra-0.93b/AUTHORS
  21. /usr/share/doc/zebra-0.93b/COPYING
  22. /usr/share/doc/zebra-0.93b/ChangeLog
  23. /usr/share/doc/zebra-0.93b/INSTALL
  24. /usr/share/doc/zebra-0.93b/NEWS
  25. /usr/share/doc/zebra-0.93b/README
  26. /usr/share/doc/zebra-0.93b/REPORTING-BUGS
  27. /usr/share/doc/zebra-0.93b/SERVICES
  28. /usr/share/doc/zebra-0.93b/TODO
  29. /usr/share/doc/zebra-0.93b/bgpd.conf.sample
  30. /usr/share/doc/zebra-0.93b/bgpd.conf.sample2
  31. /usr/share/doc/zebra-0.93b/ospf6d.conf.sample
  32. /usr/share/doc/zebra-0.93b/ospfd.conf.sample
  33. /usr/share/doc/zebra-0.93b/ripd.conf.sample
  34. /usr/share/doc/zebra-0.93b/ripngd.conf.sample
  35. /usr/share/doc/zebra-0.93b/tools
  36. /usr/share/doc/zebra-0.93b/tools/mrlg.cgi
  37. /usr/share/doc/zebra-0.93b/tools/rrcheck.pl
  38. /usr/share/doc/zebra-0.93b/tools/rrlookup.pl
  39. /usr/share/doc/zebra-0.93b/tools/zc.pl
  40. /usr/share/doc/zebra-0.93b/tools/zebra.el
  41. /usr/share/doc/zebra-0.93b/vtysh.conf.sample
  42. /usr/share/doc/zebra-0.93b/zebra.conf.sample
  43. /usr/share/doc/zebra-0.93b/zebra.html
  44. /usr/share/info/zebra.info-1.gz
  45. /usr/share/info/zebra.info-2.gz
  46. /usr/share/info/zebra.info-3.gz
  47. /usr/share/info/zebra.info-4.gz
  48. /usr/share/info/zebra.info.gz
  49. /usr/share/man/man1/vtysh.1.gz
  50. /usr/share/man/man8/bgpd.8.gz
  51. /usr/share/man/man8/ospf6d.8.gz
  52. /usr/share/man/man8/ospfd.8.gz
  53. /usr/share/man/man8/ripd.8.gz
  54. /usr/share/man/man8/ripngd.8.gz
  55. /usr/share/man/man8/zebra.8.gz
  56. /var/log/zebra
  57. [bob@mail tempdir]$
复制代码

论坛徽章:
0
10 [报告]
发表于 2007-09-12 00:25 |只看该作者
原帖由 ailms 于 2007-9-11 23:50 发表

$ mkdir tempdir
$ cd tempdir/
$ rpm2cpio ../zebra-0.93b-4.9.i386.rpm |cpio -id
6750 blocks
$ ll
total 12
drwx------  6 bob bob 4096 Sep 11 23:50 etc
drwx------  5 bob bob 4096 Sep 11 23: ...

谢谢!
$ info cpio
....
Extracting an archive requires a bit more thought because cpio will
not create directories by default.  Another characteristic, is it will
not overwrite existing files unless you tell it to.

     % cpio -iv < directory.cpio

This will retrieve the files archived in the file directory.cpio and
place them in the present directory.  The `-i' option extracts the
archive and the `-v' shows the file names as they are extracted.  If
you are dealing with an archived directory tree, you need to use the
`-d' option to create directories as necessary, something like:

     % cpio -idv < tree.cpio

   This will take the contents of the archive tree.cpio and extract it
to the current directory
. If you try to extract the files on top of
files of the same name that already exist (and have the same or later
modification time) cpio will not extract the file unless told to do so
by the -u option.
...

那天看得文档不仔细,没有发现,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP