要搜索和下载Cygwin遗漏的软件包,我需要每次都运行setup.exe GUI,单击多次并进行其他无聊的事情。
有没有一种方法可以从Cygwin的命令行直接执行此操作?就像apt-get工具一样。
要搜索和下载Cygwin遗漏的软件包,我需要每次都运行setup.exe GUI,单击多次并进行其他无聊的事情。
有没有一种方法可以从Cygwin的命令行直接执行此操作?就像apt-get工具一样。
Answers:
在这里看看:
除了其他方面,它还提供以下选项列表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
grep
至少可以做到...
这将对所有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无人值守安装模式
zsh: command not found: setup.exe
,但是安装exe在这里。
no-shortcuts
为什么还需要no-desktop
和no-startmenu
?
另一种解决方案是使用GitHub上可用的apt-cyg
脚本。
Cygwin的安装位置似乎有所变化和分裂。现在您需要
wget http://cygwin.com/setup-x86.exe
要么
wget http://cygwin.com/setup-x86_64.exe
bin\wget.exe --timestamping http://www.cygwin.com/setup-x86_64.exe && start setup-x86_64.exe
,请确保我始终运行最新的安装程序,并且仅在实际存在新版本的情况下才下载安装程序(这是--timestamping所做的工作),然后bat文件将其启动
所述安装程序允许它从命令行(升高壳,请):
setup-x86.exe --root c:\cygwin -q --upgrade-also
对于64位版本:
setup-x86_64.exe --root c:\cygwin -q --upgrade-also
细节:
c:\cygwin
为CygWin的根安装目录。net stop sshd
如果已安装OpenSSH)。-q
不是必需的。通过GUI(DOS外壳)或什至在远程控制台(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
。
setup-86[_x64].exe -B
以当前用户身份运行。如果需要,您可以稍后将cygrunsrv提升为Windows服务。
不久前我就觉得需要这样做。我以前只是保持安装程序文件的下载状态,所以我可以运行它进行安装,但是由于Cygwin有时会被更新,因此安装程序文件会过时。我最终创建了一个Powershell脚本,该脚本会自动提升,下载安装程序并运行无人值守的升级。我将其放在桌面上,只需右键单击并“使用Powershell运行”,它将对我的所有Cygwin软件包进行就地升级。唯一需要用户交互的是UAC,并在最后提示“按任意键继续”。但是,它也可以从命令行运行,因为它只是一个脚本。
我已经在这里放置了一段时间的代码:http : //pastebin.com/wMRctAuL
我在下面复制了它。我也是在一些StackOverflow问答的帮助下编写的。:)要运行它,您要做的就是在计算机上启用本地Powershell脚本。这是一个完整的Windows本机解决方案。
# 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")
扩展@Johnny的答案https://superuser.com/a/624731/110335
我遇到的烦恼是偶尔会提示.ini文件来自Cygwin的setup.exe的较新版本。
我为自己编写了以下脚本以进行自我更新,然后非交互地更新所有需要的脚本。
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
无人值守升级
https://cygwin.com/faq.html#faq.setup.cli
setup-x86.exe -q -g
含义:
Command Line Options:
-q --quiet-mode Unattended setup mode
-g --upgrade-also also upgrade installed packages
cygwin1.dll
,Cygwin程序将开始出现异常,并且Cygwin文档建议重新启动。因此,最好关闭所有Cygwin程序,然后setup.exe
直接从中运行cmd
(如果要自动化,请使用批处理文件,而不是Shell脚本)。