Ubuntu – What happens during a package upgrade

aptdebpackage-managementpackaging

I recently started building Ubuntu packages for my software on Launchpad. They are pretty simple; most of them just contain some files and scripts that are trigged through the .install .preinst .postinst .prerm and .postrm files. Installation and removing seems to work OK. However, upgrading from one version to the next is tricky.

What exactly happens when a package is being upgraded? Is it the same thing as uninstalling the previous version and installing the new version? Are all the files from the previous packages removed, and replaced with the files in the .install list from the new package? Are all of the .prerm, postrm, preinst, postinst scripts executed? How do I distinguish stuff that should only happen during a 'new install' and an upgrade?

Best Answer

The debian wiki is pretty much usefull to understand the process (which is explained in details here).

For example :

  • the case of a simple installation of package

    enter image description here

    • the case of a the upgrade of a package

enter image description here