Anand Buddhdev
2015-Jun-27 23:59 UTC
[CentOS] Old and new package version numbers during RPM update
Hi CentOS folk, In an RPM post-install script, is it possible to know the previous version number, and the new version number of a package if it's an update? I need to know this, because for a certain package, if updating from version 1.x to 2.x, I need to run a program to convert the config file of the package from version 1.x format to version 2.x format. I've looked at SPEC file documentation, but haven't found anything relevant. Regards, Anand
Joseph L. Casale
2015-Jun-28 00:17 UTC
[CentOS] Old and new package version numbers during RPM update
> I need to know this, because for a certain package, if updating from version 1.x to 2.x, I need to run a program to convert the config file of the package from version 1.x format to version 2.x format.Your script within the rpm should have the logic. Clearly if you know how to update it, you know how to identify if it needs updating. jlc
Anand Buddhdev
2015-Jun-28 00:38 UTC
[CentOS] Old and new package version numbers during RPM update
On 28/06/15 02:17, Joseph L. Casale wrote:> Your script within the rpm should have the logic. Clearly if > you know how to update it, you know how to identify if it > needs updating.Thanks Joseph. I am aware of this option, but it would be only a last resort, because checking the format of the config file is error-prone. I would prefer RPM to tell me the old and new version numbers, so my question still stands. Regards, Anand
Leon Fauster
2015-Jun-28 11:44 UTC
[CentOS] Old and new package version numbers during RPM update
Am 28.06.2015 um 01:59 schrieb Anand Buddhdev <anandb at ripe.net>:> In an RPM post-install script, is it possible to know the previous > version number, and the new version number of a package if it's an update? > > I need to know this, because for a certain package, if updating from > version 1.x to 2.x, I need to run a program to convert the config file > of the package from version 1.x format to version 2.x format. > > I've looked at SPEC file documentation, but haven't found anything relevant.OLDVER=$(rpm -q --qf '%{VERSION}\n' <pkgname> | sort -V |head -1) -- LF
Rex Dieter
2015-Jun-29 19:29 UTC
[CentOS] Old and new package version numbers during RPM update
Anand Buddhdev wrote:> Hi CentOS folk, > > In an RPM post-install script, is it possible to know the previous > version number, and the new version number of a package if it's an update? > > I need to know this, because for a certain package, if updating from > version 1.x to 2.x, I need to run a program to convert the config file > of the package from version 1.x format to version 2.x format. > > I've looked at SPEC file documentation, but haven't found anything > relevant.triggers can support that, you can implement a trigger scriplet to run only if upgrading from < 2.x, using something like: %triggerun foo < 2.x convert_config... See also: http://rpm.org/api/4.4.2.2/triggers.html -- Rex