Skip to main content

Read rpm archive files

Project description

rpmfile

Build Status Actions Status 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==19.10b0
$ 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-1.1.1.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

rpmfile-1.1.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rpmfile-1.1.1.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for rpmfile-1.1.1.tar.gz
Algorithm Hash digest
SHA256 6717077b5431746d860483cc36b9c9cba55df124606781ceb70b24b366def02b
MD5 1827aa3096833dbea55d21d2a7c3f849
BLAKE2b-256 dfa14ef3aba6c4c23e38b0ec766f0cd01c9db4abbe6febaa557b47541dc18000

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rpmfile-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for rpmfile-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7292c964f317e0770e084707da23dacc199cb4d228c8157f46efb8f44cf268d0
MD5 580b33eca9364735a2f51e3fb6145b7d
BLAKE2b-256 f8a2760a8fd1426bd92aae064f9cd46aeb77fd830beb2428aee2a8ba7021b439

See more details on using hashes here.

Supported by

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