1

Here is my situation, I have two .deb installer A and B. The package B is package A's successor. For user who has already installed package A, and will install package B, I want to completely replace the package A and keep the data in ~/.A (and move to ~/.B for future use).

First, to replace old package A with new package B, I use Conflicts and Replaces options in DEBIAN/control file of package B.

Second, to keep the data in ~/.A, I write a function in preinst script of package B to check whether package A is installed. If package A is found, I move ~/.A to ~/.B. Then the new package B can use the old data of package A to perform the migration process. The steps would be:

  1. prerm of A
  2. preinst of B (check the package A and move data here)
  3. uninstallation of A
  4. postrm of A
  5. installation of B
  6. postinst of B

Everything goes well if I use dpkg to install these packages:

sudo dpkg -i package-a.deb
sudo dpkg -i package-b.deb

However, if I install the packages with Software Center (gnome-software) on Ubuntu 18.04, a problem occurs. The old package A was uninstalled before the preinst script was executed. The installation steps changed to:

  1. prerm of A
  2. uninstallation of A
  3. postrm of A
  4. preinst of B (check the package A and move data here, but everything in ~/.A was deleted)
  5. installation of B
  6. postinst of B

After some investigations, I found that gnome-sofware on Ubuntu 18.04 use packagekit as backend (which seems to use apt as backend) to install .deb files. And I used the following apt command to install the package and the same problem occurred!

Note: this apt method can reproduce the problem on both Ubuntu 16.04 & 18.04

sudo apt install ./package-a.deb
sudo apt install ./package-b.deb

This problem has been bothering me for a few weeks and there has been no good solution. It is still not possible to replace the old package and move the old data at the same time. Any suggestions are welcome.

migrated from stackoverflow.com Jan 16 at 1:36

This question came from our site for professional and enthusiast programmers.

  • Reading between the lines, seems like you have an improper rule that deletes files from ~. That's unwise, and will get the package rejected from Debian and similar repos. Home dirs are one of the few exceptions from idempotence. – user535733 Jan 16 at 2:48
  • @user535733 What does the improper rule mean? I actually use the full path instead of the ~/xxx path to move the data. – Allen Yang Jan 16 at 2:54
  • dpkg must not remove files in /etc on a normal 'remove' - a 'purge' is required. dpkg must not, under any circumstances, remove any file in /home. Installed packages can manipulate files in /home and /etc, but dpkg must not as part of the install or remove. – user535733 Jan 16 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.