Cleanup package scripts
- Remove the use of posttrans script for RPMs. We can handle them in postinst itself using value of
$1
- Run the postinst script only if it is a successful install/upgrade. For DEB based distros, that means
$1
will beconfigure
. For RPM based distros that means$1
will be1
or2
for install and upgrade respectively. This is needed because DEB-based and RPM-based distros handle failure of preinst differently. In RPM based distros, if%pre
script fails, the installation/upgrade is aborted. However, in DEB-based distros, ifpreinst
fails, the execution moves aspreinst
=>postrm abort-upgrade
=>postinst abort-upgrade
. That means, even if preinst fails, postinst is being called. So the stuff in postinst script gets executed even if preinst fails. Moving them to inside the conditional will fix it.
References:
- https://fedoraproject.org/wiki/Packaging:Scriptlets
- https://www.debian.org/doc/debian-policy/#maintainer-script-flowcharts
Tests:
-
CentOS 6 -
Fresh Installation -
Upgrade from already installed package
-
-
CentOS 7 -
Fresh Installation -
Upgrade from already installed package
-
-
Debian 7 -
Fresh Installation -
Upgrade from already installed package
-
-
Debian 8 -
Fresh Installation -
Upgrade from already installed package
-
-
Debian 9 -
Fresh Installation -
Upgrade from already installed package
-
-
OpenSUSE 42.2 -
Fresh Installation -
Upgrade from already installed package
-
-
Ubuntu 14.04 -
Fresh Installation -
Upgrade from already installed package
-
-
Ubuntu 16.04 -
Fresh Installation -
Upgrade from already installed package
-
Edited by Balasankar 'Balu' C