Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: preserve /usr/bin/pulsar and /usr/bin/ppm on RPM updates #1091

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

am97
Copy link
Contributor

@am97 am97 commented Sep 12, 2024

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/pulsar missing, as the post-uninstall.sh from the old package was used
  • Installed again my locally built RPM
  • /usr/bin/pulsar exists this time !

Release Notes

  • Fix: preserve /usr/bin/pulsar and /usr/bin/ppm on RPM updates

@savetheclocktower
Copy link
Contributor

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.

@DeeDeeG
Copy link
Member

DeeDeeG commented Oct 14, 2024

Thanks for this!

It's working for me in some quick testing.

TESTING SETUP:

I tested by grabbing two .rpms...

And booting a live USB of Fedora Workstation 40.

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.

Copy link
Member

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving based on testing I've done, both showing that it worked, and confirming that the fix was needed.

The short diff looks reasonable as well. Just creating a .rpm-specific variant of the post-uninstall script with a workaround that's tested working for .rpms, but might not work with e.g. .debs. Seems like a reasonable way to handle it, IMO. .debs can continue to use the original script without this workaround.

@DeeDeeG DeeDeeG merged commit 7340f4e into pulsar-edit:master Oct 15, 2024
103 of 104 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPM upgrade process loses /usr/bin binary
3 participants