On Thursday 30 June 2005 10:17 am, Mathieu Fluhr wrote: > Hello, > > I have a short question about update processes handling with RPM (when > you use the -U option). I have a package that contains 2 scripts: > - 1 post-install script that detects the distribution used and adds > shortcuts to it. > - 1 pre-uninstall script that removes these shortcuts. > > As the shortcuts places can be different depending on the distribution > that is used (with old ones that does not fit freedesktop standards...) > I need these 2 scripts. > > The problem is the following: When I update an old version of the > package to the lastest one for example, the post-installation script of > the newest one is executed _BEFORE_ the pre-uninstall script of the old > one. > > My question is simple: Is this normal ? And if yes, how can I make it > work, so that the shortcuts are kept when the package is updated. > Yes, this is normal. This should be covered in "Hints and Kinks" (http://www.rpm.org/hintskinks/) or something. Maybe it is somewhere but I couldn't see it. Indeed, during an upgrade, the pre and post scripts of the _new_ package are executed _before_ the pre-un and post-un script of the _old_ package. What you need to do is check the value of $1 in your pre-uninstall script (or post-uninstall script). This tells you how many packages of the same name will be left after the current package is uninstalled. So, if this value is zero, do your cleanup stuff. If it is not zero, don't do your cleanup stuff. Unfortunately you have to do this in the _old_ package. If you've already shipped it without this check, you're in a bit of pain. You can work around it with a %triggerpostun. Check /usr/share/docs/packages/rpm/manual/triggers for info on this. -- Bart Whiteley