Fixes for many, but not all the things from zab's code review
This commit is contained in:
2
Makefile
2
Makefile
@@ -49,7 +49,7 @@ I2P:
|
|||||||
build/I2P: build
|
build/I2P: build
|
||||||
rm -rf build/I2P
|
rm -rf build/I2P
|
||||||
cp -rv I2P build/I2P ; true
|
cp -rv I2P build/I2P ; true
|
||||||
cp "$(I2P_JBIGI)"/*windows*.dll build/I2P/runtime/lib
|
cp "$(I2P_JBIGI)"/*windows*.dll build/I2P/runtime/lib; true
|
||||||
|
|
||||||
configdir: src/I2P/config
|
configdir: src/I2P/config
|
||||||
|
|
||||||
|
|||||||
2
build.sh
2
build.sh
@@ -39,7 +39,7 @@ mkdir build
|
|||||||
cp "$I2P_JARS"/*.jar build
|
cp "$I2P_JARS"/*.jar build
|
||||||
|
|
||||||
cd java
|
cd java
|
||||||
"$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE"/build/i2p.jar:"$HERE"/build/router.jar:"$HERE"/build/routerconsole.jar net/i2p/router/WinLauncher.java net/i2p/router/WindowsUpdatePostProcessor.java
|
"$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE"/build/i2p.jar:"$HERE"/build/router.jar:"$HERE"/build/routerconsole.jar net/i2p/router/WinLauncher.java net/i2p/router/WindowsUpdatePostProcessor.java net/i2p/router/WinUpdateProcess.java
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
#echo "building launcher.jar"
|
#echo "building launcher.jar"
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package net.i2p.router;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import net.i2p.crypto.*;
|
||||||
|
|
||||||
import net.i2p.app.ClientAppManager;
|
import net.i2p.app.ClientAppManager;
|
||||||
import net.i2p.router.RouterLaunch;
|
import net.i2p.router.RouterLaunch;
|
||||||
import net.i2p.router.Router;
|
import net.i2p.router.Router;
|
||||||
@@ -72,9 +74,9 @@ public class WinLauncher {
|
|||||||
sleep(1000);
|
sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
wupp = new WindowsUpdatePostProcessor();
|
wupp = new WindowsUpdatePostProcessor(ctx);
|
||||||
um.register(wupp, UpdateType.ROUTER_SIGNED_SU3, 6);//SU3File.TYPE_EXE);
|
um.register(wupp, UpdateType.ROUTER_SIGNED_SU3, SU3File.TYPE_EXE);
|
||||||
um.register(wupp, UpdateType.ROUTER_DEV_SU3, 6);//SU3File.TYPE_EXE);
|
um.register(wupp, UpdateType.ROUTER_DEV_SU3, SU3File.TYPE_EXE);
|
||||||
};
|
};
|
||||||
|
|
||||||
private static void sleep(int millis) {
|
private static void sleep(int millis) {
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ package net.i2p.router;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.*;
|
||||||
|
|
||||||
|
|
||||||
|
import net.i2p.crypto.*;
|
||||||
import static net.i2p.update.UpdateType.*;
|
import static net.i2p.update.UpdateType.*;
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.update.UpdateType;
|
import net.i2p.update.UpdateType;
|
||||||
@@ -18,36 +21,77 @@ import java.lang.InterruptedException;
|
|||||||
|
|
||||||
public class WindowsUpdatePostProcessor implements UpdatePostProcessor {
|
public class WindowsUpdatePostProcessor implements UpdatePostProcessor {
|
||||||
private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(WindowsUpdatePostProcessor.class);
|
private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(WindowsUpdatePostProcessor.class);
|
||||||
|
private final RouterContext ctx;
|
||||||
protected static Router i2pRouter = null;
|
protected static Router i2pRouter = null;
|
||||||
|
private final AtomicBoolean hook = new AtomicBoolean();
|
||||||
public void updateDownloadedandVerified(UpdateType type, int fileType, String version, File file) throws IOException {
|
private volatile String version;
|
||||||
if (fileType == 6) {
|
WindowsUpdatePostProcessor() {
|
||||||
File newFile = moveUpdateInstaller(file);
|
this.ctx = null;
|
||||||
runUpdateInstaller(newFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private File moveUpdateInstaller(File file){
|
WindowsUpdatePostProcessor(RouterContext ctx) {
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateDownloadedandVerified(UpdateType type, int fileType, String version, File file) throws IOException {
|
||||||
|
_log.info("Got an update to post-process");
|
||||||
|
|
||||||
|
if (type != UpdateType.ROUTER_SIGNED_SU3 && type != UpdateType.ROUTER_DEV_SU3) {
|
||||||
|
_log.warn("Unsupported update type " + type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileType != SU3File.TYPE_EXE) {
|
||||||
|
_log.warn("Unsupported file type " + fileType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File positionedFile = moveUpdateInstaller(file);
|
||||||
|
|
||||||
|
this.version = version;
|
||||||
|
|
||||||
|
if (!hook.compareAndSet(false,true)) {
|
||||||
|
_log.info("shutdown hook was already set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_log.info("adding shutdown hook");
|
||||||
|
ctx.addFinalShutdownTask(new WinUpdateProcess(ctx, this::getVersion, positionedFile));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private File moveUpdateInstaller(File file) throws IOException{
|
||||||
RouterContext i2pContext = i2pRouter.getContext();
|
RouterContext i2pContext = i2pRouter.getContext();
|
||||||
if (i2pContext != null) {
|
if (i2pContext != null) {
|
||||||
File appDir = i2pContext.getAppDir();
|
File appDir = i2pContext.getAppDir();
|
||||||
File newFile = new File(i2pContext.getAppDir().getAbsolutePath(), file.getName());
|
File newFile = new File(workDir(), file.getName());
|
||||||
file.renameTo(newFile);
|
file.renameTo(newFile);
|
||||||
return newFile;
|
return newFile;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runUpdateInstaller(File file){
|
private File workDir() throws IOException{
|
||||||
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", file.getAbsolutePath(), "/S");
|
RouterContext i2pContext = i2pRouter.getContext();
|
||||||
try {
|
if (i2pContext != null) {
|
||||||
pb.start();
|
File workDir = new File(i2pContext.getAppDir().getAbsolutePath(), "i2p_update_win");
|
||||||
} catch (IOException ex) {
|
if (workDir.exists()) {
|
||||||
if (_log.shouldWarn())
|
if (workDir.isFile())
|
||||||
_log.warn("Unable to loop update-program in background. Update will fail.");
|
throw new IOException(workDir + " exists but is a file, get it out of the way");
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
workDir.mkdirs();
|
||||||
|
}
|
||||||
|
return workDir;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected File selectProgramFile() {
|
protected File selectProgramFile() {
|
||||||
if (SystemVersion.isWindows()) {
|
if (SystemVersion.isWindows()) {
|
||||||
File jrehome = new File(System.getProperty("java.home"));
|
File jrehome = new File(System.getProperty("java.home"));
|
||||||
|
|||||||
@@ -215,9 +215,9 @@ Function routerDetect
|
|||||||
SetOutPath "$I2PINSTEXE\certificates\"
|
SetOutPath "$I2PINSTEXE\certificates\"
|
||||||
File /nonfatal /a /r "I2P\config\certificates\"
|
File /nonfatal /a /r "I2P\config\certificates\"
|
||||||
|
|
||||||
createDirectory "$I2PINSTEXE\certificates\"
|
createDirectory "$I2PINSTEXE\eepsite\"
|
||||||
SetOutPath "$I2PINSTEXE\certificates\"
|
SetOutPath "$I2PINSTEXE\eepsite\"
|
||||||
File /nonfatal /a /r "I2P\config\certificates\"
|
File /nonfatal /a /r "I2P\config\eepsite\"
|
||||||
|
|
||||||
Abort directory
|
Abort directory
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|||||||
Reference in New Issue
Block a user