blob: b193f036b73bfda0a283ad6bbad150eb3d0bd6ac [file] [log] [blame]
Tobias Werth218e8f62018-12-13 04:44:35 -08001#!/bin/bash
2
3# Copyright 2018 The Bazel Authors. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# This script creates from the full JDK a minimized version that only contains
18# the specified JDK modules.
19
20set -euo pipefail
21
22fulljdk=$1
23modules=$(cat "$2" | paste -sd "," - | tr -d '\r')
24out=$3
25
26UNAME=$(uname -s | tr 'A-Z' 'a-z')
27
28if [[ "$UNAME" =~ msys_nt* ]]; then
29 set -x
30 unzip "$fulljdk"
31 cd zulu*
32 echo -e "MODULES: >>$modules<<\n"
33 ./bin/jlink --module-path ./jmods/ --add-modules "$modules" \
34 --vm=server --strip-debug --no-man-pages \
35 --output reduced
36 cp DISCLAIMER readme.txt reduced/
37 zip -r -9 ../reduced.zip reduced/
38 cd ..
39 mv reduced.zip "$out"
40else
41 tar xf "$fulljdk"
42 cd zulu*
43 ./bin/jlink --module-path ./jmods/ --add-modules "$modules" \
44 --vm=server --strip-debug --no-man-pages \
45 --output reduced
46 cp DISCLAIMER readme.txt reduced/
47 GZIP=-9 tar -zcf ../reduced.tgz reduced
48 cd ..
49 mv reduced.tgz "$out"
50fi