如何从命令行安装 cygwin 组件?

发布于 2025-01-04 15:46:04 字数 75 浏览 1 评论 0 原文

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

Is there a tool in the Cygwin package similar to apt-get on Debian or yum on redhat that allows me to install components from the command line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

小ぇ时光︴ 2025-01-11 15:46:04

Cygwin 的安装程序接受命令行参数从命令行安装软件包。

例如 setup-x86.exe -q -P packagename1,packagename2 无需任何 GUI 交互即可安装软件包(“无人值守安装模式”)。

(请注意,您需要根据需要使用 setup-x86.exesetup-x86_64.exe。)

请参阅 https://cygwin.com/packages/ 查看软件包列表。

Cygwin's setup accepts command-line arguments to install packages from the command-line.

e.g. setup-x86.exe -q -P packagename1,packagename2 to install packages without any GUI interaction ('unattended setup mode').

(Note that you need to use setup-x86.exe or setup-x86_64.exe as appropriate.)

See https://cygwin.com/packages/ for the package list.

探春 2025-01-11 15:46:04

为了更方便的安装程序,您可能需要使用
apt-cyg 作为您的包管理器。其语法类似于
apt-get,这是一个优点。为此,请遵循上述
步骤,然后使用 Cygwin Bash 执行以下步骤

wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin

现在 apt-cyg 已安装。以下是一些例子
安装一些包

apt-cyg install nano
apt-cyg install git
apt-cyg install ca-certificates

For a more convenient installer, you may want to use
apt-cyg as your package manager. Its syntax similar to
apt-get, which is a plus. For this, follow the above
steps and then use Cygwin Bash for the following steps

wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
chmod +x apt-cyg
mv apt-cyg /usr/local/bin

Now that apt-cyg is installed. Here are few examples of
installing some packages

apt-cyg install nano
apt-cyg install git
apt-cyg install ca-certificates
忘你却要生生世世 2025-01-11 15:46:04

“setup.exe”安装程序中没有专门提供以下功能的工具
apt-get 的功能。但是,有一个命令行包安装程序
Cygwin 可以单独下载,但它并不完全稳定,
依赖于解决方法。

apt-cyg: http://github.com/transcode-open/apt-cyg

查看项目的问题选项卡以查看已知问题。

There is no tool specifically in the 'setup.exe' installer that offers the
functionality of apt-get. There is, however, a command-line package installer
for Cygwin that can be downloaded separately, but it is not entirely stable and
relies on workarounds.

apt-cyg: http://github.com/transcode-open/apt-cyg

Check out the issues tab for the project to see the known problems.

半世蒼涼 2025-01-11 15:46:04

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

安装或删除软件包很好,Cygwin 的每个软件包管理器都可以做到这一点。但更新很痛苦,因为 Windows 不允许您覆盖当前正在运行的可执行文件。因此,您无法更新 Cygwin DLL 或任何包含 Cygwin 本身当前运行的可执行文件的包。 Cygwin Installation 页面上还有此注释:

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

Cygwin 的安装程序使用 Windows 注册表来覆盖正在使用的可执行文件
并且此方法需要重新启动Windows。因此,最好关闭
更新软件包之前的所有 Cygwin 进程
,因此您不必重新启动
您的计算机实际应用更改。安装新包
应该完全没有任何麻烦。我认为没有任何包管理器
除了 Cygwin 的 setup.exe 实现任何覆盖正在使用的文件的方法之外,
所以如果它不能覆盖它们,它就会失败。


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进行安装。


Chocolatey 的 cyg-get

如果您使用 Chocolatey 安装 Cygwin,则可以安装该软件包 cyg-get,它实际上是用 PowerShell 编写的 Cygwin setup.exe 的简单包装。


Cygwin 的 setup.exe

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

使用示例:

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

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

alias cyg-get="/cygdrive/d/path/to/cygwin/setup-x86_64.exe -q -P"

然后例如,您可以使用以下命令安装 Vim 软件包:

cyg-get vim

There exist some scripts, which can be used as simple package managers for Cygwin. But it’s important to know, that they always will be quite limited, because of...ehm...Windows.

Installing or removing packages is fine, each package manager for Cygwin can do that. But updating is a pain since Windows doesn’t allow you to overwrite an executable, which is currently running. So you can’t update e.g. Cygwin DLL or any package which contains the currently running executable from the Cygwin itself. There is also this note on the Cygwin Installation page:

"The basic reason for not having a more full-featured package manager is that
such a program would need full access to all of Cygwin’s POSIX functionality.
That is, however, difficult to provide in a Cygwin-free environment, such as
exists on first installation. Additionally, Windows does not easily allow
overwriting of in-use executables so installing a new version of the Cygwin
DLL while a package manager is using the DLL is problematic."

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.


Some package managers for Cygwin:

apt-cyg

Update: the repository was disabled recently due to copyright issues (DMCA takedown). It looks like the owner of the repository issued the DMCA takedown on his own repository and created a new project called Sage (see bellow).

The best one for me. Simply because it’s one of the most recent. It doesn’t use Cygwin’s setup.exe, it rather re-implements, what setup.exe does. It works correctly for both platforms - x86 as well as x86_64. There are a lot of forks with more or less additional features. For example, the kou1okada fork is one of the improved versions, which is really great.

apt-cyg is just a shell script, there is no installation. Just download it (or clone the repository), make it executable and copy it somewhere to the 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

There is also bunch of forks with different features.


sage

Another package manager implemented as a shell script. I didn't try it but it actually looks good.

It can search for packages in a repository, list packages in a category, check dependencies, list package files, and more. It has features which other package managers don't have.


cyg-apt

Fork of abandoned original cyg-apt with improvements and bugfixes. It has quite a lot of features and it's implemented in Python. Installation is made using make.


Chocolatey’s cyg-get

If you used Chocolatey to install Cygwin, you can install the package cyg-get, which is actually a simple wrapper around Cygwin’s setup.exe written in PowerShell.


Cygwin’s setup.exe

It also has a command line mode. Moreover, it allows you to upgrade all installed packages at once (as apt-get upgrade does on Debian based Linux).

Example use:

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

You can create an alias for easier use, for example:

alias cyg-get="/cygdrive/d/path/to/cygwin/setup-x86_64.exe -q -P"

Then you can, for example, install Vim package with:

cyg-get vim

白况 2025-01-11 15:46:04

首先,下载安装程序:https://cygwin.com/setup-x86_64.exe(Windows 64位),那么:

# 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

First, download installer at: https://cygwin.com/setup-x86_64.exe (Windows 64bit), then:

# 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

e.g.

# install vim
cygwin vim

# see other options
cygwin --help
静待花开 2025-01-11 15:46:04

我想要一个类似于 apt-get --print-uris 的解决方案,但不幸的是 apt-cyg 不这样做。以下是一个解决方案,允许我仅下载我需要的包及其依赖项,并将它们复制到目标进行安装。下面是一个 bash 脚本,它将 apt-cyg 的输出解析为 URI 列表:

#!/usr/bin/bash

package=$1
depends=$( \
    apt-cyg depends $package \
    | perl -ne 'while ($x = /> ([^>\s]+)/g) { print "$1\n"; }' \
    | sort \
    | uniq)
depends=$(echo -e "$depends\n$package")
for curpkg in $depends; do
    if ! grep -q "^$curpkg " /etc/setup/installed.db; then
    apt-cyg show $curpkg \
        | perl -ne '
            if ($x = /install: ([^\s]+)/) { 
                print "$1\n"; 
            }
            if (/\[prev\]/) { 
                exit; 
            }'
    fi
done

上面将打印出需要下载的包的路径,相对于 cygwin 镜像根目录,省略任何包已经安装的。为了下载它们,我将输出写入文件 cygwin-packages-list ,然后使用 wget:

mirror=http://cygwin.mirror.constant.com/
uris=$(for line in $(cat cygwin-packages-list); do echo "$mirror$line"; done)
wget -x $uris

然后可以使用安装程序从本地缓存目录进行安装。请注意,为此,我需要将 setup.ini 从以前的 cygwin 包缓存复制到包含下载文件的目录(否则安装程序不知道是什么)。

I wanted a solution for this similar to apt-get --print-uris, but unfortunately apt-cyg doesn't do this. The following is a solution that allowed me to download only the packages I needed, with their dependencies, and copy them to the target for installation. Here is a bash script that parses the output of apt-cyg into a list of URIs:

#!/usr/bin/bash

package=$1
depends=$( \
    apt-cyg depends $package \
    | perl -ne 'while ($x = /> ([^>\s]+)/g) { print "$1\n"; }' \
    | sort \
    | uniq)
depends=$(echo -e "$depends\n$package")
for curpkg in $depends; do
    if ! grep -q "^$curpkg " /etc/setup/installed.db; then
    apt-cyg show $curpkg \
        | perl -ne '
            if ($x = /install: ([^\s]+)/) { 
                print "$1\n"; 
            }
            if (/\[prev\]/) { 
                exit; 
            }'
    fi
done

The above will print out the paths of the packages that need downloading, relative to the cygwin mirror root, omitting any packages that are already installed. To download them, I wrote the output to a file cygwin-packages-list and then used wget:

mirror=http://cygwin.mirror.constant.com/
uris=$(for line in $(cat cygwin-packages-list); do echo "$mirror$line"; done)
wget -x $uris

The installer can then be used to install from a local cache directory. Note that for this to work I needed to copy setup.ini from a previous cygwin package cache to the directory with the downloaded files (otherwise the installer doesn't know what's what).

杯别 2025-01-11 15:46:04

老问题,但仍然相关。这是今天对我有用的方法(2016 年 6 月 26 日)。

从 bash shell 中:

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

Old question, but still relevant. Here is what worked for me today (6/26/16).

From the bash shell:

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin
指尖微凉心微凉 2025-01-11 15:46:04

Dawid Ferenczy 的答案相当完整,但在我尝试了他几乎所有的选项后,我发现 Chocolatey 的 cyg- get 是最好的(至少是我能开始工作的唯一一个)。

我想安装wget,步骤是这样的:

choco install cyg-get

然后:

cyg-get wget

Dawid Ferenczy's answer is pretty complete but after I tried almost all of his options I've found that the Chocolatey’s cyg-get was the best (at least the only one that I could get to work).

I was wanting to install wget, the steps was this:

choco install cyg-get

Then:

cyg-get wget
薯片软お妹 2025-01-11 15:46:04

通常在安装软件包之前必须知道它的确切名称:

# 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>>"

Usually before installing a package one has to know its exact 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>>"
忘你却要生生世世 2025-01-11 15:46:04

如果您通过 Chocolatey 安装了 cygwin,则可以使用特殊的 替代源

choco install -y packagename1 packagename2 packagename3 --source=cygwin

替代来源 - Cygwin
这指定源是 Cygwin 并且我们正在安装 cygwin 软件包,例如 bash。如果您没有安装 Cygwin,它将首先安装 Cygwin,然后再安装请求的产品。例如 choco install bash --source cygwin

If you have cygwin installed via chocolatey, you could use special alternative sources:

choco install -y packagename1 packagename2 packagename3 --source=cygwin

Alternative Source - Cygwin
This specifies the source is Cygwin and that we are installing a cygwin package, such as bash. If you do not have Cygwin installed, it will install that first and then the product requested. e.g. choco install bash --source cygwin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文