Issue
Reading the docs on %posttrans here:
https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/
It's not very clear what %posttrans actually does. When this is executed is the RPM lock still held by another process?
Solution
Even if you could that would be bad practice. If you don't need other packages anymore when your package is installed, consider using Obsoletes
or Conflicts
to let the package manager do the installation/uninstallation of packages.
Answered By - Chris Maes