On 8/21/20 9:20 PM, John Paul Adrian Glaubitz wrote:
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?
Not really an other suggestion, but for a while docker used to check the version of docker in %pre then based off that write a file to disk indicating that a special migration action needed to take place in %postun https://build.opensuse.org/package/view_file/openSUSE:Leap:42.1:Update/docke... -- Simon Lees (Simotek) http://simotek.net Emergency Update Team keybase.io/simotek SUSE Linux Adelaide Australia, UTC+10:30 GPG Fingerprint: 5B87 DB9D 88DC F606 E489 CEC5 0922 C246 02F0 014B