Skip to content

Cleanup package scripts

Balasankar C requested to merge cleanup-package-scripts into master
  1. Remove the use of posttrans script for RPMs. We can handle them in postinst itself using value of $1
  2. Run the postinst script only if it is a successful install/upgrade. For DEB based distros, that means $1 will be configure. For RPM based distros that means $1 will be 1 or 2 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, if preinst fails, the execution moves as preinst => 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:

  1. https://fedoraproject.org/wiki/Packaging:Scriptlets
  2. 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 C

Merge request reports