What happens with package when I upgrade rather than removing and reinstalling? What is the real difference between the two? How will the results differ?Are following two options equal (by package preinst/postint/prerm/postrm steps) ?apt-get updateapt-get remove <packagename>apt-get install <packagename>andapt-get updateapt-get install --only-upgrade <packagename>Can you handle upgrade command specially? Is it possible to make a handler for upgrade instead of deleting and installing?
What exactly happens when I exec apt-get upgrade?
apt
Upgrading a package is not the same thing as removing and then installing it. Upgrading takes care to minimize the time during which the package isn't fully operational, whereas removing then installing leaves a window during which none of the package's files are present. Apart from that, they don't run the same maintainer scripts: upgrading runs the maintainer scripts (old prerm, new preinst, old postrm, new postinst) with the upgrade action, whereas removing then reinstalling runs old prerm remove, old postrm remove, new preinst install, new postinst configure. See the Debian policy manual for details, or the wiki for diagrams.If you're making deb packages and you want to do something special on an upgrade, do it for the upgrade action of the relevant maintainer script (usually postinst to upgrade configuration files and restart daemons).