From 322faf247ec79b247bd43d6a5a668a49ad0db503 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sat, 12 Apr 2025 19:33:43 +0000 Subject: [PATCH] Fixes [stage] --- .../xpipe/app/core/AppDistributionType.java | 26 +++++++++++++++---- .../io/xpipe/app/update/CommandUpdater.java | 9 ++++--- version | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/AppDistributionType.java b/app/src/main/java/io/xpipe/app/core/AppDistributionType.java index 61c24588c..ab24eb7f4 100644 --- a/app/src/main/java/io/xpipe/app/core/AppDistributionType.java +++ b/app/src/main/java/io/xpipe/app/core/AppDistributionType.java @@ -7,6 +7,7 @@ import io.xpipe.app.util.LocalExec; import io.xpipe.app.util.Translatable; import io.xpipe.core.process.CommandBuilder; import io.xpipe.core.process.OsType; +import io.xpipe.core.process.ShellScript; import io.xpipe.core.util.XPipeInstallation; import javafx.beans.value.ObservableValue; @@ -24,17 +25,32 @@ public enum AppDistributionType implements Translatable { PORTABLE("portable", false, () -> new PortableUpdater(true)), NATIVE_INSTALLATION("install", true, () -> new GitHubUpdater(true)), HOMEBREW("homebrew", true, () -> { - return new CommandUpdater(CommandBuilder.of().add("brew", "upgrade", "--cask", AppProperties.get().isStaging() ? "xpipe-io/pbb/xpipe-ptb" : "xpipe-io/tap/xpipe")); + return new CommandUpdater(ShellScript.lines("brew upgrade --cask " + (AppProperties.get().isStaging() ? "xpipe-io/ptb/xpipe-ptb" : "xpipe-io/tap/xpipe"))); }), APT_REPO("apt", true, () -> { - return new CommandUpdater(CommandBuilder.of().add("sudo", "apt", "update", "&&", "sudo", "apt", "install", AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe")); + return new CommandUpdater(ShellScript.lines( + "+ sudo apt update && sudo apt install " + (AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe"), + "sudo apt update", + "sudo apt install " + (AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe") + )); }), RPM_REPO("rpm", true, () -> { - return new CommandUpdater(CommandBuilder.of().add("sudo", "yum", "upgrade", AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe", "--refresh")); + return new CommandUpdater(ShellScript.lines( + "+ sudo yum upgrade " + (AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe") + " --refresh", + "sudo yum upgrade " + (AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe") + " --refresh" + )); }), WEBTOP("webtop", true, () -> new WebtopUpdater()), CHOCO("choco", true, () -> { - return new CommandUpdater(CommandBuilder.of().add("choco", "upgrade", AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe")); + var systemWide = Files.exists(XPipeInstallation.getCurrentInstallationBasePath().resolve("system")); + var pkg = AppProperties.get().isStaging() ? "xpipe-ptb" : "xpipe"; + if (systemWide) { + return new CommandUpdater(ShellScript.lines( + "powershell -Command \"Start-Process -Verb runAs -FilePath choco -ArgumentList upgrade, " + pkg + "\"" + )); + } else { + return new CommandUpdater(ShellScript.lines("choco upgrade " + pkg)); + } }); private static AppDistributionType type; @@ -60,7 +76,7 @@ public enum AppDistributionType implements Translatable { } if (!AppProperties.get().isImage()) { - type = DEVELOPMENT; + type = CHOCO; return; } diff --git a/app/src/main/java/io/xpipe/app/update/CommandUpdater.java b/app/src/main/java/io/xpipe/app/update/CommandUpdater.java index f597ee58e..a5450b641 100644 --- a/app/src/main/java/io/xpipe/app/update/CommandUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/CommandUpdater.java @@ -9,6 +9,7 @@ import io.xpipe.app.util.DocumentationLink; import io.xpipe.app.util.Hyperlinks; import io.xpipe.app.util.LocalShell; import io.xpipe.core.process.CommandBuilder; +import io.xpipe.core.process.ShellScript; import java.nio.file.Files; import java.util.ArrayList; @@ -16,11 +17,11 @@ import java.util.List; public class CommandUpdater extends PortableUpdater { - private final CommandBuilder command; + private final ShellScript script; - public CommandUpdater(CommandBuilder command) { + public CommandUpdater(ShellScript script) { super(true); - this.command = command; + this.script = script; } @Override @@ -60,7 +61,7 @@ public class CommandUpdater extends PortableUpdater { var performedUpdate = new PerformedUpdate(p.getVersion(), p.getBody(), p.getVersion()); AppCache.update("performedUpdate", performedUpdate); OperationMode.executeAfterShutdown(() -> { - TerminalLauncher.openDirect("Update", command); + TerminalLauncher.openDirect("XPipe Updater", script); }); } catch (Throwable t) { ErrorEvent.fromThrowable(t).handle(); diff --git a/version b/version index d0968bd3c..478d26259 100644 --- a/version +++ b/version @@ -1 +1 @@ -16.0-30 +16.0-31