-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathpackagesbuild.sh
executable file
·205 lines (189 loc) · 5.55 KB
/
packagesbuild.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/usr/bin/env bash
################################################################################
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
set -eu
SIGN_OPTION=
SIGN_CMD=
NOTARIZE_OPTION=
IDENTIFIER=
VENDOR="temurin"
PACKAGE_NAME="Eclipse Temurin"
LOGO="Resources/adoptium.png"
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "options:"
echo "-h, --help show brief help"
echo "--major_version <8,11,17,19>"
echo "--full_version 17.0.3_7"
echo "-i, --input_directory path to extracted jdk"
echo "-o, --output_directory name of the pkg file"
echo "--jvm hotspot or openj9"
echo "--architecture x86_64 or arm64"
echo "--type jdk or jre"
echo "--vendor adoptium, dragonwell etc"
echo "--package-name full name of the package (shown in the title)"
echo "--logo Relative path to a custom logo (bottom left)"
echo "--identifier override the identifier e.g net.adoptopenjdk.17.jdk"
echo "-s, --sign sign the installer"
exit 0
;;
--major_version)
shift
MAJOR_VERSION=$1
shift
;;
--full_version)
shift
FULL_VERSION=$1
shift
;;
-i|--input_directory)
shift
INPUT_DIRECTORY=$1
shift
;;
-o|--output_directory)
shift
OUTPUT_DIRECTORY=$1
shift
;;
--jvm)
shift
JVM=$1
shift
;;
--architecture)
shift
ARCHITECTURE="$1"
shift
;;
--type)
shift
TYPE=$1
shift
;;
--vendor)
shift
VENDOR="$1"
shift
;;
--package-name)
shift
PACKAGE_NAME="$1"
shift
;;
--logo)
shift
LOGO="$1"
shift
;;
--identifier)
shift
IDENTIFIER="$1"
shift
;;
-s|--sign)
shift
SIGN_OPTION="true"
SIGN_CERT="$1"
NOTARIZE_OPTION="true"
shift
;;
*)
break
;;
esac
done
# Ensures that ARCHITECTURE is valid to avoid incorrectly compiled PKGs
case $ARCHITECTURE in
x86_64) ;;
arm64) ;;
*)
echo "Unknown architecture: $ARCHITECTURE"
exit 1
;;
esac
case $JVM in
openj9)
if [ -z "$IDENTIFIER" ]; then
IDENTIFIER="net.${VENDOR}.${MAJOR_VERSION}-openj9.${TYPE}"
fi
DIRECTORY="${VENDOR}-${MAJOR_VERSION}-openj9.${TYPE}"
BUNDLE="${PACKAGE_NAME} (OpenJ9)"
cp Licenses/license-OpenJ9.en-us.rtf Resources/license.rtf
case $TYPE in
jre) BUNDLE="${PACKAGE_NAME} (OpenJ9, JRE)" ;;
jdk) BUNDLE="${PACKAGE_NAME} (OpenJ9)" ;;
esac
;;
*)
if [ -z "$IDENTIFIER" ]; then
IDENTIFIER="net.${VENDOR}.${MAJOR_VERSION}.${TYPE}"
fi
DIRECTORY="${VENDOR}-${MAJOR_VERSION}.${TYPE}"
cp Licenses/license-GPLv2+CE.en-us.rtf Resources/license.rtf
case $TYPE in
jre) BUNDLE="${PACKAGE_NAME} (JRE)" ;;
jdk) BUNDLE="${PACKAGE_NAME}" ;;
esac
;;
esac
OUTPUT_FILE=$(basename "$OUTPUT_DIRECTORY" | cut -f 1 -d '.')
rm -rf *.pkg build/*.pkg distribution.xml Resources/en.lproj/welcome.html Resources/en.lproj/conclusion.html OpenJDKPKG.pkgproj "${DIRECTORY}"
cp -R "${INPUT_DIRECTORY}" "${DIRECTORY}"
if [ ! -z "$SIGN_OPTION" ]; then
xattr -cr .
security unlock-keychain -p `cat ~/.password` login.keychain-db
/usr/bin/codesign --verbose=4 --deep --force -s - ${DIRECTORY}
fi
cat OpenJDKPKG.pkgproj.template \
| sed -E "s~\\{path\\}~$DIRECTORY~g" \
| sed -E "s~\\{output\\}~$OUTPUT_FILE~g" \
| sed -E "s~\\{identifier\\}~$IDENTIFIER~g" \
| sed -E "s~\\{package-name\\}~$PACKAGE_NAME~g" \
| sed -E "s~\\{directory\\}~$DIRECTORY~g" \
| sed -E "s~\\{logo\\}~$LOGO~g" \
| sed -E "s~\\{arch\\}~$ARCHITECTURE~g" \
| sed -E "s~\\{full-version\\}~$FULL_VERSION~g" \
>OpenJDKPKG.pkgproj ; \
cat Resources/en.lproj/welcome.html.tmpl \
| sed -E "s/\\{full_version\\}/$FULL_VERSION/g" \
| sed -E "s/\\{directory\\}/$DIRECTORY/g" \
| sed -E "s~\\{package-name\\}~$PACKAGE_NAME~g" \
>Resources/introduction.html ; \
cat Resources/en.lproj/conclusion.html.tmpl \
| sed -E "s/\\{full_version\\}/$FULL_VERSION/g" \
| sed -E "s/\\{directory\\}/$DIRECTORY/g" \
| sed -E "s~\\{package-name\\}~$PACKAGE_NAME~g" \
>Resources/summary.html ; \
/usr/local/bin/packagesbuild -v OpenJDKPKG.pkgproj
if [ ! -z "$SIGN_OPTION" ]; then
/usr/bin/productsign --sign "${SIGN_CERT}" build/"$OUTPUT_FILE.pkg" "$OUTPUT_DIRECTORY"
else
mv build/"$OUTPUT_FILE.pkg" "$OUTPUT_DIRECTORY"
fi
if [ ! -z "$NOTARIZE_OPTION" ]; then
echo "Notarizing the installer (please be patient! this takes aprox 10 minutes)"
sudo xcode-select --switch /Applications/Xcode.app || true
cd notarize
npm install
node notarize.js --appBundleId $IDENTIFIER --appPath ${OUTPUT_DIRECTORY}
if [ $? != 0 ]; then
exit 1
fi
# Validates that the app has been notarized
spctl -a -v --type install ${OUTPUT_DIRECTORY}
cd -
fi