From 0ddbd2fef705a0c9896554515b41afa655a34df8 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Thu, 6 Mar 2025 15:23:52 +0000 Subject: [PATCH 1/3] updater: Implement deb installer --- .../java/bisq/updater/linux/DebInstaller.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 updater/src/main/java/bisq/updater/linux/DebInstaller.java diff --git a/updater/src/main/java/bisq/updater/linux/DebInstaller.java b/updater/src/main/java/bisq/updater/linux/DebInstaller.java new file mode 100644 index 0000000000..0c4bad4a39 --- /dev/null +++ b/updater/src/main/java/bisq/updater/linux/DebInstaller.java @@ -0,0 +1,29 @@ +package bisq.updater.linux; + +import java.nio.file.Path; + +import java.util.List; + +import lombok.extern.slf4j.Slf4j; + + + +import bisq.updater.InstallationFailedException; +import bisq.updater.linux.pkexec.PkExec; + +@Slf4j +public class DebInstaller { + public static void install(Path debFile) { + log.info("Installing {}", debFile); + + var cmd = List.of("dpkg", "--install", debFile.toAbsolutePath().toString()); + Process dpkgProcess = PkExec.run(cmd); + + int exitCode = dpkgProcess.exitValue(); + if (exitCode != 0) { + throw new InstallationFailedException("Deb installation exited with " + exitCode); + } + + log.info("Installation finished."); + } +} From b4711c092f0d5cdf91b9c699a502e1650ba0f108 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Thu, 6 Mar 2025 15:25:21 +0000 Subject: [PATCH 2/3] updater: Implement rpm installer --- .../java/bisq/updater/linux/RpmInstaller.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 updater/src/main/java/bisq/updater/linux/RpmInstaller.java diff --git a/updater/src/main/java/bisq/updater/linux/RpmInstaller.java b/updater/src/main/java/bisq/updater/linux/RpmInstaller.java new file mode 100644 index 0000000000..2c3993a310 --- /dev/null +++ b/updater/src/main/java/bisq/updater/linux/RpmInstaller.java @@ -0,0 +1,29 @@ +package bisq.updater.linux; + +import java.nio.file.Path; + +import java.util.List; + +import lombok.extern.slf4j.Slf4j; + + + +import bisq.updater.InstallationFailedException; +import bisq.updater.linux.pkexec.PkExec; + +@Slf4j +public class RpmInstaller { + public static void install(Path rpmFile) { + log.info("Installing {}", rpmFile); + + var cmd = List.of("rpm", "--upgrade", rpmFile.toAbsolutePath().toString()); + Process rpmProcess = PkExec.run(cmd); + + int exitCode = rpmProcess.exitValue(); + if (exitCode != 0) { + throw new InstallationFailedException("Deb installation exited with " + exitCode); + } + + log.info("Installation finished."); + } +} From 4df1450ff81f7d118d59cfd4c86ea5c489b8b308 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Thu, 6 Mar 2025 15:26:34 +0000 Subject: [PATCH 3/3] updater: Implement msi installer --- .../bisq/updater/windows/MsiInstaller.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 updater/src/main/java/bisq/updater/windows/MsiInstaller.java diff --git a/updater/src/main/java/bisq/updater/windows/MsiInstaller.java b/updater/src/main/java/bisq/updater/windows/MsiInstaller.java new file mode 100644 index 0000000000..544bd16083 --- /dev/null +++ b/updater/src/main/java/bisq/updater/windows/MsiInstaller.java @@ -0,0 +1,44 @@ +package bisq.updater.windows; + +import java.nio.file.Path; + +import java.io.IOException; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import lombok.extern.slf4j.Slf4j; + + + +import bisq.updater.InstallationFailedException; + +@Slf4j +public class MsiInstaller { + public static void install(Path msiFile, Path logFile) { + try { + log.info("Installing {}", msiFile); + + var cmd = List.of("msiexec", + "/package", msiFile.toAbsolutePath().toString(), + "/passive", + "/norestart", + "/log", logFile.toAbsolutePath().toString()); + + Process process = new ProcessBuilder(cmd) + .redirectErrorStream(true) + .redirectOutput(ProcessBuilder.Redirect.DISCARD) + .start(); + + boolean isSuccess = process.waitFor(2, TimeUnit.MINUTES); + if (!isSuccess) { + throw new InstallationFailedException("MSI installation didn't finish after 2 minutes."); + } + + } catch (IOException | InterruptedException e) { + throw new InstallationFailedException("MSI installation failed.", e); + } finally { + log.info("Installation finished."); + } + } +}