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

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

为了搜索和下载 Cygwin 中缺少的包,我每次都需要运行 setup.exe GUI,多次单击并执行其他无聊的事情。

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

答案1

请看这里:

除其他事项外,它还提供了以下选项列表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

所以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)

产生如下输出(来自上述网站的示例):

$ 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

答案2

这将对所有 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

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

cd C:\cygwin
wget -N https://cygwin.com/setup-x86.exe
setup-x86.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode

升级完成后您应该重新启动以防止 Cygwin 应用程序因升级而出现故障cygwin1.dll

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

答案3

另一种解决方案是使用apt-cyg脚本可在 GitHub 上获取。

答案4

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

setup-x86.exe --root c:\cygwin -q --upgrade-also

对于 64 位版本:

setup-x86_64.exe --root c:\cygwin -q --upgrade-also

细节:

  • 替换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

如果在更新过程中,您问题像这些:

The following DLLs couldn't be rebased due to errors:
  /usr/bin/cygcrypt-0.dll

或者:

The following DLLs couldn't be rebased because they were in use:
  /usr/bin/cygcrypt-0.dll

或者:

ReBaseImage (/usr/bin/cygcrypt-0.dll) failed with last error = 6

...那么你必须在安装后重新设置基准:

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

相关内容