分割 debian 软件包。他们的关系应该是怎样的?

分割 debian 软件包。他们的关系应该是怎样的?

我有foo已部署的包/usr/lib/libfoo1.so/usr/lib/libfoo2.so.

我想分成foo两个包: foo1foo2,但我无法弄清楚正确的关系。我想我想要替换整个包,强制将其删除,但这似乎只在重命名包时才有效(而不是拆分它们)。


这是我的测试debian/control

Source: libfoo
Maintainer: Stewart <[email protected]>
Build-Depends: debhelper-compat (= 11)

Package: foo
Architecture: all
Description: Old package

Package: foo1
Architecture: all
Conflicts: foo
Replaces: foo
Provides: foo

Package: foo2
Architecture: all
Conflicts: foo
Replaces: foo
Provides: foo

Package: bar
Architecture: all
Depends: foo
Description: Old rdepends, don't want this breaking

Package: baz
Architecture: all
Depends: foo1, foo2
Description: New rdepends, this needs to work too

然后测试我:

dpkg-buildpackage

# Set up an existing system
sudo dpkg -i ../foo_1.0.0_all.deb ../bar_1.0.0_all.deb

# Simulate what will happen during upgrade
sudo dpkg -i ../baz_1.0.0_all.deb ../foo1_1.0.0_all.deb ../foo2_1.0.0_all.deb

我试图得到一种情况,其中foo1foo2被安装,foo被卸载,并且barbaz都高兴。


情况{Conflicts,Replaces,Provides}: foo导致:

$ sudo dpkg -i ../foo1_1.0.0_all.deb ../foo2_1.0.0_all.deb ../baz_1.0.0_all.deb 
dpkg: regarding ../foo1_1.0.0_all.deb containing foo1:
 foo1 breaks foo
  foo (version 1.0.0) is present and installed.

dpkg: error processing archive ../foo1_1.0.0_all.deb (--install):
 installing foo1 would break foo, and
 deconfiguration is not permitted (--auto-deconfigure might help)
dpkg: regarding ../foo2_1.0.0_all.deb containing foo2:
 foo2 breaks foo
  foo (version 1.0.0) is present and installed.

dpkg: error processing archive ../foo2_1.0.0_all.deb (--install):
 installing foo2 would break foo, and
 deconfiguration is not permitted (--auto-deconfigure might help)
Preparing to unpack ../baz_1.0.0_all.deb ...
Unpacking baz (1.0.0) over (1.0.0) ...
dpkg: dependency problems prevent configuration of baz:
 baz depends on foo1; however:
  Package foo1 is not installed.
 baz depends on foo2; however:
  Package foo2 is not installed.

dpkg: error processing package baz (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 ../foo1_1.0.0_all.deb
 ../foo2_1.0.0_all.deb
 baz


我能得到的最接近的是设置{Conflicts,Replaces,Provides}:foo1,而不是 foo2。这给出:

$ sudo dpkg -i ../foo1_1.0.0_all.deb ../foo2_1.0.0_all.deb ../baz_1.0.0_all.deb 
Selecting previously unselected package baz.
(Reading database ... 538326 files and directories currently installed.)
Preparing to unpack ../baz_1.0.0_all.deb ...
Unpacking baz (1.0.0) ...
Selecting previously unselected package foo1.
dpkg: considering removing foo in favour of foo1 ...
dpkg: yes, will remove foo in favour of foo1
Preparing to unpack ../foo1_1.0.0_all.deb ...
Unpacking foo1 (1.0.0) ...
Selecting previously unselected package foo2.
Preparing to unpack ../foo2_1.0.0_all.deb ...
Unpacking foo2 (1.0.0) ...
Setting up foo1 (1.0.0) ...
Setting up foo2 (1.0.0) ...
Setting up baz (1.0.0) ...

答案1

Debian 政策提供了一个示例,其中foo分为foofoo-data。这就是这里适用的情况。

我们实际上不应该fooProvides:预期的包来替换。这是因为当添加Provides: foofoo1和 时foo2,任何一个包都会满足bar,而实际上 bar 可能依赖于foo1、 或的内容foo2,但不是任意的。因此,满足foo意味着您需要foo1AND foo2。您只能在以下情况下这样做foo Depends: foo1, foo2

所以初始的控制文件应该是这样的:

Source: libfoo
Maintainer: Stewart <[email protected]>
Build-Depends: debhelper-compat (= 11)

Package: foo
Architecture: all

Package: bar
Architecture: all
Depends: foo

从这里dpkg -i foo_1.0.0_all.deb bar_1.0.0_all.deb开始设置您的初始条件。然后将控制文件更改为:

Source: libfoo
Maintainer: Stewart <[email protected]>
Build-Depends: debhelper-compat (= 11)

Package: foo
Architecture: all
Depends: foo1, foo2

Package: foo1
Architecture: all
Breaks: foo (<< 1.1)
Replaces: foo (<< 1.1)

Package: foo2
Architecture: all
Breaks: foo (<< 1.1)
Replaces: foo (<< 1.1)

Package: baz
Architecture: all
Depends: foo1, foo2

然后构建这个,你会发现当你安装/升级、、、foo和时,它们都会正确安装,并且不会破坏。foo1foo2bazbar

相关内容