mirror of
https://github.com/wownero/i2p-zero.git
synced 2026-10-25 10:09:56 +01:00
Now doesn't require any Ubuntu packages to be installed in order to build (java, ant, i2p). Produces a distribution with zero dependencies.
This commit is contained in:
@@ -2,45 +2,29 @@
|
||||
|
||||
This project will build a native launcher. The launcher will include the I2P router, a SAM listener and a minimal JVM.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This project requires the JAR files and base configuration dir from an existing I2P installation.
|
||||
|
||||
To install I2P on Ubuntu so that these files are available to you, type:
|
||||
|
||||
```
|
||||
sudo apt-add-repository ppa:i2p-maintainers/i2p
|
||||
sudo apt-get update
|
||||
sudo apt-get install i2p
|
||||
```
|
||||
|
||||
Then copy the following 6 JAR files from the I2P installation to the import/lib directory in your clone of this GitHub project:
|
||||
|
||||
```
|
||||
mkdir -p import/lib
|
||||
for i in i2p.jar mstreaming.jar router.jar sam.jar streaming.jar gnu-getopt.jar libintl.jar; do cp /usr/share/i2p/lib/$i import/lib/; done
|
||||
mv import/lib/gnu-getopt.jar import/lib/gnugetopt.jar
|
||||
```
|
||||
|
||||
You will need OpenJDK 11 installed:
|
||||
|
||||
`sudo apt install openjdk-11-jdk-headless`
|
||||
|
||||
## Building the launcher
|
||||
|
||||
`bin/build-launcher.sh`
|
||||
retrieve this project from git:
|
||||
|
||||
This will convert the imported JARs to modules, compile the Java source code in this project, and then use the jlink tool
|
||||
to build a platform-specific launcher executable.
|
||||
`git clone https://github.com/knaccc/embedded-i2p-java-router-with-sam.git`
|
||||
|
||||
Note that the current version of this script uses jdk-11.0.2. If this version of Java becomes no longer available for
|
||||
download, then update the references to jdk-11.0.2 in this folder structure to the later version.
|
||||
|
||||
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
|
||||
|
||||
2. `bin/build-original-i2p.sh` to build the i2p project retrieved from the I2P repository
|
||||
|
||||
3. `build-launcher.sh` to convert the imported 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.
|
||||
|
||||
## Running the launcher
|
||||
|
||||
The launcher will need access to the /usr/share/i2p base directory. It will create a .i2p directory for configuration
|
||||
files in the current user's home directory if it does not already exist.
|
||||
|
||||
To run the router, type:
|
||||
|
||||
`target/router/bin/router`
|
||||
`target/router/bin/launch.sh`
|
||||
|
||||
If it launches successfully, you'll see the message:
|
||||
|
||||
@@ -49,6 +33,3 @@ If it launches successfully, you'll see the message:
|
||||
## Check that the I2P router is running and that it is listening for SAM connections
|
||||
|
||||
`fuser 7656/tcp`
|
||||
|
||||
## Todo
|
||||
Need to determine the most minimal base configuration directory contents, and include it as part of this project.
|
||||
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
|
||||
# retrieve the I2P Java sources, OpenJDK and the Ant build tool
|
||||
$basedir/bin/import-packages.sh
|
||||
|
||||
# build the i2p project retrieved from the I2P repository
|
||||
$basedir/bin/build-original-i2p.sh
|
||||
|
||||
# convert the imported 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
|
||||
$basedir/bin/build-launcher.sh
|
||||
+14
-4
@@ -2,20 +2,30 @@
|
||||
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
|
||||
export JAVA_HOME=`realpath $basedir/import/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
|
||||
|
||||
# compile the Main class that starts the I2P router and SAM listener
|
||||
echo "*** Compiling Main class"
|
||||
javac --module-path import/lib -d target/classes $(find src -name '*.java')
|
||||
$JAVA_HOME/bin/javac --module-path import/lib -d target/classes $(find src -name '*.java')
|
||||
|
||||
# package as a modular jar
|
||||
echo "*** Packaging as a modular jar"
|
||||
jar --create --file target/org.getmonero.i2p.embedded.jar --main-class org.getmonero.i2p.embedded.Main -C target/classes .
|
||||
$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"
|
||||
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
|
||||
$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
|
||||
|
||||
cp $basedir/resources/launch.sh $basedir/target/router/bin/
|
||||
|
||||
cp -r $basedir/import/i2p.base $basedir/target/router/
|
||||
mkdir -p $basedir/target/router/i2p.config
|
||||
|
||||
mkdir -p $basedir/dist/
|
||||
mv $basedir/target/router $basedir/dist/
|
||||
|
||||
echo "*** Done ***"
|
||||
echo "To run, type: target/router/bin/router"
|
||||
echo "To run, type: dist/router/bin/launch.sh"
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
|
||||
cd $basedir/import
|
||||
|
||||
export JAVA_HOME=`realpath $basedir/import/jdk-11.0.2`
|
||||
|
||||
|
||||
# build the jars we're going to modularize
|
||||
cd $basedir/import/i2p.i2p
|
||||
$basedir/import/apache-ant-1.10.5/bin/ant pkg
|
||||
$basedir/import/apache-ant-1.10.5/bin/ant updaterWithJbigi
|
||||
cd ..
|
||||
|
||||
|
||||
# copy the jars that we're going to modularize
|
||||
mkdir -p $basedir/import/lib
|
||||
for i in i2p.jar mstreaming.jar router.jar sam.jar streaming.jar; do cp $basedir/import/i2p.i2p/build/$i $basedir/import/lib/; done
|
||||
|
||||
# build a minimal i2p.base dir
|
||||
mkdir -p $basedir/import/i2p.base
|
||||
cp $basedir/import/i2p.i2p/build/jbigi.jar $basedir/import/i2p.base/
|
||||
for i in blocklist.txt hosts.txt certificates; do cp -r $basedir/import/i2p.i2p/installer/resources/$i $basedir/import/i2p.base/; done
|
||||
|
||||
mkdir -p $basedir/import/i2p.base/geoip
|
||||
for i in continents.txt countries.txt; do cp -r $basedir/import/i2p.i2p/installer/resources/$i $basedir/import/i2p.base/geoip/; done
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
|
||||
export JAVA_HOME=`realpath $basedir/import/jdk-11.0.2`
|
||||
|
||||
jarPaths=`find $basedir/import/lib -name '*.jar'`
|
||||
|
||||
mkdir -p $basedir/target/modules
|
||||
@@ -10,12 +12,12 @@ rm -f $basedir/target/modules/*
|
||||
for jarPath in $jarPaths; do
|
||||
moduleName=$(basename "${jarPath%.*}")
|
||||
echo "*** Determining dependencies for $moduleName"
|
||||
jdeps --module-path $basedir/import/lib --add-modules=ALL-MODULE-PATH --generate-module-info $basedir/target/module-info $jarPath
|
||||
$JAVA_HOME/bin/jdeps --module-path $basedir/import/lib --add-modules=ALL-MODULE-PATH --generate-module-info $basedir/target/module-info $jarPath
|
||||
done
|
||||
for jarPath in $jarPaths; do
|
||||
moduleName=$(basename "${jarPath%.*}")
|
||||
echo "*** Creating new modular jar for $moduleName"
|
||||
javac --module-path $basedir/import/lib --patch-module $moduleName=$jarPath $basedir/target/module-info/$moduleName/module-info.java
|
||||
$JAVA_HOME/bin/javac --module-path $basedir/import/lib --patch-module $moduleName=$jarPath $basedir/target/module-info/$moduleName/module-info.java
|
||||
cp $jarPath $basedir/target/modules/
|
||||
jar uf $basedir/target/modules/${moduleName}.jar -C $basedir/target/module-info/$moduleName module-info.class
|
||||
$JAVA_HOME/bin/jar uf $basedir/target/modules/${moduleName}.jar -C $basedir/target/module-info/$moduleName module-info.class
|
||||
done
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
|
||||
mkdir $basedir/import
|
||||
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
|
||||
|
||||
tar zxvf openjdk-11.0.2_linux-x64_bin.tar.gz
|
||||
tar zxvf apache-ant-1.10.5-bin.tar.gz
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
|
||||
$basedir/bin/java -cp $basedir/i2p.base/jbigi.jar -m org.getmonero.i2p.embedded --i2p.dir.base=$basedir/i2p.base --i2p.dir.config=$basedir/i2p.config
|
||||
@@ -4,7 +4,5 @@ module org.getmonero.i2p.embedded {
|
||||
requires streaming;
|
||||
requires router;
|
||||
requires sam;
|
||||
requires libintl;
|
||||
requires gnugetopt;
|
||||
requires jdk.crypto.ec;
|
||||
}
|
||||
Reference in New Issue
Block a user