-
Notifications
You must be signed in to change notification settings - Fork 94
Fix POSTUN scriptlet on RPM upgrade and uninstall #76
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
Conversation
@@ -0,0 +1,14 @@ | |||
#!/bin/bash | |||
|
|||
# This check works only for RPMs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check was copied from pulsar-edit/pulsar@a47da8e. I'm not sure how they came up with this solution, but it works.
exit 0 | ||
fi | ||
|
||
# Delete the link to the binary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adopted the POSTUN script created by electron-builder (as verified by recreating the SPEC file):
#!/bin/bash
# Delete the link to the binary
if type update-alternatives >/dev/null 2>&1; then
update-alternatives --remove 'httptoolkit' '/usr/bin/httptoolkit'
else
rm -f '/usr/bin/httptoolkit'
fi
|
||
# Delete the link to the binary | ||
if type update-alternatives >/dev/null 2>&1; then | ||
update-alternatives --remove "httptoolkit" "/opt/HTTP Toolkit/httptoolkit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As explained here, the second argument to update-alternatives --remove
should be /opt/HTTP Toolkit/toolkit
, not /usr/bin/toolkit
.
if type update-alternatives >/dev/null 2>&1; then | ||
update-alternatives --remove "httptoolkit" "/opt/HTTP Toolkit/httptoolkit" | ||
else | ||
rm -f "/usr/bin/httptoolkit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If update-alternatives
is not installed, the /usr/bin/httptoolkit
is removed directly. The %post script created by electron-builder does the same thing on installs and upgrades:
#!/bin/bash
if type update-alternatives 2>/dev/null >&1; then
# Remove previous link if it doesn't use update-alternatives
if [ -L '/usr/bin/httptoolkit' -a -e '/usr/bin/httptoolkit' -a "`readlink '/usr/bin/httptoolkit'`" != '/etc/alternatives/httptoolkit' ]; then
rm -f '/usr/bin/httptoolkit'
fi
update-alternatives --install '/usr/bin/httptoolkit' 'httptoolkit' '/opt/HTTP Toolkit/httptoolkit' 100 || ln -sf '/opt/HTTP Toolkit/httptoolkit' '/usr/bin/httptoolkit'
else
ln -sf '/opt/HTTP Toolkit/httptoolkit' '/usr/bin/httptoolkit'
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @rosahaj! Thanks for digging into this, great stuff.
I'll merge now. This won't be live immediately and I don't think it's urgent, but I'm planning to do a release next week so it'll be included there.
By the way, in case you're not aware, HTTP Toolkit Pro is totally free for all contributors. Is that something you'd be interested in? If so just let me know what email you'd like for your account - either here or by email at tim @ httptoolkit.com.
As mentioned in httptoolkit/httptoolkit-website#85 (comment), upgrading or uninstalling the HttpToolkit RPM package produces the same messages as in this issue: IsmaelMartinez/teams-for-linux#958.
I was curious how other projects addressed this problem and stumbled upon pulsar-edit/pulsar@a47da8e. I combined Pulsar's upgrade check with the POSTUN scriptlet produced by electron-builder to create a custom post-uninstall script for RPM packages.
I tested the fix on Fedora 40 by
All of these actions succeeded without any issues. Upgrading does not remove the symlink from
/usr/bin/httptoolkit
to/opt/HTTP Toolkit/httptoolkit
. Removing the package removes the/usr/bin/httptoolkit
symlink as expected.