Search code examples
chocolatey

Unable to extract tar.gz package using Install-ChocolateyZipPackage function


Problem

Extracting a tar.gz package using Install-ChocolateyZipPackage results in creation of a file PackageNameInstall containing the directory, while the directory should be extracted.

$url = "http://packageName.tar.gz"
$extractionPath = "C:/$packageName"
Install-ChocolateyZipPackage "$packageName" "$url" "$extractionPath"

It is possible to include 7zip.commandline as a dependency and subsequently extract the tar.gz package multiple times and removing the downloaded package afterwards.

Question

Which Chocolatey function is able to extract tar.gz packages?


Solution

  • Chocolatey v0.9.10.1+: Chocolatey's built in Install-ChocolateyZipPackage and Get-ChocolateyUnzip use a vendored 7z.exe full, so they take advantage of the widest amount of formats able to be uncompressed.

    Original Answer

    You can build a dependency on 7z.commandline package and then use it to extract a tar.gz file in the powershell installation steps. There is not a built-in command for this but at least you would have that to move forward right now.

    Here's an example on github:

    $installDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" 
    Start-Process "7za" -ArgumentList "x -o`"$installDir`" -y `"$file`"" -Wait