Why?

Sometimes, it is necessary for a package to get a new name. Although this should rather seldom be the case, there are some situations when it makes sense, for example when the name of the upstream application changes. Of course an apt-get dist-upgrade should still seamlessly upgrade the package, best by completely removing the old package and installing the new one as a replacement.

Basically, the solution is to define a binary dummy package with the same name as the old package in the control file of the new package. The new source package takes over the binary dummy package, and the old source package, which is then binaryless, will be cleaned up by rene, an archive cleanup tool.

Method A

Assume that the last upstream version of the old package "oldPkg" was 1.5 and the package was renamed to "newPkg" for version 2.0.

Then, the dummy package is defined like this in debian/control:

 Package: oldPkg
 Depends: newPkg
 Architecture: all
 Description: transitional dummy package

This entry defines the binary dummy package. It will get version 2.0-1 and automatically be pulled in by an apt-get dist-upgrade if an earlier version of oldPkg was already installed.

The package only installs the mandatory files in /usr/share/doc/oldPkg.

Since it depends on newPkg, it also installs the new package.

Note that the package does not contain any architecture specific files anymore and therefore the Architecture is set to "All", even if it was "Any" before.

The new package is defined like this:

 Package: newPkg
 Provides: oldPkg
 Replaces: oldPkg (<< 2.0-1)
 Conflicts: oldPkg (<< 2.0-1)

The Provides: entry makes sure that reverse dependencies do net get broken so that other packages which depend on the old unversioned package name can still be installed.

Please make sure not to forget the Debian-revision of the first renamed version which entered/will enter the archive in the Replaces: and Conflicts: line unless you want to stumble across bugs like #397993.

Method B (NOT CURRENTLY APPLICABLE)

There is an even more elegant way which installs less files and effectively provides a real replacement mechanism.

The dummy package is defined like this in debian/control:

 Package: oldPkg
 Depends: newPkg
 Architecture: all
 Description: transitional dummy package

The dummy package only installs a link (and nothing else!) like /usr/share/doc/oldPkg -> /usr/share/doc/newPkg, for example with the dh_link debhelper script.

The new package is defined like this in debian/control:

 Package: newPkg
 Provides: oldPkg
 Replaces: oldPkg
 Conflicts: oldPkg (<< 2.0)

The new package installs all its necessary files, and the same link as the dummy package, /usr/share/doc/oldPkg -> /usr/share/doc/newPkg

Now, when an earlier version of the oldPkg is installed and the system is upgraded with apt-get dist-upgrade, the new version of the dummy package is installed which pulls in the new package newPkg. The link is then taken over by newPkg, so that no installed files remain for the old dummy package oldPkg. dpkg is aware of this situation and notices that oldPkg is now completely replaced.

However, through a bug in dpkg, it tries to configure the old dummy package at a later time, which fails because the package was already removed. Thus, at least for etch, this approach can not be used. (Still doesn't work for sid as of today -- 2008-01-12. ?GregorHerrmann ; It seems to be working properly since at least Lenny, but this Provides/Replaces/Conflicts combination doesn't seem to trigger the old package vanishing -- 2009-12-18. ?MikeHommey)