-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·180 lines (148 loc) · 6.09 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/bash
set -e
git describe --tags `git rev-list --tags --max-count=1` || exit 1
export GITHUB_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | sed 's|i2p||g' | tr -d a-z-)
if echo "$GITHUB_TAG" | grep -q '.\..\..'; then
PUBLISH_VERSION="$GITHUB_TAG"
else
echo "github tag $GITHUB_TAG does not match version pattern"
# no way to guess here, so if it's unset it must default to the latest version number:
if [ -z "$PUBLISH_VERSION" ]; then
PUBLISH_VERSION="2.7.0"
fi
fi
if [ -z "$I2P_VERSION" ]; then
I2P_VERSION="i2p-$GITHUB_TAG"
fi
if echo "$I2P_VERSION" | grep -q '.\..\..'; then
if [ -z "$I2P_RELEASE_VERSION" ]; then
I2P_RELEASE_VERSION="$I2P_VERSION"
fi
else
if [ -z "$I2P_RELEASE_VERSION" ]; then
I2P_RELEASE_VERSION=$GITHUB_TAG
fi
fi
echo "using $PUBLISH_VERSION as our release version to placate jpackage"
if [ -z "$I2P_BUILD_NUMBER" ]; then
I2P_BUILD_NUMBER=1
fi
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 ')
if [ -z "$JAVA" ]; then
echo "Failed to parse Java version, java is:"
java -version
exit 1
fi
if [ "$JAVA" -lt "16" ]; then
echo "Java 16+ must be used to compile with jpackage on Mac, java is $JAVA"
exit 1
fi
if [ -z "${JAVA_HOME}" ]; then
JAVA_HOME=$(/usr/libexec/java_home)
fi
if [ -z "$I2P_SIGNER_USERPHRASE" ]; then
I2P_SIGNER_USERPHRASE=$(security find-identity -v -p codesigning | head -n 1 | cut -d '"' -f 2)
echo "Warning: using automatically configured signer ID, make sure this is the one you want: $I2P_SIGNER_USERPHRASE"
echo "continuing in 10 seconds"
sleep 10
fi
echo "JAVA_HOME is $JAVA_HOME"
echo "cleaning"
./clean.sh
ARCH=$(uname -m)
HERE=$PWD
I2P_SRC=$HERE/i2p.i2p-jpackage-mac/
I2P_SRC_BASE=$HERE/i2p.i2p/
rm -rf "$I2P_SRC"
if [ ! -d "$I2P_SRC_BASE" ]; then
git clone https://i2pgit.org/i2p-hackers/i2p.i2p "$I2P_SRC_BASE"
fi
cd "$I2P_SRC_BASE" && git pull --tags && cd "$HERE"
git clone -b "$I2P_VERSION" "$I2P_SRC_BASE" "$I2P_SRC"
I2P_JARS=$HERE/i2p.i2p-jpackage-mac/pkg-temp/lib
I2P_PKG=$HERE/i2p.i2p-jpackage-mac/pkg-temp
cd "$I2P_SRC"
OLDEXTRA=$(grep 'String EXTRA' "$I2P_SRC/router/java/src/net/i2p/router/RouterVersion.java")
if [ -z "$EXTRA" ]; then
export EXTRACODE="mac"
export EXTRA=" public final static String EXTRA = \"-$EXTRACODE\";"
fi
sed -i.bak "s|$OLDEXTRA|$EXTRA|g" "$I2P_SRC/router/java/src/net/i2p/router/RouterVersion.java"
git commit -am "$I2P_RELEASE_VERSION-$EXTRACODE"
git checkout -b "$I2P_RELEASE_VERSION-$EXTRACODE" || git checkout "$I2P_RELEASE_VERSION-$EXTRACODE"
git archive --format=tar.gz --output="$HERE/i2p.i2p.jpackage-mac.tar.gz" "$I2P_RELEASE_VERSION-$EXTRACODE"
if [ ! -d "$I2P_PKG" ]; then
ant clean preppkg-osx-only
fi
cd "$HERE"
mkdir build
echo "compiling custom launcher and update processor"
cc -v -Wl,-lobjc -mmacosx-version-min=10.9 -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" -Ic -o build/libMacLauncher.jnilib -shared c/net_i2p_router_MacLauncher.c
cp "$I2P_JARS"/*.jar build
cd java
javac -d ../build -classpath ../build/i2p.jar:../build/router.jar net/i2p/router/MacLauncher.java net/i2p/update/*.java
cd "$HERE"
echo "copying mac-update.sh"
cp bash/mac-update.sh build
echo "building launcher.jar"
cd build
jar -cf launcher.jar net mac-update.sh
cd ..
echo "preparing to invoke jpackage for I2P version $I2P_RELEASE_VERSION build $I2P_BUILD_NUMBER"
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
sed -i.bak "s/I2P_VERSION/$I2P_RELEASE_VERSION/g" build/Info.plist
sed -i.bak "s/I2P_BUILD_NUMBER/$I2P_BUILD_NUMBER/g" build/Info.plist
cp resources/I2P-dmg-setup.scpt.template build/I2P-dmg-setup.scpt
sed -i.bak "s@__HERE__@${HERE}@g" build/I2P-dmg-setup.scpt
rm build/*.bak
if [ -z $I2P_SIGNER_USERPHRASE ]; then
SIGNING_ARG="--mac-signing-key-user-name $I2P_SIGNER_USERPHRASE"
fi
jpackage --name I2P \
--java-options "-Xmx512m" \
--java-options "--add-opens java.base/java.lang=ALL-UNNAMED" \
--java-options "--add-opens java.base/sun.nio.fs=ALL-UNNAMED" \
--java-options "--add-opens java.base/java.nio=ALL-UNNAMED" \
--type app-image \
--verbose \
--resource-dir build \
$SIGNING_ARG \
--mac-entitlements resources/entitlements.xml \
--input build --main-jar launcher.jar --main-class net.i2p.router.MacLauncher
echo "adding pkg-temp to resources"
cp -R "$I2P_PKG"/* I2P.app/Contents/Resources
for i in i2prouter lib locale man wrapper.config eepget runplain.sh postinstall.sh osid; do
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
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
# consider there might be some reason to re-enable this if an external maintainer arrives
#cp "$HERE"/resources/*.crt I2P.app/Contents/Resources/certificates/router
jpackage --name I2P --app-version "$PUBLISH_VERSION" \
--java-options "-Xmx512m" \
--java-options "--add-opens java.base/java.lang=ALL-UNNAMED" \
--java-options "--add-opens java.base/sun.nio.fs=ALL-UNNAMED" \
--java-options "--add-opens java.base/java.nio=ALL-UNNAMED" \
--type dmg \
--verbose \
--resource-dir build \
$SIGNING_ARG \
--mac-entitlements resources/entitlements.xml \
--input build --main-jar launcher.jar --main-class net.i2p.router.MacLauncher
ls -lah I2P*.dmg
ls -lahd I2P*