Spliting debian package - how to handle files correctly?
I am trying to split debian package to smaller packages.
Original package MyPackage-1.0.deb was split to few smaler packages (MyPackage-2.0.deb, MyPackage-config-2.0.deb).
The MyPackage-1.0.deb contained all files, during split I moved all files from directory /etc to package MyPackage-config-2.0.deb.
dpkg-buildpackage process was without errors.
When I try upgrade by apt-get upgrade i get this message.
Unpacking MyPackage-config (from .../MyPackage-config-2.0.deb) ... dpkg: error processing /var/cache/apt/archives/MyPackage-config-2.0.deb (--unpack): trying to overwrite '/etc/MyPackage.conf', which is also in package MyPackage 1.0 dpkg-deb: subprocess paste killed by signal (Broken pipe)
The package did not install unitil I forced it by apt-get -o Dpkg::Options::="--force-overwrite" upgrade
In file debian/control there is:
Source: MyPackage Section: metapackages Priority: optional Maintainer: Just Me <firstname.lastname@example.org> Standards-Version: 3.9.3 Build-Depends: debhelper (>= 4) Package: MyPackage Architecture: i386 Conflicts: gnumeric Pre-depends: MyPackage-config Depends: libreoffice-common Description: This package Package: MyPackage-config Essential: yes Architecture: i386 Depends: openssh-server Description: config files
How should I split packages to prevent the error?
You probably want to add these lines to MyPackage-config:
Breaks: MyPackage (<< 2.0) Replaces: MyPackage (<< 2.0)
This tells dpkg not to allow MyPackage 1.0 and MyPackage-config 2.0 to be installed at the same time (cause, obviously, they would both want to own /etc/MyPackage.conf), and also that it's ok for MyPackage-config 2.0 to take over some of the files previously owned by MyPackage 1.0.
See http://www.debian.org/doc/debian-policy/ch-relationships.html for in-depth information.
As an unrelated aside, having "Essential: yes" on MyPackage-config is probably a bad idea.