Build the process with processbuilder, check the I2P version when upgrading from NSIS in silent mode, check the RESTART_I2P environment variable when upgrading from NSIS in silent mode
This commit is contained in:
5
Makefile
5
Makefile
@@ -13,12 +13,15 @@ all: .version install.exe
|
||||
|
||||
.version:
|
||||
sed 's|!define VERSION||g' src/nsis/i2pbrowser-version.nsi | sed 's| |=|g' > .version
|
||||
make version.txt
|
||||
make version.txt src/nsis/i2pbrowser_jpackage.nsi
|
||||
|
||||
version.txt:
|
||||
echo "$(PROFILE_VERSION)" > src/profile/version.txt
|
||||
echo "$(PROFILE_VERSION)" > src/app-profile/version.txt
|
||||
|
||||
src/nsis/i2pbrowser_jpackage.nsi:
|
||||
echo "!define I2P_VERSION $(I2P_VERSION)" > src/nsis/i2pbrowser_jpackage.nsi
|
||||
|
||||
jpackage: .version I2P all
|
||||
|
||||
help: .version
|
||||
|
||||
@@ -11,17 +11,34 @@ class WinUpdateProcess implements Runnable {
|
||||
private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(WinUpdateProcess.class);
|
||||
private final RouterContext ctx;
|
||||
private final Supplier<String> versionSupplier;
|
||||
private final File file = null;
|
||||
private final File file;
|
||||
|
||||
WinUpdateProcess(RouterContext ctx, Supplier<String> versionSupplier, File file) {
|
||||
this.ctx = ctx;
|
||||
this.versionSupplier = versionSupplier;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
private void runUpdateInstaller(File file){
|
||||
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", file.getAbsolutePath(), "/S");
|
||||
String version = versionSupplier.get();
|
||||
|
||||
var workingDir = new File(ctx.getConfigDir(), "mac_updates");
|
||||
var logFile = new File(workingDir, "log-" + version + ".txt");
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(file.getAbsolutePath());
|
||||
var env = pb.environment();
|
||||
env.put("OLD_I2P_VERSION", version);
|
||||
env.remove("RESTART_I2P");
|
||||
|
||||
int exitCode = ctx.router().scheduledGracefulExitCode();
|
||||
if (exitCode == Router.EXIT_HARD_RESTART || exitCode == Router.EXIT_GRACEFUL_RESTART)
|
||||
env.put("RESTART_I2P", "true");
|
||||
|
||||
try {
|
||||
pb.start();
|
||||
pb.directory(workingDir).
|
||||
redirectErrorStream(true).
|
||||
redirectOutput(logFile).
|
||||
start();
|
||||
} catch (IOException ex) {
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Unable to run update-program in background. Update will fail.");
|
||||
|
||||
@@ -11,6 +11,7 @@ UniCode true
|
||||
!define CONSOLE_URL "http://127.0.0.1:7657/home"
|
||||
|
||||
!include i2pbrowser-version.nsi
|
||||
!include i2pbrowser-jpackage.nsi
|
||||
!include FindProcess.nsh
|
||||
|
||||
var FFINSTEXE
|
||||
@@ -242,25 +243,53 @@ Section Install
|
||||
${If} ${FileExists} "$I2PINSTEXE\jpackaged"
|
||||
createDirectory $I2PINSTEXE
|
||||
SetOutPath $I2PINSTEXE
|
||||
File /nonfatal /a /r "I2P\"
|
||||
File /nonfatal "I2P\config\jpackaged"
|
||||
|
||||
createDirectory "$I2PINSTEXE\"
|
||||
SetOutPath "$I2PINSTEXE\"
|
||||
${If} ${Silent}
|
||||
ReadEnvStr $0 OLD_I2P_VERSION
|
||||
${If} $0 < ${I2P_VERSION}
|
||||
File /nonfatal /a /r "I2P\"
|
||||
File /nonfatal "I2P\config\jpackaged"
|
||||
|
||||
createDirectory "$I2PINSTEXE\webapps\"
|
||||
SetOutPath "$I2PINSTEXE\webapps\"
|
||||
File /nonfatal /a /r "I2P\config\webapps\"
|
||||
createDirectory "$I2PINSTEXE\"
|
||||
SetOutPath "$I2PINSTEXE\"
|
||||
|
||||
createDirectory "$I2PINSTEXE\geoip\"
|
||||
SetOutPath "$I2PINSTEXE\geoip\"
|
||||
File /nonfatal /a /r "I2P\config\geoip\"
|
||||
createDirectory "$I2PINSTEXE\webapps\"
|
||||
SetOutPath "$I2PINSTEXE\webapps\"
|
||||
File /nonfatal /a /r "I2P\config\webapps\"
|
||||
|
||||
createDirectory "$I2PINSTEXE\certificates\"
|
||||
SetOutPath "$I2PINSTEXE\certificates\"
|
||||
File /nonfatal /a /r "I2P\config\certificates\"
|
||||
createDirectory "$I2PINSTEXE\geoip\"
|
||||
SetOutPath "$I2PINSTEXE\geoip\"
|
||||
File /nonfatal /a /r "I2P\config\geoip\"
|
||||
|
||||
createDirectory "$I2PINSTEXE\certificates\"
|
||||
SetOutPath "$I2PINSTEXE\certificates\"
|
||||
File /nonfatal /a /r "I2P\config\certificates\"
|
||||
${EndIf}
|
||||
${Else}
|
||||
File /nonfatal /a /r "I2P\"
|
||||
File /nonfatal "I2P\config\jpackaged"
|
||||
|
||||
createDirectory "$I2PINSTEXE\"
|
||||
SetOutPath "$I2PINSTEXE\"
|
||||
|
||||
createDirectory "$I2PINSTEXE\webapps\"
|
||||
SetOutPath "$I2PINSTEXE\webapps\"
|
||||
File /nonfatal /a /r "I2P\config\webapps\"
|
||||
|
||||
createDirectory "$I2PINSTEXE\geoip\"
|
||||
SetOutPath "$I2PINSTEXE\geoip\"
|
||||
File /nonfatal /a /r "I2P\config\geoip\"
|
||||
|
||||
createDirectory "$I2PINSTEXE\certificates\"
|
||||
SetOutPath "$I2PINSTEXE\certificates\"
|
||||
File /nonfatal /a /r "I2P\config\certificates\"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Install the launcher scripts
|
||||
createDirectory "$INSTDIR\licenses"
|
||||
SetOutPath "$INSTDIR"
|
||||
@@ -419,6 +448,12 @@ SectionEnd
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
Function LaunchLink
|
||||
#ExecShell "" "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk"
|
||||
Exec "$INSTDIR\i2pbrowser.bat"
|
||||
${If} ${Silent}
|
||||
ReadEnvStr $0 RESTART_I2P
|
||||
${If} $0 != ""
|
||||
Exec "$INSTDIR\i2pbrowser.bat"
|
||||
${EndIf}
|
||||
${Else}
|
||||
Exec "$INSTDIR\i2pbrowser.bat"
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
!define I2P_VERSION 0.9.50
|
||||
Reference in New Issue
Block a user