chocolatey-archive / chocolatey

[DEPRECATED - https://github.com/chocolatey/choco] Chocolatey NuGet - Like apt-get, but for windows.
https://chocolatey.org
Apache License 2.0
2.8k stars 344 forks source link

[BUG] Can't install on Server Core 2008 R2 #59

Closed Iristyle closed 11 years ago

Iristyle commented 12 years ago

The COM Shell.Application instance apparently doesn't have the code necessary to unzip on Core. Unfortunately I don't think there's an easy way around this one, other than to download some sort of unzip application first like 7-zip, unzip, etc.

Here's a solution for this that I use, but... it's probably not something you'd want to do.

Import-Module BitsTransfer $Is32Bit = (($Env:PROCESSOR_ARCHITECTURE -eq 'x86') -and ($Env:PROCESSOR_ARCHITEW6432 -eq $null))

7zip

$7zUri = if ($Is32Bit) { 'http://sourceforge.net/projects/sevenzip/files/7-Zip/9.22/7z922.msi/download' } ` else { 'http://sourceforge.net/projects/sevenzip/files/7-Zip/9.22/7z922-x64.msi/download' }

Start-BitsTransfer $7zUri 7z922.msi Start-Process -FilePath "msiexec.exe" -ArgumentList '/i 7z922.msi /norestart /q INSTALLDIR="c:\program files\7-zip"' -Wait SetX Path "${Env:Path};C:\Program Files\7-zip" /m $Env:Path += ';C:\Program Files\7-Zip' del 7z922.msi

Here's the error output during the install:

PS C:\Users\Administrator> Invoke-Expression ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))

Mode LastWriteTime Length Name


d---- 1/28/2012 1:17 AM chocInstall Downloading http://chocolatey.org/api/v1/package/chocolatey to C:\Users\ADMINI~1\AppData\Local\Temp\2\chocolatey\chocInstall\chocolatey.zip Extracting C:\Users\ADMINI~1\AppData\Local\Temp\2\chocolatey\chocInstall\chocolatey.zip to ... Exception calling "NameSpace" with "1" argument(s): "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))" At line:35 char:42

You cannot call a method on a null-valued expression. At line:37 char:46

Installing chocolatey on this machine The term 'C:\Users\ADMINI~1\AppData\Local\Temp\2\chocolatey\chocInstall\tools\chocolateyInstall.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:44 char:2

Ensuring chocolatey commands are on the path Updating chocolatey to the latest version The term 'cup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:60 char:4

ferventcoder commented 12 years ago

interesting that you would use BITS...

Iristyle commented 12 years ago

BITS works surprisingly well... except when you're over WinRM -- access denied due to security reasons, in case you were wondering. You need to use WebClient in that case.

Of course, one of the first things I do in my EC2 image bootstrapper scripts is install curl, so that I don't have to bother with either BITS or WebClient. Much more friendly when dealing with redirects, custom headers, POST data, etc, etc.

ferventcoder commented 12 years ago

Maybe choco should use Curl - how does it do with proxies?

Iristyle commented 12 years ago

http://curl.haxx.se/docs/manpage.html Anything you could want to do, it can do... at least in my experience...

My example above was less about the download mechanism though, and more about grabbing 7z to use to unzip on Server Core though. Other alternatives that I can think of

Obviously it's up to you, but I would vote for the lightest / simplest / fastest / most side effect-free way to get zip support. 7z fits the bill for me, but I own my servers and maybe there's another better general purpose way that works for everyone.

Iristyle commented 11 years ago

Also discussed in the forum here.

Another newer option (for the sake of completeness) is System.IO.Compression.ZipArchive, but that's .NET 4.5 only. Probably don't want that as a dependency.

My vote at this point is to ship the SharpZipLib ASM along with Chocolatey, as that will give the most bang for the buck in implementation cost. It's probably the most robust, as 7zip does require the C++ runtime which might not be installed on target systems. PsCx introduces a whole bunch of extra goop.

For reference -- here are the file sizes.

I think the ultimate best solution is to just embed the C# parts of SharpZipLib needed to unzip files, but someone will have to rip through that code and make it part of Chocolatey.

Iristyle commented 11 years ago

A nice single file embed option looks to be ZipStorer. I don't know much about this one... but some of the comments seem to indicate that the goal is exactly the one we would have with Chocolatey -- swap out COM shell stuff with something simple and small in .NET.

poehlert commented 11 years ago

Though it's not ideal, Server core and in fact all windows for ages have included expand.exe to extract .cab files. This is part of windows setup so isn't like to change... well really ever. For early boot-strapping, it works well though I haven't found it particularly adept at compressing things.

ferventcoder commented 11 years ago

This is in 97b94b2d7d5874da2e94bad693b3e8c51a146b64 and 5a9d3968042cdacfdfce62f05e0108a772c5019e. This closes #297