When upgrading a package portage calls the phases in the following order: * src_compile testapp-2 * src_test testapp-2 * src_install testapp-2 * pkg_preinst testapp-2 * pkg_postinst testapp-2 * pkg_prerm testapp-1 * pkg_postrm testapp-1 so postinst for the new version is called before prerm of the old version, while the PMS specifies postinst for the new version happens after postrm for the old version. On downgrades the same thing happens. On remerges behaviour matches PMS.
Oops. r160.