Rpm queries (or other uses) from within scriptlets is not a good idea. It works most of the time, but there are situations where it WILL break and there's no way for the package to know when that happens.
A much safer choice is to for example test for file existence: if a file from pkg1 doesn't exist at pkg2's %pre, pkg1 quite obviously isn't installed at that point.
Rpm queries (or other uses) from within scriptlets is not a good idea. It works most of the time, but there are situations where it WILL break and there's no way for the package to know when that happens.
A much safer choice is to for example test for file existence: if a file from pkg1 doesn't exist at pkg2's %pre, pkg1 quite obviously isn't installed at that point.