Fix: preserve /usr/bin/pulsar and /usr/bin/ppm on RPM updates
Identify the Bug
Fixes #544
Description of the Change
Currently, when pulsar rpm is upgraded, the post-uninstall.sh script is run after post-install.sh.
Inspecting the RPM for the current release with rpm -qp Linux.pulsar-1.120.0.x86_64.rpm --scripts shows that electron-builder placed the scripts in the %post and %postun sections, described here: https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering
As you can see, %postun is there also on upgrades (as the old package is uninstalled). There's a method that a scriptlet in %postun can use to check if we're doing an upgrade or a removal, which relies on the first argument supplied to the scriptlet ($1). Check for example the output for the Caddy package on my system (rpm -q caddy --scripts):
caddy_rpm_scripts.log
This PR adds a separate post-uninstall-rpm.sh script which terminates early if we're performing an upgrade. I did not include the check on post-uninstall.sh as other package managers may pass different kind of args to the scripts.
Alternate Designs
Keep a single post-uninstall.sh script and add extra checks to determine if we are in a RPM, however that would add more complexity.
Possible Drawbacks
Different post-uninstall scripts to keep in sync
Verification Process
- Installed v120 RPM
- Installed my locally built RPM
-
/usr/bin/pulsarmissing, as thepost-uninstall.shfrom the old package was used - Installed again my locally built RPM
-
/usr/bin/pulsarexists this time !
Release Notes
- Fix: preserve /usr/bin/pulsar and /usr/bin/ppm on RPM updates
We're about to do the 1.121.0 release, but I want to comment here to thank you for this PR and make sure we didn't run the risk of appearing ungrateful.
I'll set some reminders to make sure we review this before 1.122.0.
Paging @daeraxa, the reporter of #544 more than a year ago, in case they're in a better position to verify.
Thanks for this!
It's working for me in some quick testing.
TESTING SETUP:
I tested by grabbing two .rpms...
- This PR's CI binary .rpm, with the fixed post-uninstall script
- https://github.com/pulsar-edit/pulsar/actions/runs/10835203105/artifacts/1927743201
- Latest master branch .rpm, via pulsar-rolling-releases repo
- https://github.com/pulsar-edit/pulsar-rolling-releases/releases/download/v1.121.2024100715/pulsar-1.121.2024100715.x86_64.rpm
And booting a live USB of Fedora Workstation 40.
- https://torrent.fedoraproject.org/torrents/Fedora-Workstation-Live-x86_64-40.torrent
TESTING PROCEDURE + RESULTS
I did the following, in order, and got the following results:
- Installed latest master branch .rpm without the fix.
- sudo dnf install /path/to/no-fix-pulsar.rpm
- pulsar --version and ppm --version worked (expected, didn't hit the post-uninstall script yet)
-
Reinstalled latest master branch .rpm without the fix.
- sudo dnf reinstall /path/to/no-fix-pulsar.rpm
- pulsar --version and ppm --version did not work, consistent with the bug report ℹ️
- Installed this PR's CI binary .rpm, with the fixed post-uninstall script
- sudo dnf install /path/to/yes-fixed-pulsar.rpm
- pulsar --version and ppm --version did not work, again expected, since the master branch post-uninstall script is the one that just ran in this case, without the fix in place.
-
Reinstalled this PR's CI binary .rpm, with the fixed post-uninstall script
- pulsar --version and ppm --version worked this time ✅
- This would appear to indicate the fix is indeed working! ✅
- Installed latest master branch .rpm again, without the fix
- pulsar --version and ppm --version worked, perhaps unintuitively, because the fixed post-uninstall script from the fixed .rpm behaved itself, so we still have bins on the PATH. This further indicates the fix works! ✅
-
Reinstalled latest master branch .rpm without the fix.
- pulsar --version and ppm --version did not work, once more consistent with the bug report (expected, this is the consequence of the situation on master behaving in a broken manner.) Once again showing the need for the fix.
MISCELLANEOUS TESTING NOTE
I had to clear up space on the virtual disk of the LiveUSB environment in order to perform any subsequent Pulsar installs (or re-installs) after the first one. To free up space, I first installed ncdu to look for what was using up all the disk space...
- sudo dnf install ncdu
- ncdu /
Which led me to delete all Libreoffice and Firefox packages to free up about 700-ish to 800-ish MB.
- sudo dnf remove libreoffice-*
- sudo dnf remove firefox*
That left me with enough free space to install/reinstall Pulsar additional times as needed for the testing.