mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-19 22:01:12 +00:00
Rework windows updater
This commit is contained in:
parent
fb8e990083
commit
5ef3e1d508
|
@ -8,6 +8,7 @@ import io.xpipe.app.util.LocalShell;
|
||||||
import io.xpipe.app.util.ScriptHelper;
|
import io.xpipe.app.util.ScriptHelper;
|
||||||
import io.xpipe.app.util.TerminalLauncher;
|
import io.xpipe.app.util.TerminalLauncher;
|
||||||
import io.xpipe.core.process.OsType;
|
import io.xpipe.core.process.OsType;
|
||||||
|
import io.xpipe.core.process.ShellDialects;
|
||||||
import io.xpipe.core.store.FileNames;
|
import io.xpipe.core.store.FileNames;
|
||||||
import io.xpipe.core.store.LocalStore;
|
import io.xpipe.core.store.LocalStore;
|
||||||
import io.xpipe.core.util.XPipeInstallation;
|
import io.xpipe.core.util.XPipeInstallation;
|
||||||
|
@ -65,26 +66,46 @@ public class AppInstaller {
|
||||||
@Override
|
@Override
|
||||||
public void installLocal(String file) throws Exception {
|
public void installLocal(String file) throws Exception {
|
||||||
var shellProcessControl = new LocalStore().control().start();
|
var shellProcessControl = new LocalStore().control().start();
|
||||||
var exec = XPipeInstallation.getCurrentInstallationBasePath()
|
var exec = (AppProperties.get().isDevelopmentEnvironment() ? Path.of(XPipeInstallation.getLocalDefaultInstallationBasePath()) :
|
||||||
.resolve(XPipeInstallation.getDaemonExecutablePath(OsType.getLocal()));
|
XPipeInstallation.getCurrentInstallationBasePath())
|
||||||
|
.resolve(XPipeInstallation.getDaemonExecutablePath(OsType.getLocal())).toString();
|
||||||
var logsDir = FileNames.join(XPipeInstallation.getDataDir().toString(), "logs");
|
var logsDir = FileNames.join(XPipeInstallation.getDataDir().toString(), "logs");
|
||||||
var logFile = FileNames.join(logsDir, "installer_" + FileNames.getFileName(file) + ".log");
|
var logFile = FileNames.join(logsDir, "installer_" + FileNames.getFileName(file) + ".log");
|
||||||
var script = ScriptHelper.createExecScript(
|
var script = ScriptHelper.createExecScript(
|
||||||
shellProcessControl,
|
shellProcessControl,
|
||||||
String.format(
|
LocalShell.getShell().getShellDialect().equals(ShellDialects.CMD) ?
|
||||||
"""
|
getCmdCommand(file, logFile, exec) : getPowershellCommand(file, logFile, exec));
|
||||||
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));
|
|
||||||
TerminalLauncher.openDirect("XPipe Updater", LocalShell.getShell(), script);
|
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
|
@Override
|
||||||
public String getExtension() {
|
public String getExtension() {
|
||||||
return ".msi";
|
return ".msi";
|
||||||
|
|
Loading…
Reference in a new issue