Files
clash-verge-rev/src-tauri/packages/linux/service-uninstall.sh
T
Tunglies ba2df9a828 refactor(linux): package the service uninstaller wrapper through Tauri files
Place both uninstaller files in /usr/bin directly from the deb and rpm
`files` maps instead of having prebuild copy the wrapper over the
uninstaller sidecar and move the real binary to /usr/lib.

/usr/bin/clash-verge-service-uninstall stays the entry point that
released rpm %preun scripts and the app call, and is now
packages/linux/service-uninstall.sh itself. The real uninstaller is
packaged as /usr/bin/clash-verge-service-uninstall.real.

`files` sources cannot vary by target, while release builds run one
prebuild per Linux target, so prebuild stores the uninstaller without
the target-triple suffix. It is no longer an externalBin.

Refs #8515
2026-11-10 07:54:05 +08:00

29 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Installed as /usr/bin/clash-verge-service-uninstall. During an rpm upgrade the new %post
# reinstalls an existing Service before the previous package's %preun runs, and released
# %preun scripts uninstall it unconditionally through this path. Skip only that call: one
# made by a scriptlet of the transaction that %post recorded.
RECORD=/run/clash-verge-service-rpm-upgrade
UNINSTALLER=/usr/bin/clash-verge-service-uninstall.real
# Fields after the parenthesised command name, which may itself contain spaces.
stat_field() {
sed 's/.*) //' "/proc/$1/stat" 2>/dev/null | cut -d' ' -f"$2"
}
if [ -f "$RECORD" ] && [ ! -L "$RECORD" ] && read -r txn_pid txn_start <"$RECORD" && [ -n "$txn_start" ]; then
pid=$PPID
depth=0
while [ "$depth" -lt 4 ] && [ -n "$pid" ] && [ "$pid" -gt 1 ]; do
if [ "$pid" = "$txn_pid" ] && [ "$(stat_field "$pid" 20)" = "$txn_start" ]; then
rm -f "$RECORD"
echo "Keeping the Clash Verge Service through this upgrade."
exit 0
fi
pid="$(stat_field "$pid" 2)"
depth=$((depth + 1))
done
fi
exec "$UNINSTALLER" "$@"