autopkg icon indicating copy to clipboard operation
autopkg copied to clipboard

Add option for Unarchiver to handle gzip/gz files other than '.tar.gz'

Open apizz opened this issue 4 years ago • 0 comments

Describe the problem When Unarchiver is presented with a .dmg.gzip or .dmg.gz it fails to decompress. The applicable lines of the processor are https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/Unarchiver.py#L136-L141.

It appears that gzip was coded to be a valid file type, but unless it is a .tar.gz, it does not like it. Below are my Unarchiver settings, which is the exact same as another working recipe: https://github.com/autopkg/gregneagle-recipes/blob/master/SuspiciousPackageXip/SuspiciousPackageXip.pkg.recipe

<dict>
    <key>Processor</key>
    <string>Unarchiver</string>
    <key>Arguments</key>
    <dict>
        <key>archive_format</key>
        <string>gzip</string>
        <key>archive_path</key>
        <string>%pathname%</string>
        <key>destination_path</key>
        <string>%RECIPE_CACHE_DIR%/unarchive</string>
        <key>purge_destination</key>
        <true/>
    </dict>
</dict>

In my case I am trying to create a recipe which downloads the following package: http://business.toshiba.com/downloads/KB/f1Ulds/17881/TOSHIBA_MonoMFP.dmg.gz

When decompressed natively on the Mac, the TOSHIBA_MonoMFP.dmg.gz file becomes TOSHIBA_MonoMFP.dmg, which is mountable and contains a PKG installer inside.

I've confirmed that running the following command with gzip does successfully decompress the file with the proper .dmg extension: /usr/bin/gzip -d -k <filename>.dmg.<gzip|gz> OR /usr/bin/gunzip -k <filename>.dmg.<gzip|gz>

The problem here is that as far as I can tell, there isn't a native way with gzip or gunzip to decompress the resulting file into another directory. In the grand scheme of things, this isn't a big deal for me personally because the resulting file will get created in the recipe's default downloads folder and can easily be manipulated as needed with FileFinder and PkgCopier. However, this would differ from other compression formats with the processor, thereby preventing this one filetype from decompressing to a specified destination_path.

Preferences contents

AutoPkg output When run as part of my recipe, produces the following error:

Error in com.github.apizz.download.ToshibaCopierDrivers: Processor: Unarchiver: Error: Unarchiving /Users/<user>/Library/AutoPkg/Cache/com.github.apizz.download.ToshibaCopierDrivers/downloads/ToshibaDrivers.dmg.gz with ditto failed: ditto: cpio read error: bad file format

When the corresponding tar command is run on line 141 - /usr/bin/tar -x -f archive_path -C destination_path -z - the following error occurs:

tar: Unrecognized archive format
tar: Error exit delayed from previous errors.

When the corresponding ditto command is run manually on line 139 - /usr/bin/ditto --noqtn -x archive_path destination_path - the following error occurs:

tar: Unrecognized archive format
tar: /Users/<user>/<path>: Not found in archive
tar: Error exit delayed from previous errors.

Expected behavior Properly decompress a gzip or gz file. In my case, produce a .dmg.

Version (please complete the following information):

  • OS version: 10.14.6
  • AutoPkg Version: 2.1

apizz avatar Jun 02 '20 02:06 apizz