From cd1c39a6ea32e27fbc51da2dafb33988c326926b Mon Sep 17 00:00:00 2001 From: knaccc Date: Wed, 16 Jan 2019 07:40:19 +0000 Subject: [PATCH] Updated README --- README.md | 18 ++++++++++++------ bin/build-launcher.sh | 28 ++++++++++++++++++---------- bin/build-original-i2p.sh | 2 +- bin/convert-jars-to-modules.sh | 2 +- bin/import-packages.sh | 14 +++++++++++--- resources/launch.bat | 3 +++ 6 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 resources/launch.bat diff --git a/README.md b/README.md index 70b843a..0ccfa59 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Embedded I2P Java Router with SAM interface -This project will build a native launcher. The launcher will include the I2P router, a SAM listener and a minimal JVM. +This project will run under Linux, and build native launchers for Linux, MacOS and Windows. The launchers will include the I2P router, a SAM listener and a minimal JVM. -## Building the launcher +## Building the launchers First, retrieve this project from git: @@ -12,6 +12,8 @@ Note that the current version of this script uses jdk-11.0.2. If this version of download, then update the references to jdk-11.0.2 in this folder structure to the later version. To locate a recent JDK download URL, see https://jdk.java.net/11/ +Also note that JDKs for Linux, MacOS and Windows will be downloaded, which will total several hundred megabytes. + Run the `bin/build-all.sh` script, which will in turn call the following scripts: 1. `bin/import-packages.sh` to retrieve the I2P Java sources, OpenJDK and the Ant build tool @@ -19,13 +21,17 @@ Run the `bin/build-all.sh` script, which will in turn call the following scripts 2. `bin/build-original-i2p.sh` to build the I2P project retrieved from the I2P repository 3. `build-launcher.sh` to convert the I2P JARs to modules, compile the Java source code in this project, and then use -the jlink tool to build a zero-dependency platform-specific launcher. +the jlink tool to build a zero-dependency platform-specific launchers. -## Running the launcher +## Running the launchers -To run the router, type: +To run the Linux or MacOS router, type: -`dist/router/bin/launch.sh` +`dist/linux/router/bin/launch.sh` + +For Windows, run: + +`dist/windows/router/bin/launch.bat` If it launches successfully, you'll see the message: diff --git a/bin/build-launcher.sh b/bin/build-launcher.sh index b6ac698..1965a4e 100755 --- a/bin/build-launcher.sh +++ b/bin/build-launcher.sh @@ -2,7 +2,7 @@ basedir=$(dirname $(dirname $(readlink -fm $0))) -export JAVA_HOME=`realpath $basedir/import/jdk-11.0.2` +export JAVA_HOME=`realpath $basedir/import/jdks/linux/jdk-11.0.2` # convert the jar files from an existing I2P build into modules suitable for use with jlink $basedir/bin/convert-jars-to-modules.sh @@ -15,17 +15,25 @@ $JAVA_HOME/bin/javac --module-path import/lib -d target/classes $(find src -name echo "*** Packaging as a modular jar" $JAVA_HOME/bin/jar --create --file target/org.getmonero.i2p.embedded.jar --main-class org.getmonero.i2p.embedded.Main -C target/classes . -# create an OS specific launcher which will bundle together the code and a minimal JVM -echo "*** Performing jlink" -$JAVA_HOME/bin/jlink --module-path target/modules:target/org.getmonero.i2p.embedded.jar --add-modules org.getmonero.i2p.embedded --launcher router=org.getmonero.i2p.embedded --output target/router --strip-debug --compress 2 --no-header-files --no-man-pages +mkdir -p $basedir/dist/linux $basedir/dist/mac $basedir/dist/win -cp $basedir/resources/launch.sh $basedir/target/router/bin/ +# create OS specific launchers which will bundle together the code and a minimal JVM +echo "*** Performing jlink (Linux)" +$JAVA_HOME/bin/jlink --module-path $JAVA_HOME/jmods:target/modules:target/org.getmonero.i2p.embedded.jar --add-modules org.getmonero.i2p.embedded --launcher router=org.getmonero.i2p.embedded --output dist/linux/router --strip-debug --compress 2 --no-header-files --no-man-pages -cp -r $basedir/import/i2p.base $basedir/target/router/ -mkdir -p $basedir/target/router/i2p.config +echo "*** Performing jlink (Mac)" +$JAVA_HOME/bin/jlink --module-path $basedir/import/jdks/mac/jdk-11.0.2.jdk/Contents/Home/jmods:target/modules:target/org.getmonero.i2p.embedded.jar --add-modules org.getmonero.i2p.embedded --launcher router=org.getmonero.i2p.embedded --output dist/mac/router --strip-debug --compress 2 --no-header-files --no-man-pages -mkdir -p $basedir/dist/ -mv $basedir/target/router $basedir/dist/ +echo "*** Performing jlink (Windows)" +$JAVA_HOME/bin/jlink --module-path $basedir/import/jdks/win/jdk-11.0.2/jmods:target/modules:target/org.getmonero.i2p.embedded.jar --add-modules org.getmonero.i2p.embedded --launcher router=org.getmonero.i2p.embedded --output dist/win/router --strip-debug --compress 2 --no-header-files --no-man-pages + + +cp $basedir/resources/launch.sh $basedir/dist/linux/router/bin/ +cp $basedir/resources/launch.sh $basedir/dist/mac/router/bin/ +cp $basedir/resources/launch.bat $basedir/dist/win/router/bin/ + +for i in linux mac win; do cp -r $basedir/import/i2p.base $basedir/dist/$i/router/; done +for i in linux mac win; do mkdir -p $basedir/dist/$i/router/i2p.config; done echo "*** Done ***" -echo "To run, type: dist/router/bin/launch.sh" \ No newline at end of file +echo "To run, type: dist/linux/router/bin/launch.sh" \ No newline at end of file diff --git a/bin/build-original-i2p.sh b/bin/build-original-i2p.sh index 9fdbb4b..6df6142 100755 --- a/bin/build-original-i2p.sh +++ b/bin/build-original-i2p.sh @@ -4,7 +4,7 @@ basedir=$(dirname $(dirname $(readlink -fm $0))) cd $basedir/import -export JAVA_HOME=`realpath $basedir/import/jdk-11.0.2` +export JAVA_HOME=`realpath $basedir/import/jdks/linux/jdk-11.0.2` # build the jars we're going to modularize diff --git a/bin/convert-jars-to-modules.sh b/bin/convert-jars-to-modules.sh index 539b08b..c661004 100755 --- a/bin/convert-jars-to-modules.sh +++ b/bin/convert-jars-to-modules.sh @@ -2,7 +2,7 @@ basedir=$(dirname $(dirname $(readlink -fm $0))) -export JAVA_HOME=`realpath $basedir/import/jdk-11.0.2` +export JAVA_HOME=`realpath $basedir/import/jdks/linux/jdk-11.0.2` jarPaths=`find $basedir/import/lib -name '*.jar'` diff --git a/bin/import-packages.sh b/bin/import-packages.sh index d4216bc..807bf6f 100755 --- a/bin/import-packages.sh +++ b/bin/import-packages.sh @@ -7,8 +7,16 @@ cd $basedir/import git clone https://github.com/i2p/i2p.i2p.git -wget https://download.java.net/java/GA/jdk11/7/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -wget https://www-us.apache.org/dist//ant/binaries/apache-ant-1.10.5-bin.tar.gz +mkdir jdks +mkdir jdks/linux jdks/mac jdks/win +wget --directory-prefix=jdks/linux https://download.java.net/java/GA/jdk11/7/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz +wget --directory-prefix=jdks/mac https://download.java.net/java/GA/jdk11/7/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz +wget --directory-prefix=jdks/win https://download.java.net/java/GA/jdk11/7/GPL/openjdk-11.0.2_windows-x64_bin.zip + +wget https://www-us.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.tar.gz + +tar zxvf jdks/linux/openjdk-11.0.2_linux-x64_bin.tar.gz -C jdks/linux/ +tar zxvf jdks/mac/openjdk-11.0.2_osx-x64_bin.tar.gz -C jdks/mac/ +unzip jdks/win/openjdk-11.0.2_windows-x64_bin.zip -d jdks/win/ -tar zxvf openjdk-11.0.2_linux-x64_bin.tar.gz tar zxvf apache-ant-1.10.5-bin.tar.gz \ No newline at end of file diff --git a/resources/launch.bat b/resources/launch.bat new file mode 100644 index 0000000..b5b2efe --- /dev/null +++ b/resources/launch.bat @@ -0,0 +1,3 @@ +@echo off +set DIR=%~dp0 +"%DIR%\java" -cp %DIR%\..\i2p.base\jbigi.jar -m org.getmonero.i2p.embedded --i2p.dir.base=%DIR%\..\i2p.base --i2p.dir.config=%DIR%\..\i2p.config %* \ No newline at end of file