linux_new: Template de-duplication — Debian (DEB) shared templates
- Dominant language
- Jinja
- Stars
- 168
- Forks
- 77
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 12
Description
Part of: #1445
---
## Background
The `linux_new` pipeline maintains separate Debian template files for every supported Java
version under:
jdk/debian/src/main/packaging/temurin/{version}/debian/
jre/debian/src/main/packaging/temurin/{version}/debian/
With 8 active versions (8, 11, 17, 21, 23, 24, 25, 26) × 2 package types (jdk/jre) × ~8 files
per directory, this is ~128 files where the meaningful differences between versions are:
| File | What actually differs between versions |
|---|---|
| `control.template.j2` | `Provides:` list grows by ~3 entries per new version (backward-compat declarations) |
| `rules.template.j2` | Priority number (e.g. `1111` → `2111`); tool list changes at known version thresholds |
| `jinfo.in` | Same tool list changes as `rules.template.j2` |
| `changelog.template.j2` | Only the package name token (e.g. `temurin-11-jdk`) — structure is identical |
| `postinst.in` / `prerm.in` | Only the package name token — logic is identical |
Known tool change boundaries:
- JDK < 17: includes `jaotc`, `jjs`, `pack200`, `rmic`, `unpack200`
- JDK ≥ 16: adds `jpackage`
- JDK ≥ 17: removes the above deprecated tools
- JDK ≥ 18: adds `jwebserver`
---
## Goal
Replace the per-version template copies with a single shared template set that uses Jinja2
`{% for %}` / `{% if version|int >= N %}` logic driven by the version number already passed
to `generate_spec.py`. Adding a new Java version will require **no new template files**.
---
## Prerequisite
> ⚠️ The **golden file baseline** (child issue #4 — regression tests) must be committed
> **before** any templates in this issue are changed. The golden files capture current
> output to verify the shared templates produce byte-for-byte identical results.
---
## Scope
### New shared templates to create
jdk/debian/src/main/packaging/temurin/shared/debian/
control.template.j2 ← dynamic Provides: list via {% for i in range(2, version|int+1) %}
changelog.template.j2 ← identical across versions; package name via template variable
rules.template.j2 ← priority and tool list via version-threshold conditionals
postinst.in ← identical across versions
prerm.in ← identical across versions
jinfo.in ← tool list via version-threshold conditionals
jre/debian/src/main/packaging/temurin/shared/debian/
(same set — shorter Provides: list, no java-compiler/java-sdk entries)
### Jenkinsfile change
The `Generate Spec File` stage constructs `templatebase` for Debian at line ~636. Update this
to check for a per-version file first; fall back to `shared/debian/` if absent:
```groovy
// Current
templatebase = "./linux_new/${PTYPE}/${DistArrayElement}/src/main/packaging/${PRODUCT}/${Release}/${DistArrayElement}/${debianFilesArrayElement}.template.j2"
// New (pseudocode)
def versionSpecific = "./linux_new/${PTYPE}/${DistArrayElement}/src/main/packaging/${PRODUCT}/${Release}/${DistArrayElement}/${debianFilesArrayElement}.template.j2"
def shared = "./linux_new/${PTYPE}/${DistArrayElement}/src/main/packaging/${PRODUCT}/shared/${DistArrayElement}/${debianFilesArrayElement}.template.j2"
templatebase = fileExists(versionSpecific) ? versionSpecific : shared
The same fallback applies for postinst.in, prerm.in, and jinfo.in (non-templated files
copied by build.sh). Update build.sh to source from shared/ when no per-version copy exists.
Per-version directories
Once the shared templates are validated, the per-version debian/ subdirectories can be
deleted, retaining only:
compat (identical across versions — keep in place; no fallback needed, or move to shared)
copyright (identical across versions — same)
Acceptance Criteria
jdk/debian/src/main/packaging/temurin/shared/debian/ exists with all 6 template/in files
jre/debian/src/main/packaging/temurin/shared/debian/ exists with all 6 template/in files
Per-version changelog.template.j2, control.template.j2, rules.template.j2, postinst.in, prerm.in, jinfo.in files are deleted from all 8 version directories
Running generate_spec.py against the shared templates for all 8 versions produces output that is byte-for-byte identical to the committed golden files (regression test passes)
Jenkinsfile Generate Spec File stage uses the shared fallback path
build.sh copies postinst.in, prerm.in, jinfo.in from shared/ when no per-version override exists
Both jdk and jre are covered
Contributor guide
Assessment
This issue has not been assessed yet.