Cygwin包中是否有类似于Debian上的apt-get或redhat上的yum的工具,允许我从命令行安装组件?


当前回答

通常在安装一个包之前,你必须知道它的确切名称:

# define a string to search
export to_srch=perl

# get html output of search and pick only the cygwin package names
wget -qO- "https://cygwin.com/cgi-bin2/package-grep.cgi?grep=$to_srch&arch=x86_64" | \
perl -l -ne 'm!(.*?)<\/a>\s+\-(.*?)\:(.*?)<\/li>!;print $2'

# and install 
# install multiple packages at once, note the
setup-x86_64.exe -q -s http://cygwin.mirror.constant.com -P "<<chosen_package_name>>"

其他回答

通常在安装一个包之前,你必须知道它的确切名称:

# define a string to search
export to_srch=perl

# get html output of search and pick only the cygwin package names
wget -qO- "https://cygwin.com/cgi-bin2/package-grep.cgi?grep=$to_srch&arch=x86_64" | \
perl -l -ne 'm!(.*?)<\/a>\s+\-(.*?)\:(.*?)<\/li>!;print $2'

# and install 
# install multiple packages at once, note the
setup-x86_64.exe -q -s http://cygwin.mirror.constant.com -P "<<chosen_package_name>>"

首先,在https://cygwin.com/setup-x86_64.exe (Windows 64bit)下载安装程序,然后:

# move installer to cygwin folder
mv C:/Users/<you>/Downloads/setup-x86_64.exe C:/cygwin64/

# add alias to bash_aliases
echo "alias cygwin='C:/cygwin64/setup-x86_64.exe -q -P'" >> ~/.bash_aliases
source ~/.bash_aliases

# add bash_aliases to bashrc if missing
echo "source ~/.bash_aliases" >> ~/.profile

如。

# install vim
cygwin vim

# see other options
cygwin --help

有一些脚本可以用作Cygwin的简单包管理器。但重要的是要知道,它们总是非常有限的,因为……嗯……Windows。

安装或删除包是很好的,Cygwin的每个包管理器都可以做到这一点。但是更新是一件痛苦的事情,因为Windows不允许你覆盖当前正在运行的可执行文件。因此,您不能更新例如Cygwin DLL或任何包含当前运行的Cygwin本身的可执行文件的包。在Cygwin安装页面上也有这样的说明:

“没有一个功能更全的包管理器的基本原因是 这样的程序需要完全访问Cygwin的所有POSIX功能。 然而,这在无cygwin的环境中很难提供,例如 第一次安装时存在。此外,Windows不容易允许 覆盖正在使用的可执行文件,从而安装新版本的Cygwin 当包管理器使用DLL时,DLL是有问题的。”

Cygwin’s setup uses Windows registry to overwrite executables which are in use and this method requires a reboot of Windows. Therefore, it’s better to close all Cygwin processes before updating packages, so you don’t have to reboot your computer to actually apply the changes. Installation of a new package should be completely without any hassles. I don’t think any of package managers except of Cygwin’s setup.exe implements any method to overwrite files in use, so it would simply fail if it cannot overwrite them.


Cygwin的一些包管理器:

apt-cyg

更新:仓库最近由于版权问题被禁用(DMCA下架)。看起来像是存储库的所有者在他自己的存储库上发布了DMCA删除命令,并创建了一个名为Sage的新项目(见下文)。

对我来说最好的。因为它是最近的一种。它没有使用Cygwin的setup.exe,而是重新实现了setup.exe的功能。它适用于x86和x86_64两种平台。有许多带有或多或少附加特性的分支。例如,kou1okada fork就是其中的一个改进版本,它真的很棒。

Apt-cyg只是一个shell脚本,不需要安装。只需下载它(或克隆存储库),使其可执行,并将其复制到PATH:

chmod +x apt-cyg # set executable bit
mv apt-cyg /usr/local/bin # move somewhere to PATH
# ...and use it:
apt-cyg install vim

也有一些具有不同功能的分支。


sage

另一个作为shell脚本实现的包管理器。我没试过,不过看起来不错。

它可以在存储库中搜索包、在类别中列出包、检查依赖关系、列出包文件等等。它具有其他包管理器不具备的特性。


cyg-apt

分叉的废弃原始cyg-apt与改进和错误修复。它有很多特性,而且是用Python实现的。使用make进行安装。


巧克力色的cyg-get

如果您使用Chocolatey来安装Cygwin,那么您可以安装cyg-get包,它实际上是一个简单的包装器,包装了用PowerShell编写的Cygwin setup.exe。


Cygwin的setup . exe

它还有一个命令行模式。此外,它允许您一次升级所有已安装的包(就像apt-get upgrade在基于Debian的Linux上所做的那样)。

使用示例:

setup-x86_64.exe -q --packages=bash,vim

你可以创建一个别名以方便使用,例如:

别名cygdrive/d/path/to/cygwin/setup-x86_64.exe -q -P

然后你可以,例如,安装Vim包:

天鹅座-获取 VIM

Dawid Ferenczy的答案非常完整,但在我尝试了他几乎所有的选择后,我发现Chocolatey的cyg-get是最好的(至少是我唯一能找到的)。

我想安装wget,步骤如下:

choco install cyg-get

然后:

cyg-get wget

老问题了,但仍然相关。以下是今天对我有效的方法(6/26/16)。

来自bash shell:

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin