2021-03-18 23:54:13 +00:00
|
|
|
#!/bin/bash
|
2021-03-19 02:46:56 +00:00
|
|
|
set -e
|
2021-03-18 23:54:13 +00:00
|
|
|
|
2021-03-19 19:14:24 -04:00
|
|
|
JAVA=$(java --version | tr -d 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n' | cut -d ' ' -f 2 | cut -d '.' -f 1 | tr -d '\n\t ')
|
|
|
|
|
|
|
|
if [ "$JAVA" -lt "14" ]; then
|
2021-03-19 19:58:59 -04:00
|
|
|
echo "Java 14+ must be used to compile with jpackage, java is $JAVA"
|
|
|
|
exit 1
|
2021-03-18 23:54:13 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-19 19:14:24 -04:00
|
|
|
|
|
|
|
if [ -z "${JAVA_HOME}" ]; then
|
2021-03-19 19:58:59 -04:00
|
|
|
JAVA_HOME=`type -p java|xargs readlink -f|xargs dirname|xargs dirname`
|
|
|
|
echo "Building with: $JAVA, $JAVA_HOME"
|
2021-03-19 19:14:24 -04:00
|
|
|
fi
|
|
|
|
|
2021-03-18 23:54:13 +00:00
|
|
|
echo "cleaning"
|
2021-03-19 01:27:42 -04:00
|
|
|
./clean.sh
|
2021-03-18 23:12:52 -04:00
|
|
|
|
2021-03-18 23:54:13 +00:00
|
|
|
HERE=$PWD
|
2021-03-18 23:12:52 -04:00
|
|
|
RES_DIR=$HERE/../i2p.i2p/installer/resources
|
|
|
|
I2P_JARS=$HERE/../i2p.i2p/pkg-temp/lib
|
|
|
|
I2P_PKG=$HERE/../i2p.i2p/pkg-temp
|
|
|
|
|
2021-03-18 23:54:13 +00:00
|
|
|
|
|
|
|
echo "preparing resources.csv"
|
|
|
|
mkdir build
|
|
|
|
cd $RES_DIR
|
2021-03-19 02:46:56 +00:00
|
|
|
find certificates -name *.crt -exec echo '{},{},true' >> $HERE/build/resources.csv \;
|
2021-03-19 01:23:25 -04:00
|
|
|
cd portable/configs
|
2021-03-19 13:03:03 -04:00
|
|
|
find . -name '*.config' -exec echo 'config/{},{},false' >> $HERE/build/resources.csv \;
|
|
|
|
echo "config/hosts.txt,hosts.txt,false" >> $HERE/build/resources.csv
|
2021-03-18 23:12:52 -04:00
|
|
|
echo "preparing webapps"
|
|
|
|
cd $I2P_PKG
|
2021-03-19 13:03:03 -04:00
|
|
|
find webapps -name '*.war' -exec echo '{},{},true' >> $HERE/build/resources.csv \;
|
2021-03-19 02:46:56 +00:00
|
|
|
# TODO add others
|
2021-03-18 23:54:13 +00:00
|
|
|
cd $HERE
|
2021-03-19 02:46:56 +00:00
|
|
|
echo "geoip/GeoLite2-Country.mmdb,geoip/GeoLite2-Country.mmdb,true" >> build/resources.csv
|
|
|
|
# TODO: decide on blocklist.txt
|
2021-03-18 23:54:13 +00:00
|
|
|
|
2021-03-20 01:20:21 +00:00
|
|
|
sed -i.bak 's|\./||g' build/resources.csv
|
2021-03-18 23:12:52 -04:00
|
|
|
|
2021-03-18 23:54:13 +00:00
|
|
|
echo "copying certificates"
|
|
|
|
cp -R $RES_DIR/certificates build/
|
2021-03-18 23:12:52 -04:00
|
|
|
echo "copying config"
|
2021-03-19 01:23:25 -04:00
|
|
|
cp -R $RES_DIR/portable/configs build/config
|
2021-03-19 01:25:56 -04:00
|
|
|
cp -R $RES_DIR/hosts.txt build/config/hosts.txt
|
2021-03-18 23:12:52 -04:00
|
|
|
cp -R $I2P_PKG/webapps build/
|
2021-03-18 23:54:13 +00:00
|
|
|
|
|
|
|
echo "copying GeoIP"
|
|
|
|
mkdir build/geoip
|
|
|
|
cp $RES_DIR/GeoLite2-Country.mmdb.gz build/geoip
|
|
|
|
gunzip build/geoip/GeoLite2-Country.mmdb.gz
|
|
|
|
|
|
|
|
echo "compiling custom launcher"
|
2021-03-19 01:49:56 +00:00
|
|
|
cp $I2P_JARS/*.jar build
|
2021-03-18 23:54:13 +00:00
|
|
|
cd java
|
|
|
|
$JAVA_HOME/bin/javac -d ../build -classpath ../build/i2p.jar:../build/router.jar net/i2p/router/PackageLauncher.java
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo "building launcher.jar"
|
|
|
|
cd build
|
2021-03-19 01:23:25 -04:00
|
|
|
$JAVA_HOME/bin/jar -cf launcher.jar net certificates geoip config webapps resources.csv
|
2021-03-18 23:54:13 +00:00
|
|
|
cd ..
|
|
|
|
|
2021-03-20 01:32:30 +00:00
|
|
|
VERSION=$($JAVA_HOME/bin/java -cp build/router.jar net.i2p.router.RouterVersion | sed "s/.*: //" | head -n 1)
|
|
|
|
|
|
|
|
echo "preparing to invoke jpackage for I2P version $VERSION"
|
2021-03-18 23:54:13 +00:00
|
|
|
cp $I2P_JARS/*.jar build
|
2021-03-18 21:50:05 -04:00
|
|
|
|
|
|
|
if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
|
|
|
$JAVA_HOME/bin/jpackage --type app-image --name I2P --input build --main-jar launcher.jar --main-class net.i2p.router.PackageLauncher
|
|
|
|
else
|
2021-03-20 01:32:30 +00:00
|
|
|
$JAVA_HOME/bin/jpackage --name I2P --app-version $VERSION \
|
2021-03-20 01:44:04 +00:00
|
|
|
--license-file $I2P_PKG/LICENSE.txt \
|
2021-03-20 01:32:30 +00:00
|
|
|
--input build --main-jar launcher.jar --main-class net.i2p.router.PackageLauncher
|
2021-03-18 21:50:05 -04:00
|
|
|
fi
|