Skip to content

Commit fcb9d5a

Browse files
authored
Enabled Suse RPMs to get built locally (#1163)
* Initial commit: added .spec files for SUSE installers * Added ability to local build locally for SUSE installers * Fixed line spacing * Modified linux/jdk/suse/build.gradle file to properly pass local_build inputs * Added ability to build suse JREs locally * Added explicit wording to show that suse + redhat RPMs can be built locally * Added to 'supported versions' text in README.md * Updated README.md allowed inputs * Fixed spacing * Updated msopenjdk-17 -- removed override_arch_ * Removed custom suseRegistry * Updated to corrrect package name * Updated new README.md * Propagated suse gradle changes to linux_new * Propagated suse build.sh changes to linux_new * Removed override_arch_ from remaining msft suse spec files * Propagated suse jre build.gradle changes to linux_new * Propagated suse jre build.sh changes to linux_new * Fixed spacing * Updated suse spec files for msft Apr-2025-PSU
1 parent 02edb3d commit fcb9d5a

File tree

19 files changed

+911
-48
lines changed

19 files changed

+911
-48
lines changed

linux/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ You'll want to make sure you've set the exact versions of the binaries you want
3131

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

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

@@ -62,8 +62,8 @@ _src/packageTest/java/packaging_ on them.
6262

6363
### Build a Debian specific package for a version
6464

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

6969
```shell
@@ -74,8 +74,8 @@ export _JAVA_OPTIONS="-Xmx4g"
7474

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

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

8080
```shell
8181
export DOCKER_BUILDKIT=1
@@ -85,8 +85,8 @@ export _JAVA_OPTIONS="-Xmx4g"
8585

8686
### Build a SUSE specific package for a version
8787

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

9191
```shell
9292
export DOCKER_BUILDKIT=1
@@ -98,7 +98,7 @@ export _JAVA_OPTIONS="-Xmx4g"
9898

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

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

108108
## Building from local files
109109

110-
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
110+
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
111111

112112
Example:
113113
```shell
@@ -182,8 +182,8 @@ rpmbuild --define "_sourcedir $(pwd)" --define "_specdir $(pwd)" \
182182
## Supported packages
183183

184184
### APK (Alpine)
185-
- Supported JDK version 8,11,17,19
186-
- Supported JRE version 8,11,17,19
185+
- Supported JDK version 8,11,17,19,20,21,22,23
186+
- Supported JRE version 8,11,17,19,20,21,22,23
187187

188188
Supported platform amd64
189189

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

194194
### DEB
195-
- Supported JDK version 8,11,17,19
196-
- Supported JRE version 8,11,17,19
195+
- Supported JDK version 8,11,17,19,20,21,22,23
196+
- Supported JRE version 8,11,17,19,20,21,22,23
197197

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

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

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

218218
Supported platform x86_64, aarch64, armv7hl, ppc64le, s390x (s390x is only available for jdk > 8)
219219
SRPM also available.

linux/jdk/redhat/src/main/packaging/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ if grep -q %_gpg_name /home/builder/.rpmmacros; then
6666
rm -f ~/.gnupg/public-keys.d/pubring.db.lock
6767
for file in `ls /home/builder/out/*.rpm`; do
6868
echo Signing: $file
69-
rpmsign --addsign $file
69+
rpmsign --addsign $file
7070
done
7171
fi;

linux/jdk/suse/build.gradle

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,40 @@ task packageJdkSuse {
6060
def gpgKey = getGPGKey()
6161
def arch = getArch()
6262

63+
def input_dir = getInputDir()
64+
def buildLocalFlag = getLocalBuildStatus()
65+
6366
// Get container registry property. If not set, return empty string that is equivalent to dockerhub
6467
def containerRegistry = getContainerRegistry()
6568

6669
doLast {
6770
if (!file("src/main/packaging/$product/$productVersion").exists()) {
6871
throw new IllegalArgumentException("Unknown product $product/$productVersion")
6972
}
73+
if (input_dir != null && !file(input_dir).exists()) {
74+
throw new IllegalArgumentException("Input directory '$input_dir' not found")
75+
}
7076

7177
project.copy {
7278
from("src/main/packaging/$product/$productVersion/")
7379
into("${buildDir}/generated/packaging")
7480
}
81+
if ("$buildLocalFlag" == "true") {
82+
// copy jdk's tarfile to build dir
83+
copy {
84+
from("$input_dir")
85+
into("${buildDir}/jdk")
86+
include("*.tar.gz")
87+
}
88+
89+
// copy jdk's .sha256sum.txt file (or .sha256.txt file) to build dir
90+
copy {
91+
from("$input_dir")
92+
into("${buildDir}/jdk")
93+
include("*.sha256*.txt")
94+
}
95+
}
96+
7597
if (gpgKey) {
7698
project.exec {
7799
workingDir "src/main/packaging"
@@ -99,6 +121,7 @@ task packageJdkSuse {
99121
"--rm",
100122
"-e", "buildArch=${arch}",
101123
"-e", "buildVersion=${productVersion}",
124+
"-e", "buildLocalFlag=${buildLocalFlag}",
102125
"--mount", "type=bind,source=${buildDir},target=/home/builder/build",
103126
"--mount", "type=bind,source=${outputDir.absolutePath},target=/home/builder/out",
104127
"adoptium-packages-linux-jdk-suse:latest"
@@ -122,7 +145,11 @@ task checkJdkSuse(type: Test) {
122145

123146
def containerRegistry = getContainerRegistry()
124147

125-
environment "PACKAGE", "$product-$productVersion-jdk"
148+
if (product == "microsoft") {
149+
environment "PACKAGE", "msopenjdk-$productVersion"
150+
} else {
151+
environment "PACKAGE", "$product-$productVersion-jdk"
152+
}
126153
if (gpgKey != null) {
127154
environment "JDKGPG", "$gpgKey"
128155
println "We set the gpgkey!"

linux/jdk/suse/src/main/packaging/build.sh

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ set -euxo pipefail
44
# Ensure necessary directories for rpmbuild operation are present.
55
rpmdev-setuptree
66

7+
if [ "$buildLocalFlag" == "true" ]; then
8+
# Copy all sha256 files into SOURCE directory
9+
count=1
10+
for sha in $(ls /home/builder/build/jdk/*.sha256*.txt); do
11+
cp $sha /home/builder/rpmbuild/SOURCES/local_build_jdk${count}.tar.gz.sha256.txt
12+
count=$((count + 1))
13+
done;
14+
# Copy all source tar files into SOURCE directory
15+
count=1
16+
for jdk in $(ls /home/builder/build/jdk/*.tar.gz); do
17+
cp $jdk /home/builder/rpmbuild/SOURCES/local_build_jdk${count}.tar.gz
18+
19+
# Change name of *.tar.gz in .sha256.txt contents to match new name (local_build_jdk#.tar.gz)
20+
# Example:
21+
# f579751fdcd627552a550e37ee00f8ff7a04e53bb385154ac17a0fb1fbb6ed12 <vendor>-jdk-17.0.7-linux-x64.tar.gz
22+
# To
23+
# f579751fdcd627552a550e37ee00f8ff7a04e53bb385154ac17a0fb1fbb6ed12 local_build_jdk1.tar.gz
24+
sed -i "s/$(basename $jdk)/local_build_jdk${count}.tar.gz/" /home/builder/rpmbuild/SOURCES/local_build_jdk${count}.tar.gz.sha256.txt
25+
26+
count=$((count + 1))
27+
done;
28+
fi
29+
730
echo "DEBUG: building Suse arch ${buildArch} with version ${buildVersion}"
831
# Build specified target or build all
932
if [ "${buildArch}" != "all" ]; then
@@ -16,6 +39,8 @@ fi
1639

1740
for spec in "$(ls /home/builder/build/generated/packaging/*.spec)"; do
1841
rpmdev-spectool -g -R "$spec";
42+
rpmbuild --define "local_build ${buildLocalFlag}" \
43+
--nodeps -bs "$spec"; # build src.rpm
1944
rpmbuild --nodeps -bs "$spec";
2045
# if buildArch == all, extract ExclusiveArch from the spec file
2146
if [ "${buildArch}" = "all" ]; then
@@ -26,7 +51,9 @@ for spec in "$(ls /home/builder/build/generated/packaging/*.spec)"; do
2651
[ -n "$ExclusiveArch" ] && targets="${ExclusiveArch}"
2752
fi
2853
for target in $targets; do
29-
rpmbuild --target "$target" --rebuild /home/builder/rpmbuild/SRPMS/*.src.rpm;
54+
rpmbuild --target "$target" \
55+
--define "local_build ${buildLocalFlag}" \
56+
--rebuild /home/builder/rpmbuild/SRPMS/*.src.rpm; # build binary package from src.rpm
3057
done;
3158
done;
3259

0 commit comments

Comments
 (0)