Read rpm archive files
Project description
rpmfile
Tools for inspecting RPM files in python. This module is modeled after the tarfile module.
Install
$ python -m pip install -U rpmfile
If you want to use rpmfile
with zstd
compressed rpms, you'll need to install
the zstandard module.
zstd
also requires that you are using Python >= 3.5
$ python -m pip install -U zstandard
Example
See the tests for more examples.
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)
Command line usage
You can use rpmfile
via it's module invocation or via rpmfile
command if
your PATH
environment variable is configured correctly. Pass --help
for all
options.
List RPM contents
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | python -m rpmfile -l -
./path/to/file
Extract files
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -x -
./path/to/file
Extract files to directory
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xC /tmp -
/tmp/path/to/file
Classes
- rpmfile.RPMFile: The RPMFile object provides an interface to a RPM archive
- rpmfile.RPMInfo: An RPMInfo object represents one member in a RPMFile.
Contributing
The black formater should be used on all files before submitting a contribution. Version 19.10b0.
$ pip install black==19.10b0
$ black .
Code in this module was borrowed from:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rpmfile-1.0.5.tar.gz
(18.1 kB
view hashes)