Bug 516898 - Solaris2mpm can't convert patch 121692-01
Solaris2mpm can't convert patch 121692-01
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Solaris (Show other bugs)
All Linux
high Severity high
: ---
: ---
Assigned To: Miroslav Suchý
Martin Minar
Depends On:
Blocks: sat531-triage 596147
  Show dependency treegraph
Reported: 2009-08-11 16:18 EDT by Issue Tracker
Modified: 2016-07-03 20:54 EDT (History)
7 users (show)

See Also:
Fixed In Version: rhnpush-5.3.1-6
Doc Type: Bug Fix
Doc Text:
When processing ZIP archives, the solaris2mpm utility no longer fails if the patch is not placed in a directory.
Story Points: ---
Clone Of:
Last Closed: 2011-07-20 11:32:33 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
requested sun patch file (2.81 MB, application/octet-stream)
2010-01-21 15:24 EST, James M. Leddy
no flags Details

  None (edit)
Description Issue Tracker 2009-08-11 16:18:16 EDT
Escalated to Bugzilla from IssueTracker
Comment 1 Issue Tracker 2009-08-11 16:18:18 EDT
Event posted on 08-10-2009 01:17pm EDT by savas

Most patch zip files contain the directory as part of the zip file: 

[savas@nhuudlm43 savas]$ unzip -l 121692-01.zip.fixed
Archive:  121692-01.zip.fixed
  Length     Date   Time    Name
 --------    ----   ----    ----
        0  08-04-09 09:18   121692-01/

Solaris2mpm looks at the unzip output ang gets the directory from the 4th field of the fourth line. In the zip file solaris2mpm expects that to be the directory. In this patch, however it looks like this:

[savas@nhuudlm43 savas]$ unzip -l 121692-01.zip
Archive:  121692-01.zip
  Length     Date   Time    Name
 --------    ----   ----    ----
  3159237  10-05-06 16:05   121692-01/802-3233-25.ps

Which is the name of a file in the patch. solaris2mpm will barf with the following error:
solaris2mpm 121692-01.zip
Opening archive, this may take a while
Error creating mpm for /tmp/121692-01.zip:
Traceback (most recent call last):
  File "/opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/solaris2mpm.py", line 184, in _run
    archive_parser = get_archive_parser(archive, tempdir=options.TEMPDIR)
  File "/opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/archive.py", line 408, in get_archive_parser
    return Class(archive, tempdir)
  File "/opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/archive.py", line 53, in __init__
  File "/opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/archive.py", line 105, in _explode
    raise InvalidArchiveError("Archive did not expand to %s" % self._archive_dir)
InvalidArchiveError: Archive did not expand to /tmp/tmpq6_RmT/121692-01/802-3233-25.p

The easy solution is to re-zip the patch so that it has the directory in the zip file. However this isn't scalable. Another fix is to update the archive.py file. Below is a patch I created to fix this issue. The TODO is there because there is the potential that the first file in the zip file may be another directory. Since we only want the first directory my patch won't work.

bash-3.00# diff -u /opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/archive.py /opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/archive.py.new
--- /opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/archive.py     Mon Aug 10 13:11:25 2009
+++ /opt/redhat/rhn/solaris/lib/python2.4/site-packages/rhnpush/archive.py.new Mon Aug 10 13:11:21 2009
@@ -241,6 +241,12 @@
             raise ArchiveException("cannot open %s, 'unzip' not found" % self._archive)

         self._archive_dir = os.path.join(self._temp_dir, self._get_archive_dir())
+       # Some patches (121692-01) don't zip the entire directory. Some only
+        # zip the contents. In that case get a dirname of the first element
+       # TODO: A better way might be to regex the filename from the beginning
+       #       the first / and return that from _get_archive_dir
+       if not os.path.isdir( self._archive_dir ):
+               self._archive_dir = os.path.dirname( self._archive_dir )

         return "unzip -q -n %s -d %s" % (self._archive, self._temp_dir)

This event sent from IssueTracker by xdmoon  [Support Engineering Group]
 issue 328399
Comment 5 James M. Leddy 2010-01-21 15:24:56 EST
Created attachment 386000 [details]
requested sun patch file
Comment 6 Miroslav Suchý 2010-05-06 10:54:47 EDT
Fixed in spacewalk git.
Commit:  e643c0d5df922f5b9b7edd8db647cad970c970dd
Comment 7 Miroslav Suchý 2010-05-18 10:50:17 EDT
Cherry picked to satellite.git as commit bea21105b9fa95750ea054c5a9c848a57cc99f79
Comment 11 Jaromir Hradilek 2010-09-02 16:59:19 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    New Contents:
When processing ZIP archives, the solaris2mpm utility no longer fails if the patch is not placed in a directory.

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