File tree Expand file tree Collapse file tree 7 files changed +41
-11
lines changed
artifacts/opt/jboss/container/java/jlink
s2i/bash/artifacts/usr/local/s2i Expand file tree Collapse file tree 7 files changed +41
-11
lines changed Original file line number Diff line number Diff line change 22
33function generatejdkdeps() {
44 echo " Generating JDK deps"
5- $JAVA_HOME /bin/java --list-modules > java-modules.txt
6- < java-modules.txt sed " s/\\ @.*//" > modules.txt
7- grep -Fx -f stripped-deps.txt modules.txt | tr ' \n' ' ,' | tr -d " [:space:]" > module-deps.txt
8- echo " jdk.zipfs" >> module-deps.txt
5+ $JAVA_HOME /bin/java --list-modules > $S2I_JLINK_TEMP_PATH / java-modules.txt
6+ < $S2I_JLINK_TEMP_PATH / java-modules.txt sed " s/\\ @.*//" > $S2I_JLINK_TEMP_PATH / modules.txt
7+ grep -Fx -f $S2I_JLINK_TEMP_PATH / stripped-deps.txt $S2I_JLINK_TEMP_PATH / modules.txt | tr ' \n' ' ,' | tr -d " [:space:]" > $S2I_JLINK_TEMP_PATH / module-deps.txt
8+ echo " jdk.zipfs" >> $S2I_JLINK_TEMP_PATH / module-deps.txt
99}
Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ function generate_deps() {
2121 --module-path dependencies \
2222 " $JAVA_APP_JAR " \
2323 " $JAVA_LIB_DIR " /** /* .jar \
24- > deps.txt
24+ > $S2I_JLINK_TEMP_PATH / deps.txt
2525 else
2626 $JAVA_HOME /bin/jdeps --multi-release $JAVA_VERSION -R -s \
2727 --module-path dependencies \
2828 " $JAVA_APP_JAR " \
29- > deps.txt
30- cat deps.txt
29+ > $S2I_JLINK_TEMP_PATH / deps.txt
30+ cat $S2I_JLINK_TEMP_PATH / deps.txt
3131 fi
3232}
Original file line number Diff line number Diff line change 22# TODO: Still Needed?
33set -euo pipefail
44
5- depsfile=" module-deps.txt"
5+ depsfile=" $S2I_JLINK_TEMP_PATH / module-deps.txt"
66
77function generate_jre_image() {
88 test -f $depsfile
Original file line number Diff line number Diff line change 22set -euo pipefail
33
44function mkstrippeddeps() {
5- if [ -f " deps.txt" ]; then
5+ if [ -f " $S2I_JLINK_TEMP_PATH / deps.txt" ]; then
66 echo " deps exists, filtering"
7- < deps.txt \
7+ < $S2I_JLINK_TEMP_PATH / deps.txt \
88 grep ' java\|jdk\.' | # mostly removes target/, but also jdk8internals
99 sed -E " s/Warning: .*//" | # remove extraneous warnings
1010 sed -E " s/.*-> //" | # remove src of src -> dep
1111 sed -E " s/.*\.jar//" | # remove extraneous dependencies
1212 sed " s#/.*##" | # delete anything after a slash. in practice target/..
1313 sort | uniq |
14- tee stripped-deps.txt
14+ tee $S2I_JLINK_TEMP_PATH / stripped-deps.txt
1515 echo " Stripping dependencies complete"
1616 else
1717 echo " deps does not exist"
Original file line number Diff line number Diff line change 1414 value : /opt/jboss/container/java/jlink
1515- name : S2I_JLINK_OUTPUT_PATH
1616 value : /tmp/jre
17+ - name : S2I_JLINK_TEMP_PATH
18+ value : /tmp/jlink
1719
1820modules :
1921 install :
Original file line number Diff line number Diff line change @@ -18,3 +18,19 @@ Scenario: Check that /tmp/jre/bin/java and /tmp/jre/lib/modules exist post s2i b
1818 | S2I_ENABLE_JLINK | true |
1919 Then file /tmp/jre/bin/java should exist and be a file
2020 And file /tmp/jre/lib/modules should exist and be a file
21+
22+ Scenario : Check that /tmp/jlink is deleted when S2I_DELETE_SOURCE is set
23+ Given s2i build https://github.com/rh-openjdk/openjdk-container-test-applications from quarkus-quickstarts/getting-started-3.9.2-uberjar
24+ | variable | value |
25+ | S2I_ENABLE_JLINK | true |
26+ | S2I_DELETE_SOURCE | true |
27+ Then s2i build log should contain Cleaning up temporary file directory /tmp/jlink
28+ And file /tmp/jlink should not exist
29+
30+ Scenario : Check that /tmp/jlink is not deleted when S2I_DELETE_SOURCE is set to false
31+ Given s2i build https://github.com/rh-openjdk/openjdk-container-test-applications from quarkus-quickstarts/getting-started-3.9.2-uberjar
32+ | variable | value |
33+ | S2I_ENABLE_JLINK | true |
34+ | S2I_DELETE_SOURCE | false |
35+ Then s2i build log should not contain Cleaning up temporary file directory /tmp/jlink
36+ And file /tmp/jlink should exist
Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ if [ "$S2I_ENABLE_JLINK" = "true" ]; then
2525 jlink_techpreview_warning
2626 jlink_preflight_check
2727
28+ if [ ! -d " ${S2I_JLINK_TEMP_PATH} " ]; then
29+ log_info " S2I_JLINK_TEMP_PATH does not exist, creating ${S2I_JLINK_TEMP_PATH} "
30+ mkdir -pm 775 " ${S2I_JLINK_TEMP_PATH} "
31+ fi
32+
2833 source " ${JBOSS_CONTAINER_JAVA_JLINK_MODULE} /mkdeps.sh"
2934 echo " Invoking mkdeps"
3035 generate_deps || {
@@ -53,4 +58,11 @@ if [ "$S2I_ENABLE_JLINK" = "true" ]; then
5358 exit 1
5459 }
5560
61+ if [ " $S2I_DELETE_SOURCE " == " true" ]; then
62+ if [ -n " $( find $S2I_JLINK_TEMP_PATH -maxdepth 0 -type d ! -empty 2> /dev/null) " ]; then
63+ log_info " Cleaning up temporary file directory $S2I_JLINK_TEMP_PATH "
64+ rm -rf $S2I_JLINK_TEMP_PATH
65+ fi
66+ fi
5667fi
68+
You can’t perform that action at this time.
0 commit comments