From 946ae3275556ba0d6f81582642baa1362dfd4040 Mon Sep 17 00:00:00 2001 From: rosahaj <141790572+rosahaj@users.noreply.github.com> Date: Wed, 6 Nov 2024 03:29:51 +0100 Subject: [PATCH] Fix POSTUN scriptlet on RPM upgrade and uninstall --- package.json | 3 ++- scripts/post-uninstall-rpm.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 scripts/post-uninstall-rpm.sh diff --git a/package.json b/package.json index 5567510..225e0c5 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,8 @@ ] }, "rpm": { - "artifactName": "HttpToolkit-${version}.rpm" + "artifactName": "HttpToolkit-${version}.rpm", + "afterRemove": "scripts/post-uninstall-rpm.sh" }, "appImage": { "artifactName": "HttpToolkit-${version}.AppImage" diff --git a/scripts/post-uninstall-rpm.sh b/scripts/post-uninstall-rpm.sh new file mode 100644 index 0000000..7a49db4 --- /dev/null +++ b/scripts/post-uninstall-rpm.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# This check works only for RPMs +if [ $1 -ge 1 ]; then + # Package upgrade, do not uninstall + exit 0 +fi + +# Delete the link to the binary +if type update-alternatives >/dev/null 2>&1; then + update-alternatives --remove "httptoolkit" "/opt/HTTP Toolkit/httptoolkit" +else + rm -f "/usr/bin/httptoolkit" +fi \ No newline at end of file