-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #401 from Josh-Matsuoka/ubi9-jlink
Integrate the JLink workflow and scripts into the Ubi9 container sources
- Loading branch information
Showing
16 changed files
with
308 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ envs: | |
packages: | ||
install: | ||
- java-11-openjdk-devel | ||
- java-11-openjdk-jmods | ||
- tzdata-java | ||
|
||
modules: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ envs: | |
packages: | ||
install: | ||
- java-17-openjdk-devel | ||
- java-17-openjdk-jmods | ||
|
||
modules: | ||
install: | ||
|
9 changes: 9 additions & 0 deletions
9
modules/jlink/artifacts/opt/jboss/container/java/jlink/generatejdkdeps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
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 | ||
} |
35 changes: 35 additions & 0 deletions
35
modules/jlink/artifacts/opt/jboss/container/java/jlink/mkdeps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
shopt -s globstar | ||
|
||
function generate_deps() { | ||
# Create a temporary directory for a module path | ||
# This works around "Module java.xml.bind not found, required by java.ws.rs" | ||
mkdir dependencies | ||
|
||
if [[ -v JAVA_LIB_DIR ]]; then | ||
# Serially copy all library JARsinto a flat directory. Serially as we may | ||
# have multiple libs with the same name; in which case, we clobber all but | ||
# one rather than fail the script | ||
find $JAVA_LIB_DIR -type f -name '*.jar' -exec cp -vt dependencies {} \; | ||
|
||
echo "Working with: " | ||
echo $JAVA_APP_JAR | ||
echo $JAVA_LIB_DIR | ||
# generate the dependency list | ||
$JAVA_HOME/bin/jdeps --multi-release $JAVA_VERSION -R -s \ | ||
--module-path dependencies \ | ||
"$JAVA_APP_JAR" \ | ||
"$JAVA_LIB_DIR"/**/*.jar \ | ||
> deps.txt || { | ||
echo "jdeps failed: return code $?" | ||
exit $? | ||
} | ||
else | ||
$JAVA_HOME/bin/jdeps --multi-release $JAVA_VERSION -R -s \ | ||
--module-path dependencies \ | ||
"$JAVA_APP_JAR" \ | ||
> deps.txt | ||
cat deps.txt | ||
fi | ||
} |
15 changes: 15 additions & 0 deletions
15
modules/jlink/artifacts/opt/jboss/container/java/jlink/mkjreimage.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# TODO: Still Needed? | ||
set -euo pipefail | ||
|
||
depsfile="module-deps.txt" | ||
|
||
function generate_jre_image() { | ||
test -f $depsfile | ||
modules="$(cat $depsfile)" | ||
|
||
$JAVA_HOME/bin/jlink --output "$S2I_JLINK_OUTPUT_PATH" \ | ||
--add-modules "$modules" \ | ||
--strip-debug --no-header-files --no-man-pages \ | ||
--compress=2 | ||
} |
19 changes: 19 additions & 0 deletions
19
modules/jlink/artifacts/opt/jboss/container/java/jlink/mkstrippeddeps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
function mkstrippeddeps() { | ||
if [ -f "deps.txt" ]; then | ||
echo "deps exists, filtering" | ||
<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 | ||
echo "Stripping dependencies complete" | ||
else | ||
echo "deps does not exist" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
# Configure module | ||
set -e | ||
|
||
SCRIPT_DIR=$(dirname $0) | ||
ARTIFACTS_DIR=${SCRIPT_DIR}/artifacts | ||
|
||
chown -R default:root $SCRIPT_DIR | ||
chmod -R ug+rwX $SCRIPT_DIR | ||
chmod ug+x ${ARTIFACTS_DIR}/opt/jboss/container/java/jlink/* | ||
|
||
pushd ${ARTIFACTS_DIR} | ||
cp -pr * / | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
schema_version: 1 | ||
|
||
name: "jboss.container.java.jlink" | ||
version: "2.0" | ||
description: ^ | ||
"Provides support for building custom JREs with a slimmed | ||
down set of modules by making use of Jdeps and Jlink" | ||
|
||
execute: | ||
- script: configure.sh | ||
|
||
envs: | ||
- name: JBOSS_CONTAINER_JAVA_JLINK_MODULE | ||
value: /opt/jboss/container/java/jlink | ||
- name: S2I_JLINK_OUTPUT_PATH | ||
value: /tmp/jre | ||
|
||
modules: | ||
install: | ||
- name: jboss.container.java.run | ||
- name: jboss.container.util.pathfinder | ||
|
||
packages: | ||
install: | ||
- binutils # for objcopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.