Andrei Borzenkov <arvidjaar@gmail.com> writes:
21.08.2020 14:50, John Paul Adrian Glaubitz пишет:
Hello!
I'm currently trying to solve a tricky problem with the google-compute-engine-{init,oslogin} and google-guest-{agent,oslogin,configs} packages. The latter are replacement packages for the former, i.e. the google-guest-* packages are obsoleting the google-compute-engine-* packages.
The google-guest-* packages contain systemd services which need to be enabled in case the packages are being installed as an upgrade over the old google-compute-engine-* packages.
While RPM has a mechanism for determining whether a package is being upgraded or newly installed [1], this mechanism does not work when the upgrade process involves replacing the old packages with a new package involving the Obsoletes+Replaces mechanism.
The reason why that doesn't work is because the scriptlet parameter that indicates the upgrade process actually just notifies the scriptlet of the number of packages with the same name are currently being installed which is "2" during an upgrade [1], so that number will be "1" when google-compute-engine-oslogin is being replaced with google-guest-oslogin, for example.
Does anyone have a suggestion how to solve this? I have been thinking about writing a temporary file empty to the filesystem in the %pre scriptlet to disk which is then detected by the %post scriptlet.
The empty file would be written if the old services are found as enabled in the %pre section and the %post section would enable the services if the temporary file is found. The file can be created with "mktemp --suffix .google-compute-engine".
Any other suggestions?
It may work with triggers. Add
%triggerun -- google-compute-engine-oslogin
Note that you have to use file triggers (%filetrigger[in|un]) and don't use %transfiletrigger[in|un] as these are unreliable in zypper [1]. Cheers, Dan Footnotes: [1] https://bugzilla.suse.com/show_bug.cgi?id=1041742 -- Dan Čermák <dcermak@suse.com> Software Engineer Development tools SUSE Software Solutions Germany GmbH Maxfeldstr. 5 90409 Nuremberg Germany (HRB 36809, AG Nürnberg) Managing Director: Felix Imendörffer