From 265d235732015f095bef366bed2aecd0897a15d7 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Wed, 3 Jun 2026 16:00:04 +0300 Subject: [PATCH] Add 64k tempalte for AlmaLinux --- config.yaml | 45 ++++++++++++++++--- scripts/generate-patch-for-64k.sh | 23 ++++++++++ scripts/generate-patch-for-v2.sh | 2 +- scripts/lorax-templates-almalinux-requires.sh | 27 +++++++++-- 4 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 scripts/generate-patch-for-64k.sh diff --git a/config.yaml b/config.yaml index c4e1c1b..8d7073c 100644 --- a/config.yaml +++ b/config.yaml @@ -4,11 +4,13 @@ actions: find: "%define templatedir %{_datadir}/lorax/templates.d/" replace: | %define templatedir %{_datadir}/lorax/templates.d/ - %define almatemplatedir %{templatedir}/70-almalinux + %define almatemplate 70-almalinux + %define alma64ktemplate 60-almalinux-64k # AlmaLinux support and rebranding Patch1001: Add-x86_64_v2-support.patch Patch1002: Add-risv64-support.patch + Patch1003: Add-almalinux-64k-support.patch count: 1 - target: "spec" @@ -28,7 +30,15 @@ actions: %description -n lorax-templates-almalinux AlmaLinux-specific Lorax templates for creating the boot.iso and live isos are - placed in %{almatemplatedir} + placed in %{templatedir}/%{almatemplate} + + %package -n lorax-templates-almalinux-64k + Summary: AlmaLinux build templates for lorax and livemedia-creator using the aarch64 64k kernel + Requires: + + %description -n lorax-templates-almalinux-64k + AlmaLinux-specific Lorax templates that install kernel-64k on aarch64. All other arches + are identical to lorax-templates-almalinux. Templates are placed in %{templatedir}/%{alma64ktemplate} count: 1 - target: "spec" @@ -53,6 +63,14 @@ actions: sed -i '/libreport-rhel-anaconda-bugzilla/d' 70-almalinux/runtime-install.tmpl sed -i '/redhat-release-eula/d' 70-almalinux/runtime-install.tmpl + # Prepare AlmaLinux 64k templates: start from the fully-branded + # AlmaLinux templates and apply the same delta that upstream applies + # between 80-rhel and 70-64k (install kernel-64k on aarch64). + # The patch is generated automatically by + # generate-patch-for-64k.sh, mirroring generate-patch-for-v2.sh. + cp -a 70-almalinux 60-almalinux-64k + %patch -P 1003 -p1 + count: 1 - target: "spec" find: | @@ -65,8 +83,12 @@ actions: cp -a 70-64k $RPM_BUILD_ROOT/%{templatedir} # Install AlmaLinux templates - mkdir -p $RPM_BUILD_ROOT/%{almatemplatedir} - cp -a 70-almalinux/* $RPM_BUILD_ROOT/%{almatemplatedir} + mkdir -p $RPM_BUILD_ROOT/%{templatedir}/%{almatemplate} + cp -a %{almatemplate}/* $RPM_BUILD_ROOT/%{templatedir}/%{almatemplate} + + # Install AlmaLinux 64k templates + mkdir -p $RPM_BUILD_ROOT/%{templatedir}/%{alma64ktemplate} + cp -a %{alma64ktemplate}/* $RPM_BUILD_ROOT/%{templatedir}/%{alma64ktemplate} count: 1 @@ -81,8 +103,12 @@ actions: %{templatedir}/80-rhel/* %files -n lorax-templates-almalinux - %dir %{almatemplatedir} - %{almatemplatedir}/* + %dir %{templatedir}/%{almatemplate} + %{templatedir}/%{almatemplate}/* + + %files -n lorax-templates-almalinux-64k + %dir %{templatedir}/%{alma64ktemplate} + %{templatedir}/%{alma64ktemplate}/* count: 1 @@ -91,6 +117,8 @@ actions: cwd: "rpms" - script: "generate-patch-for-v2.sh" cwd: "rpms" + - script: "generate-patch-for-64k.sh" + cwd: "rpms" - changelog_entry: - name: "Yuriy Kohut" @@ -102,6 +130,7 @@ actions: line: - "Add riscv64 support" - "Add x86_64_v2 support" + - "Add AlmaLinux 64k templates (60-almalinux-64k)" - add_files: # will be generated by generate-patch-for-v2.sh so it should not be added here @@ -110,6 +139,10 @@ actions: # name: "Add-x86_64_v2-support.patch" # number: 1001 # modify_spec: false + # - type: "patch" + # name: "Add-almalinux-64k-support.patch" + # number: 1003 + # modify_spec: false - type: "patch" name: "Add-risv64-support.patch" number: 1002 diff --git a/scripts/generate-patch-for-64k.sh b/scripts/generate-patch-for-64k.sh new file mode 100644 index 0000000..7f33edb --- /dev/null +++ b/scripts/generate-patch-for-64k.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +# Re-express the upstream "80-rhel -> 70-64k" delta (install kernel-64k on +# aarch64) as a patch that applies on top of the AlmaLinux 64k template +# directory (60-almalinux-64k, which in %prep is a branded copy of +# 70-almalinux). +# +# This mirrors generate-patch-for-v2.sh: the patch is generated at autopatch +# time from the directories shipped in the source tree, so it always tracks +# the current upstream delta instead of being a hand-maintained snapshot. + +TEMPLATE_DIR=60-almalinux-64k + +mkdir -p a b + +cp -r 80-rhel a/${TEMPLATE_DIR} +cp -r 70-64k b/${TEMPLATE_DIR} + +diff -aruN a/${TEMPLATE_DIR} b/${TEMPLATE_DIR} > Add-almalinux-64k-support.patch || [ $? -eq 1 ] + +rm -rf a b diff --git a/scripts/generate-patch-for-v2.sh b/scripts/generate-patch-for-v2.sh index 03de421..e76ce56 100644 --- a/scripts/generate-patch-for-v2.sh +++ b/scripts/generate-patch-for-v2.sh @@ -7,7 +7,7 @@ mkdir -p a b cp -r 80-rhel a/${TEMPLATE_DIR} cp -r 80-rhel b/${TEMPLATE_DIR} -# Добавляем x86_v2 конфиги и шаблоны +# Add x86_v2 config files and templates mkdir -p b/${TEMPLATE_DIR}/live/config_files/x86_v2 cp b/${TEMPLATE_DIR}/live/config_files/x86/* b/${TEMPLATE_DIR}/live/config_files/x86_v2/ cp b/${TEMPLATE_DIR}/x86.tmpl b/${TEMPLATE_DIR}/x86_v2.tmpl diff --git a/scripts/lorax-templates-almalinux-requires.sh b/scripts/lorax-templates-almalinux-requires.sh index 6c1a7fb..6df49b2 100644 --- a/scripts/lorax-templates-almalinux-requires.sh +++ b/scripts/lorax-templates-almalinux-requires.sh @@ -2,8 +2,27 @@ set -e -# Get the "Requires" from the lorax-templates-rhel.spec file (main package) -# and replace the 'Requires: ' string for the lorax-templates-almalinux subpackage +SPEC=lorax-templates-rhel.spec -requires=$(grep 'Requires:' lorax-templates-rhel.spec | grep -v '' | head -1) -sed -i "s/^Requires:.*/$requires/" lorax-templates-rhel.spec +# Extract the "Requires" of each source package from its own section, so the +# AlmaLinux subpackages mirror exactly the package they are derived from +# (independent of the order of the "Requires:" lines in the spec). + +# Main package: the first "Requires:" before any %package preamble. +requires=$(awk '/^%package/ {exit} /^Requires:/ {print; exit}' "$SPEC") + +# Upstream 64k subpackage (%package 64k -> lorax-templates-rhel-64k): +# the first "Requires:" inside the "%package 64k" section. +requires64k=$(awk '/^%package[[:space:]]+64k([[:space:]]|$)/ {f=1; next} + f && /^Requires:/ {print; exit}' "$SPEC") + +if [ -z "$requires" ] || [ -z "$requires64k" ]; then + echo "ERROR: failed to extract Requires (main='${requires}', 64k='${requires64k}')" >&2 + exit 1 +fi + +# Replace the placeholders of the AlmaLinux subpackages: +# -> lorax-templates-almalinux (mirrors the main package) +# -> lorax-templates-almalinux-64k (mirrors the 64k subpackage) +sed -i "s/^Requires:.*/$requires64k/" "$SPEC" +sed -i "s/^Requires:.*/$requires/" "$SPEC"