mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Rework windows updater
This commit is contained in:
parent
fb8e990083
commit
5ef3e1d508
1 changed files with 34 additions and 13 deletions
|
@ -8,6 +8,7 @@ import io.xpipe.app.util.LocalShell;
|
|||
import io.xpipe.app.util.ScriptHelper;
|
||||
import io.xpipe.app.util.TerminalLauncher;
|
||||
import io.xpipe.core.process.OsType;
|
||||
import io.xpipe.core.process.ShellDialects;
|
||||
import io.xpipe.core.store.FileNames;
|
||||
import io.xpipe.core.store.LocalStore;
|
||||
import io.xpipe.core.util.XPipeInstallation;
|
||||
|
@ -65,26 +66,46 @@ public class AppInstaller {
|
|||
@Override
|
||||
public void installLocal(String file) throws Exception {
|
||||
var shellProcessControl = new LocalStore().control().start();
|
||||
var exec = XPipeInstallation.getCurrentInstallationBasePath()
|
||||
.resolve(XPipeInstallation.getDaemonExecutablePath(OsType.getLocal()));
|
||||
var exec = (AppProperties.get().isDevelopmentEnvironment() ? Path.of(XPipeInstallation.getLocalDefaultInstallationBasePath()) :
|
||||
XPipeInstallation.getCurrentInstallationBasePath())
|
||||
.resolve(XPipeInstallation.getDaemonExecutablePath(OsType.getLocal())).toString();
|
||||
var logsDir = FileNames.join(XPipeInstallation.getDataDir().toString(), "logs");
|
||||
var logFile = FileNames.join(logsDir, "installer_" + FileNames.getFileName(file) + ".log");
|
||||
var script = ScriptHelper.createExecScript(
|
||||
shellProcessControl,
|
||||
String.format(
|
||||
"""
|
||||
echo Installing %s ...
|
||||
cd /D "%%HOMEDRIVE%%%%HOMEPATH%%"
|
||||
echo + msiexec /i "%s" /lv "%s" /qr
|
||||
start "" /wait msiexec /i "%s" /lv "%s" /qr
|
||||
echo Starting XPipe ...
|
||||
echo + "%s"
|
||||
start "" "%s"
|
||||
""",
|
||||
file, file, logFile, file, logFile, exec, exec));
|
||||
LocalShell.getShell().getShellDialect().equals(ShellDialects.CMD) ?
|
||||
getCmdCommand(file, logFile, exec) : getPowershellCommand(file, logFile, exec));
|
||||
TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), script);
|
||||
}
|
||||
|
||||
private String getCmdCommand(String file, String logFile, String exec) {
|
||||
return String.format(
|
||||
"""
|
||||
echo Installing %s ...
|
||||
cd /D "%%HOMEDRIVE%%%%HOMEPATH%%"
|
||||
echo + msiexec /i "%s" /lv "%s" /qr
|
||||
start "" /wait msiexec /i "%s" /lv "%s" /qr
|
||||
echo Starting XPipe ...
|
||||
echo + "%s"
|
||||
start "" "%s"
|
||||
""",
|
||||
file, file, logFile, file, logFile, exec, exec);
|
||||
}
|
||||
|
||||
private String getPowershellCommand(String file, String logFile, String exec) {
|
||||
return String.format(
|
||||
"""
|
||||
echo Installing %s ...
|
||||
cd "$env:HOMEDRIVE\\$env:HOMEPATH"
|
||||
echo '+ msiexec /i "%s" /lv "%s" /qr'
|
||||
Start-Process msiexec -Wait -ArgumentList "/i", "`"%s`"", "/lv", "`"%s`"", "/qr"
|
||||
echo 'Starting XPipe ...'
|
||||
echo '+ "%s"'
|
||||
Start-Process -FilePath "%s"
|
||||
""",
|
||||
file, file, logFile, file, logFile, exec, exec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExtension() {
|
||||
return ".msi";
|
||||
|
|
Loading…
Reference in a new issue