读取rpm存档文件
项目描述
rpmfile
用于在Python中检查RPM文件的工具。此模块仿照了tarfile模块。
安装
$ python -m pip install -U rpmfile
如果您想使用rpmfile
与zstd
压缩的rpm文件,您需要安装zstandard模块。
zstd
还要求您使用Python >= 3.5
$ python -m pip install -U zstandard
示例
查看测试以获取更多示例。
import rpmfile
with rpmfile.open('file.rpm') as rpm:
# Inspect the RPM headers
print(rpm.headers.keys())
print(rpm.headers.get('arch', 'noarch'))
# Extract a fileobject from the archive
fd = rpm.extractfile('./usr/bin/script')
print(fd.read())
for member in rpm.getmembers():
print(member)
命令行使用
您可以通过模块调用或通过配置正确的PATH
环境变量使用rpmfile
命令。使用--help
获取所有选项。
列出RPM内容
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | python -m rpmfile -l -
./path/to/file
提取文件
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xv -
./path/to/file
将文件提取到目录
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xvC /tmp -
/tmp/path/to/file
显示RPM信息(类似于Linux中的命令rpm -qip
)
curl -sfL 'https://example.com/some.rpm.gz' |gzip -d - | rpmfile -i -
Name : something
Version : 1.02
Release : 1
Architecture: noarch
Group : default
Size : 1234
License : BSD
Signature : None
Source RPM : some.src.rpm
Build Date : Tue Apr 9 08:55:16 2019
Build Host : demo
URL : http://example.com/some
Summary : Example of something
Description :
The description of something.
It can display more than one line.
类
- rpmfile.RPMFile:RPMFile对象提供对RPM存档的接口
- rpmfile.RPMInfo:RPMInfo对象代表RPMFile中的一个成员
贡献
在提交贡献之前,应在所有文件上使用black格式化器。版本19.10b0。
$ pip install black==19.10b0
$ black .
此模块中的代码借鉴自
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分布
rpmfile-2.1.0.tar.gz (21.1 kB 查看哈希值)
构建分布
rpmfile-2.1.0-py3-none-any.whl (17.5 kB 查看哈希值)