Skip to content

Enabled Suse RPMs to get built locally #1163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
32 changes: 16 additions & 16 deletions linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ You'll want to make sure you've set the exact versions of the binaries you want

In all the examples below you'll need to replace the following variables:

* Replace `<version>` with `8|11|17|19`
* Replace `<vendor>` with `temurin|dragonwell`
* Replace `<version>` with `8|11|17|19|20|21|22|23`
* Replace `<vendor>` with `temurin|dragonwell|microsoft|openj9`
* Replace `<platform>` with `Alpine|Debian|RedHat|Suse`
* Replace `<type>` with `Jdk|Jre` (or `CaCertificates` for the `Debian` platform)

Expand Down Expand Up @@ -62,8 +62,8 @@ _src/packageTest/java/packaging_ on them.

### Build a Debian specific package for a version

- replace `<version>` with `8|11|17|19`
- replace `<vendor>` with `temurin|dragonwell`
- replace `<version>` with `8|11|17|19|20|21|22|23`
- replace `<vendor>` with `temurin|dragonwell|microsoft`
- Replace `<type>` with `Jdk|Jre`

```shell
Expand All @@ -74,8 +74,8 @@ export _JAVA_OPTIONS="-Xmx4g"

### Build a Red Hat specific package for a version

- replace `<version>` with `8|11|17|19`
- replace `<vendor>` with `temurin|dragonwell`
- replace `<version>` with `8|11|17|19|20|21|22|23`
- replace `<vendor>` with `temurin|dragonwell|microsoft|openj9`

```shell
export DOCKER_BUILDKIT=1
Expand All @@ -85,8 +85,8 @@ export _JAVA_OPTIONS="-Xmx4g"

### Build a SUSE specific package for a version

- replace `<version>` with `8|11|17|19`
- replace `<vendor>` with `temurin|dragonwell`
- replace `<version>` with `8|11|17|19|20|21|22|23`
- replace `<vendor>` with `temurin|dragonwell|microsoft`

```shell
export DOCKER_BUILDKIT=1
Expand All @@ -98,7 +98,7 @@ export _JAVA_OPTIONS="-Xmx4g"

In order to GPG sign the generated RPMs/APKs you must add the following argument to the gradlew command:
- replace `<DISTRO>` with `Alpine|RedHat|Suse`
- replace `<version>` with `8|11|17|19`
- replace `<version>` with `8|11|17|19|20|21|22|23`
- replace `<vendor>` with `temurin|dragonwell`

```shell
Expand All @@ -107,7 +107,7 @@ In order to GPG sign the generated RPMs/APKs you must add the following argument

## Building from local files

In order to build a jdk/jre package for RPM or DEB from local `tar.gz` file(s), put both the `tar.gz` and the `sha256.txt` files in an empty input directory. If the vendor supports building locally, then one can specify this directory when running `./gradlew clean` using the `-PINPUT_DIR` flag
In order to build a jdk/jre package for RPM (suse/redhat) or DEB from local `tar.gz` file(s), put both the `tar.gz` and the `sha256.txt` files in an empty input directory. If the vendor supports building locally, then one can specify this directory when running `./gradlew clean` using the `-PINPUT_DIR` flag

Example:
```shell
Expand Down Expand Up @@ -182,8 +182,8 @@ rpmbuild --define "_sourcedir $(pwd)" --define "_specdir $(pwd)" \
## Supported packages

### APK (Alpine)
- Supported JDK version 8,11,17,19
- Supported JRE version 8,11,17,19
- Supported JDK version 8,11,17,19,20,21,22,23
- Supported JRE version 8,11,17,19,20,21,22,23

Supported platform amd64

Expand All @@ -192,8 +192,8 @@ Supported platform amd64
| alpine/3.x.x | x86_64 | |

### DEB
- Supported JDK version 8,11,17,19
- Supported JRE version 8,11,17,19
- Supported JDK version 8,11,17,19,20,21,22,23
- Supported JRE version 8,11,17,19,20,21,22,23

Supported platform amd64, arm64, armhf, ppc64le, s390x (s390x is only available for jdk > 8)

Expand All @@ -212,8 +212,8 @@ Supported platform amd64, arm64, armhf, ppc64le, s390x (s390x is only available
- Ubuntu Releases: https://ubuntu.com/about/release-cycle

### RPM (RedHat and Suse)
- Supported JDK version 8,11,17,19
- Supported JRE version 8,11,17,19
- Supported JDK version 8,11,17,19,20,21,22,23
- Supported JRE version 8,11,17,19,20,21,22,23

Supported platform x86_64, aarch64, armv7hl, ppc64le, s390x (s390x is only available for jdk > 8)
SRPM also available.
Expand Down
2 changes: 1 addition & 1 deletion linux/jdk/redhat/src/main/packaging/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ if grep -q %_gpg_name /home/builder/.rpmmacros; then
rm -f ~/.gnupg/public-keys.d/pubring.db.lock
for file in `ls /home/builder/out/*.rpm`; do
echo Signing: $file
rpmsign --addsign $file
rpmsign --addsign $file
done
fi;
29 changes: 28 additions & 1 deletion linux/jdk/suse/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,40 @@ task packageJdkSuse {
def gpgKey = getGPGKey()
def arch = getArch()

def input_dir = getInputDir()
def buildLocalFlag = getLocalBuildStatus()

// Get container registry property. If not set, return empty string that is equivalent to dockerhub
def containerRegistry = getContainerRegistry()

doLast {
if (!file("src/main/packaging/$product/$productVersion").exists()) {
throw new IllegalArgumentException("Unknown product $product/$productVersion")
}
if (input_dir != null && !file(input_dir).exists()) {
throw new IllegalArgumentException("Input directory '$input_dir' not found")
}

project.copy {
from("src/main/packaging/$product/$productVersion/")
into("${buildDir}/generated/packaging")
}
if ("$buildLocalFlag" == "true") {
// copy jdk's tarfile to build dir
copy {
from("$input_dir")
into("${buildDir}/jdk")
include("*.tar.gz")
}

// copy jdk's .sha256sum.txt file (or .sha256.txt file) to build dir
copy {
from("$input_dir")
into("${buildDir}/jdk")
include("*.sha256*.txt")
}
}

if (gpgKey) {
project.exec {
workingDir "src/main/packaging"
Expand Down Expand Up @@ -99,6 +121,7 @@ task packageJdkSuse {
"--rm",
"-e", "buildArch=${arch}",
"-e", "buildVersion=${productVersion}",
"-e", "buildLocalFlag=${buildLocalFlag}",
"--mount", "type=bind,source=${buildDir},target=/home/builder/build",
"--mount", "type=bind,source=${outputDir.absolutePath},target=/home/builder/out",
"adoptium-packages-linux-jdk-suse:latest"
Expand All @@ -122,7 +145,11 @@ task checkJdkSuse(type: Test) {

def containerRegistry = getContainerRegistry()

environment "PACKAGE", "$product-$productVersion-jdk"
if (product == "microsoft") {
environment "PACKAGE", "msopenjdk-$productVersion"
} else {
environment "PACKAGE", "$product-$productVersion-jdk"
}
if (gpgKey != null) {
environment "JDKGPG", "$gpgKey"
println "We set the gpgkey!"
Expand Down
29 changes: 28 additions & 1 deletion linux/jdk/suse/src/main/packaging/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ set -euxo pipefail
# Ensure necessary directories for rpmbuild operation are present.
rpmdev-setuptree

if [ "$buildLocalFlag" == "true" ]; then
# Copy all sha256 files into SOURCE directory
count=1
for sha in $(ls /home/builder/build/jdk/*.sha256*.txt); do
cp $sha /home/builder/rpmbuild/SOURCES/local_build_jdk${count}.tar.gz.sha256.txt
count=$((count + 1))
done;
# Copy all source tar files into SOURCE directory
count=1
for jdk in $(ls /home/builder/build/jdk/*.tar.gz); do
cp $jdk /home/builder/rpmbuild/SOURCES/local_build_jdk${count}.tar.gz

# Change name of *.tar.gz in .sha256.txt contents to match new name (local_build_jdk#.tar.gz)
# Example:
# f579751fdcd627552a550e37ee00f8ff7a04e53bb385154ac17a0fb1fbb6ed12 <vendor>-jdk-17.0.7-linux-x64.tar.gz
# To
# f579751fdcd627552a550e37ee00f8ff7a04e53bb385154ac17a0fb1fbb6ed12 local_build_jdk1.tar.gz
sed -i "s/$(basename $jdk)/local_build_jdk${count}.tar.gz/" /home/builder/rpmbuild/SOURCES/local_build_jdk${count}.tar.gz.sha256.txt

count=$((count + 1))
done;
fi

echo "DEBUG: building Suse arch ${buildArch} with version ${buildVersion}"
# Build specified target or build all
if [ "${buildArch}" != "all" ]; then
Expand All @@ -16,6 +39,8 @@ fi

for spec in "$(ls /home/builder/build/generated/packaging/*.spec)"; do
rpmdev-spectool -g -R "$spec";
rpmbuild --define "local_build ${buildLocalFlag}" \
--nodeps -bs "$spec"; # build src.rpm
rpmbuild --nodeps -bs "$spec";
# if buildArch == all, extract ExclusiveArch from the spec file
if [ "${buildArch}" = "all" ]; then
Expand All @@ -26,7 +51,9 @@ for spec in "$(ls /home/builder/build/generated/packaging/*.spec)"; do
[ -n "$ExclusiveArch" ] && targets="${ExclusiveArch}"
fi
for target in $targets; do
rpmbuild --target "$target" --rebuild /home/builder/rpmbuild/SRPMS/*.src.rpm;
rpmbuild --target "$target" \
--define "local_build ${buildLocalFlag}" \
--rebuild /home/builder/rpmbuild/SRPMS/*.src.rpm; # build binary package from src.rpm
done;
done;

Expand Down
Loading