Compare commits

...

22 Commits

Author SHA1 Message Date
idk
64a11096b0 exit with status 0 2022-09-12 20:36:46 -04:00
idk
573f16c380 update jpackage-only install instructions 2022-09-12 20:32:31 -04:00
idk
d8887fdfa5 remove and replace TODO comment 2022-09-12 20:29:09 -04:00
idk
5171164167 if NSIS hasn't put files in place already, get them from the config dir. 2022-09-12 18:53:20 -04:00
idk
0ae1609f0f Copy config file from NSIS, keep a reference to the router in the WinLauncher class 2022-09-12 16:45:27 -04:00
idk
09af24a115 set up the router in advance and run it with runRouter instead of RouterLaunch.main 2022-09-11 17:10:04 -04:00
idk
5cbf441715 targz is 2 levels up from build dir 2022-09-11 12:39:08 -04:00
idk
d2e005a583 fix tarball uploader 2022-09-11 12:08:05 -04:00
idk
3ad4216ce4 make my TODO 2022-09-11 02:18:32 -04:00
idk
50d803d191 bump up the profile manager version again 2022-09-11 02:11:00 -04:00
idk
5d23b012ed change selectHome log message 2022-09-11 01:58:16 -04:00
idk
299cf5ef3e change from never call setStarting except in checkStarting 2022-09-11 01:53:08 -04:00
idk
fe68a39d94 change from never call setStarting except in checkStarting 2022-09-11 01:35:01 -04:00
idk
2f0f99f609 add functionality to find base config 2022-09-11 01:31:08 -04:00
idk
cf67f6c476 include config in app content 2022-09-11 00:31:31 -04:00
idk
4a7fb5f55c include config in app content 2022-09-11 00:21:57 -04:00
idk
a34079c8ab setNotStarting before i2pBrowser.launch 2022-09-11 00:06:27 -04:00
idk
bfcdabd794 Factor out functions in WinLauncher 2022-09-11 00:03:30 -04:00
idk
733167ea8d Factor out factors in WinLauncher 2022-09-10 23:56:57 -04:00
idk
36d61b3bf6 Factor out factors in WinLauncher 2022-09-10 23:51:13 -04:00
idk
d403fd4b09 start organizing the functions used to gather information about the environment it's running in differently so they make more sense 2022-09-10 22:14:34 -04:00
idk
736071a992 Start moving config copy logic 2022-09-09 00:52:54 -04:00
8 changed files with 448 additions and 176 deletions

View File

@ -78,7 +78,7 @@ build/I2P: I2P build
cp -rv I2P build/I2P ; true
cp "$(I2P_JBIGI)"/*windows*.dll build/I2P/runtime/lib; true
src/I2P/config: build/I2P
src/I2P/config:
mkdir -p src/I2P/config
rm -rf src/I2P/config/geoip src/I2P/config/webapps src/I2P/config/certificates
echo true | tee src/I2P/config/jpackaged

View File

@ -41,7 +41,7 @@ sleep 5s
HERE="$PWD"
if [ ! -d "$HERE/../i2p.i2p.jpackage-build/" ]; then
git clone -b "$VERSION" https://i2pgit.org/i2p-hackers/i2p.i2p "$HERE/../i2p.i2p.jpackage-build/"
tar --exclude="$HERE/../i2p.i2p.jpackage-build/.git" cvzf i2p.i2p.jpackage-build.tar.gz "$HERE/../i2p.i2p.jpackage-build/"
tar --exclude="$HERE/../i2p.i2p.jpackage-build/.git" -cvzf i2p.i2p.jpackage-build.tar.gz "$HERE/../i2p.i2p.jpackage-build/"
fi
cd "$HERE/../i2p.i2p.jpackage-build/"
for i in $COUNT; do
@ -72,6 +72,7 @@ fi
cd java
"$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE/build/i2pfirefox.jar:$HERE/build/jna.jar":"$HERE/build/jna-platform.jar":"$HERE/build/i2p.jar":"$HERE/build/router.jar":"$HERE/build/routerconsole.jar" \
net/i2p/router/CopyConfigDir.java \
net/i2p/router/Elevator.java \
net/i2p/router/Shell32X.java \
net/i2p/router/WinLauncher.java \
@ -91,6 +92,9 @@ fi
echo "preparing to invoke jpackage for I2P version $I2P_VERSION"
rm -rf I2P
make src/I2P/config
"$JAVA_HOME"/bin/jpackage --type app-image --name I2P --app-version "$I2P_VERSION" \
--verbose \
--java-options "-Xmx512m" \
@ -101,6 +105,7 @@ rm -rf I2P
--java-options "--add-opens java.base/java.util.Properties.defaults=ALL-UNNAMED" \
$JPACKAGE_OPTS \
--resource-dir build \
--app-content src/I2P/config \
--input build --main-jar launcher.jar --main-class net.i2p.router.WinLauncher
cp "$I2P_PKG/licenses/"* license/

View File

@ -50,6 +50,6 @@ ZIPCHECKSUM=$(sha256sum "../I2P.zip")
echo github-release upload -R -u "$GITHUB_USERNAME" -r "i2p.firefox" -f "../I2P.zip" -l "$ZIPCHECKSUM" -t "$TODAYSDATE" -n "I2P.zip"
github-release upload -R -u "$GITHUB_USERNAME" -r "i2p.firefox" -f "../I2P.zip" -l "$ZIPCHECKSUM" -t "$TODAYSDATE" -n "I2P.zip"
TARCHECKSUM=$(sha256sum "i2p.i2p.jpackage-build.tar.gz")
echo github-release upload -R -u "$GITHUB_USERNAME" -r "i2p.firefox" -f "i2p.i2p.jpackage-build.tar.gz" -l "Upstream I2P Router source code $TARCHECKSUM" -t "$TODAYSDATE" -n "i2p.i2p.jpackage-build.tar.gz"
github-release upload -R -u "$GITHUB_USERNAME" -r "i2p.firefox" -f "i2p.i2p.jpackage-build.tar.gz" -l "Upstream I2P Router source code $TARCHECKSUM" -t "$TODAYSDATE" -n "i2p.i2p.jpackage-build.tar.gz"
TARCHECKSUM=$(sha256sum "../../i2p.i2p.jpackage-build.tar.gz")
echo github-release upload -R -u "$GITHUB_USERNAME" -r "i2p.firefox" -f "../../i2p.i2p.jpackage-build.tar.gz" -l "Upstream I2P Router source code $TARCHECKSUM" -t "$TODAYSDATE" -n "i2p.i2p.jpackage-build.tar.gz"
github-release upload -R -u "$GITHUB_USERNAME" -r "i2p.firefox" -f "../../i2p.i2p.jpackage-build.tar.gz" -l "Upstream I2P Router source code $TARCHECKSUM" -t "$TODAYSDATE" -n "i2p.i2p.jpackage-build.tar.gz"

14
exe.sh
View File

@ -6,7 +6,8 @@
. ./config.sh
. ./i2pversion
jpackage --name I2P-MSI --app-version "$I2P_VERSION" \
./build.sh
jpackage --name I2P-EXE --app-version "$I2P_VERSION" \
--verbose \
--java-options "-Xmx512m" \
--java-options "--add-opens java.base/java.lang=ALL-UNNAMED" \
@ -15,16 +16,7 @@ jpackage --name I2P-MSI --app-version "$I2P_VERSION" \
--java-options "--add-opens java.base/java.util.Properties=ALL-UNNAMED" \
--java-options "--add-opens java.base/java.util.Properties.defaults=ALL-UNNAMED" \
$JPACKAGE_OPTS \
--app-content build/I2P/config/certificates \
--app-content build/I2P/config/eepsite \
--app-content build/I2P/config/geoip \
--app-content build/I2P/config/webapps \
--app-content build/I2P/config/clients.config \
--app-content build/I2P/config/hosts.txt \
--app-content build/I2P/config/i2ptunnel.config \
--app-content build/I2P/config/jpackaged \
--app-content build/I2P/config/router.config \
--app-content build/I2P/config/wrappper.config \
--app-content src/I2P/config \
--input build \
--verbose \
--type exe \

View File

@ -3,7 +3,7 @@
JNA_VERSION=5.11.0
export JNA_VERSION=5.11.0
I2PFIREFOX_VERSION=0.0.34
export I2PFIREFOX_VERSION=0.0.34
export I2PFIREFOX_VERSION=0.0.36
# Comment this out to build from an alternate branch or
# the tip of the master branch.
VERSIONMAJOR=1

View File

@ -0,0 +1,293 @@
package net.i2p.router;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class CopyConfigDir {
static Logger logger = Logger.getLogger("configlog");
static WindowsUpdatePostProcessor wupp = null;
static FileHandler fh;
public CopyConfigDir() {
try {
// This block configure the logger with handler and formatter
fh = new FileHandler(logFile().toString());
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
// the following statement is used to log any messages
logger.info("My first log");
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static boolean copyDirectory(String baseDir, String workDir) {
File baseFile = new File(baseDir);
File workFile = new File(workDir);
return copyDirectory(baseFile, workFile);
}
public static boolean copyDirectory(File baseDir, File workDir) {
for (File file : baseDir.listFiles()) {
String fPath = file.getAbsolutePath().replace(
file.getParentFile().getAbsolutePath(), "");
String newPath = workDir.toString() + fPath;
if (file.isDirectory())
if (copyDirectory(file, new File(newPath)))
return false;
if (file.isFile())
if (!copyFile(file, new File(newPath), true))
return false;
}
return true;
}
public static boolean copyConfigDirectory(File baseDir, File workDir) {
for (File file : baseDir.listFiles()) {
// System.out.println(file.getAbsolutePath());
String fPath = file.getAbsolutePath().replace(
file.getParentFile().getAbsolutePath(), "");
String newPath = workDir.toString() + fPath;
if (file.isDirectory())
if (!copyConfigDirectory(file, new File(newPath)))
return false;
if (file.isFile())
if (!copyFileNeverOverwrite(
file,
new File(newPath))) // new File(workDir, file.toString())))
return false;
}
return true;
}
public static boolean copyFileNeverOverwrite(String basePath,
String workPath) {
File baseFile = new File(basePath);
File workFile = new File(workPath);
return copyFileNeverOverwrite(baseFile, workFile);
}
public static boolean copyFileNeverOverwrite(File basePath, File workPath) {
return copyFile(basePath, workPath, false);
}
public static boolean copyFile(File basePath, File workPath,
boolean overWrite) {
if (!basePath.exists()) {
logger.info(basePath.getAbsolutePath() + " doesn't exist, not copying");
return false;
}
if (!overWrite && workPath.exists()) {
logger.info(workPath.getAbsolutePath() +
" already exists, not overwriting");
return true;
}
File workDir = workPath.getParentFile();
if (!workDir.exists()) {
workDir.mkdirs();
}
try (InputStream in =
new BufferedInputStream(new FileInputStream(basePath));
OutputStream out =
new BufferedOutputStream(new FileOutputStream(workPath))) {
byte[] buffer = new byte[1024];
int lengthRead;
while ((lengthRead = in.read(buffer)) > 0) {
out.write(buffer, 0, lengthRead);
out.flush();
}
in.close();
out.close();
return true;
} catch (Throwable e) {
logger.warning(e.toString());
logger.warning("failed to copy " + basePath.getAbsolutePath() + " to " +
workPath.getAbsolutePath());
return false;
}
}
protected static File selectHome() { // throws Exception {
String path_override = System.getenv("I2P_CONFIG");
if (path_override != null) {
File path = new File(path_override);
if (path != null && path.exists()) {
if (path.isDirectory())
return path.getAbsoluteFile();
else
throw new RuntimeException("I2P_CONFIG is not a directory: " + path);
}
}
if (osName() == "windows") {
File i2p = appImageHome();
logger.info("Checking for signs of life in I2P directory: " + i2p);
return i2p;
} else {
File i2p = appImageHome();
File programs = new File(i2p, ".i2p");
logger.info("Linux portable jpackage wrapper starting up, using: " +
programs + " as base config");
return programs.getAbsoluteFile();
}
}
protected static File selectProgramFile() {
String path_override = System.getenv("I2P");
if (path_override != null) {
File path = new File(path_override);
if (path.exists()) {
if (path.isDirectory())
return path.getAbsoluteFile();
else
throw new RuntimeException("I2P is not a directory: " + path);
}
}
if (osName() == "windows") {
File jrehome = new File(System.getProperty("java.home"));
File programs = jrehome.getParentFile();
logger.info("Windows portable jpackage wrapper found, using: " +
programs + " as working config");
return programs.getAbsoluteFile();
} else {
File jrehome = new File(System.getProperty("java.home"));
File programs = new File(jrehome.getParentFile().getParentFile(), "i2p");
logger.info("Linux portable jpackage wrapper found, using: " + programs +
" as working config");
return programs.getAbsoluteFile();
}
}
/**
* get the OS name(windows, mac, linux only)
*
* @return os name in lower-case, "windows" "mac" or "linux"
*/
protected static String osName() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows"))
return "windows";
if (osName.contains("mac"))
return "mac";
return "linux";
}
/**
* get the path to the java home, for jpackage this is related to the
* executable itself, which is handy to know. It's a directory called runtime,
* relative to the root of the app-image on each platform:
*
* Windows - Root of appimage is 1 directory above directory named runtime
* ./runtime
*
* Linux - Root of appimage is 2 directories above directory named runtime
* ./lib/runtime
*
* Mac OSX - Unknown for now
*
* @return
*/
protected static File javaHome() {
File jrehome = new File(System.getProperty("java.home"));
if (jrehome != null) {
if (jrehome.exists()) {
return jrehome;
}
}
return null;
}
/**
* get the path to the root of the app-image root by getting the path to
* java.home and the OS, and traversing up to the app-image root based on that
* information.
*
* @return the app-image root
*/
protected static File appImageHome() {
File jreHome = javaHome();
if (jreHome != null) {
switch (osName()) {
case "windows":
return jreHome.getAbsoluteFile().getParentFile();
case "mac":
case "linux":
return jreHome.getAbsoluteFile().getParentFile().getParentFile();
}
}
return null;
}
/**
* get the path to the default config of the app-image by getting the path to
* java.home and the OS, and traversing up to the app-image root based on that
* information, then appending the config directory to the end onn a
* per-platform basis
*
* @return the app-image root
*/
protected static File appImageConfig() {
File aih = appImageHome();
if (aih == null) {
return null;
}
String osName = osName();
switch (osName) {
case "windows":
File winConfigDir = new File(aih, "config");
if (winConfigDir != null) {
if (winConfigDir.exists()) {
return winConfigDir;
}
}
case "mac":
case "linux":
File linConfigDir = new File(aih, "lib/config");
if (linConfigDir != null) {
if (linConfigDir.exists()) {
return linConfigDir;
}
}
}
return null;
}
protected static boolean copyConfigDir() {
File appImageConfigDir = appImageConfig();
File appImageHomeDir = appImageHome();
return copyConfigDirectory(appImageConfigDir, appImageHomeDir);
}
/**
* set up the path to the log file
*
* @return
*/
protected static File logFile() { return logFile("launcher.log"); }
/**
* set up the path to the log file
*
* @return
*/
protected static File logFile(String p) {
File log = new File(selectProgramFile(), "logs");
if (!log.exists())
log.mkdirs();
return new File(log, p);
}
}

View File

@ -18,7 +18,6 @@ import net.i2p.router.RouterLaunch;
import net.i2p.update.*;
import net.i2p.update.UpdateManager;
import net.i2p.update.UpdatePostProcessor;
import net.i2p.util.SystemVersion;
/**
* Launches a router from %PROGRAMFILES%/I2P using configuration data in
@ -30,24 +29,12 @@ import net.i2p.util.SystemVersion;
* appdata
* router.pid - the pid of the java process.
*/
public class WinLauncher {
static Logger logger = Logger.getLogger("launcherlog");
static FileHandler fh;
public class WinLauncher extends CopyConfigDir {
static WindowsUpdatePostProcessor wupp = null;
private static Router i2pRouter;
public static void main(String[] args) throws Exception {
try {
// This block configure the logger with handler and formatter
fh = new FileHandler(logFile().toString());
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
// the following statement is used to log any messages
logger.info("My first log");
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
setupLauncher();
boolean privateBrowsing = false;
boolean usabilityMode = false;
boolean chromiumFirst = false;
@ -97,38 +84,19 @@ public class WinLauncher {
}
}
File programs = selectProgramFile();
if (!programs.exists())
programs.mkdirs();
else if (!programs.isDirectory()) {
logger.warning(
programs +
" exists but is not a directory. Please get it out of the way");
File programs = programFile();
File home = homeDir();
// This actually does most of what we use NSIS for if NSIS hasn't
// already done it, which essentially makes this whole thing portable.
if (!copyConfigDir()) {
logger.severe("Cannot copy the configuration directory");
System.exit(1);
}
File home = selectHome();
if (!home.exists())
home.mkdirs();
else if (!home.isDirectory()) {
logger.warning(
home +
" exists but is not a directory. Please get it out of the way");
System.exit(1);
}
if (i2pIsRunning()) {
setNotRunning();
logger.warning("I2P is already running");
I2PBrowser i2pBrowser = new I2PBrowser();
i2pBrowser.usability = usabilityMode;
i2pBrowser.chromiumFirst = chromiumFirst;
i2pBrowser.firefox = !chromiumFirst;
i2pBrowser.chromium = chromiumFirst;
i2pBrowser.setProxyTimeoutTime(proxyTimeoutTime);
System.out.println("I2PBrowser");
String[] newArgs = newArgsList.toArray(new String[newArgsList.size()]);
i2pBrowser.launch(privateBrowsing, newArgs);
return;
if (launchBrowser(privateBrowsing, usabilityMode, chromiumFirst,
proxyTimeoutTime, newArgsList)) {
System.exit(0);
}
System.setProperty("i2p.dir.base", programs.getAbsolutePath());
@ -138,6 +106,7 @@ public class WinLauncher {
logger.info("\t" + System.getProperty("i2p.dir.base") + "\n\t" +
System.getProperty("i2p.dir.config") + "\n\t" +
System.getProperty("router.pid"));
/**
* IMPORTANT: You must set user.dir to the same directory where the
* jpackage is intstalled, or when the launcher tries to re-run itself
@ -146,7 +115,7 @@ public class WinLauncher {
*/
System.setProperty("user.dir", programs.getAbsolutePath());
// wupp.i2pRouter = new Router(System.getProperties());
i2pRouter = new Router(System.getProperties());
logger.info("Router is configured");
Thread registrationThread = new Thread(REGISTER_UPP);
@ -154,14 +123,87 @@ public class WinLauncher {
registrationThread.setDaemon(true);
registrationThread.start();
setNotRunning();
// wupp.i2pRouter.runRouter();
RouterLaunch.main(args);
setNotStarting();
i2pRouter.runRouter();
System.exit(0);
}
private static void setupLauncher() {
try {
// This block configure the logger with handler and formatter
fh = new FileHandler(logFile().toString());
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
// the following statement is used to log any messages
logger.info("My first log");
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
File jrehome = javaHome();
logger.info("jre home is: " + jrehome.getAbsolutePath());
File appimagehome = appImageHome();
logger.info("appimage home is: " + appimagehome.getAbsolutePath());
}
private static File programFile() {
File programs = selectProgramFile();
if (!programs.exists())
programs.mkdirs();
else if (!programs.isDirectory()) {
logger.warning(
programs +
" exists but is not a directory. Please get it out of the way");
System.exit(1);
}
return programs;
}
private static File homeDir() {
File home = selectHome();
if (!home.exists())
home.mkdirs();
else if (!home.isDirectory()) {
logger.warning(
home +
" exists but is not a directory. Please get it out of the way");
System.exit(1);
}
return home;
}
private static boolean launchBrowser(boolean privateBrowsing,
boolean usabilityMode,
boolean chromiumFirst,
int proxyTimeoutTime,
ArrayList<String> newArgsList) {
if (i2pIsRunning()) {
logger.info("I2P is already running, launching an I2P browser");
I2PBrowser i2pBrowser = new I2PBrowser();
i2pBrowser.usability = usabilityMode;
i2pBrowser.chromiumFirst = chromiumFirst;
i2pBrowser.firefox = !chromiumFirst;
i2pBrowser.chromium = chromiumFirst;
if (chromiumFirst) {
logger.warning("favoring Chromium instead of Firefox");
}
i2pBrowser.setProxyTimeoutTime(proxyTimeoutTime);
System.out.println("I2PBrowser");
String[] newArgs = newArgsList.toArray(new String[newArgsList.size()]);
setNotStarting();
i2pBrowser.launch(privateBrowsing, newArgs);
return true;
}
return false;
}
// see
// https://stackoverflow.com/questions/434718/sockets-discover-port-availability-using-java
public static boolean isAvailable(int portNr) {
private static boolean isAvailable(int portNr) {
boolean portFree;
try (var ignored = new ServerSocket(portNr)) {
portFree = true;
@ -173,55 +215,55 @@ public class WinLauncher {
private static boolean i2pIsRunningCheck() {
// check if there's something listening on port 7657(Router Console)
if (!isAvailable(7657)) {
if (!isAvailable(7657))
return true;
}
// check if there's something listening on port 7654(I2CP)
if (!isAvailable(7654)) {
if (!isAvailable(7654))
return true;
if (checkPing())
return true;
}
// check for the existence of router.ping file, if it's less then 2
// minutes old, exit
File home = selectHome();
File ping = new File(home, "router.ping");
if (ping.exists()) {
long diff = System.currentTimeMillis() - ping.lastModified();
if (diff < 60 * 1000) {
logger.info(
"router.ping exists and is less than 1 minute old, I2P appears to be running already.");
logger.info("If I2P is not running, wait 60 seconds and try again.");
return true;
}
}
return false;
}
private static void setNotRunning() {
private static void setNotStarting() {
logger.info("removing startup file, the application has started");
File home = selectHome();
File running = new File(home, "running");
if (running.exists()) {
running.delete();
File starting = new File(home, "starting");
if (starting.exists()) {
starting.delete();
}
}
private static void setRunning() {
private static void setStarting() {
logger.info("creating startup file, router is starting up");
File home = selectHome();
File running = new File(home, "running");
if (!running.exists()) {
File starting = new File(home, "starting");
if (!starting.exists()) {
try {
running.createNewFile();
starting.createNewFile();
} catch (IOException e) {
logger.info(e.toString());
}
}
}
private static boolean i2pIsRunning() {
private static boolean checkStarting() {
logger.info("checking startup file");
File home = selectHome();
File running = new File(home, "running");
if (running.exists()) {
File starting = new File(home, "starting");
if (starting.exists()) {
logger.info("startup file exists, I2P is already starting up");
return true;
}
setRunning();
logger.info("startup file does not exist but we're running now");
setStarting();
return false;
}
// check for the existence of router.ping file, if it's less then 2
// minutes old, exit
private static boolean checkPing() {
File home = selectHome();
File ping = new File(home, "router.ping");
if (ping.exists()) {
long diff = System.currentTimeMillis() - ping.lastModified();
@ -230,8 +272,18 @@ public class WinLauncher {
"router.ping exists and is more than 1 minute old, I2P does not appear to be running.");
logger.info("If I2P is running, report this as a bug.");
return false;
} else {
return true;
}
}
return false;
}
private static boolean i2pIsRunning() {
if (checkStarting())
return true;
if (checkPing())
return true;
if (i2pIsRunningCheck())
return true;
for (int i = 0; i < 10; i++) {
@ -243,31 +295,30 @@ public class WinLauncher {
}
private static final Runnable REGISTER_UPP = () -> {
// first wait for the RouterContext to appear
RouterContext ctx;
while ((ctx = (RouterContext)RouterContext.getCurrentContext()) == null) {
while ((ctx = i2pRouter.getContext()) == null) {
sleep(1000);
}
// then wait for the update manager
ClientAppManager cam;
while ((cam = ctx.clientAppManager()) == null) {
sleep(1000);
}
UpdateManager um;
while ((um = (UpdateManager)cam.getRegisteredApp(UpdateManager.APP_NAME)) ==
null) {
sleep(1000);
}
WindowsUpdatePostProcessor wupp = new WindowsUpdatePostProcessor(ctx);
um.register(wupp, UpdateType.ROUTER_SIGNED_SU3, SU3File.TYPE_EXE);
um.register(wupp, UpdateType.ROUTER_DEV_SU3, SU3File.TYPE_EXE);
};
/**
* sleep for 1 second
*
* @param millis
*/
private static void sleep(int millis) {
try {
Thread.sleep(millis);
@ -276,66 +327,4 @@ public class WinLauncher {
throw new RuntimeException(bad);
}
}
private static File selectHome() { // throws Exception {
String path_override = System.getenv("I2P_CONFIG");
if (path_override != null) {
File path = new File(path_override);
if (path != null && path.exists()) {
if (path.isDirectory())
return path.getAbsoluteFile();
else
throw new RuntimeException("I2P_CONFIG is not a directory: " + path);
}
}
if (SystemVersion.isWindows()) {
File home = new File(System.getProperty("user.home"));
File appData = new File(home, "AppData");
File local = new File(appData, "Local");
File i2p;
i2p = new File(local, "I2P");
logger.info("Windows jpackage wrapper starting up, using: " + i2p +
" as base config");
return i2p.getAbsoluteFile();
} else {
File jrehome = new File(System.getProperty("java.home"));
File programs = new File(jrehome.getParentFile().getParentFile(), ".i2p");
logger.info("Linux portable jpackage wrapper starting up, using: " +
programs + " as base config");
return programs.getAbsoluteFile();
}
}
private static File selectProgramFile() {
String path_override = System.getenv("I2P");
if (path_override != null) {
File path = new File(path_override);
if (path.exists()) {
if (path.isDirectory())
return path.getAbsoluteFile();
else
throw new RuntimeException("I2P is not a directory: " + path);
}
}
if (SystemVersion.isWindows()) {
File jrehome = new File(System.getProperty("java.home"));
File programs = jrehome.getParentFile();
logger.info("Windows portable jpackage wrapper found, using: " +
programs + " as working config");
return programs.getAbsoluteFile();
} else {
File jrehome = new File(System.getProperty("java.home"));
File programs = new File(jrehome.getParentFile().getParentFile(), "i2p");
logger.info("Linux portable jpackage wrapper found, using: " + programs +
" as working config");
return programs.getAbsoluteFile();
}
}
private static File logFile() {
File log = new File(selectProgramFile(), "log");
if (!log.exists())
log.mkdirs();
return new File(log, "launcher.log");
}
}

13
msi.sh
View File

@ -6,6 +6,8 @@
. ./config.sh
. ./i2pversion
./build.sh
jpackage --name I2P-MSI --app-version "$I2P_VERSION" \
--verbose \
--java-options "-Xmx512m" \
@ -15,16 +17,7 @@ jpackage --name I2P-MSI --app-version "$I2P_VERSION" \
--java-options "--add-opens java.base/java.util.Properties=ALL-UNNAMED" \
--java-options "--add-opens java.base/java.util.Properties.defaults=ALL-UNNAMED" \
$JPACKAGE_OPTS \
--app-content build/I2P/config/certificates \
--app-content build/I2P/config/eepsite \
--app-content build/I2P/config/geoip \
--app-content build/I2P/config/webapps \
--app-content build/I2P/config/clients.config \
--app-content build/I2P/config/hosts.txt \
--app-content build/I2P/config/i2ptunnel.config \
--app-content build/I2P/config/jpackaged \
--app-content build/I2P/config/router.config \
--app-content build/I2P/config/wrappper.config \
--app-content src/I2P/config \
--input build \
--verbose \
--type msi \