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

When using 7zip to extract with strip_components >= 1 (default is 1) extracts to home_dir, not path #164

Closed
sgtcoolguy opened this issue Nov 16, 2016 · 1 comment

Comments

@sgtcoolguy
Copy link
Contributor

Cookbook version

2.0.2

Chef-client version

12.16.42

Platform Details

Windows 10

Scenario:

Attempting to use ark to grab a 7z file (https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.7z) and extract it to C:\Program Files(x86)\boost

Steps to Reproduce:

ark 'boost' do
  url "https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.7z"
  extension '7z'
  version '1.62.0'
  checksum 'b91c2cda8bee73ea613130e19e72c9589e9ef0357c4c5cc5f7523de82cce11f7'
  win_install_dir 'C:\\Program Files (x86)\\boost'
end

Expected Result:

I expect it to be able to download the file, and unpack to win_install_dir.

Actual Result:

It grabs the remote file, then extracts to a temp directory and attempts to copy it over to home_dir.

See https://github.com/chef-cookbooks/ark/blob/7559940dc37cfd672178d15571b7178f267178cb/libraries/sevenzip_command_builder.rb#L43

Additionally, on a re-run, it fails because the temp directories contents already exist and 7-zip prompts for what to do about the clash.

==> default: Would you like to replace the existing file:
==> default: 
==> default:   Path:     C:/Users/vagrant/AppData/Local/Temp/d20161115-456-osek4r\boost-no-inspect
==> default: 
==> default:   Size:     80 bytes (1 KiB)
==> default:   Modified: 2016-09-21 14:33:25
==> default: 
==> default: with the file from archive:
==> default: 
==> default:   Path:     boost_1_62_0\libs\geometry\doc\generated\boost-no-inspect
==> default: 
==> default:   Size:     32 bytes (1 KiB)
==> default: 
==> default:   Modified: 2016-09-21 14:33:29
==> default: 
==> default: ? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? 
==> default: 
==> default: Archives with Errors: 1
==> default: STDERR: ERROR: Can't allocate required memory!
==> default: ---- End output of "c:\Program Files\7-Zip\\7z.exe" e "C:/chef/cache/boost-1.62.0.7z" -o"C:/Users/vagrant/AppData/Local/Temp/d20161115-456-osek4r" -uy && for /f %1 in ('dir /ad /b "C:\Users\vagrant\AppData\Local\Temp\d20161115-456-osek4r"') do C:\Windows\System32\xcopy "C:\Users\vagrant\AppData\Local\Temp\d20161115-456-osek4r\%1" "/usr/local/boost" /s /e ----
==> default: Ran "c:\Program Files\7-Zip\\7z.exe" e "C:/chef/cache/boost-1.62.0.7z" -o"C:/Users/vagrant/AppData/Local/Temp/d20161115-456-osek4r" -uy && for /f %1 in ('dir /ad /b "C:\Users\vagrant\AppData\Local\Temp\d20161115-456-osek4r"') do C:\Windows\System32\xcopy "C:\Users\vagrant\AppData\Local\Temp\d20161115-456-osek4r\%1" "/usr/local/boost" /s /e returned 2
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
@sgtcoolguy
Copy link
Contributor Author

Looks to me like the call to resource.home_dir should just be replaced by resource.path fir the first part of the bug. For the second, I guess make_temp_dir should not only make the directory but ensure it's empty?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants