Skip to content

Commit 4df1450

Browse files
committed
updater: Implement msi installer
1 parent b4711c0 commit 4df1450

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package bisq.updater.windows;
2+
3+
import java.nio.file.Path;
4+
5+
import java.io.IOException;
6+
7+
import java.util.List;
8+
import java.util.concurrent.TimeUnit;
9+
10+
import lombok.extern.slf4j.Slf4j;
11+
12+
13+
14+
import bisq.updater.InstallationFailedException;
15+
16+
@Slf4j
17+
public class MsiInstaller {
18+
public static void install(Path msiFile, Path logFile) {
19+
try {
20+
log.info("Installing {}", msiFile);
21+
22+
var cmd = List.of("msiexec",
23+
"/package", msiFile.toAbsolutePath().toString(),
24+
"/passive",
25+
"/norestart",
26+
"/log", logFile.toAbsolutePath().toString());
27+
28+
Process process = new ProcessBuilder(cmd)
29+
.redirectErrorStream(true)
30+
.redirectOutput(ProcessBuilder.Redirect.DISCARD)
31+
.start();
32+
33+
boolean isSuccess = process.waitFor(2, TimeUnit.MINUTES);
34+
if (!isSuccess) {
35+
throw new InstallationFailedException("MSI installation didn't finish after 2 minutes.");
36+
}
37+
38+
} catch (IOException | InterruptedException e) {
39+
throw new InstallationFailedException("MSI installation failed.", e);
40+
} finally {
41+
log.info("Installation finished.");
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)