Bug 1282024 - Have rpm2cpio use rpm libraries for decompression
Summary: Have rpm2cpio use rpm libraries for decompression
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-14 12:22 UTC by DaveG
Modified: 2016-01-29 13:32 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2016-01-29 13:32:23 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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


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