Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/UpdateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
45 changes: 43 additions & 2 deletions src/ipc/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand All @@ -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}`);
Expand Down Expand Up @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions src/utils/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Loading