joefitzgerald / packer-windows

Windows Packer Templates
MIT License
1.63k stars 1.12k forks source link

Installation of Cygwin #256

Open larytet opened 6 years ago

larytet commented 6 years ago

My goal is to script Cygwin installation in Windows 10. I added

# get cygwin
$cygwin_download_url = "https://www.cygwin.com/setup-x86_64.exe"
Write-Output "Downloading $cygwin_download_url"
(New-Object System.Net.WebClient).DownloadFile($cygwin_download_url, "C:\Users\User\Downloads\setup-x86.exe")

to the OPENSSH.PS1 script and a section in the Autounattend.xml

                <SynchronousCommand wcm:action="add">
                    <CommandLine>cmd.exe /c C:\Windows\Temp\setup-x86.exe -q -R C:\cygwin -l C:\Windows\Temp --packages "wget,zip,screen" -s http://cygwin.mirror.constant.com</CommandLine>
                    <Description>Install Cygwin</Description>
                    <Order>99</Order>
                    <RequiresUserInput>true</RequiresUserInput>
                </SynchronousCommand>

The Cygwin setup fails when "Changing gid to Administrators". The same or similar problem I experience when running a powershell script with

Start-Process "C:\Windows\Temp\setup-x86.exe" -ArgumentList "-q -R C:\cygwin -l C:\Windows\Temp --packages `"wget,zip,screen`" -s http://cygwin.mirror.constant.com" -NoNewWindow -Wait

I suspect that if I switch the uid to a regular user the setup will work - it works from the command line in the installed system after I login. I am new with PowerShell and can not figure how to do this. I will appreciate any tips.

Thanks

StefanScherer commented 6 years ago

You might want to look at https://github.com/boxcutter/windows/blob/master/eval-win10x64-enterprise-cygwin.json - there are templates with cygwin which could be useful.

larytet commented 6 years ago

Thanks - this was a great tip. Specifically https://github.com/boxcutter/windows/blob/master/floppy/cygwin.bat
I ma definitely not alone. The following was encouraging

:: Force CYGWIN_ARCH to 32-bit - 64-bit seems to crash a lot

This line works, or at least works most of the time

C:\Users\user\Downloads\setup-x86.exe -q -R C:\cygwin -s http://mirrors.kernel.org/sourceware/cygwin -P "wget,screen,cat" -a x86 -v -B -d -n -N