Tobias Werth | 218e8f6 | 2018-12-13 04:44:35 -0800 | [diff] [blame] | 1 | #!/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 | |
| 20 | set -euo pipefail |
| 21 | |
| 22 | fulljdk=$1 |
| 23 | modules=$(cat "$2" | paste -sd "," - | tr -d '\r') |
| 24 | out=$3 |
| 25 | |
| 26 | UNAME=$(uname -s | tr 'A-Z' 'a-z') |
| 27 | |
| 28 | if [[ "$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" |
| 40 | else |
| 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" |
| 50 | fi |