设置 apt-get 选项以容忍无害的 'dpkg --force-conflicts' kludge?

agc*_*agc 7 linux debian dpkg apt package-management

一个平凡的冲突的包foo的,可向工作与酒吧,通过运行dpkg --force-conflicts -i foo。但最终是时候升级了,'apt-get' 对象:

% apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 foo : Conflicts: bar but 0.2-1 is installed
E: Unmet dependencies. Try using -f.
Run Code Online (Sandbox Code Playgroud)

可以调整/强制apt-get来容忍(几乎固定的)冲突,然后升级吗?

(快速存在证明:卸载foo,然后升级,然后像以前一样重新安装foo。因此可能,问题是找到最不麻烦的机制。)


一个例子,但这个问题不是关于任何两个特定的包。

几年来,GNU parallelmoretutils发生了微不足道的冲突;每个都提供/usr/bin/paralleldpkg可以强制共存:

# assume 'moreutils' is already installed, and 'parallel' is in
# apt's cache directory.
dpkg --force-conflicts -i /var/cache/apt/archives/parallel_20141022+ds1-1_all.deb
Run Code Online (Sandbox Code Playgroud)

这会创建一个转移,将moreutils版本重命名为/usr/bin/parallel.moreutils。两个程序都可以工作,直到用户升级。

我尝试了-o选项,但这并没有带来和平:

apt-get -o Dpkg::Options::="--force-conflicts" install parallel moreutils
Run Code Online (Sandbox Code Playgroud)

可能的-o选项有数百个,但是......

phk*_*phk 6

由于 OP 在对 Gilles 的回答的评论中要求提供命令列表(用于更改包的相关元数据),因此这里是:

# download .deb
apt download parallel
# alternatively: aptitude download parallel

# unpack
dpkg-deb -R parallel_*.deb tmp/

# make changes to the package metadata
sed -i \
  -e '/^Version:/s/$/~nomoreutconfl/' \
  -e '/^Conflicts: moreutils/d' \
  tmp/DEBIAN/control

# pack anew
dpkg-deb -b tmp parallel_custom.deb

# install
dpkg -i parallel_custom.deb
Run Code Online (Sandbox Code Playgroud)

这是在冲突行仅moreutils作为条目(并且没有版本限制)与我的安装情况一样的假设下。否则,'/^Conflicts:/s/\(, \)\?moreutils\( [^,]\+\)\?//'作为第二个sed脚本使用,只删除该行的相关部分并支持版本限制。

您已安装的软件包不会被存储库中的较新版本覆盖,如果您想使此软件包保持最新,则必须为 GNU 并行软件包的每次更新手动重复此过程。