0

cat /etc/redhat-release

CentOS Linux release 7.4.1708 (Core) 

yum list yum

yum.noarch  3.4.3-154.el7.centos

Repo: https://github.com/patsevanton/simple-package-update

I build 1-th and 2-th version command

mvn clean package

When update 1-th version to 2-th

Running transaction
  Updating   : simple-package-update-1-2.noarch  1/2 

Run postinstall.sh
Run preremove.sh
  Cleanup    : simple-package-update-1-1.noarch  2/2 
  Verifying  : simple-package-update-1-2.noarch  1/2 
  Verifying  : simple-package-update-1-1.noarch  2/2 

Updated:
  simple-package-update.noarch 0:1-2 

First

Run postinstall.sh

Second

Run preremove.sh

How correct update rpm if preremove.sh scipt run after postinstall.sh?

preremove.sh contain deregister service

postinstall.sh contain register service

1 Answer 1

0

%preun scriptlet (in your case preremove.sh) is called when the package is being removed. This happens even during upgrade, because old package is being removed and new installed. You can check if it is upgrade or not using the value of $1. It is documented for example here https://fedoraproject.org/wiki/Packaging:Scriptlets

2
  • Can i user this construction? pastebin.com/1LrCKzkY Commented Dec 15, 2017 at 5:33
  • if [ $1 -gt 0 ] ; then preremove.sh ..... This will be called when you are upgrading package (removing the old version). When you want to call it when the package is really being removed then you have to if [ $1 = 0 ] ; then
    – msuchy
    Commented Dec 19, 2017 at 10:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .