[Rpm-maint] [rpm-software-management/rpm] Unexpected behavior when using -q --queryformat in %pre scriplet (#1331)

Ivan Dzikovsky notifications at github.com
Thu Aug 13 14:28:58 UTC 2020


I need to backup some conf files of my package during upgrade into directory called e.g `/mypackage-<old-version>`.
So I'm trying to get old package version in `%pre` scriplet and doing it in the following way:
```
%pre
VERS=$(rpm --queryformat='%{VERSION}' -q mypackage)
VERS_ALTERNATIVE=$(rpm -qi mypackage | awk -F': ' '/Version/ {print $2}')
```
And the strange thing is that `VERS` variable got version of the package that I'm upgrading to (newer), while value of `VERS_ALTERNATIVE` contains version of the package that I'm upgrading from (older).

I'm do realize that invoking `rpm -q` in RPM scirplets is not the best idea, but anyway for me seems like this behavior is some kind of bug, as I suppose that in all cases result of `rpm -qi` and `rpm --queryformat` should output similar information.

I got this in CentOS 8 with RPM version 4.14.2. Same problem in CentOS 7.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1331
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200813/2437fde3/attachment.html>


More information about the Rpm-maint mailing list