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 -xv -
./path/to/file
Extract files to directory
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xvC /tmp -
/tmp/path/to/file
Display RPM information (similar to command rpm -qip
in Linux)
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.
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
Built Distribution
File details
Details for the file rpmfile-2.1.0.tar.gz
.
File metadata
- Download URL: rpmfile-2.1.0.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ac2bba89277c7185cb861c9c6d7d0c9a268be5169516dbc6a68f1556a9e3f99 |
|
MD5 | cb308f8ff75355f5e76f156b38ee5bae |
|
BLAKE2b-256 | 5b1eccb1b2f1cc9f3d5351bf0ab9db4db30ca349f7d3b23b2751e4e2fb48e50f |
File details
Details for the file rpmfile-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: rpmfile-2.1.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d180ffffef5ca1377a33eb4af3e2de69dccafe7e10aa20b06d191bd8e8d369c |
|
MD5 | 18076a7d5634a8201546c4c6c1bd38fa |
|
BLAKE2b-256 | 27e439aa91edc46e2f7c0939b05468ccebdaa8efbd83c65807d60ccf574916c0 |