Open alexchandel opened 9 years ago
I will tackle this one.
@ferventcoder - after looking at the code I noticed there is a lot of code just to get reasonable process monitoring and status back from 7zip.
So I am contemplating having Get-ChocolateyUnzip.ps1 call itself recursively for a second pass at the file since all that logic would be reused for the second pass.
Some questions / observations for your comment:
I think something like this code at the end of the function might do it?
#If our unzip resulted in a .tar file that matches our input zip file without it's extensions, unzip it
#does not work with archive names that contain a '.' before the extensions
$matchingtarname = "$destinationNoRedirection\$((split-path -leaf $fileFullPathNoRedirection).split('.')[0]).tar"
If ((Test-path $matchingtarname) -AND (!$RecursiveCall))
{
Write-Host "Automatically detected this archive contained a .tar matching the original archive name, unzipping `"$matchingtarname`" ..."
Get-ChocolateyUnzip -fileFullPath "$matchingtarname" -destination "$destination" -specificFolder "$specificFolder" -packagename "$packagename" -recursivecall
remove-item $matchingtarname
}
If (!$RecursiveCall)
{
#Untouched end of function code below to show position of above
$env:ChocolateyPackageInstallLocation = $destination
return $destination
}
}```
OK - my proposal for conservatively determining the embedded archive name does not work because Get-ChocolateyWebFile or Get-WebFile rename the fetched archive to [packageid][install].extension.
@ferventcoder - is there a variable available to me (maybe from a parent or global scope) while I am in Get-ChocolateyUnzip.ps1 that would reveal the original archive name?
If not, then we'd have to do something like unzip a found .tar in ONLY the root of \tools back to the root of \tools. Maybe we limit the logic to do this ONLY if we find a SINGLE .tar at the root of \tools (leading to the hopeful conclusion that the found *.tar was the only contents of the original archive) ?
@ferventcoder - I dumped all variables from within Get-ChocolateyUnzip and I see that the original file name appears in both URL and ZipFileList.
I have the code working against $url - but easy to change.
Since I have a working sample, I submitted the pull request so you can see the working code - can make any changes needed.
Definitely interested in seeing this implemented. I find the Java .tar.gz and so many others much easier to work with than handling a self extracting .exe that doesn't take parameters and then figuring out where it put things just to move them where I actually wanted them.
@ferventcoder - I had this code fail a test recently - it was acting like $url was not available in that scenario. Should "ZipFileList" be available in every scenario where Get-ChocolateyUnzip is called?
@DarwinJS not completely sure on that. The code would be the best place to know.
I originally found $url by dumping all variables from within the function. I have switched to $zipfilelist and left the function running on my machine for some weeks now and no problems.
So I check if the variable exists and also if it contains data - if so I know we can at least formulate a file name to check for the existence of a *.tar. If somehow $zipfilelist is sometimes populated when we aren't processing a zip file - no problem, the existence check simply fails and no one is the wiser.
I have setup automatic packages for both Kafka and prometheus but both of these packages depend on this feature working as they are either tar.gz or tgz files which contain a tar that doesn't current get extracted.
I would rather not write specialized code for these packages and instead rely on Install-ChocolateyZipPackage to handle this.
Used the technique of running get-chocolateyunzip function after the initial Install-ChocolateyZipPackag and things are now working. Example. It would still be nice to have this built in but we are not blocked on this any longer.
It was recently suggested that
Install-ChocolateyZipPackage
only produces a.tar
file when called on a.tar.xz
, and that chocolatey#473 from the old repository was intended to correct this. This should be implemented.