Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

[BUG] Unzip specific folder feature is broken after introducing 7zip #406

Closed
AnthonyMastrean opened this issue Jan 22, 2014 · 14 comments
Closed

Comments

@AnthonyMastrean
Copy link
Contributor

I'm updating a package that downloads an archive with x64 and Win32 subdirectories. I used to extract the entire thing and manually remove the unneeded components. But, I figured I would try the as-yet undocumented -specificFolder parameter of Install-ChocolateyZipPackage.

$name   = "bellavista"
$url    = "http://.../bellavista.zip"
$tools  = Split-Path $MyInvocation.MyCommand.Definition
$folder = if(Get-ProcessorBits 64) { "x64" } else { "Win32" }


Install-ChocolateyZipPackage -PackageName $name -Url $url -UnzipLocation $tools -SpecificFolder $folder

But, it didn't work. The first thing I saw was a goofy log message. Look at the "full path" in bold. It contains a non-path

"Extracting c:\users\foo\temp\chocolatey\bellavista\bellavistaInstall.zip\x64 to c:\Chocolatey\lib\bellavista.1.0\tools..."

And, digging in the source, I saw a bad 7za command line being constructed

7za x -o"c:\Chocolatey\lib\bellavista.1.0\tools" -y "c:\users\foo\temp\chocolatey\bellavista\bellavistaInstall.zip\x64"

From my reading of the command line reference, and hacking my helper function, the correct command line should be...

7za x "c:\users\foo\temp\chocolatey\bellavista\bellavistaInstall.zip -o"c:\Chocolatey\lib\bellavista.1.0\tools" "x64" -y

And, actually, with this fix, you could supply any glob pattern to 7za, not just a specific folder.

@AnthonyMastrean
Copy link
Contributor Author

I can supply the patch if you agree it's broken :)

@rismoney
Copy link
Contributor

I say go ahead! I added the -specificfolder switch before we went 7za so imho it's a regression.

@AnthonyMastrean
Copy link
Contributor Author

Can I use pester to mock the 7za call?

@mwrock
Copy link
Contributor

mwrock commented Jan 22, 2014

yes.

Mock 7za

@AnthonyMastrean
Copy link
Contributor Author

OMG, it's that easy, huh? I guess powershell isn't treating native commands differently than cmdlets, it's interpreting everything and if it finds my mock first, I win, right?

Actually... am I able to mock a full file path? The script joins together everything down to the .exe.

$7zip = Join-Path "$env:ChocolateyInstall" 'chocolateyinstall\tools\7za.exe'

Nevermind, I'm mocking Start-Process instead, got it ;)

@mwrock
Copy link
Contributor

mwrock commented Jan 22, 2014

You win!! :)

Yeah as long as you can do a

Get-Command 7za

it should work. Pester creates a proxy command and hides the original command.

@ferventcoder
Copy link
Contributor

Undocumented means unsupported ;)

@ferventcoder
Copy link
Contributor

AKA dark features. Actually I think this is probably undocumented b/c it's something we may have missed documenting... :(

@AnthonyMastrean
Copy link
Contributor Author

I'll take care of that too ;)

@ghost ghost assigned AnthonyMastrean Jan 23, 2014
@ferventcoder
Copy link
Contributor

@AnthonyMastrean Did I miss the PR?

@AnthonyMastrean
Copy link
Contributor Author

Nah, life attacked and I haven't gotten around to it or a million other things I want to work on ;) I do remember my initial patch not working entirely (there's a lot of quoting/escaping going on in the line in question). But, this can be a good reminder to get on it.

@ferventcoder
Copy link
Contributor

I'm going to bump this to the next version while waiting for updates.

@rubenqba
Copy link

When is solved this issue??

@ferventcoder
Copy link
Contributor

Migrated to chocolatey/choco#676

@chocolatey-archive chocolatey-archive locked and limited conversation to collaborators Mar 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants