Bug 1282024

Summary: Have rpm2cpio use rpm libraries for decompression
Product: [Fedora] Fedora Reporter: DaveG <daveg>
Component: dnfAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 22CC: jsilhan, mluscon, packaging-team-maint, pnemade, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-29 13:32:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description DaveG 2015-11-14 12:22:09 UTC
Description of problem:

dnf.rpm.miscutils.rpm2cpio uses gzip directly to decompress RPM payload.
This limits the utility to gzip packages only, while most RPM now use other compression methods.

The RPM library can be used to handle the decompression directly.

This will allow the python utility to support all compression methods supported by RPM and it's command-line utility.


Version-Release number of selected component (if applicable):
rpm-4.12.0.1-13.fc22.x86_64
dnf-1.1.3-1.fc22.noarch

How reproducible:


Steps to Reproduce:


Actual results:


Expected results:


Additional info:

The method I have been using and appears to work well employs the RPM file handling interface rather than gzip.FZipFile.

Unified diff:

--- a/dnf/rpm/miscutils.py	2015-10-14 17:40:12.000000000 +0100
+++ b/dnf/rpm/miscutils.py	2015-11-14 11:57:15.814296763 +0000
@@ -17,7 +17,6 @@
 from __future__ import unicode_literals
 import dnf.pycomp
 import rpm
-import gzip
 import os
 import sys
 import locale
@@ -148,13 +147,7 @@
     del ts
 
     compr = hdr[rpm.RPMTAG_PAYLOADCOMPRESSOR] or 'gzip'
-    #XXX FIXME
-    #if compr == 'bzip2':
-        # TODO: someone implement me!
-    #el
-    if compr != 'gzip':
-        raise RpmUtilsError('Unsupported payload compressor: "%s"' % compr)
-    f = gzip.GzipFile(None, 'rb', None, os.fdopen(fdno, 'rb', bufsize))
+    f = rpm.fd.open(fdno, 'r', compr)
     while 1:
         tmp = f.read(bufsize)
         if tmp == "": break

Comment 1 Michal Luscon 2015-11-18 14:04:54 UTC
Would you mind creating a pull request? https://github.com/rpm-software-management/dnf

Comment 2 DaveG 2015-11-19 00:13:45 UTC
First-time GitHub user, something I've been meaning to try out.

Hope I did it right.

Pull request #386. Still needs a test build.

-- David.

Comment 3 DaveG 2016-01-29 13:32:23 UTC
Resolved in GitHub - function will be dropped.
https://github.com/rpm-software-management/dnf/pull/386