简体   繁体   English

管理Chocolatey软件包依赖关系

[英]Manage Chocolatey package dependencies

I am new to Chocolatey and I installed zulu as an alternative to Oracle Java ( choco install zulu ). 我是Chocolatey的新手,我安装了zulu作为Oracle Java的替代产品( choco install zulu )。 Then I installed an app requiring Java choco install pdfsam.install , which installed Oracle JRE as a dependency. 然后,我安装了一个需要Java choco install pdfsam.install的应用程序,该应用程序将Oracle JRE安装为依赖项。 I thought to be smart and, later, I tried to choco uninstall javaruntime . 我以为很聪明,后来我尝试选择choco uninstall javaruntime But I got an error "because 'pdfsam.install 3.3.2' depends on it.". 但是我收到一个错误“因为'pdfsam.install 3.3.2'取决于它。”。

By reading the commands' help, I saw the install switch --ignore-dependencies and the uninstall switch --force-dependencies and --force . 通过阅读命令的帮助,我看到了安装开关--ignore-dependencies和卸载开关--force-dependencies--force
The first two are clear. 前两个很清楚。 So I could: 所以,我可以:

choco uninstall pdfsam.install --force-dependencies
choco install pdfsam.install --ignore-dependencies

As regards --force , it is unclear what it does and its use is kind of discouraged: 至于--force ,目前尚不清楚它的作用,并且不鼓励使用它:

--force - 力
Force - force the behaviour. 强制-强制行为。 Do not use force during normal operation - it subverts some of the smart behaviour for commands. 在正常操作期间不要用力-这会破坏命令的某些智能行为。

It could mean uninstall a package even if another package depends on it. 这可能意味着卸载一个软件包,即使另一个软件包依赖于该软件包。 (who knows?) (谁知道?)

My questions are: 我的问题是:

  1. What if I run a routine choco upgrade all to removed dependencies? 如果我运行常规的choco upgrade all程序以删除choco upgrade all依赖项怎么办?
  2. My app is just an example. 我的应用只是一个例子。 Beyond JRE an app might have other non-ignorable dependencies. 除JRE之外,应用程序可能还具有其他不可忽略的依赖关系。 Can I selectively ignore dependencies? 我可以选择性地忽略依赖项吗?

When you first install, you will want to use --ignore-depdendencies (or on an upgrade specified explicitly), then turn on useRememberedArgumentsForUpgrades feature. 首次安装时,您将要使用--ignore-depdendencies (或明确指定的升级),然后启用useRememberedArgumentsForUpgrades功能。 Then when you upgrade, it may continue to ignore dependencies (as long as that is not one of the switches that is ignored). 然后,在升级时,它可能会继续忽略依赖项(只要不是被忽略的开关之一)。

If it is not one you find is ignored, file a ticket at https://github.com/chocolatey/choco/issues/new to have us add it as an enhancement. 如果不是您发现的人,请在https://github.com/chocolatey/choco/issues/new上提交票证,以使我们将其添加为增强功能。

When you force-uninstall a dependency project, this dependency will be re-installed once the depending project gets updated. 当您强制卸载依赖项项目时,依赖项一旦更新,此依赖项将重新安装。

as example: 例如:

a package 'foo' depends on a package 'bar' you decide to install foo, therefore bar gets installed too. 软件包“ foo”取决于您决定安装foo的软件包“ bar”,因此bar也需要安装。

now you can force-uninstall bar, but foo still stays installed (choco uninstall bar --force). 现在您可以强制卸载bar,但foo仍保持安装状态(choco卸载bar --force)。 as soon as you update foo, iff it still has the dependency on bar, bar will get installed again. 一旦您更新foo,如果它仍然对bar有依赖关系,bar将重新安装。

sample command sequence: 示例命令序列:

choco install foo

  • foo and bar get installed 安装foo和bar

choco uninstall bar

  • bar won't uninstall and print a message foo depends on it 栏将不会卸载并显示消息foo取决于它

choco uninstall bar --force

  • forces bar to uninstall (if foo still works correctly or not depends on the package, no way to tell for some unknown package) 强制删除栏(如果foo仍然可以正常工作或是否依赖于软件包,则无法判断某些未知软件包)

choco upgrade foo

  • this will upgrade foo (if a newer version exists) and ensures all dependencies are met - therefore bar will be installed again 这将升级foo(如果存在较新的版本)并确保满足所有依赖关系-因此将再次安装bar

I've put together a gist with the required nuspecs and the output for this example: https://gist.github.com/mwallner/b10bcd6ccd1f7b3d65a56a06c8c8aa0a 我已经将要点与所需的nuspec和此示例的输出放在一起: https ://gist.github.com/mwallner/b10bcd6ccd1f7b3d65a56a06c8c8aa0a

as for your second question, I don't know if it's possible to selectively ignore dependecies, maybe ferventcoder can help here. 至于第二个问题,我不知道是否可以有选择地忽略依赖,ferventcoder可以在这里提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM