From a9fce956e22be72e352e3fc0baff685ae0c35178 Mon Sep 17 00:00:00 2001 From: truelockmc <168660625+truelockmc@users.noreply.github.com> Date: Mon, 18 May 2026 22:13:24 +0200 Subject: [PATCH] In-App updater now properly updates .pacman installs --- src/components/UpdateModal.jsx | 1 + src/ipc/player.js | 45 ++++++++++++++++++++++++++++++++-- src/utils/updates.js | 2 ++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/components/UpdateModal.jsx b/src/components/UpdateModal.jsx index 189282b..353a4d9 100644 --- a/src/components/UpdateModal.jsx +++ b/src/components/UpdateModal.jsx @@ -484,6 +484,7 @@ export default function UpdateModal({ const formatLabel = { appimage: "AppImage", deb: ".deb package", + pacman: ".pacman (Arch)", exe: "Windows installer", dmg: "macOS installer", dmg_arm64: "macOS (Apple Silicon)", diff --git a/src/ipc/player.js b/src/ipc/player.js index 748f234..5b8f2a0 100644 --- a/src/ipc/player.js +++ b/src/ipc/player.js @@ -200,8 +200,12 @@ function register(getMainWindow, { writeSecretMigration }) { if (process.platform === "win32") return "exe"; if (process.platform === "darwin") return process.arch === "arm64" ? "dmg_arm64" : "dmg"; - if (process.platform === "linux") - return process.env.APPIMAGE ? "appimage" : "deb"; + if (process.platform === "linux") { + if (process.env.APPIMAGE) return "appimage"; + const isArch = + spawnSync("which", ["pacman"], { encoding: "utf8" }).status === 0; + return isArch ? "pacman" : "deb"; + } return null; }); @@ -213,6 +217,7 @@ function register(getMainWindow, { writeSecretMigration }) { const ext = format === "exe" ? ".exe" : format === "deb" ? ".deb" + : format === "pacman" ? ".pacman" : format === "dmg" || format === "dmg_arm64" ? ".dmg" : ".AppImage"; const destPath = path.join(os.tmpdir(), `streambert-update${ext}`); @@ -317,6 +322,42 @@ function register(getMainWindow, { writeSecretMigration }) { } writeSecretMigration(); app.exit(0); + } else if (format === "pacman") { + fs.chmodSync(destPath, 0o644); + // notify renderer + const mwPac = getMainWindow(); + if (mwPac && !mwPac.isDestroyed()) { + mwPac.webContents.send("update-progress", { + percent: 100, + label: "Installing…", + }); + } + const pacmanLaunchers = [ + { bin: "pkexec", args: ["pacman", "-U", "--noconfirm", destPath] }, + { bin: "pamac-installer", args: [destPath] }, + ]; + let launched = false; + for (const { bin, args } of pacmanLaunchers) { + try { + const which = spawnSync("which", [bin], { encoding: "utf8" }); + if (which.status !== 0) continue; + // spawnSync, to wait for pacman to finish before relaunching + const result = spawnSync(bin, args, { stdio: "inherit" }); + if (result.status === 0) { + launched = true; + break; + } + } catch { + continue; + } + } + if (launched) { + writeSecretMigration(); + app.relaunch(); + app.exit(0); + } else { + shell.openPath(destPath); + } } else if (format === "deb") { fs.chmodSync(destPath, 0o644); const debLaunchers = [ diff --git a/src/utils/updates.js b/src/utils/updates.js index 54d6cc2..2e6efaa 100644 --- a/src/utils/updates.js +++ b/src/utils/updates.js @@ -61,6 +61,8 @@ export async function checkForUpdates() { else if (name.endsWith(".deb")) assets.deb = asset.browser_download_url; else if (name.endsWith(".exe")) assets.exe = asset.browser_download_url; + else if (name.endsWith(".pacman")) + assets.pacman = asset.browser_download_url; else if (name.endsWith("arm64.dmg")) assets.dmg_arm64 = asset.browser_download_url; else if (name.endsWith(".dmg"))