未安装RPM包内文件树及脚本获取

本文介绍了如何在RPM包未安装的情况下,获取其文件树信息和安装脚本。RPM包由标识区、签名、头部和负载组成,其中头部包含版权信息、版本号等,并可能包含预安装脚本。通过`rpm2cpio`和`cpio`命令在Linux中解压获取文件,使用`rpm`命令获取安装脚本。在Windows环境下,可以使用7-Zip等工具解压查看。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

未安装RPM包内文件树及脚本获取

RPMRedHatPackageManager)软件包管理工具是某些Linux系统中的打包以及安装卸载软件工具,使用十分方便,本文主要从两个方面出发来介绍:

1RPM包的具体构成;

2RPM包在未安装的情况下,提取包中的文件树信息以及与包相关的脚本信息。


RPM包的具体构成

RPM package filescontain four sections. The first is a leading identification areathat marks the file as an RPM package (created with a particularversion of the RPM system). The remaining sections are the signature,the tagged data (called the header), and the payload. Each of thesesections has important information about the package, although thepayload section contains the actual content of the package.

Signature

The signatureappears after the lead or identifier section, which marks the file asan RPM file. Like your signature when you sign a check, the RPMsignature helps verify the integrity of the package. No, thesignature doesn’t check for bugs in software applications. Instead,it ensures that you have downloaded a valid RPM archive.

The signature worksby performing a mathematical function on the header and archivesections of the file. The mathematical function can be an encryptionprocess, such as PGP (Pretty Good Privacy), or a message digest inMD5 format.

Header

The header containszero or more tagged blocks of data that pertain to the package. Theheader contains information such as copyright messages, versionnumbers, and package summaries.The optional PRE tag holds apre-installation script, a script that the rpm command runs prior toinstalling the files in the package payload.

Payload

The payload sectioncontains the actual files used in the package. These files areinstalled when you install the package. To save space, data in thepayload section is compressed in GNU gzip format.

上边这几段节选自fedoraRPM Guide文档(http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/index.html),由上可知RPM包最核心的东西就是HeaderPayload,前者主要包含RPM包的一些基本信息以及包在安装或者卸载时执行的脚本,后者主要包括就是RPM包真正安装到系统中的文件。

RPM内容获取

1)文件树获取,即真正安装到系统中的文件获取。

Linux环境下,可以使用rpm2cpio结合cpio命令获取。具体用法如下:

        rpm2cpiogimp-devel-2.6.9-6.el6_5.x86_64.rpm | cpio -dimv

    执行完毕后即可在当前目录看到gimp包解压出来的文件在Windows环境下,可以直接使用压缩软件进行解压查看,比如用7-Zip查看

2)脚本获取,即在软件安装或卸载时执行的脚本程序。

Linux环境下,可以使用rpm命令获取。具体用法如下:

        rpm-qp --scripts jdk-7u25-linux-x64.rpm > jdk-7u25-linux-x64.sh

    一般会包括preinstallation, postinstallation,preuninstallation,以及postuninstallationscripts,有的包可能不需要部分脚本。另外,如果软件包已经安装,也可以获取相关脚本,去掉上边选项p即可。如rpm-qp --scripts httpd >httpd.sh


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值