From ba2df9a82879621ee165e2ff5f19a2638e9289de Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:46:30 +0800 Subject: [PATCH] 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 --- scripts/prebuild.mjs | 29 ++++--------------- src-tauri/packages/linux/post-install-rpm.sh | 2 -- src-tauri/packages/linux/post-install.sh | 2 -- src-tauri/packages/linux/service-uninstall.sh | 2 +- src-tauri/tauri.linux.conf.json | 7 +++-- 5 files changed, 10 insertions(+), 32 deletions(-) diff --git a/scripts/prebuild.mjs b/scripts/prebuild.mjs index ac9ad75e2..6715dd5fc 100644 --- a/scripts/prebuild.mjs +++ b/scripts/prebuild.mjs @@ -550,16 +550,13 @@ const SERVICE_BINARIES = [ 'clash-verge-service-uninstall', ] -// Linux packages install the uninstaller under /usr/lib behind a wrapper sidecar; see -// src-tauri/packages/linux/service-uninstall.sh and the files entries in tauri.linux.conf.json. -const LINUX_UNINSTALLER_FILE = 'clash-verge-service-uninstall-bin' - function serviceFileInfo(name) { const ext = platform === 'win32' ? '.exe' : '' - const suffix = platform === 'linux' ? `-${SIDECAR_HOST}` : '' - if (platform === 'linux' && name === 'clash-verge-service-uninstall') { - return { sourceFile: name, targetFile: LINUX_UNINSTALLER_FILE } - } + // The Linux uninstaller is packaged through `files`, whose sources cannot vary by target. + const suffix = + platform === 'linux' && name !== 'clash-verge-service-uninstall' + ? `-${SIDECAR_HOST}` + : '' return { sourceFile: `${name}${ext}`, targetFile: `${name}${suffix}${ext}`, @@ -580,22 +577,6 @@ async function findExtractedFile(dir, fileName) { } async function resolveServiceBundle() { - await fetchServiceBundle() - if (platform === 'linux') { - const wrapper = path.join( - SERVICE_DIR, - `clash-verge-service-uninstall-${SIDECAR_HOST}`, - ) - await fsp.copyFile( - path.join(cwd, 'src-tauri', 'packages', 'linux', 'service-uninstall.sh'), - wrapper, - ) - await fsp.chmod(wrapper, 0o755) - await updateHashCache(wrapper) - } -} - -async function fetchServiceBundle() { const files = SERVICE_BINARIES.map((name) => { const info = serviceFileInfo(name) return { diff --git a/src-tauri/packages/linux/post-install-rpm.sh b/src-tauri/packages/linux/post-install-rpm.sh index e2206986a..eab4cdb02 100644 --- a/src-tauri/packages/linux/post-install-rpm.sh +++ b/src-tauri/packages/linux/post-install-rpm.sh @@ -3,8 +3,6 @@ set -e chmod +x /usr/bin/clash-verge-service-install chmod +x /usr/bin/clash-verge-service-uninstall -# The /usr/bin uninstaller is the service-uninstall.sh wrapper; this is the real binary it runs. -chmod +x /usr/lib/clash-verge-rev/clash-verge-service-uninstall chmod +x /usr/bin/clash-verge-service SERVICE_UNIT="clash-verge-service.service" diff --git a/src-tauri/packages/linux/post-install.sh b/src-tauri/packages/linux/post-install.sh index ce0d19071..92ae78cef 100644 --- a/src-tauri/packages/linux/post-install.sh +++ b/src-tauri/packages/linux/post-install.sh @@ -1,8 +1,6 @@ #!/bin/bash chmod +x /usr/bin/clash-verge-service-install chmod +x /usr/bin/clash-verge-service-uninstall -# The /usr/bin uninstaller is the service-uninstall.sh wrapper; this is the real binary it runs. -chmod +x /usr/lib/clash-verge-rev/clash-verge-service-uninstall chmod +x /usr/bin/clash-verge-service SERVICE_UNIT="clash-verge-service.service" diff --git a/src-tauri/packages/linux/service-uninstall.sh b/src-tauri/packages/linux/service-uninstall.sh index 417a1e422..1a27f4c14 100755 --- a/src-tauri/packages/linux/service-uninstall.sh +++ b/src-tauri/packages/linux/service-uninstall.sh @@ -4,7 +4,7 @@ # %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/lib/clash-verge-rev/clash-verge-service-uninstall +UNINSTALLER=/usr/bin/clash-verge-service-uninstall.real # Fields after the parenthesised command name, which may itself contain spaces. stat_field() { diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json index d0734fdd3..e59677ef6 100644 --- a/src-tauri/tauri.linux.conf.json +++ b/src-tauri/tauri.linux.conf.json @@ -13,7 +13,8 @@ "postInstallScript": "./packages/linux/post-install.sh", "preRemoveScript": "./packages/linux/pre-remove.sh", "files": { - "/usr/lib/clash-verge-rev/clash-verge-service-uninstall": "./sidecar/clash-verge-service-uninstall-bin" + "/usr/bin/clash-verge-service-uninstall": "./packages/linux/service-uninstall.sh", + "/usr/bin/clash-verge-service-uninstall.real": "./sidecar/clash-verge-service-uninstall" } }, "rpm": { @@ -26,14 +27,14 @@ "postInstallScript": "./packages/linux/post-install-rpm.sh", "preRemoveScript": "./packages/linux/pre-remove.sh", "files": { - "/usr/lib/clash-verge-rev/clash-verge-service-uninstall": "./sidecar/clash-verge-service-uninstall-bin" + "/usr/bin/clash-verge-service-uninstall": "./packages/linux/service-uninstall.sh", + "/usr/bin/clash-verge-service-uninstall.real": "./sidecar/clash-verge-service-uninstall" } } }, "externalBin": [ "./sidecar/clash-verge-service", "./sidecar/clash-verge-service-install", - "./sidecar/clash-verge-service-uninstall", "./sidecar/verge-mihomo", "./sidecar/verge-mihomo-alpha" ]