Skip to content

Commit

Permalink
Add JRE 8 for Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerd Aschemann committed Jan 14, 2023
1 parent e8dea4e commit 04e4dd6
Show file tree
Hide file tree
Showing 22 changed files with 662 additions and 5 deletions.
7 changes: 4 additions & 3 deletions linux/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ env.PRODUCT = 'temurin'

class Types {
final static String JDK = 'Jdk'
final static String JRE = 'Jre'
final static String CA_CERTIFICATES = 'CaCertificates'

final static List<String> ALL = [JDK, CA_CERTIFICATES]
final static List<String> ALL = [JDK, JRE, CA_CERTIFICATES]

static String displayName(TYPE, VERSION, ARCH, DISTRO) {
return TYPE != CA_CERTIFICATES ? "${TYPE.toLowerCase()}${VERSION} - ${ARCH} - ${DISTRO}" : "${TYPE} - ${DISTRO}"
Expand Down Expand Up @@ -277,7 +278,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 @@ -288,7 +289,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
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-8-jre (8.0.352.0.0+8-2) STABLE; urgency=medium

* Eclipse Temurin 8.0.352.0.0+8-2 release.

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

Package: temurin-8-jre
Architecture: amd64 armhf arm64 ppc64el
Depends: adoptium-ca-certificates,
fonts-dejavu,
java-common,
libasound2,
libatomic1 [armhf],
libc6,
libfontconfig1,
libfreetype6,
libx11-6,
libxext6,
libxi6,
libxrender1,
libxtst6,
zlib1g
Recommends: fonts-dejavu-core,
fonts-dejavu-extra
Provides: java-runtime,
java-runtime-headless,
java2-runtime,
java5-runtime,
java6-runtime,
java7-runtime,
java8-runtime,
java2-runtime-headless,
java5-runtime-headless,
java6-runtime-headless,
java7-runtime-headless,
java8-runtime-headless
Description: Eclipse Temurin 8 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
16 changes: 16 additions & 0 deletions linux/jre/debian/src/main/packaging/temurin/8/debian/jinfo.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name=@pkg_alias@
alias=@pkg_alias@
priority=@priority@
section=contrib

hl java /usr/lib/jvm/@jvm_dir@/bin/java
hl jjs /usr/lib/jvm/@jvm_dir@/bin/jjs
hl keytool /usr/lib/jvm/@jvm_dir@/bin/keytool
hl orbd /usr/lib/jvm/@jvm_dir@/bin/orbd
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
jre policytool /usr/lib/jvm/@jvm_dir@/bin/policytool
hl servertool /usr/lib/jvm/@jvm_dir@/bin/servertool
hl tnameserv /usr/lib/jvm/@jvm_dir@/bin/tnameserv
hl unpack200 /usr/lib/jvm/@jvm_dir@/bin/unpack200
42 changes: 42 additions & 0 deletions linux/jre/debian/src/main/packaging/temurin/8/debian/postinst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
set -eu

priority="@priority@"
jdk_base_dir="/usr/lib/jvm/@jvm_dir@"
tools="@jvm_tools@"

case "$1" in
configure)
for tool in $tools; do
for tool_path in "$jdk_base_dir/bin/$tool" "$jdk_base_dir/lib/$tool"; do
if [ ! -e "$tool_path" ]; then
continue
fi

slave=""
tool_man_path="$jdk_base_dir/man/man1/$tool.1"
if [ -e "$tool_man_path" ]; then
slave="--slave /usr/share/man/man1/$tool.1 $tool.1 $tool_man_path"
fi

update-alternatives \
--install \
"/usr/bin/$tool" \
"$tool" \
"$tool_path" \
"$priority" \
$slave
done
done
;;

abort-upgrade | abort-remove | abort-deconfigure)
# Nothing to do
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

exit 0
28 changes: 28 additions & 0 deletions linux/jre/debian/src/main/packaging/temurin/8/debian/prerm.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
set -eu

jdk_base_dir="/usr/lib/jvm/@jvm_dir@"
tools="@jvm_tools@"

case "$1" in
purge)
# Nothing to do
;;
remove | upgrade | failed-upgrade | abort-install | abort-upgrade | disappear | deconfigure)
for tool in $tools; do
for tool_path in "$jdk_base_dir/bin/$tool" "$jdk_base_dir/lib/$tool"; do
if [ ! -e "$tool_path" ]; then
continue
fi

update-alternatives --remove "$tool" "$tool_path"
done
done
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac

exit 0
Loading

0 comments on commit 04e4dd6

Please sign in to comment.