### Install rpmfile Python package Source: https://github.com/srossross/rpmfile/blob/master/README.md This command installs the `rpmfile` Python package using pip. It ensures the latest version is installed globally or in the current environment. ```console $ python -m pip install -U rpmfile ``` -------------------------------- ### Install zstandard for zstd compressed RPMs Source: https://github.com/srossross/rpmfile/blob/master/README.md This command installs the `zstandard` Python module, which is required to use `rpmfile` with zstd-compressed RPM archives. Python 3.5 or higher is necessary for zstd support. ```console $ python -m pip install -U zstandard ``` -------------------------------- ### List RPM contents from URL via command line Source: https://github.com/srossross/rpmfile/blob/master/README.md This command-line example shows how to pipe a downloaded and decompressed RPM file to `rpmfile` to list its contents. It uses `curl` to fetch the file, `gzip -d` to decompress, and `python -m rpmfile -l -` to list members from standard input. ```console curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | python -m rpmfile -l - ./path/to/file ``` -------------------------------- ### Format Python code with Black for contributions Source: https://github.com/srossross/rpmfile/blob/master/README.md These commands install the specific version of the `black` formatter required for contributions and then apply it to the current directory. This ensures consistent code style across the project. ```console $ pip install black==19.10b0 $ black . ``` -------------------------------- ### Inspect and Extract RPM files using Python rpmfile Source: https://github.com/srossross/rpmfile/blob/master/README.md This Python example demonstrates how to open an RPM file, inspect its headers (e.g., `arch`), extract a specific file object, and iterate through all members in the archive. It uses the `rpmfile.open` context manager for safe file handling. ```python 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) ``` -------------------------------- ### Display RPM package information via command line Source: https://github.com/srossross/rpmfile/blob/master/README.md This command displays detailed information about an RPM package, similar to `rpm -qip` in Linux. It pipes the RPM content from a URL and uses `rpmfile -i -` to show metadata like Name, Version, Architecture, and Summary. ```console 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. ``` -------------------------------- ### Extract all files from RPM via command line Source: https://github.com/srossross/rpmfile/blob/master/README.md This command demonstrates extracting all files from an RPM archive piped from a URL. The `-xv` flags enable verbose extraction, outputting the paths of extracted files. ```console curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xv - ./path/to/file ``` -------------------------------- ### rpmfile Python API Classes Source: https://github.com/srossross/rpmfile/blob/master/README.md This section outlines the core classes provided by the `rpmfile` module for interacting with RPM archives. `RPMFile` serves as the primary interface for an archive, while `RPMInfo` represents individual members within it. ```APIDOC rpmfile.RPMFile: The RPMFile object provides an interface to a RPM archive rpmfile.RPMInfo: An RPMInfo object represents one member in a RPMFile. ``` -------------------------------- ### Extract RPM files to a specified directory via command line Source: https://github.com/srossross/rpmfile/blob/master/README.md This command extracts files from an RPM archive to a target directory, `/tmp`, using the `-C` flag. It's useful for controlling where the extracted contents are placed. ```console curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xvC /tmp - /tmp/path/to/file ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.