Skip to content

Commit 73d02f7

Browse files
committed
implement jinja templating to handle linux installer updates
1 parent 45d34f1 commit 73d02f7

File tree

14 files changed

+451
-113
lines changed

14 files changed

+451
-113
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ Thumbs.db
3030

3131
node_modules/
3232
wix/Workdir/
33+
34+
35+
lib/
36+
bin/
37+
.venv/
38+
adoptium_cache.sqlite

linux/config/temurin.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# https://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
15+
supported_distributions:
16+
Distros: [alpine]
17+
Versions: [8, 11, 17, 21, 22]

linux/generate-linux-specs.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# https://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
#
13+
14+
import os
15+
16+
import requests
17+
import requests_cache
18+
import yaml
19+
from jinja2 import Environment, FileSystemLoader
20+
21+
requests_cache.install_cache("adoptium_cache", expire_after=3600)
22+
23+
# Setup the Jinja2 environment
24+
env = Environment(loader=FileSystemLoader("linux/templates"))
25+
26+
headers = {
27+
"User-Agent": "Adoptium Linux Specfile Updater",
28+
}
29+
30+
31+
def archHelper(arch):
32+
if arch == "x64":
33+
return "x86_64"
34+
else:
35+
return arch
36+
37+
# Load the YAML configuration
38+
with open("linux/config/temurin.yml", "r") as file:
39+
config = yaml.safe_load(file)
40+
41+
for image_type in ["jdk", "jre"]:
42+
# Iterate through supported_distributions
43+
for distro in config["supported_distributions"]["Distros"]:
44+
for version in config["supported_distributions"]["Versions"]:
45+
46+
# Fetch latest release for version from Adoptium API
47+
url = f"https://api.adoptium.net/v3/assets/feature_releases/{version}/ga?page=0&image_type={image_type}&os=alpine-linux&page_size=1&vendor=eclipse"
48+
response = requests.get(url, headers=headers)
49+
response.raise_for_status()
50+
data = response.json()
51+
52+
release = response.json()[0]
53+
54+
# Extract the version number from the release name
55+
openjdk_version = release["release_name"]
56+
57+
# If version doesn't equal 8, get the more accurate version number
58+
if version != 8:
59+
openjdk_version = (
60+
release["version_data"]["openjdk_version"]
61+
)
62+
# if openjdk_version contains -LTS remove it
63+
if "-LTS" in openjdk_version:
64+
openjdk_version = openjdk_version.replace("-LTS", "")
65+
66+
# Convert version from 11.0.24+8 to 11.0.24_p8
67+
openjdk_version = openjdk_version.replace("jdk", "")
68+
openjdk_version = openjdk_version.replace("+", "_p")
69+
openjdk_version = openjdk_version.replace("u", ".")
70+
openjdk_version = openjdk_version.replace("-b", ".")
71+
72+
# Generate the data for each architecture
73+
arch_data = {}
74+
75+
for binary in release["binaries"]:
76+
arch_data[archHelper(binary["architecture"])] = {
77+
"download_url": binary["package"]["link"],
78+
"checksum": binary["package"]["checksum"],
79+
"filename": binary["package"]["name"],
80+
}
81+
82+
# Set path to the specfiles
83+
path = f"linux/{image_type}/{distro}/src/main/packaging/temurin/{version}"
84+
85+
# Check that the path exists
86+
os.makedirs(path, exist_ok=True)
87+
88+
# Load the template
89+
template = env.get_template(f"{distro}.spec.j2")
90+
91+
# Render the template
92+
rendered = template.render(
93+
arch_data=arch_data,
94+
openjdk_version=openjdk_version,
95+
release_name=release["release_name"],
96+
version=version,
97+
image_type=image_type
98+
)
99+
100+
# Set filename based on switch distro e.g APKBUILD for alpine, spec for others
101+
filename = "APKBUILD" if distro == "alpine" else "temurin.spec"
102+
103+
# Write the rendered template to the file
104+
with open(f"{path}/{filename}", "w") as file:
105+
file.write(rendered)
106+
print(f"Generated {path}/{filename}")

linux/jdk/alpine/src/main/packaging/temurin/11/APKBUILD

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# Maintainer: Eclipse Adoptium Package Maintainers <temurin-dev@eclipse.org>
22
pkgname=temurin-11
33
pkgver=11.0.24_p8
4-
# replace _p1 with _1
5-
_pkgver=${pkgver/_p/_}
6-
_pkgverplus=${pkgver/_p/+}
7-
_pkgvername=${_pkgverplus/+/%2B}
8-
pkgrel=1
4+
pkgrel=0
95
pkgdesc="Eclipse Temurin 11"
106
provider_priority=11
117
url="https://adoptium.net"
12-
arch="noarch"
8+
arch="x86_64"
139
license="GPL-2.0-with-classpath-exception"
1410
makedepends="
1511
alsa-lib-dev
@@ -25,8 +21,9 @@ makedepends="
2521
"
2622
depends=""
2723
subpackages="$pkgname-src:_src:noarch
28-
$pkgname-jdk:_jdk:x86_64"
29-
source="https://github.com/adoptium/temurin11-binaries/releases/download/jdk-$_pkgvername/OpenJDK11U-jdk_x64_alpine-linux_hotspot_$_pkgver.tar.gz
24+
$pkgname-jdk:_jdk"
25+
source="
26+
https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%2B8/OpenJDK11U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_11.0.24_8.tar.gz
3027
3128
HelloWorld.java
3229
TestECDSA.java
@@ -43,7 +40,7 @@ prepare() {
4340
}
4441

4542
check() {
46-
local _java_bin="./jdk-$_pkgverplus/bin"
43+
local _java_bin="./jdk-11.0.24+8/bin"
4744

4845
# 1) compile and run a simple hello world
4946
$_java_bin/javac -d . "$srcdir"/HelloWorld.java
@@ -60,7 +57,7 @@ check() {
6057

6158
package() {
6259
mkdir -p "$pkgdir/$_java_home"
63-
cp -r "$srcdir"/jdk-"$_pkgverplus"/* "$pkgdir/$_java_home"
60+
cp -r "$srcdir"/jdk-11.0.24+8/* "$pkgdir/$_java_home"
6461
}
6562

6663
_src() {
@@ -94,8 +91,14 @@ _jdk() {
9491
"$_toroot/lib/security/cacerts"
9592
}
9693

94+
case "$CARCH" in
95+
x86_64)
96+
_arch_sum="ae988c72eeb2d78bb729a3387601ce0ea84305734ebdbe95d276f39952a8e019"
97+
;;
98+
esac
99+
97100
sha256sums="
98-
ae988c72eeb2d78bb729a3387601ce0ea84305734ebdbe95d276f39952a8e019 OpenJDK11U-jdk_x64_alpine-linux_hotspot_$_pkgver.tar.gz
101+
$_arch_sum OpenJDK11U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_11.0.24_8.tar.gz
99102
e9185736dde99a4dc570a645a20407bdb41c1f48dfc34d9c3eb246cf0435a378 HelloWorld.java
100103
22d2ff9757549ebc64e09afd3423f84b5690dcf972cd6535211c07c66d38fab0 TestCryptoLevel.java
101104
9fb00c7b0220de8f3ee2aa398459a37d119f43fd63321530a00b3bb9217dd933 TestECDSA.java

linux/jdk/alpine/src/main/packaging/temurin/17/APKBUILD

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# Maintainer: Eclipse Adoptium Package Maintainers <temurin-dev@eclipse.org>
22
pkgname=temurin-17
33
pkgver=17.0.12_p7
4-
# replace _p1 with _1
5-
_pkgver=${pkgver/_p/_}
6-
_pkgverplus=${pkgver/_p/+}
7-
_pkgvername=${_pkgverplus/+/%2B}
8-
pkgrel=1
4+
pkgrel=0
95
pkgdesc="Eclipse Temurin 17"
106
provider_priority=17
117
url="https://adoptium.net"
12-
arch="noarch"
8+
arch="x86_64"
139
license="GPL-2.0-with-classpath-exception"
1410
makedepends="
1511
alsa-lib-dev
@@ -25,8 +21,9 @@ makedepends="
2521
"
2622
depends=""
2723
subpackages="$pkgname-src:_src:noarch
28-
$pkgname-jdk:_jdk:x86_64"
29-
source="https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$_pkgvername/OpenJDK17U-jdk_x64_alpine-linux_hotspot_$_pkgver.tar.gz
24+
$pkgname-jdk:_jdk"
25+
source="
26+
https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_17.0.12_7.tar.gz
3027
3128
HelloWorld.java
3229
TestECDSA.java
@@ -43,7 +40,7 @@ prepare() {
4340
}
4441

4542
check() {
46-
local _java_bin="./jdk-$_pkgverplus/bin"
43+
local _java_bin="./jdk-17.0.12+7/bin"
4744

4845
# 1) compile and run a simple hello world
4946
$_java_bin/javac -d . "$srcdir"/HelloWorld.java
@@ -60,7 +57,7 @@ check() {
6057

6158
package() {
6259
mkdir -p "$pkgdir/$_java_home"
63-
cp -r "$srcdir"/jdk-"$_pkgverplus"/* "$pkgdir/$_java_home"
60+
cp -r "$srcdir"/jdk-17.0.12+7/* "$pkgdir/$_java_home"
6461
}
6562

6663
_src() {
@@ -94,8 +91,14 @@ _jdk() {
9491
"$_toroot/lib/security/cacerts"
9592
}
9693

94+
case "$CARCH" in
95+
x86_64)
96+
_arch_sum="6d274a292a717a6f8d00a3ed0695497405c5c634c27fec1692dd13784f6ff6fa"
97+
;;
98+
esac
99+
97100
sha256sums="
98-
6d274a292a717a6f8d00a3ed0695497405c5c634c27fec1692dd13784f6ff6fa OpenJDK17U-jdk_x64_alpine-linux_hotspot_$_pkgver.tar.gz
101+
$_arch_sum OpenJDK17U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_17.0.12_7.tar.gz
99102
e9185736dde99a4dc570a645a20407bdb41c1f48dfc34d9c3eb246cf0435a378 HelloWorld.java
100103
22d2ff9757549ebc64e09afd3423f84b5690dcf972cd6535211c07c66d38fab0 TestCryptoLevel.java
101104
9fb00c7b0220de8f3ee2aa398459a37d119f43fd63321530a00b3bb9217dd933 TestECDSA.java

linux/jdk/alpine/src/main/packaging/temurin/21/APKBUILD

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Maintainer: Eclipse Adoptium Package Maintainers <temurin-dev@eclipse.org>
22
pkgname=temurin-21
33
pkgver=21.0.4_p7
4-
# replace _p1 with _1
5-
_pkgver=${pkgver/_p/_}
6-
_pkgverplus=${pkgver/_p/+}
7-
_pkgvername=${_pkgverplus/+/%2B}
8-
pkgrel=1
4+
pkgrel=0
95
pkgdesc="Eclipse Temurin 21"
106
provider_priority=21
117
url="https://adoptium.net"
@@ -27,7 +23,7 @@ depends=""
2723
subpackages="$pkgname-src:_src:noarch
2824
$pkgname-jdk:_jdk"
2925
source="
30-
https://github.com/adoptium/temurin21-binaries/releases/download/jdk-$_pkgvername/OpenJDK21u-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_$_pkgver.tar.gz
26+
https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.4%2B7/OpenJDK21U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_21.0.4_7.tar.gz
3127
3228
HelloWorld.java
3329
TestECDSA.java
@@ -44,7 +40,7 @@ prepare() {
4440
}
4541

4642
check() {
47-
local _java_bin="./jdk-$_pkgverplus/bin"
43+
local _java_bin="./jdk-21.0.4+7/bin"
4844

4945
# 1) compile and run a simple hello world
5046
$_java_bin/javac -d . "$srcdir"/HelloWorld.java
@@ -61,7 +57,7 @@ check() {
6157

6258
package() {
6359
mkdir -p "$pkgdir/$_java_home"
64-
cp -r "$srcdir"/jdk-"$_pkgverplus"/* "$pkgdir/$_java_home"
60+
cp -r "$srcdir"/jdk-21.0.4+7/* "$pkgdir/$_java_home"
6561
}
6662

6763
_src() {
@@ -96,16 +92,16 @@ _jdk() {
9692
}
9793

9894
case "$CARCH" in
99-
x86_64)
100-
_arch_sum="8fa232fc9de5a861c1a6b0cbdc861d0b0a2bdbdd27da53d991802a460a7f0973"
101-
;;
10295
aarch64)
10396
_arch_sum="849c6d5a62a1f3dc2a3d2d7be07ffda089d35b862f6160b2a288c0408c2d8be8"
10497
;;
98+
x86_64)
99+
_arch_sum="8fa232fc9de5a861c1a6b0cbdc861d0b0a2bdbdd27da53d991802a460a7f0973"
100+
;;
105101
esac
106102

107103
sha256sums="
108-
$_arch_sum OpenJDK21u-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_$_pkgver.tar.gz
104+
$_arch_sum OpenJDK21U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_21.0.4_7.tar.gz
109105
e9185736dde99a4dc570a645a20407bdb41c1f48dfc34d9c3eb246cf0435a378 HelloWorld.java
110106
22d2ff9757549ebc64e09afd3423f84b5690dcf972cd6535211c07c66d38fab0 TestCryptoLevel.java
111107
9fb00c7b0220de8f3ee2aa398459a37d119f43fd63321530a00b3bb9217dd933 TestECDSA.java

linux/jdk/alpine/src/main/packaging/temurin/22/APKBUILD

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Maintainer: Eclipse Adoptium Package Maintainers <temurin-dev@eclipse.org>
22
pkgname=temurin-22
33
pkgver=22.0.2_p9
4-
# replace _p1 with _1
5-
_pkgver=${pkgver/_p/_}
6-
_pkgverplus=${pkgver/_p/+}
7-
_pkgvername=${_pkgverplus/+/%2B}
8-
pkgrel=1
4+
pkgrel=0
95
pkgdesc="Eclipse Temurin 22"
106
provider_priority=22
117
url="https://adoptium.net"
@@ -27,7 +23,7 @@ depends=""
2723
subpackages="$pkgname-src:_src:noarch
2824
$pkgname-jdk:_jdk"
2925
source="
30-
https://github.com/adoptium/temurin22-binaries/releases/download/jdk-$_pkgvername/OpenJDK22u-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_$_pkgver.tar.gz
26+
https://github.com/adoptium/temurin22-binaries/releases/download/jdk-22.0.2%2B9/OpenJDK22U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_22.0.2_9.tar.gz
3127
3228
HelloWorld.java
3329
TestECDSA.java
@@ -44,7 +40,7 @@ prepare() {
4440
}
4541

4642
check() {
47-
local _java_bin="./jdk-$_pkgverplus/bin"
43+
local _java_bin="./jdk-22.0.2+9/bin"
4844

4945
# 1) compile and run a simple hello world
5046
$_java_bin/javac -d . "$srcdir"/HelloWorld.java
@@ -61,7 +57,7 @@ check() {
6157

6258
package() {
6359
mkdir -p "$pkgdir/$_java_home"
64-
cp -r "$srcdir"/jdk-"$_pkgverplus"/* "$pkgdir/$_java_home"
60+
cp -r "$srcdir"/jdk-22.0.2+9/* "$pkgdir/$_java_home"
6561
}
6662

6763
_src() {
@@ -96,16 +92,16 @@ _jdk() {
9692
}
9793

9894
case "$CARCH" in
99-
x86_64)
100-
_arch_sum="49f73414824b1a7c268a611225fa4d7ce5e25600201e0f1cd59f94d1040b5264"
101-
;;
10295
aarch64)
10396
_arch_sum="8ac93a2d5a55aabbc0f7156c2f9032026e87c185689d628ef8a4184b6e9ab006"
10497
;;
98+
x86_64)
99+
_arch_sum="49f73414824b1a7c268a611225fa4d7ce5e25600201e0f1cd59f94d1040b5264"
100+
;;
105101
esac
106102

107103
sha256sums="
108-
$_arch_sum OpenJDK22u-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_$_pkgver.tar.gz
104+
$_arch_sum OpenJDK22U-jdk_${CARCH/x86_64/x64}_alpine-linux_hotspot_22.0.2_9.tar.gz
109105
e9185736dde99a4dc570a645a20407bdb41c1f48dfc34d9c3eb246cf0435a378 HelloWorld.java
110106
22d2ff9757549ebc64e09afd3423f84b5690dcf972cd6535211c07c66d38fab0 TestCryptoLevel.java
111107
9fb00c7b0220de8f3ee2aa398459a37d119f43fd63321530a00b3bb9217dd933 TestECDSA.java

0 commit comments

Comments
 (0)