Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use Get-ChocolateyUnzip with "Extract"[e] instead of "eXtract with full paths"[x] -- 7z (cmd) #1824

Open
n3rd4i opened this issue May 12, 2019 · 10 comments

Comments

@n3rd4i
Copy link

n3rd4i commented May 12, 2019

Current situation when using Get-ChocolateyUnzip the 7z command that gets executed is "x":

  • 7z.exe x which means "eXtract with full paths"
    Ability to change this to "e" could be beneficial for download/zip files which contain folders and only files (not folders) from the archive are needed, example:
  • 7z.exe e which means "Extract"

I could not find workaround this issue.

One could try to use move commands after unzip but that defeats the intended functionality?

@ferventcoder
Copy link
Member

Not sure I follow all of this. Extract with full paths basically ensures the file structure of what is zipped up. If you wanted it without file structure, why not put it into the zip that way?

@n3rd4i
Copy link
Author

n3rd4i commented May 13, 2019

Problem is that not me is doing that, this is how the package is set up by Upstream if you want to call it that.

For example I'm creating SW package based on 3 components:

  1. Component Support pinning #1: a zip package which has some files inside and an *.exe
  2. Component Support switching shims between multiple installed versions #2: another zip file which has a folder inside and some files inside that folder
  3. Last component Support regenerating shims #3: which has same situation as Support pinning #1

Because the Install-ChocolateyZipPackage currently uses Get-ChocolateyUnzip which in place uses hardcoded 7zip command from which only 7z.exe x is supported I could not find easy way to flat-out the upstream package:

E.g.:

$params = "x -aoa -bd -bb1 -o`"$destinationNoRedirection`" -y `"$fileFullPathNoRedirection`""

IMO it could beneficial if there is a way to "flat-out" some zipped content so that user could do that. Currently I need to do workaround for this like:

Install-ChocolateyZipPackage @UnZipPackageArgs
& Move-Item -force $installLocation/ZIP_FOLDER/*.fileExt $installLocation/
& Remove-Item $installLocation/ZIP_FOLDER

@bcurran3
Copy link

bcurran3 commented May 14, 2019

You can run "&$ENV:ChocolateyInstall\tools\7z.exe e ZIPFILE"

@ferventcoder
Copy link
Member

ferventcoder commented May 14, 2019

@bcurran3 that is not considered part of the public API. So it's likely we will move those things and it will break packages using these internal things. In other words, please refrain from assuming these things will be here, and absolutely do not use them directly.

@ferventcoder
Copy link
Member

So it sounds like we need to expose a flatten parameter?

@ferventcoder ferventcoder added this to the 0.10.15 milestone May 14, 2019
@bcurran3
Copy link

@n3rd4i - you can also use 7zip.commandline as a dependency to solve this problem. (The shim will make you happy.)

Using my previous method, you'd want to put a dependency of chocolatey and limit it's version through the current beta to be safe.

@ferventcoder - I understand that things (Chocolatey install method) could change...

  1. Are there PLANNED changes?
  2. We've bumped into the topic of "public API" a few times. Where is it published? The only thing I've ever found is helper functions that say they aren't part of the public API. Are you talking about choco.dll or do you refer to the Chocolatey helper functions as an "API?"

@ferventcoder
Copy link
Member

This is the API - https://chocolatey.org/docs/helpers-reference. If you don't see it here, don't use it as it is not part of the published API.

@ferventcoder
Copy link
Member

Basically the only contracts for Chocolatey provided things that change slowly and with long term compatibility are the Chocolatey functions, unless a function specifically states it is not part of the public API and should not be used directly (as you pointed out).

@ferventcoder
Copy link
Member

  1. Are there PLANNED changes?

Not at this time, but you wouldn't want something to break if we did. We have moved things in that area in the past and it did break things for some package authors. We warned them against it as well when we saw they were doing it. Just to remind myself to keep folks on the right track, I've added this chocolatey/package-validator#189. Better to know right off you are not following a best practice and stick to what's available - and request for enhancements here, like @n3rd4i has done.

you can also use 7zip.commandline as a dependency to solve this problem.

I definitely like this aspect, as it is more flexible until Chocolatey can support it.

@AdmiringWorm
Copy link
Member

you can also use 7zip.commandline as a dependency to solve this problem.

Just an FYI, do not use the 7zip.commandline package, this package have been deprecated for 2 years now. Instead, use the 7zip.portable package instead.

@gep13 gep13 modified the milestones: 0.10.15, 0.10.16 May 31, 2019
@pauby pauby modified the milestones: 0.10.16, 0.10.x May 11, 2021
@vexx32 vexx32 modified the milestones: 0.11.x, Future, Future_ Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants