build: Fix incorrect provider registration in upgrade path
build: Fix incorrect provider registration in upgrade path

The scriplet logic was incorrectly assuming that the superseded package's
%postun script would be called before the superceding packages %pre/%post.
This effectively broke upgrades of libvirt-cim because all the providers
were deregistered.
We are now checking whether we are in an upgrade situation and if so
will not deregister the providers in postun.
Another enhancement is that we do a full deregistration in the %post
section for tog-pegasus now. This should make installs and upgrades more
robust against potentially damaged repositories (e.g., on development
systems).

As a reminder here's a short description of RPM's scriptlet processing.

action:         install upgrade uninstall
        %pre    1       >1       -
        %post   1       >1       -
        %preun  -       1        0
        %postun -       1        0

Scriptlet invocation order on upgrade
1. %pre(new_package)
2. %post(new_package)
3. %preun(old_package)
4. %postun(old_package)

Signed-off-by: Viktor Mihajlovski <a96a137ca8976b5ff3114c85be7aeb3b6464dad7@linux.vnet.ibm.com>

libvirt/libvirt-cim,libvirt/libvirt-cim,libvirt/libvirt-cim