77
34
To search and download a package missed from Cygwin I need to run setup.exe GUI each time, click many times and do other boring things.
Is there a way to do the same from Cygwin's command line directly? Like apt-get tools do.
77
34
To search and download a package missed from Cygwin I need to run setup.exe GUI each time, click many times and do other boring things.
Is there a way to do the same from Cygwin's command line directly? Like apt-get tools do.
41
Take a look here:
Aside from the other things, it gives the following list of options to setup.exe
:
Command Line Options:
-A --disable-buggy-antivirus Disable known or suspected buggy anti
virus software packages during execution.
-C --categories Specify entire categories to install
-D --download Download from internet
-d --no-desktop Disable creation of desktop shortcut
-h --help print help
-K --pubkey Path to extra public key file (gpg format)
-L --local-install Install from local directory
-l --local-package-dir Local package directory
-n --no-shortcuts Disable creation of desktop and start menu
shortcuts
-N --no-startmenu Disable creation of start menu shortcut
-O --only-site Ignore all sites except for -s
-P --packages Specify packages to install
-p --proxy HTTP/FTP proxy (host:port)
-q --quiet-mode Unattended setup mode
-r --no-replaceonreboot Disable replacing in-use files on next
reboot.
-R --root Root installation directory
-S --sexpr-pubkey Extra public key in s-expr format
-s --site Download site
-U --keep-untrusted-keys Use untrusted keys and retain all
-u --untrusted-keys Use untrusted keys from last-extrakeys
-X --no-verify Don't verify setup.ini signatures
So setup.exe -P <package name>
should do the job. Don't have cygwin right here, so test it to confirm it works as expected.
To search for a package, per:
you can use cygcheck -p
:
cygcheck -p REGEXP
...
-p, --package-query search for REGEXP in the entire cygwin.com package
repository (requires internet connectivity)
which produces output like (example from above site):
$ cygcheck -p 'libexpat.*\.a'
Found 2 matches for 'libexpat.*\.a'.
expat-1.95.7-1 XML parser library written in C
expat-1.95.8-1 XML parser library written in C
24
This performs an unattended upgrade of all cygwin components
cd C:\cygwin
wget -N https://cygwin.com/setup-x86.exe
setup-x86.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode
You should reboot after the upgrade is completed to prevent cygwin apps from misbehaving due to upgraded cygwin1.dll
--no-desktop Disable creation of desktop shortcut
--no-shortcuts Disable creation of desktop and start menu
--no-startmenu Disable creation of start menu shortcut
--quiet-mode Unattended setup mode
11I believe now you may need setup-x86_64.exe or setup-x86.exe. – drescherjm – 2014-07-30T17:10:37.850
On cygwin 2.9, I get zsh: command not found: setup.exe
, but setup exe is here. – Timo – 2017-12-17T10:40:32.097
If you're using no-shortcuts
why would you also need no-desktop
and no-startmenu
? – Hashim – 2018-03-07T00:57:36.507
Very helpful, I never knew about this. You can even specify which packages to install, which is a time saver. See here for an example: https://gist.github.com/piotrpolak/c616455f1da8dfc2d4e101afbfdcdc8d
– Sridhar Sarnobat – 2018-04-29T03:22:30.947Would you mind expanding on the answer to explain what each command does? – Raystafarian – 2013-07-27T01:32:27.200
10
An alternate solution would be to use the apt-cyg
script available on GitHub.
3It doesn't support upgrading cygwin itself, I think. – thoni56 – 2015-06-18T05:02:06.477
@ThomasNilsson why do you think that? – André Chalella – 2015-10-18T21:26:40.483
1Since you'd be running it from a shell using cygwin1.dll. Of course you could use another shell... – thoni56 – 2015-10-20T07:04:16.540
the "real" question was NOT update, but "how to install one package without using setup UI", and this is the REAL answer ... really, is a LOT better than setup -p be cuz, it WILL TELL YOU WHAT IT DOES, and not just put your faith blindly on setup – THESorcerer – 2015-10-28T16:56:55.350
7
The location for Cygwin's setup seems to have changes and split. Now you need either
wget http://cygwin.com/setup-x86.exe
or
wget http://cygwin.com/setup-x86_64.exe
i have a setup.bat with the content bin\wget.exe --timestamping http://www.cygwin.com/setup-x86_64.exe && start setup-x86_64.exe
, making sure i always run the latest installer and only download the installer if there's actually a new version (that's what --timestamping does), then the bat file starts it – hanshenrik – 2019-05-01T16:27:32.693
5
The installer allows it from command line (elevated shell, please):
setup-x86.exe --root c:\cygwin -q --upgrade-also
for 64 bits version:
setup-x86_64.exe --root c:\cygwin -q --upgrade-also
Details:
c:\cygwin
with your CygWin's root installation directory.net stop sshd
if you installed OpenSSH).-q
is not mandatory.Works via GUI (DOS shell) or even on remote console (SSH or telnet). Not tested on PowerShell (someone did?).
Example of correct updating output:
G:\Instalac\CygWin\v2.852>Starting cygwin install, version 2.852
User has backup/restore rights
Current Directory: g:\Instalac\CygWin\Packages
Could not open service McShield for query, start and stop. McAfee may not be installed, or we don't have access.
root: c:\cygwin system
Selected local directory: g:\Instalac\CygWin\Packages
net: Direct
Loaded cached mirror list
get_url_to_membuf http://cygwin.com/mirrors.lst
getUrlToStream http://cygwin.com/mirrors.lst
site: http://ftp.hawo.stw.uni-erlangen.de/cygwin/
get_url_to_membuf http://ftp.hawo.stw.uni-erlangen.de/cygwin/x86/setup.bz2
getUrlToStream http://ftp.hawo.stw.uni-erlangen.de/cygwin/x86/setup.bz2
get_url_to_membuf http://ftp.hawo.stw.uni-erlangen.de/cygwin/x86/setup.bz2.sig
getUrlToStream http://ftp.hawo.stw.uni-erlangen.de/cygwin/x86/setup.bz2.sig
Changing gid back to original
Visited: 122 nodes out of 4415 while creating dependency order.
Dependency order of packages: _autorebase base-cygwin cygwin _update-info-dir libgcc1 libiconv2 libintl8 alternatives libattr1 li
bgmp10 coreutils libstdc++6 terminfo libncursesw10 libreadline7 bash findutils sed base-files libuuid1 libblkid1 libsmartcols1 zl
ib0 util-linux bashdb zlib-devel binutils libbz2_1 bzip2 libffi6 libp11-kit0 libtasn1_6 p11-kit p11-kit-trust ca-certificates cry
pt libmpfr4 gawk editrights libpcre1 grep libsigsegv2 diffutils csih cygrunsrv popt libpopt0 cygutils cygwin-devel dash file liba
tomic1 libcloog-isl4 libgomp1 libisl10 libmpc3 libquadmath0 libssp0 w32api-headers w32api-runtime windows-default-manifest gcc-co
re libexpat1 liblzma5 libdb4.8 libgdbm4 libopenssl100 libsqlite3_0 libcharset1 libiconv libintl-devel libuuid-devel python gdb li
bargp getent groff gzip hostname info ipc-utils libncurses10 less libapr1 libiodbc2 libmysqlclient18 libcom_err2 libkrb5support0
libk5crypto3 libkrb5_3 libgssapi_krb5_2 libsasl2_3 libopenldap2_4_2 perl openssl libpq5 libaprutil1 libedit0 libproxy1 libneon27
libpipeline1 libserf1_0 login lynx make man-db mintty nano ncurses openssh procps psmisc rebase run screen subversion xz tar tzco
de vim-minimal which zsh
Changing gid to Administrators
Ending cygwin install
If, during update, you had issues like these:
The following DLLs couldn't be rebased due to errors:
/usr/bin/cygcrypt-0.dll
or:
The following DLLs couldn't be rebased because they were in use:
/usr/bin/cygcrypt-0.dll
or:
ReBaseImage (/usr/bin/cygcrypt-0.dll) failed with last error = 6
...then you must rebase after installation:
1.- Close all CygWin shell, programs and services.
2.- Open c:\CygWin\bin\ash.exe
as admin (elevated).
3.- Run /bin/rebaseall
.
1Works for me. Thanks. Need to download the latest setup-x86.exe or setup-x86_64.exe first. And using the cmd Run As Administrator – Marslo – 2017-05-26T09:20:56.737
2There's almost no reason to run setup as administrator or with --root if you are not installing for all users (i.e. where cygwin root requires admin to write to...). setup-86[_x64].exe -B
to run as current user. You can later elevate to install cygrunsrv as a windows service if needed. – cowbert – 2018-11-13T20:46:56.663
1
I felt this need too a while ago. I used to just keep the installer file downloaded so I could just run it to install, but occasionally as Cygwin would be updated, the installer file would become out of date. I ended up creating a Powershell script that auto-elevates, downloads the installer, and runs an unattended upgrade. I have it sit on my desktop and can just right-click and "Run with Powershell" and it will perform an in-place upgrade of all my Cygwin packages. The only user interaction needed is for UAC and a "Press any key to continue" prompt at the very end. It can be run from the command-line as well, though, as it is just a script.
I have had the code up here for a while: http://pastebin.com/wMRctAuL
I copied it below. I wrote it with the help of a few StackOverflow Q&As as well. :) All you have to do to be able to run it is to enable local Powershell scripts on your machine. It's a complete, Windows-native solution.
# Get the ID and security principal of the current user account
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
if ($myWindowsPrincipal.IsInRole($adminRole)) {
# We are running "as Administrator" - so change the title and background color to indicate this
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)"
$Host.UI.RawUI.BackgroundColor = "DarkBlue"
clear-host
}
else {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
exit
}
# Run your code that needs to be elevated here
(new-object System.Net.WebClient).DownloadFile('http://cygwin.com/setup-x86_64.exe','setup-x86_64.exe')
if (!$?) {
Write-Host "Something wrong happened when downloading the Cygwin installer."
Write-Host -NoNewLine "Press any key to continue..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
exit
}
$p = Start-Process .\setup-x86_64.exe -ArgumentList "--upgrade-also --quiet-mode" -wait -NoNewWindow -PassThru
if ($p.ExitCode -ne 0) {
Write-Host "Cygwin setup failed with an error!"
}
Remove-Item .\setup-x86_64.exe
Write-Host -NoNewLine "Press any key to continue..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
1
Expanding on @Johnny's answer https://superuser.com/a/624731/110335
The annoyance I faced were occasion prompts that the .ini file is from a newer version of Cygwin's setup.exe
I wrote myself the following script to self-update, and then update all that needs to, noninteractively.
cygwinSetup64.cmd
@echo on
cd /d e:\cygwin
move /y cygwinSetup-x86_64.exe setup-x86_64.exe
wget --progress=dot -S -N http://cygwin.com/setup-x86_64.exe
move /y setup-x86_64.exe cygwinSetup-x86_64.exe
cygwinSetup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode
0
Unattended upgrade
https://cygwin.com/faq.html#faq.setup.cli
setup-x86.exe -q -g
Meaning:
Command Line Options:
-q --quiet-mode Unattended setup mode
-g --upgrade-also also upgrade installed packages
0
Create a batch file such as "cygwin-update.bat" with the following contents and put it in your path:
@echo off
"%~dp0\gnubin\wget.exe" --no-check-certificate https://www.cygwin.com/setup-x86_64.exe -O C:\cygwin64\setup-x86_64.exe
cd /d C:\cygwin64
setup-x86_64.exe -q -g
9Caveat: if the update replaces
cygwin1.dll
, Cygwin programs will start to misbehave, and the Cygwin documentations recommend a reboot. So it's best to close all Cygwin programs, then runsetup.exe
directly fromcmd
(if you want to automate, use a batch file, not a shell script). – Gilles 'SO- stop being evil' – 2010-11-25T01:52:21.910Thanks! Another thing I need is the ability to search, because I don't know yet what a package I want to download. Once I'll find the full list of packages I could
grep
it at least... – Pavel Vlasov – 2010-11-25T12:18:36.607See the edit for an example. – icyrock.com – 2010-11-25T14:02:10.337