During `%preun servers`:export OLD_VERSION="$(rpm -qa openldap | awk -F- '/^openldap/ && split($2,ver,/\./) >= 1 {print ver[1] "." ver[2] "." ver[3]}')"
Then, during `%post servers`
if [ $1 -lt 2 ] || [ "%{major_version}.%{minor_version}" = "${OLD_VERSION}" ] ; then# do something
I wonder what the "do something" is, because comparing versions is almost always the wrong choice IMHO.
I second Vít. Comparing version is wrong approach. IMO.
1) it is definitelly bad idea if you call `rpm -qa` because rpm is not reentrant. So calling rpm from scriptlet may work, but one day it will do something really bad.
2) you did not take in consideration epoch. So it may cause you a problem few years in future.
3) such decision should be always based on capabilities. Does such config exists? Is some variable in config set? Or not set?
In your case, I would check for existence of /etc/openldap/migrated_from_version_1 file. And if it does not exist then do the migration and when done, touch this file. And you should own this file as %ghost.
Miroslav
_______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue