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 if [ "$2" -eq 0 ]; then do your conversion fi to google-guest-oslogin package (I do not know exact package structure so pick your choice). Trigger will run when google-compute-engine-oslogin before any package scripts and before package is deleted, so will see current package state. Triggers get number of remaining target packages as $2 (similar to $1 for regular scripts). -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org