让“aptitude”自动选择解决方案“安装”而不是“保留”

让“aptitude”自动选择解决方案“安装”而不是“保留”

我正在尝试自动安装软件包而不询问用户任何问题。对于以下情况,aptitude选择“保留”作为第一的解决方案,并且不安装. 我想强制aptitude选择“安装”解决方案并升级

$ sudo aptitude install -y -f --no-gui --without-recommends \
    -o Dpkg::Options::='--force-confnew' \
    -o Debug::pkgProblemResolver=yes \
    pkg_a=1.1 pkg_b=1.2

The following NEW packages will be installed:
  pkg_b{b}
0 packages upgraded, 1 newly installed, 0 to remove

The following packages have unmet dependencies:
 pkg_b : Depends: pkg_a (= 1.2) but 1.1 is installed.

The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     pkg_b [Not Installed]

如果我手动(不-y)运行上述命令,然后回答..:转到下一个解决方案),资质建议另一种解决方案:

The following actions will resolve these dependencies:

     Install the following packages:
1)     pkg_b [1.2 (stable)]

     Upgrade the following packages:
2)     pkg_a [1.1 (now, stable) -> 1.2 (stable)]

所以这个解决方案对我来说是最好的。

答案1

有效的解决方案是添加此参数:

-o Aptitude::ProblemResolver::SolutionCost='100*canceled-actions,200*removals'

通过查看发现aptitude手册。工作原理 - 我们只是增加了将要使用的解决方案的成本:

  • 不要保持, 如果可以的话安装或者升级(通过增加canceled-actions计数器)
  • 增加removals计数器,因为我们希望保留 pkgs,如果aptitude决定删除

相关内容