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

script: Clean up pulsar and ppm on uninstall #297

Merged
merged 2 commits into from
Jan 9, 2023

Conversation

DeeDeeG
Copy link
Member

@DeeDeeG DeeDeeG commented Jan 4, 2023

For Linux .rpm and .deb targets only.

Requirements for Contributing a Bug Fix (from template, click to expand):

Identify the Bug

Follow-up to:

Description of the Change

When uninstalling the .deb and .rpm packages on Linux, clean up the pulsar (pulsar.sh) and ppm (symlink to /opt/Pulsar/resources/app/ppm/bin/apm) stuff from /usr/bin.

(Note: These are only automatically created for the .deb and .rpm Linux packages. So there is nothing to clean up on other OSes or targets, other than the tangentially related but off-topic for this PR macOS bins users have to manually request installation of.)

Relevant docs: https://www.electron.build/configuration/linux#linuxtargetspecificoptions-apk-freebsd-pacman-p5p-and-rpm-options

Alternate Designs

Not cleaning up is bad, so I didn't consider just not cleaning up. However:

I do want to move these from /usr/bin (distro packages install here and there are obscure conflicts with a ppm bin from a Perl package manager package, and with a bin pulsar from an MRI science package called odin) to /usr/local/bin, which is coincidentally where Atom installed its atom and apm bins to, presumably for the same reason.

(See: https://pkgs.org/search/?q=%2Fusr%2Fbin%2Fpulsar and https://pkgs.org/search/?q=%2Fusr%2Fbin%2Fppm)

BUT: IMO we need to have this cleanup code out in the wild for a while to clean up all the old bins people have installed, before making the move to /usr/local/bin.

Possible Drawbacks

I would say there is a risk of deleting the Perl package manager ppm or the MRI science pulsar bin from Odin... but hey, we have already been clobbering these with our own bins! So... It's already too late for that! Oops. No drawbacks that I can think of that would be new as of this PR.

So yeah, let's move these to /usr/local/bin instead of /usr/bin, after about a month or so, say?

Verification Process

TODO: Grab one of the built packages from Cirrus and test this out. I'll be testing the .deb package, personally.

Release Notes

Clean up pulsar and ppm bins/scripts/symlinks upon uninstalling the .rpm or .deb packages.

For Linux .rpm and .deb targets only.
Copy link
Member

@confused-Techie confused-Techie left a comment

Choose a reason for hiding this comment

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

The code looks solid, but I'm not in a position to quite test. But seeing @mauricioszabo's approval is encouraging, so we should be good to go

@DeeDeeG DeeDeeG marked this pull request as draft January 5, 2023 22:24
Use `test -L` rather than `test -f` for `post-install.sh`.

(Note: `[ ]` is an alternate invocation of the `test` shell builtin.)

`[ -f some_path ]`, for a symlink "dereferences" the symlink, meaning
it checks if its target (or the ultimate target, in the case of
a chain of symlinks) exists and is a real file.

By coincidence, as this runs after we extract/install ppm from the deb
or rpm, the symlink target exists and is a real file. However, if we
changed the install path for our package manager, the target might not
exist, and this step might fail.

`[ -L some_path ]` instead checks for if the path exists and is a
symlink. This is more correct -- it's more directly what we're trying
to check.

So we will use `-L` rather than `-f`.
@DeeDeeG
Copy link
Member Author

DeeDeeG commented Jan 7, 2023

Update: I tested it, and this works. 👍


Something related I noticed: I was using test -L ("is the path a symlink?") for ppm's symlink on the post-uninstall script, but test -f ("is the path a regular file?") on the post-install script. -L is more correct. (See the commit message for much, much verbose explanation of this.) So I added a commit here that slightly improved the correctness of the post-install.sh script, by switching from [ -f ] to [ -L ] in the post-install.sh script.

Still on the same theme of cleaning up correctly, sort of? So I added it to this same PR.

Would appreciate another review, but it's such a tiny change (it's a one character diff!), and I tested it pretty thoroughly on my machine, so I may merge if no-one gets around to reviewing.

@DeeDeeG DeeDeeG marked this pull request as ready for review January 7, 2023 05:44
Copy link
Member

@confused-Techie confused-Techie left a comment

Choose a reason for hiding this comment

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

My approval still applys that the code looks solid, and if you were able to test and ensure this works that's awesome.

Would you like me to post the binary this creates on Discord so we can try to have others tests? Otherwise if you feel your system is a good example for what's expected here lets get it merged

@Daeraxa
Copy link
Member

Daeraxa commented Jan 8, 2023

Just had a try on MX Linux and yup, pulsar and ppm are created but after installing which pulsar and which ppm return nothing and /opt/Pulsar no longer exists (and nothing in /usr/bin).

@DeeDeeG
Copy link
Member Author

DeeDeeG commented Jan 9, 2023

@confused-Techie yeah, I'm confident -L works, as seen in #273, and as tested again here. And other than that bit, me and Spiker985 discussed the basic code pattern for these shell scripts in #228, and I feel pretty comfortable with what we came up with. People are welcome to improve it if there's a reason for it, but it's pretty simple and it's working, so I am comfortable with it.

Was away from the project for the weekend, thanks for the approves @mauricioszabo and @confused-Techie, thanks for testing and confirming it works @Daeraxa. Merging this now!!

@DeeDeeG DeeDeeG merged commit 50a6e6c into master Jan 9, 2023
@DeeDeeG DeeDeeG deleted the Linux-clean-up-pulsar-and-ppm-bins-on-uninstall branch February 4, 2023 03:33
@kaosine kaosine restored the Linux-clean-up-pulsar-and-ppm-bins-on-uninstall branch February 5, 2023 00:24
@Spiker985 Spiker985 deleted the Linux-clean-up-pulsar-and-ppm-bins-on-uninstall branch February 24, 2023 07:21
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.

4 participants