Skip to main content

Read rpm archive files

Project description

rpmfile

Tests PyPI version

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==26.3.1
$ black .

Code in this module was borrowed from:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rpmfile-2.2.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rpmfile-2.2.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file rpmfile-2.2.0.tar.gz.

File metadata

  • Download URL: rpmfile-2.2.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for rpmfile-2.2.0.tar.gz
Algorithm Hash digest
SHA256 2de4f4d962ceabe9bd9d0d67de7a837042f52dbdfb2f6591fb210c0302f3ffce
MD5 c72a1ddaa5e9dd77cb046441874a334a
BLAKE2b-256 0875cea8434fcd13542fa374634c120494f7b76c9a0b179789bc06a486fe2118

See more details on using hashes here.

File details

Details for the file rpmfile-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: rpmfile-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for rpmfile-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a24da33c0447db9fa28d85522eb9571656993bb7e2faef03ee2a5b39f1315f49
MD5 ce5e7b715c9a22f40a8cd5f3f7b59dab
BLAKE2b-256 e329f36df57f949c15e77de736f5ffc6c43c7e0b4a5ec85f75b21f687ce41f89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page