如何从 Cygwin 的命令行更新 Cygwin?

Pav*_*sov 81 cygwin updates

要搜索和下载 Cygwin 中遗漏的包,我需要每次运行 setup.exe GUI,多次单击并执行其他无聊的操作。

有没有办法直接从 Cygwin 的命令行执行相同的操作?就像 apt-get 工具一样。

icy*_*com 42

看看这里:

除了其他事项外,它还提供了以下选项列表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
Run Code Online (Sandbox Code Playgroud)

所以setup.exe -P <package name>应该做这项工作。这里没有 cygwin,所以测试它以确认它按预期工作。

要搜索包,请按:

你可以使用cygcheck -p

  cygcheck -p REGEXP
  ...
  -p, --package-query  search for REGEXP in the entire cygwin.com package
                       repository (requires internet connectivity)
Run Code Online (Sandbox Code Playgroud)

产生类似的输出(来自上述站点的示例):

$ 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
Run Code Online (Sandbox Code Playgroud)

  • 警告:如果更新替换了 `cygwin1.dll`,Cygwin 程序将开始运行不正常,并且 Cygwin 文档建议重新启动。所以最好关闭所有 Cygwin 程序,然后直接从 `cmd` 运行 `setup.exe`(如果你想自动化,使用批处理文件,而不是 shell 脚本)。 (9认同)

小智 25

这将对 64 位的所有 Cygwin 组件执行无人值守升级:

cd C:\cygwin
wget -N https://cygwin.com/setup-x86_64.exe
setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode
Run Code Online (Sandbox Code Playgroud)

这将对 32 位的所有 cygwin 组件执行无人值守升级:

cd C:\cygwin
wget -N https://cygwin.com/setup-x86.exe
setup-x86.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode
Run Code Online (Sandbox Code Playgroud)

您应该在升级完成后重新启动,以防止 Cygwin 应用程序因升级而出现异常行为cygwin1.dll

  • --no-desktop 禁止创建桌面快捷方式
  • --no-shortcuts 禁止创建桌面和开始菜单
  • --no-startmenu 禁止创建开始菜单快捷方式
  • --quiet-mode 无人值守设置模式


Chr*_*ruk 10

另一种解决方案是使用GitHub 上提供的apt-cyg脚本

  • 我认为它不支持升级 cygwin 本身。 (3认同)

Ski*_*man 7

Cygwin 设置的位置似乎发生了变化和分裂。现在你需要

wget http://cygwin.com/setup-x86.exe
Run Code Online (Sandbox Code Playgroud)

或者

wget http://cygwin.com/setup-x86_64.exe
Run Code Online (Sandbox Code Playgroud)


Sop*_*rez 5

所述安装程序允许它从命令行(升高壳,请):

setup-x86.exe --root c:\cygwin -q --upgrade-also
Run Code Online (Sandbox Code Playgroud)

对于 64 位版本:

setup-x86_64.exe --root c:\cygwin -q --upgrade-also
Run Code Online (Sandbox Code Playgroud)

细节:

  • 替换c:\cygwin为您的 CygWin 的根安装目录。
  • 建议关闭任何 CygWin shell 或程序(即:net stop sshd如果您安装了 OpenSSH)。
  • 该参数-q不是强制性的。

通过 GUI(DOS shell)或什至在远程控制台(SSH 或 telnet)上工作。未在 PowerShell 上测试(有人做过?)。

正确更新输出示例

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
Run Code Online (Sandbox Code Playgroud)

如果在更新过程中遇到以下问题

The following DLLs couldn't be rebased due to errors:
  /usr/bin/cygcrypt-0.dll
Run Code Online (Sandbox Code Playgroud)

或者:

The following DLLs couldn't be rebased because they were in use:
  /usr/bin/cygcrypt-0.dll
Run Code Online (Sandbox Code Playgroud)

或者:

ReBaseImage (/usr/bin/cygcrypt-0.dll) failed with last error = 6
Run Code Online (Sandbox Code Playgroud)

...那么你必须在安装后重新定位:

1.- 关闭所有 CygWin 外壳、程序和服务。
2.-c:\CygWin\bin\ash.exe以管理员身份打开(提升)。
3.- 运行/bin/rebaseall

  • 如果您不是为所有用户安装(即 cygwin root 需要管理员写入...),则几乎没有理由以管理员身份或使用 --root 运行安装程序。`setup-86[_x64].exe -B` 以当前用户身份运行。如果需要,您可以稍后升级以将 cygrunsrv 安装为 Windows 服务。 (2认同)