Bug 1282024 - Have rpm2cpio use rpm libraries for decompression
Have rpm2cpio use rpm libraries for decompression
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
22
Unspecified Unspecified
unspecified Severity low
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-14 07:22 EST by DaveG
Modified: 2016-01-29 08:32 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-01-29 08:32:23 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description DaveG 2015-11-14 07:22:09 EST
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 09:04:54 EST
Would you mind creating a pull request? https://github.com/rpm-software-management/dnf
Comment 2 DaveG 2015-11-18 19:13:45 EST
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 08:32:23 EST
Resolved in GitHub - function will be dropped.
https://github.com/rpm-software-management/dnf/pull/386

Note You need to log in before you can comment on or make changes to this bug.