Skip to content

Commit

Permalink
Add JRE (8,11,17,19) for Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerd Aschemann committed Feb 1, 2023
1 parent 30601f0 commit 1e579f5
Show file tree
Hide file tree
Showing 48 changed files with 1,353 additions and 5 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,52 @@ jobs:
name: test-results
path: '**/build/test-results/**/TEST-*.xml'

check-jre-packages:
name: "Check ${{ matrix.product.name }} ${{ matrix.product.version }} ${{ matrix.distro }}"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./linux
strategy:
fail-fast: false
matrix:
distro: [Debian]
product: [
{ name: temurin, version: 8 },
{ name: temurin, version: 11 },
{ name: temurin, version: 17 },
{ name: temurin, version: 19 },
]

steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.8.0
with:
java-version: '17'
java-package: jdk
architecture: x64
distribution: 'temurin'

- name: Build # only simulate in Jenkins when select ARCH="all"
run: |
export _JAVA_OPTIONS="-Xmx4G"
export DOCKER_BUILDKIT=1
./gradlew --parallel packageJre${{ matrix.distro }} checkJre${{ matrix.distro }} -PPRODUCT=${{ matrix.product.name }} -PPRODUCT_VERSION=${{ matrix.product.version }} --stacktrace
- name: Relocate test results
if: always() # always run even if the previous step fails
run: |
mkdir ${{ matrix.product.version }}
mv jre ${{ matrix.product.version }}
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always() # always run even if the previous step fails
with:
name: test-results
path: '**/build/test-results/**/TEST-*.xml'

# Ensures we don't accept a Gradle Wrapper update that has been tampered with.
validation:
name: "Validate Gradle Wrapper"
Expand Down
4 changes: 2 additions & 2 deletions linux/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def uploadAlpineArtifacts(String buildArch) {
}

def uploadDebArtifacts(String buildArch) {
// full list of all platforms, up to user to opt out s390x+jdk8
// full list of all platforms, up to user to opt out s390x+jdk8/jre8
def debArchList = [
'x86_64' : 'amd64',
'armv7l': 'armhf',
Expand All @@ -271,7 +271,7 @@ def uploadDebArtifacts(String buildArch) {
/*
Debian/Ubuntu 10.0 11.0 16.04 20.04 22.04 22.10
add more into list when available for release
also update linux/jdk/debian/main/packing/build.sh
also update linux/{jdk,jre}/debian/main/packing/build.sh
*/
def deb_versions = [
"bookworm", // Debian/12
Expand Down
3 changes: 2 additions & 1 deletion linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ Supported platform amd64
| alpine/3.x.x | x86_64 | |

### DEB
Supported JDK version 8,11,17,19
- Supported JDK version 8,11,17,19
- Supported JRE version 8,11,17,19

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Depends: adoptium-ca-certificates,
libasound2,
libatomic1 [armhf],
libc6,
libx11-6,
libfontconfig1,
libfreetype6,
libx11-6,
libxext6,
libxi6,
libxrender1,
Expand Down
12 changes: 12 additions & 0 deletions linux/jre/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tasks.register("packageJre") {
group = "packaging"
description = "Creates Linux packages of a JRE."
}

tasks.register("checkJrePackage") {
description = "Tests the generated JRE packages."
group = "verification"
}

rootProject.package.dependsOn(packageJre)
rootProject.checkPackage.dependsOn(checkJrePackage)
127 changes: 127 additions & 0 deletions linux/jre/debian/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
plugins {
id "java"
}

ext {
junitVersion = "5.9.1"
testcontainersVersion = "1.17.6"
assertjCoreVersion = "3.24.1"
}

repositories {
mavenCentral()
}

group "org.adoptium"
version "1.0.0-SNAPSHOT"

/*
* The versions list defines the Debian and Ubuntu versions that this package is uploaded to.
*
* If a version like sid is missing here, the package won't be included in the sid repository and therefore not
* installable via apt. Never use suite names like testing or unstable. This list is usually bigger than the list
* of versions we test with as defined by the class DebianFlavours in the source set packageTest.
*
* **Attention**: If you alter the list, check if the class DebianFlavours needs to be updated, too.
*/
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

sourceSets {
packageTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}

configurations {
packageTestImplementation.extendsFrom implementation
packageTestRuntimeOnly.extendsFrom runtimeOnly
}

dependencies {
packageTestImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
packageTestImplementation "org.testcontainers:testcontainers:$testcontainersVersion"
packageTestImplementation "org.testcontainers:junit-jupiter:$testcontainersVersion"
packageTestImplementation "org.assertj:assertj-core:$assertjCoreVersion"
}

test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}

task packageJreDebian {
dependsOn "assemble"

group = "packaging"
description = "Creates deb JRE package for Debian flavours."

def outputDir = new File(project.buildDir.absolutePath, "ospackage")
outputs.dir(outputDir)

def product = getProduct()
def productVersion = getProductVersion()
def arch = getArch()

doLast {
if (!file("src/main/packaging/$product/$productVersion").exists()) {
throw new IllegalArgumentException("Unknown product $product/$productVersion")
}

project.copy {
from("src/main/packaging/$product/$productVersion/")
into("${buildDir}/generated/packaging")
}
project.exec {
workingDir "src/main/packaging"
commandLine "docker", "build",
"-t", "adoptium-packages-linux-jdk-debian",
"-f", "Dockerfile",
getProjectDir().absolutePath + "/src/main/packaging"
}

project.exec {
workingDir getRootDir()
commandLine "docker", "run",
"--rm",
"-e", "buildArch=${arch}",
"--mount", "type=bind,source=${buildDir},target=/home/builder/build",
"--mount", "type=bind,source=${outputDir.absolutePath},target=/home/builder/out",
"adoptium-packages-linux-jdk-debian:latest"
}
}
}

task checkJreDebian(type: Test) {
dependsOn packageJreDebian

description = 'Tests the generated Debian packages.'
group = 'verification'

testClassesDirs = sourceSets.packageTest.output.classesDirs
classpath = sourceSets.packageTest.runtimeClasspath

def product = getProduct()
def productVersion = getProductVersion()

environment "PACKAGE", "${product}-${productVersion}-jre"

useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}

doFirst {
if (!file("src/main/packaging/$product/$productVersion").exists()) {
throw new IllegalArgumentException("Unknown product $product/$productVersion")
}
}
}

parent.packageJre.dependsOn(packageJreDebian)
parent.checkJrePackage.dependsOn(checkJreDebian)
33 changes: 33 additions & 0 deletions linux/jre/debian/src/main/packaging/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM debian:bullseye

# Combine apt-get update with apt-get install to prevent stale package indexes.
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential \
debhelper \
lsb-release \
reprepro \
gosu \
java-common \
libasound2 \
libc6 \
libx11-6 \
libfontconfig1 \
libfreetype6 \
libxext6 \
libxi6 \
libxrender1 \
libxtst6 \
zlib1g \
tini \
wget

# Create unprivileged user for building, see
# https://github.com/hexops/dockerfile#use-a-static-uid-and-gid
RUN groupadd -g 10001 builder \
&& useradd -m -d /home/builder -u 10000 -g 10001 builder

# Prepare entrypoint and build scripts
ADD entrypoint.sh /entrypoint.sh
ADD build.sh /home/builder/build.sh
RUN chmod +x /home/builder/build.sh

ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "/entrypoint.sh" ]
23 changes: 23 additions & 0 deletions linux/jre/debian/src/main/packaging/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euxo pipefail

# Copy build scripts into a directory within the container. Avoids polluting the mounted
# directory and permission errors.
mkdir /home/builder/workspace
cp -R /home/builder/build/generated/packaging /home/builder/workspace


# $ and $ARCH are env variables passing in from "docker run"
debVersionList="bookworm bullseye buster kinetic jammy focal bionic"

# the target package is only based on the host machine's ARCH
# ${buildArch} is only used for debug purpose what really matter is the label on the jenkins agent
echo "DEBUG: building Debian arch ${buildArch}"

# Build package and set distributions it supports
cd /home/builder/workspace/packaging
dpkg-buildpackage -us -uc -b
changestool /home/builder/workspace/*.changes setdistribution ${debVersionList}

# Copy resulting files into mounted directory where artifacts should be placed.
mv /home/builder/workspace/*.{deb,changes,buildinfo} /home/builder/out
13 changes: 13 additions & 0 deletions linux/jre/debian/src/main/packaging/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euox pipefail

# The directory mounted into the container has the UID/GID of the host user. In order to allow the user builder to write
# into it without changing its ownership (which could render the folder or its contents inaccessible to the host user),
# add the user builder to the group with the same GID as the host user.
HOST_USER_GID=$(stat -c "%g" /home/builder/out)
getent group "$HOST_USER_GID" || groupadd -g "$HOST_USER_GID" hostusrg
usermod -a -G "$HOST_USER_GID" builder
chmod g+w /home/builder/out

# Drop root privileges and build the package.
gosu builder /home/builder/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
temurin-11-jre (11.0.18.0.0+10-1) STABLE; urgency=medium

* Eclipse Temurin 11.0.18.0.0+10-1 release.

-- Eclipse Adoptium Package Maintainers <temurin-dev@eclipse.org> Mon, Jan 30 2023 11:35:00 +0000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
43 changes: 43 additions & 0 deletions linux/jre/debian/src/main/packaging/temurin/11/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Source: temurin-11-jre
Section: java
Priority: optional
Maintainer: Eclipse Adoptium Package Maintainers <temurin-dev@eclipse.org>
Build-Depends: debhelper (>= 11), lsb-release

Package: temurin-11-jre
Architecture: amd64 armhf arm64 ppc64el s390x
Depends: adoptium-ca-certificates,
java-common,
libasound2,
libc6,
libfontconfig1,
libfreetype6,
libx11-6,
libxext6,
libxi6,
libxrender1,
libxtst6,
zlib1g
Recommends: fonts-dejavu-core,
fonts-dejavu-extra
Provides: java-runtime,
java-runtime-headless,
java10-runtime,
java11-runtime,
java2-runtime,
java5-runtime,
java6-runtime,
java7-runtime,
java8-runtime,
java9-runtime,
java10-runtime-headless,
java11-runtime-headless,
java2-runtime-headless,
java5-runtime-headless,
java6-runtime-headless,
java7-runtime-headless,
java8-runtime-headless,
java9-runtime-headless
Description: Eclipse Temurin 11 JRE
Eclipse Temurin JRE is an OpenJDK-based runtime environment to execute
Java applications and services.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

Files: *
Copyright: Oracle and/or its affiliates
License: GPL-2.0+CE
15 changes: 15 additions & 0 deletions linux/jre/debian/src/main/packaging/temurin/11/debian/jinfo.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name=@pkg_alias@
alias=@pkg_alias@
priority=@priority@
section=contrib

jdkhl jaotc /usr/lib/jvm/@jvm_dir@/bin/jaotc
hl java /usr/lib/jvm/@jvm_dir@/bin/java
hl jfr /usr/lib/jvm/@jvm_dir@/bin/jfr
hl jjs /usr/lib/jvm/@jvm_dir@/bin/jjs
hl jrunscript /usr/lib/jvm/@jvm_dir@/bin/jrunscript
hl keytool /usr/lib/jvm/@jvm_dir@/bin/keytool
hl pack200 /usr/lib/jvm/@jvm_dir@/bin/pack200
hl rmid /usr/lib/jvm/@jvm_dir@/bin/rmid
hl rmiregistry /usr/lib/jvm/@jvm_dir@/bin/rmiregistry
hl unpack200 /usr/lib/jvm/@jvm_dir@/bin/unpack200
Loading

0 comments on commit 1e579f5

Please sign in to comment.