I recently realized that the RPM packages shifted from gzip-compression to xz-compression a few years ago. I need to check is the compression type of an RPM package that I have. I also need to check what compression type is considered by my system when it is trying to unpack an RPM file.
3 Answers
Query the RPM with a custom format that includes the Payloadcompressor tag ("Payload compressor name") like this:
rpm -q --queryformat '%{PAYLOADCOMPRESSOR}\n' -p qt-4.8.7-67.fc36.x86_64.rpm
By the way other interesting tags are Payloadflags ("Payload compressor level") and Payloadformat ("Payload format (cpio)").
If you use rpm2cpio
; you don't need to know the compression format. You can use rpm2cpio
to unpack rpms like this:
rpm2cpio your.rpm | cpio -idmv
To address: Which compression formats are supported?
It's easy enough to see what's not supported, e.g. trying to install an RPM from Fedora 34 on RHEL 6:
$ rpm --install https://dl.fedoraproject.org/.../Packages/t/tzdata-2021a-1.fc34.noarch.rpm
error: Failed dependencies:
rpmlib(PayloadIsZstd) <= 5.4.18-1 is needed by tzdata-2021a-1.fc34.noarch
Although this dependency is not explicitly exposed by rpm-libs
in a way which can be queried by --whatprovides
, we can infer the compression formats supported by rpm-libs
.
### why do all compression formats have "z" in the name? It's the fashion.
$ rpm -q --requires rpm-libs | grep '^lib.*z'
libbz2.so.1()(64bit)
liblzma.so.5()(64bit)
liblzma.so.5(XZ_5.0)(64bit)
liblzma.so.5(XZ_5.1.2alpha)(64bit)
libz.so.1()(64bit)
Another way to track this would be the features changes for Fedora etc.:
- Fedora 12, switch to XZ
- Fedora 31, switch to zstd
/usr/lib/rpm/rpm2cpio.sh
- this script works out what type of compression is used and will decompress it. You can probably use that as the basis for checking the compression your rpm package uses.