Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

function generatejdkdeps() {
echo "Generating JDK deps"
$JAVA_HOME/bin/java --list-modules > java-modules.txt
< java-modules.txt sed "s/\\@.*//" > modules.txt
grep -Fx -f stripped-deps.txt modules.txt | tr '\n' ',' | tr -d "[:space:]" > module-deps.txt
echo "jdk.zipfs" >> module-deps.txt
$JAVA_HOME/bin/java --list-modules > $S2I_JLINK_TEMP_PATH/java-modules.txt
< $S2I_JLINK_TEMP_PATH/java-modules.txt sed "s/\\@.*//" > $S2I_JLINK_TEMP_PATH/modules.txt
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
echo "jdk.zipfs" >> $S2I_JLINK_TEMP_PATH/module-deps.txt
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ function generate_deps() {
--module-path dependencies \
"$JAVA_APP_JAR" \
"$JAVA_LIB_DIR"/**/*.jar \
> deps.txt
> $S2I_JLINK_TEMP_PATH/deps.txt
else
$JAVA_HOME/bin/jdeps --multi-release $JAVA_VERSION -R -s \
--module-path dependencies \
"$JAVA_APP_JAR" \
> deps.txt
cat deps.txt
> $S2I_JLINK_TEMP_PATH/deps.txt
cat $S2I_JLINK_TEMP_PATH/deps.txt
fi
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# TODO: Still Needed?
set -euo pipefail

depsfile="module-deps.txt"
depsfile="$S2I_JLINK_TEMP_PATH/module-deps.txt"

function generate_jre_image() {
test -f $depsfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
set -euo pipefail

function mkstrippeddeps() {
if [ -f "deps.txt" ]; then
if [ -f "$S2I_JLINK_TEMP_PATH/deps.txt" ]; then
echo "deps exists, filtering"
<deps.txt \
< $S2I_JLINK_TEMP_PATH/deps.txt \
grep 'java\|jdk\.' | # mostly removes target/, but also jdk8internals
sed -E "s/Warning: .*//" | #remove extraneous warnings
sed -E "s/.*-> //" | # remove src of src -> dep
sed -E "s/.*\.jar//" | # remove extraneous dependencies
sed "s#/.*##" | # delete anything after a slash. in practice target/..
sort | uniq |
tee stripped-deps.txt
tee $S2I_JLINK_TEMP_PATH/stripped-deps.txt
echo "Stripping dependencies complete"
else
echo "deps does not exist"
Expand Down
2 changes: 2 additions & 0 deletions modules/jlink/module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ envs:
value: /opt/jboss/container/java/jlink
- name: S2I_JLINK_OUTPUT_PATH
value: /tmp/jre
- name: S2I_JLINK_TEMP_PATH
value: /tmp/jlink

modules:
install:
Expand Down
8 changes: 8 additions & 0 deletions modules/jlink/tests/features/jlink.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ Scenario: Check that /tmp/jre/bin/java and /tmp/jre/lib/modules exist post s2i b
| S2I_ENABLE_JLINK | true |
Then file /tmp/jre/bin/java should exist and be a file
And file /tmp/jre/lib/modules should exist and be a file

Scenario: Check that /tmp/jlink is deleted when S2I_DELETE_SOURCE is set
Given s2i build https://github.com/rh-openjdk/openjdk-container-test-applications from quarkus-quickstarts/getting-started-3.9.2-uberjar
| variable | value |
| S2I_ENABLE_JLINK | true |
| S2I_DELETE_SOURCE | true |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of S2I_DELETE_SOURCE is true. What we really need to test is that, when set to false, we don't clean them up. I guess testing both scenarios is worthwhile.

Then s2i build log should contain Cleaning up temporary file directory /tmp/jlink
And file /tmp/jlink should not exist
12 changes: 12 additions & 0 deletions modules/s2i/bash/artifacts/usr/local/s2i/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ if [ "$S2I_ENABLE_JLINK" = "true" ]; then
jlink_techpreview_warning
jlink_preflight_check

if [ ! -d "${S2I_JLINK_TEMP_PATH}" ]; then
log_info "S2I_JLINK_TEMP_PATH does not exist, creating ${S2I_JLINK_TEMP_PATH}"
mkdir -pm 775 "${S2I_JLINK_TEMP_PATH}"
fi

source "${JBOSS_CONTAINER_JAVA_JLINK_MODULE}/mkdeps.sh"
echo "Invoking mkdeps"
generate_deps || {
Expand Down Expand Up @@ -53,4 +58,11 @@ if [ "$S2I_ENABLE_JLINK" = "true" ]; then
exit 1
}

if [ "$S2I_DELETE_SOURCE" == "true" ]; then
if [ -n "$(find $S2I_JLINK_TEMP_PATH -maxdepth 0 -type d ! -empty 2> /dev/null)" ]; then
log_info "Cleaning up temporary file directory $S2I_JLINK_TEMP_PATH"
rm -rf $S2I_JLINK_TEMP_PATH
fi
fi
fi

Loading