19 Commits

Author SHA1 Message Date
idk
a6c4253965 keep a static ref to the router 2022-12-09 15:13:39 +00:00
idk
8cbdb0bcfd don't redundantly delete the update if the wrong type is downloaded 2022-11-30 15:40:05 +00:00
idk
be7e0a1386 fix spaces around else in MacLauncher.java 2022-11-30 15:37:19 +00:00
idk
103ea70d8b remove dupe line from MacLauncher.java 2022-11-30 15:36:50 +00:00
idk
bf9ce0a3f8 delete erroneous update files in case they get picked up on a restart and unpacked again somehow. 2022-11-28 21:59:58 -05:00
idk
904e91ddd9 fix some formatting 2022-11-28 21:50:22 -05:00
idk
b0f52280a8 auto-migrate update URLs if they are left blank so that an su3/zip update doesn't get unpacked on top of a jpackage install 2022-11-28 21:46:50 -05:00
idk
ebf7841a86 allow users without a signing cert to run the buildscript and generate an unsigned app image 2022-11-15 23:12:46 -05:00
idk
77ad3358fd add the actual build instructions to BUILD.md 2022-11-13 17:15:32 -05:00
idk
14a18fc993 set JAVA_HOME in build.sh if it's not set yet 2022-11-13 16:53:20 -05:00
idk
686158e24b Add config.sh and example config.sh file 2022-11-13 16:26:22 -05:00
idk
2b21d7b78f extend build instructions to describe build setup 2022-11-10 17:19:11 -05:00
Zlatin Balevsky
e9da1041f5 fix config file name 2022-07-28 18:37:09 +01:00
Zlatin Balevsky
e1dbd4ac08 do not skip jbigi on Apple silicon 2022-07-03 13:32:49 +01:00
Zlatin Balevsky
ecd387b901 separate news urls for Apple silicon 2022-06-23 03:44:22 +01:00
Zlatin Balevsky
c87daec905 Do not bundle JBigi on Apple silicon 2022-06-23 03:34:15 +01:00
Zlatin Balevsky
0d0ea58276 copy all licenses from i2p's temp bundle inside the I2P.app 2022-05-20 14:11:06 +01:00
Zlatin Balevsky
a0bfdad1a9 Append a snippet about GPLv2+CE to I2P's LICENSE.txt file 2022-05-20 13:53:41 +01:00
Zlatin Balevsky
b0cffca0ab wait for ClientAppManager like the Windows launcher does 2022-02-11 18:37:03 +00:00
7 changed files with 187 additions and 5 deletions

115
BUILD.md Normal file
View File

@@ -0,0 +1,115 @@
Building an I2P Easy-Install Bundle for Mac
===========================================
This documents building the I2P Easy-Install for Mac end-to-end, including the
set up, configuration, and maintenance of a build environment.
Setting up a Java SDK manager
-----------------------------
Unlike many popular Linux distributions, Mac OSX does not have a built-in way
of switching between Java versions. There are several third-party tools for
doing this, including `sdkman` and `asdf`. After evaluation, I found
sdkman to be the most complete and easy to use. Installation instructions are
available here:
- https://sdkman.io/install
Since it uses a curlpipe to install, please be sure to pay attention to the
content of the install script.
- https://get.sdkman.io
After you follow the install instructions, you will be able to fetch java SDKs
and automatically configure your `JAVA_HOME`.
Currently, bundles are built with OpenJDK 19.
```sh
sdk install java 19.0.1-open
sdk use java 19.0.1-open
```
Will automatically set up your OpenJDK 19.
If you do not wish to use an SDK manager, or you with to use a different SDK
manager, this [Stack Overflow link](https://stackoverflow.com/questions/52524112/how-do-i-install-java-on-mac-osx-allowing-version-switching)
shows every option in detail.
Setting up Brew and resolving build dependencies
------------------------------------------------
There are also a number of build dependencies for I2P which you will need to
keep up to date. This is aided by the use of the brew package manager. Obtain
`brew` by installing it according to the instructions here:
- https://brew.sh/
Once Brew is finished installing, install the I2P build dependencies.
```sh
brew install ant gettext gradle
```
Remember to run `brew update` and `brew upgrade ant gettext gradle` before
rebuilding I2P.
Building the I2P Router Dependencies and the Package
----------------------------------------------------
Once you have all that installed you're ready to build the core I2P router
libraries and package the application. This can all be automated with the use
of `build.sh`. In order to do this successfully, you need to be able to sign
OSX packages, using a certificate which you obtain from Apple itself. Obtaining
that certificate is outside the scope of this document primarily because I do
not have the ability to obtain such a certificate without sharing my identity
with Apple.
- https://developer.apple.com/support/certificates/
- https://developer.apple.com/documentation/appstoreconnectapi/certificates
In order to configure your release environment, you must set the following
environment variables:
- `I2P_SIGNER` should be the [Apple Developer ID of the signer](https://developer.apple.com/support/developer-id/)
- `I2P_VERSION` should be the version of the I2P router that you want to use
- `I2P_BUILD_NUMBER` should be an integer greater than `0`.
Ensure you have a copy of `i2p.i2p` checked out adjacent to the
`i2p-jpackage-mac` directory, in the same parent. If this is your first time
building the jpackage, run the following command:
```sh
git clone https://i2pgit.org/i2p-hackers/i2p.i2p
```
Change to the `i2p.i2p` directory and check out the release branch you want to
build a package for, e.g. `i2p-1.9.0`
```sh
cd ../i2p.i2p
git pull --tags
git checkout i2p-1.9.0
```
Now that you have the right branch, clean and rebuild the core library:
```sh
ant clean preppkg-osx-only
```
Then, change back to the `i2p-jpackage-mac` directory:
```sh
cd ../i2p-jpackage-mac
```
Finally, run the `build.sh` script to generate the `.dmg` file.
```sh
./build.sh
```
Creating a new release
----------------------

View File

@@ -19,7 +19,7 @@ JPackage scripts for packaging I2P on a Mac.
In order to build an AppBundle that can work from anywhere, it is necessary to use a dedicated main class which determines the current working directory and sets `i2p.dir.base` to the correct location inside the AppBundle. Therefore the `build.sh` script:
1. Compiles the custom main clas and puts it in a `launcher.jar`
1. Compiles the custom main class and puts it in a `launcher.jar`
1. Invokes JPackage with the `--app-image` switch to create the directory structure of the bundle
1. Copies the contents of `../i2p.i2p/pkg-temp` inside the AppBundle, except for the `jars` directory
1. Signs the AppBundle

View File

@@ -1,6 +1,10 @@
#!/bin/bash
set -e
if [ -f config.sh ]; then
. config.sh
fi
# old javas output version to stderr and don't support --version
JAVA=$(java --version 2>&1 | tr -d 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n' | cut -d ' ' -f 2 | cut -d '.' -f 1 | tr -d '\n\t ')
@@ -16,7 +20,7 @@ if [ "$JAVA" -lt "16" ]; then
fi
if [ -z "${I2P_SIGNER}" ]; then
echo "I2P_SIGNER variable not set, can't sign. Aborting..."
echo "I2P_SIGNER variable not set, can't sign. Script will terminate after unsigned app-image generation"
exit 1
fi
@@ -30,11 +34,16 @@ if [ -z ${I2P_BUILD_NUMBER} ]; then
exit 1
fi
if [ -z ${JAVA_HOME} ]; then
JAVA_HOME=$(/usr/libexec/java_home)
fi
echo "JAVA_HOME is $JAVA_HOME"
echo "cleaning"
./clean.sh
ARCH=$(uname -m)
HERE=$PWD
I2P_JARS=$HERE/../i2p.i2p/pkg-temp/lib
I2P_PKG=$HERE/../i2p.i2p/pkg-temp
@@ -76,6 +85,7 @@ echo "preparing to invoke jpackage for I2P version $I2P_VERSION build $I2P_BUILD
cp "$I2P_PKG/Start I2P Router.app/Contents/Resources/i2p.icns" build/I2P.icns
cp "$I2P_PKG/Start I2P Router.app/Contents/Resources/i2p.icns" build/I2P-volume.icns
cp $I2P_PKG/LICENSE.txt build
cat resources/License-JRE-snippet.txt >> build/LICENSE.txt
cp resources/I2P-background.tiff build
cp resources/Info.plist.template build/Info.plist
@@ -103,10 +113,25 @@ for i in i2prouter lib locale man wrapper.config eepget runplain.sh postinstall.
rm -rf I2P.app/Contents/Resources/$i
done
cp $HERE/resources/GPLv2+CE.txt I2P.app/Contents/Resources/licenses/LICENSE-JRE.txt
cp $I2P_PKG/licenses/* I2P.app/Contents/Resources/licenses/
cp $HERE/build/libMacLauncher.jnilib I2P.app/Contents/Resources
cp $HERE/resources/router.config I2P.app/Contents/Resources
if [ $ARCH == "arm64" ]; then
cp $HERE/resources/router.config.arm64 I2P.app/Contents/Resources/router.config
else
cp $HERE/resources/router.config I2P.app/Contents/Resources
fi
cp $HERE/resources/*.crt I2P.app/Contents/Resources/certificates/router
if [ -z $I2P_SIGNER ]; then
echo "I2P_SIGNER is unset, not proceeding to signing phase"
exit 0
fi
if [ $I2P_SIGNER = signer@mail.i2p]; then
echo "I2P_SIGNER is unset, not proceeding to signing phase"
exit 0
fi
echo "signing the runtime libraries"
find I2P.app -name *.dylib -exec codesign --force -s $I2P_SIGNER -v '{}' \;
find I2P.app -name *.jnilib -exec codesign --force -s $I2P_SIGNER -v '{}' \;

5
config.sh Normal file
View File

@@ -0,0 +1,5 @@
#! /usr/bin/env sh
I2P_SIGNER=signer@mail.i2p
I2P_VERSION=2.0.0
I2P_BUILD_NUMBER=1

View File

@@ -18,6 +18,7 @@ public class MacLauncher {
/** this is totally undocumented */
private static final String APP_PATH = "jpackage.app-path";
private static Router i2pRouter;
public static void main(String[] args) throws Exception {
String path = System.getProperty(APP_PATH,"unknown");
@@ -42,12 +43,30 @@ public class MacLauncher {
}
i2pRouter = new Router(System.getProperties());
Thread registrationThread = new Thread(REGISTER_UPP);
registrationThread.setName("UPP Registration");
registrationThread.setDaemon(true);
registrationThread.start();
RouterLaunch.main(args);
String arch = System.getProperty("os.arch");
if (arch.equals("aarch64")) {
changeSetting(i2pRouter, "router.newsURL", "http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/mac-arm64/stable/news.su3");
changeSetting(i2pRouter, "router.backupNewsURL", "http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/mac-arm64/stable/news.su3");
} else {
changeSetting(i2pRouter, "router.newsURL", "http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/mac/stable/news.su3");
changeSetting(i2pRouter, "router.backupNewsURL", "http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/mac/stable/news.su3");
}
i2pRouter.runRouter();
}
private static void changeSetting(Router i2pRouter, String key, String value){
String setting = i2pRouter.getConfigSetting(key);
if (setting == null) {
i2pRouter.saveConfig(key, value);
}
}
private static native void disableAppNap();
@@ -60,8 +79,13 @@ public class MacLauncher {
sleep(1000);
}
// then wait for ClientAppManager
ClientAppManager cam;
while ((cam = ctx.clientAppManager()) == null) {
sleep(1000);
}
// then wait for the update manager
ClientAppManager cam = ctx.clientAppManager();
UpdateManager um;
while ((um = (UpdateManager) cam.getRegisteredApp(UpdateManager.APP_NAME)) == null) {
sleep(1000);

View File

@@ -0,0 +1,11 @@
Java Runtime Environment
------------------------
This Mac bundle comes with a built-in Java Runtime
Environment which is licensed under GPLv2+Classpath
exception.
You can find the text of this license in
Source tree - resources/GPLv2+CE.txt
I2P.app bundle - Contents/Resources/licenses/LICENSE-JRE.txt

View File

@@ -0,0 +1,2 @@
router.newsURL=http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/mac-arm64/stable/news.su3
router.backupNewsURL=http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/mac-arm64/stable/news.su3