From 10f02140a33e91df38eb6b9e3bd63a62e186aece Mon Sep 17 00:00:00 2001 From: idk Date: Tue, 25 May 2021 13:46:37 -0400 Subject: [PATCH] Make it possible to optionally generate jpackage which can be added to a Linux tar.gzipped firefox profile+script. If a Firefox is added to this .tar.gz in a directory called ./firefox/, and that Firefox is configured to be portable and avoid the disk, the launching script will favor the local Firefox and it *should* never need to touch anything outside the directory it's unpacked in, making it usable from a flash drive without touching the disk on a host, for instance. More generally, forming the basis of a TBB-like package --- Makefile | 2 ++ README.md | 3 +++ build.sh | 4 ++-- java/net/i2p/router/WinLauncher.java | 31 ++++++++++++++++++++-------- src/unix/i2pbrowser.sh | 5 ++++- src/unix/i2pconfig.sh | 6 +++++- 6 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index f56db75..1f021c4 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,7 @@ profile: build/profile/user.js build/profile/prefs.js build/profile/bookmarks.ht profile.tgz: profile $(eval PROFILE_VERSION := $(shell cat src/profile/version.txt)) @echo "building profile tarball $(PROFILE_VERSION)" + bash -c 'ls I2P && cp -rv I2P build/app-profile/I2P'; true install -m755 src/unix/i2pbrowser.sh build/profile/i2pbrowser.sh cd build && tar -czf profile-$(PROFILE_VERSION).tgz profile && cp profile-$(PROFILE_VERSION).tgz ../ @@ -81,6 +82,7 @@ app-profile: build/app-profile/user.js build/app-profile/prefs.js build/app-prof app-profile.tgz: app-profile $(eval PROFILE_VERSION := $(shell cat src/app-profile/version.txt)) @echo "building app-profile tarball $(PROFILE_VERSION)" + bash -c 'ls I2P && cp -rv I2P build/app-profile/I2P'; true install -m755 src/unix/i2pconfig.sh build/app-profile/i2pconfig.sh cd build && tar -czf app-profile-$(PROFILE_VERSION).tgz app-profile && cp app-profile-$(PROFILE_VERSION).tgz ../ diff --git a/README.md b/README.md index 856ed61..246278e 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ build process for non-Windows users. End-to-End Windows build process using WSL ------------------------------------------ +**If you've already done this once, you can just use:** `./build.sh && wsl make` +**in `git bash`** to automatically build an installer. + **Prerequisites:** You need to have OpenJDK 14 or greater installed and configured with your `%JAVA_HOME%` environment variable configured and `%JAVA_HOME%/bin` on your `%PATH%`. You need to have Apache Ant installed and configured with `%ANT_HOME%` diff --git a/build.sh b/build.sh index 6dd8059..f34ff8d 100755 --- a/build.sh +++ b/build.sh @@ -3,13 +3,13 @@ set -e . i2pversion -JAVA=$(java --version | tr -d 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n' | cut -d ' ' -f 2 | cut -d '.' -f 1 | tr -d '\n\t ') +JAVA=$(java --version | tr -d 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n' | cut -d ' ' -f 2 | cut -d '.' -f 1 | tr -d '\n\t\- ') if [ "$JAVA" -lt "14" ]; then echo "Java 14+ must be used to compile with jpackage, java is $JAVA" exit 1 fi - +sleep 2s if [ -z "${JAVA_HOME}" ]; then JAVA_HOME=`type -p java|xargs readlink -f|xargs dirname|xargs dirname` diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index 7da6e90..3d8313f 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -3,6 +3,7 @@ package net.i2p.router; import java.io.*; import java.util.*; import net.i2p.router.RouterLaunch; +import net.i2p.util.SystemVersion; /** * Launches a router from %PROGRAMFILES%/I2P using configuration data in @@ -48,18 +49,30 @@ public class WinLauncher { } private static File selectHome() throws Exception { - File home = new File(System.getProperty("user.home")); - File i2p; - File appData = new File(home, "AppData"); - File local = new File(appData, "Local"); - i2p = new File(local, "I2P"); - return i2p.getAbsoluteFile(); + if (SystemVersion.isWindows()) { + File home = new File(System.getProperty("user.home")); + File i2p; + File appData = new File(home, "AppData"); + File local = new File(appData, "Local"); + i2p = new File(local, "I2P"); + return i2p.getAbsoluteFile(); + } else { + File jrehome = new File(System.getProperty("java.home")); + File programs = new File(jrehome.getParentFile().getParentFile(), ".i2p"); + return programs.getAbsoluteFile(); + } } private static File selectProgramFile() throws Exception { - File jrehome = new File(System.getProperty("java.home")); - File programs = jrehome.getParentFile(); - return programs.getAbsoluteFile(); + if (SystemVersion.isWindows()) { + File jrehome = new File(System.getProperty("java.home")); + File programs = jrehome.getParentFile(); + return programs.getAbsoluteFile(); + } else { + File jrehome = new File(System.getProperty("java.home")); + File programs = new File(jrehome.getParentFile().getParentFile(), "i2p"); + return programs.getAbsoluteFile(); + } } } diff --git a/src/unix/i2pbrowser.sh b/src/unix/i2pbrowser.sh index bbca995..43caf18 100755 --- a/src/unix/i2pbrowser.sh +++ b/src/unix/i2pbrowser.sh @@ -6,7 +6,10 @@ fi if [ ! -z $I2PROUTER ]; then echo "$I2PROUTER" "$I2PCOMMAND" - "$I2PROUTER" "$I2PCOMMAND" + http_proxy=http://127.0.0.1:4444 curl http://proxy.i2p || "$I2PROUTER" "$I2PCOMMAND" +else if [ -d "I2P/bin" ]; then + http_proxy=http://127.0.0.1:4444 curl http://proxy.i2p || ./I2P/bin/I2P; \ + echo "running the jpackaged I2P router since we can't find another one to use." fi if [ -z $BROWSING_PROFILE ]; then diff --git a/src/unix/i2pconfig.sh b/src/unix/i2pconfig.sh index 31ac7a5..b533e9b 100755 --- a/src/unix/i2pconfig.sh +++ b/src/unix/i2pconfig.sh @@ -6,7 +6,11 @@ fi if [ ! -z $I2PROUTER ]; then echo "$I2PROUTER" "$I2PCOMMAND" - "$I2PROUTER" "$I2PCOMMAND" + http_proxy=http://127.0.0.1:4444 curl http://proxy.i2p || "$I2PROUTER" "$I2PCOMMAND" +else if [ -d "I2P/bin" ]; then + http_proxy=http://127.0.0.1:4444 curl http://proxy.i2p || ./I2P/bin/I2P; \ + echo "running the jpackaged I2P router since we can't find another one to use." + fi if [ -f "$HOME/.i2p/router.config" ]; then