lorax-templates-rhel/files/Add-risv64-support.patch
eabdullin 43067a912f - Add script to generate v2 patch dynamically
- Add riscv64 support patch as a separate file
2026-01-28 17:03:38 +03:00

499 lines
17 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 5afcdaa2c518e1ec91cf9f1ce2cbfa72043d096e Mon Sep 17 00:00:00 2001
From: eabdullin <eabdullin@almalinux.org>
Date: Mon, 1 Sep 2025 14:23:08 +0300
Subject: [PATCH] Add riscv64
---
70-almalinux/config_files/riscv64/boot.msg | 3 +
70-almalinux/config_files/riscv64/grub2-efi.cfg | 46 ++++++++++
70-almalinux/efi.tmpl | 2 +
70-almalinux/live/config_files/riscv64.tmpl | 84 +++++++++++++++++
.../live/config_files/riscv64/grub2-efi.cfg | 42 +++++++++
70-almalinux/live/efi.tmpl | 2 +
70-almalinux/live/live-install.tmpl | 4 +
70-almalinux/live/riscv64.tmpl | 84 +++++++++++++++++
70-almalinux/riscv64.tmpl | 92 +++++++++++++++++++
70-almalinux/runtime-cleanup.tmpl | 5 +
70-almalinux/runtime-install.tmpl | 8 +-
11 files changed, 371 insertions(+), 1 deletion(-)
create mode 100644 70-almalinux/config_files/riscv64/boot.msg
create mode 100644 70-almalinux/config_files/riscv64/grub2-efi.cfg
create mode 100644 70-almalinux/live/config_files/riscv64.tmpl
create mode 100644 70-almalinux/live/config_files/riscv64/grub2-efi.cfg
create mode 100644 70-almalinux/live/riscv64.tmpl
create mode 100644 70-almalinux/riscv64.tmpl
diff --git a/70-almalinux/config_files/riscv64/boot.msg b/70-almalinux/config_files/riscv64/boot.msg
new file mode 100644
index 0000000..9b1722b
--- /dev/null
+++ b/70-almalinux/config_files/riscv64/boot.msg
@@ -0,0 +1,3 @@
+splash.lss
+
+ - Press the 01<ENTER>07 key to begin the installation process.
diff --git a/70-almalinux/config_files/riscv64/grub2-efi.cfg b/70-almalinux/config_files/riscv64/grub2-efi.cfg
new file mode 100644
index 0000000..1ce5d33
--- /dev/null
+++ b/70-almalinux/config_files/riscv64/grub2-efi.cfg
@@ -0,0 +1,46 @@
+set default="1"
+
+function load_video {
+ if [ x$feature_all_video_module = xy ]; then
+ insmod all_video
+ else
+ insmod efi_gop
+ insmod efi_uga
+ insmod ieee1275_fb
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+ fi
+}
+
+load_video
+set gfxpayload=keep
+insmod gzio
+insmod part_gpt
+insmod ext2
+
+set timeout=60
+### END /etc/grub.d/00_header ###
+
+search --no-floppy --set=root -l '@ISOLABEL@'
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'Install @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os {
+ linux @KERNELPATH@ @ROOT@ ro
+ initrd @INITRDPATH@
+}
+menuentry 'Test this media & install @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os {
+ linux @KERNELPATH@ @ROOT@ rd.live.check
+ initrd @INITRDPATH@
+}
+submenu 'Troubleshooting -->' {
+ menuentry 'Install @PRODUCT@ @VERSION@ in basic graphics mode' --class red --class gnu-linux --class gnu --class os {
+ linux @KERNELPATH@ @ROOT@ nomodeset
+ initrd @INITRDPATH@
+ }
+ menuentry 'Rescue a @PRODUCT@ system' --class red --class gnu-linux --class gnu --class os {
+ linux @KERNELPATH@ @ROOT@ inst.rescue
+ initrd @INITRDPATH@
+ }
+}
diff --git a/70-almalinux/efi.tmpl b/70-almalinux/efi.tmpl
index 80600d2..4e0b10b 100644
--- a/70-almalinux/efi.tmpl
+++ b/70-almalinux/efi.tmpl
@@ -8,8 +8,10 @@ APPLE_EFI_DISKNAME=inroot+"/usr/share/pixmaps/bootloader/fedora-media.vol"
mkdir ${EFIBOOTDIR}
mkdir ${EFIBOOTDIR}/fonts/
%if efiarch64:
+%if basearch != "riscv64":
install boot/efi/EFI/*/shim${efiarch64|lower}.efi ${EFIBOOTDIR}/BOOT${efiarch64}.EFI
install boot/efi/EFI/*/mm${efiarch64|lower}.efi ${EFIBOOTDIR}/
+%endif
install boot/efi/EFI/*/gcd${efiarch64|lower}.efi ${EFIBOOTDIR}/grub${efiarch64|lower}.efi
%endif
%if efiarch32:
diff --git a/70-almalinux/live/config_files/riscv64.tmpl b/70-almalinux/live/config_files/riscv64.tmpl
new file mode 100644
index 0000000..6d8784d
--- /dev/null
+++ b/70-almalinux/live/config_files/riscv64.tmpl
@@ -0,0 +1,84 @@
+<%page args="kernels, runtime_img, basearch, inroot, outroot, product, isolabel, extra_boot_args"/>
+<%
+configdir="tmp/config_files/riscv64"
+PXEBOOTDIR="images/pxeboot"
+KERNELDIR=PXEBOOTDIR
+LIVEDIR="LiveOS"
+LORAXDIR="usr/share/lorax/"
+
+## Don't allow spaces or escape characters in the iso label
+def valid_label(ch):
+ return ch.isalnum() or ch == '_'
+
+isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)
+
+import os
+from os.path import basename
+from pylorax.sysutils import joinpaths
+
+# Test the runtime_img, if it is > 4GiB we need to set -iso-level to 3
+if os.stat(joinpaths(inroot, runtime_img)).st_size >= 4*1024**3:
+ isoargs = "-iso-level 3"
+else:
+ isoargs = ""
+%>
+
+mkdir ${LIVEDIR}
+install ${runtime_img} ${LIVEDIR}/squashfs.img
+treeinfo stage2 mainimage ${LIVEDIR}/squashfs.img
+
+## install kernels
+mkdir ${KERNELDIR}
+%for kernel in kernels:
+ ## normal aarch64
+ installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
+ installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
+%endfor
+
+#FIXME: this will need adjusted when we have a real bootloader.
+## WHeeeeeeee, EFI.
+## We could remove the basearch restriction someday..
+<% efiargs=""; efigraft="" %>
+%if exists("boot/efi/EFI/*/gcdriscv64.efi"):
+ <%
+ efiarch32 = None
+ efiarch64 = 'riscv64'
+ efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot)
+ images = ["images/efiboot.img"]
+ %>
+ %for img in images:
+ <%
+ efiargs += " -eltorito-alt-boot -e {0} -no-emul-boot".format(img)
+ efigraft += " {0}={1}/{0}".format(img,outroot)
+ %>
+ treeinfo images-${basearch} ${img|basename} ${img}
+ %endfor
+ <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel, extra_boot_args=extra_boot_args"/>
+%endif
+
+# Create optional product.img and updates.img
+<% filegraft=""; images=["product", "updates"] %>
+%for img in images:
+ %if exists("%s/%s/" % (LORAXDIR, img)):
+ installimg ${LORAXDIR}/${img}/ images/${img}.img
+ treeinfo images-${basearch} ${img}.img images/${img}.img
+ <% filegraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+ %endif
+%endfor
+
+# Add the license files
+%for f in glob("usr/share/licenses/*-release-common/*"):
+ install ${f} ${f|basename}
+ <% filegraft += " {0}={1}/{0}".format(basename(f), outroot) %>
+%endfor
+
+%if exists("boot/efi/EFI/*/gcdriscv64.efi"):
+## make boot.iso
+runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \
+ ${efiargs} -R -J -V '${isolabel}' \
+ -graft-points \
+ ${KERNELDIR}=${outroot}/${KERNELDIR} \
+ ${LIVEDIR}=${outroot}/${LIVEDIR} \
+ ${efigraft} ${filegraft}
+treeinfo images-${basearch} boot.iso images/boot.iso
+%endif
diff --git a/70-almalinux/live/config_files/riscv64/grub2-efi.cfg b/70-almalinux/live/config_files/riscv64/grub2-efi.cfg
new file mode 100644
index 0000000..c874547
--- /dev/null
+++ b/70-almalinux/live/config_files/riscv64/grub2-efi.cfg
@@ -0,0 +1,42 @@
+set default="1"
+
+function load_video {
+ if [ x$feature_all_video_module = xy ]; then
+ insmod all_video
+ else
+ insmod efi_gop
+ insmod efi_uga
+ insmod ieee1275_fb
+ insmod vbe
+ insmod vga
+ insmod video_bochs
+ insmod video_cirrus
+ fi
+}
+
+load_video
+set gfxpayload=keep
+insmod gzio
+insmod part_gpt
+insmod ext2
+
+set timeout=60
+### END /etc/grub.d/00_header ###
+
+search --no-floppy --set=root -l '@ISOLABEL@'
+
+### BEGIN /etc/grub.d/10_linux ###
+menuentry 'Start @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os {
+ linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image quiet rhgb
+ initrd @INITRDPATH@
+}
+menuentry 'Test this media & start @PRODUCT@ @VERSION@' --class red --class gnu-linux --class gnu --class os {
+ linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image rd.live.check quiet
+ initrd @INITRDPATH@
+}
+submenu 'Troubleshooting -->' {
+ menuentry 'Install @PRODUCT@ @VERSION@ in basic graphics mode' --class red --class gnu-linux --class gnu --class os {
+ linux @KERNELPATH@ @ROOT@ @EXTRA@ rd.live.image nomodeset quiet rhgb
+ initrd @INITRDPATH@
+ }
+}
diff --git a/70-almalinux/live/efi.tmpl b/70-almalinux/live/efi.tmpl
index 813f91e..9af7abf 100644
--- a/70-almalinux/live/efi.tmpl
+++ b/70-almalinux/live/efi.tmpl
@@ -8,8 +8,10 @@ APPLE_EFI_DISKNAME=inroot+"/usr/share/pixmaps/bootloader/fedora-media.vol"
mkdir ${EFIBOOTDIR}
mkdir ${EFIBOOTDIR}/fonts/
%if efiarch64:
+%if basearch != "riscv64":
install boot/efi/EFI/*/shim${efiarch64|lower}.efi ${EFIBOOTDIR}/BOOT${efiarch64}.EFI
install boot/efi/EFI/*/mm${efiarch64|lower}.efi ${EFIBOOTDIR}/
+%endif
install boot/efi/EFI/*/gcd${efiarch64|lower}.efi ${EFIBOOTDIR}/grub${efiarch64|lower}.efi
%endif
%if efiarch32:
diff --git a/70-almalinux/live/live-install.tmpl b/70-almalinux/live/live-install.tmpl
index cfa9325..bbecd6f 100644
--- a/70-almalinux/live/live-install.tmpl
+++ b/70-almalinux/live/live-install.tmpl
@@ -23,3 +23,7 @@
%if basearch == "s390x":
installpkg s390utils-base
%endif
+%if basearch == "riscv64":
+ installpkg efibootmgr
+ installpkg grub2-efi-riscv64-cdboot
+%endif
diff --git a/70-almalinux/live/riscv64.tmpl b/70-almalinux/live/riscv64.tmpl
new file mode 100644
index 0000000..6d8784d
--- /dev/null
+++ b/70-almalinux/live/riscv64.tmpl
@@ -0,0 +1,84 @@
+<%page args="kernels, runtime_img, basearch, inroot, outroot, product, isolabel, extra_boot_args"/>
+<%
+configdir="tmp/config_files/riscv64"
+PXEBOOTDIR="images/pxeboot"
+KERNELDIR=PXEBOOTDIR
+LIVEDIR="LiveOS"
+LORAXDIR="usr/share/lorax/"
+
+## Don't allow spaces or escape characters in the iso label
+def valid_label(ch):
+ return ch.isalnum() or ch == '_'
+
+isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)
+
+import os
+from os.path import basename
+from pylorax.sysutils import joinpaths
+
+# Test the runtime_img, if it is > 4GiB we need to set -iso-level to 3
+if os.stat(joinpaths(inroot, runtime_img)).st_size >= 4*1024**3:
+ isoargs = "-iso-level 3"
+else:
+ isoargs = ""
+%>
+
+mkdir ${LIVEDIR}
+install ${runtime_img} ${LIVEDIR}/squashfs.img
+treeinfo stage2 mainimage ${LIVEDIR}/squashfs.img
+
+## install kernels
+mkdir ${KERNELDIR}
+%for kernel in kernels:
+ ## normal aarch64
+ installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
+ installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
+%endfor
+
+#FIXME: this will need adjusted when we have a real bootloader.
+## WHeeeeeeee, EFI.
+## We could remove the basearch restriction someday..
+<% efiargs=""; efigraft="" %>
+%if exists("boot/efi/EFI/*/gcdriscv64.efi"):
+ <%
+ efiarch32 = None
+ efiarch64 = 'riscv64'
+ efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot)
+ images = ["images/efiboot.img"]
+ %>
+ %for img in images:
+ <%
+ efiargs += " -eltorito-alt-boot -e {0} -no-emul-boot".format(img)
+ efigraft += " {0}={1}/{0}".format(img,outroot)
+ %>
+ treeinfo images-${basearch} ${img|basename} ${img}
+ %endfor
+ <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel, extra_boot_args=extra_boot_args"/>
+%endif
+
+# Create optional product.img and updates.img
+<% filegraft=""; images=["product", "updates"] %>
+%for img in images:
+ %if exists("%s/%s/" % (LORAXDIR, img)):
+ installimg ${LORAXDIR}/${img}/ images/${img}.img
+ treeinfo images-${basearch} ${img}.img images/${img}.img
+ <% filegraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+ %endif
+%endfor
+
+# Add the license files
+%for f in glob("usr/share/licenses/*-release-common/*"):
+ install ${f} ${f|basename}
+ <% filegraft += " {0}={1}/{0}".format(basename(f), outroot) %>
+%endfor
+
+%if exists("boot/efi/EFI/*/gcdriscv64.efi"):
+## make boot.iso
+runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \
+ ${efiargs} -R -J -V '${isolabel}' \
+ -graft-points \
+ ${KERNELDIR}=${outroot}/${KERNELDIR} \
+ ${LIVEDIR}=${outroot}/${LIVEDIR} \
+ ${efigraft} ${filegraft}
+treeinfo images-${basearch} boot.iso images/boot.iso
+%endif
diff --git a/70-almalinux/riscv64.tmpl b/70-almalinux/riscv64.tmpl
new file mode 100644
index 0000000..62dd763
--- /dev/null
+++ b/70-almalinux/riscv64.tmpl
@@ -0,0 +1,92 @@
+<%page args="kernels, runtime_img, basearch, inroot, outroot, product, isolabel"/>
+<%
+configdir="tmp/config_files/riscv64"
+PXEBOOTDIR="images/pxeboot"
+KERNELDIR=PXEBOOTDIR
+STAGE2IMG="images/install.img"
+LORAXDIR="usr/share/lorax/"
+
+## Don't allow spaces or escape characters in the iso label
+def valid_label(ch):
+ return ch.isalnum() or ch == '_'
+
+isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)
+
+import os
+from os.path import basename
+from pylorax.sysutils import joinpaths
+
+# Test the runtime_img, if it is > 4GiB we need to set -iso-level to 3
+if os.stat(joinpaths(inroot, runtime_img)).st_size >= 4*1024**3:
+ isoargs = "-iso-level 3"
+else:
+ isoargs = ""
+%>
+
+mkdir images
+install ${runtime_img} ${STAGE2IMG}
+treeinfo stage2 mainimage ${STAGE2IMG}
+
+## install kernels
+mkdir ${KERNELDIR}
+%for kernel in kernels:
+ ## normal aarch64
+ installkernel images-${basearch} ${kernel.path} ${KERNELDIR}/vmlinuz
+ installinitrd images-${basearch} ${kernel.initrd.path} ${KERNELDIR}/initrd.img
+%endfor
+
+#FIXME: this will need adjusted when we have a real bootloader.
+## WHeeeeeeee, EFI.
+## We could remove the basearch restriction someday..
+<% efiargs=""; efigraft="" %>
+%if exists("boot/efi/EFI/*/gcdriscv64.efi"):
+ <%
+ efiarch32 = None
+ efiarch64 = 'riscv64'
+ efigraft="EFI/BOOT={0}/EFI/BOOT".format(outroot)
+ images = ["images/efiboot.img"]
+ %>
+ %for img in images:
+ <%
+ efiargs += " -eltorito-alt-boot -e {0} -no-emul-boot".format(img)
+ efigraft += " {0}={1}/{0}".format(img,outroot)
+ %>
+ treeinfo images-${basearch} ${img|basename} ${img}
+ %endfor
+ <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch32=efiarch32, efiarch64=efiarch64, isolabel=isolabel"/>
+%endif
+
+# Create optional product.img and updates.img
+<% filegraft=""; images=["product", "updates"] %>
+%for img in images:
+ %if exists("%s/%s/" % (LORAXDIR, img)):
+ installimg ${LORAXDIR}/${img}/ images/${img}.img
+ treeinfo images-${basearch} ${img}.img images/${img}.img
+ <% filegraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+ %endif
+%endfor
+
+# Inherit iso-graft/ if it exists from external templates
+<%
+ import os
+ if os.path.exists(workdir + "/iso-graft"):
+ filegraft += " " + workdir + "/iso-graft"
+%>
+
+# Add the license files
+%for f in glob("usr/share/licenses/*-release-common/*"):
+ install ${f} ${f|basename}
+ <% filegraft += " {0}={1}/{0}".format(basename(f), outroot) %>
+%endfor
+
+%if exists("boot/efi/EFI/*/gcdriscv64.efi"):
+## make boot.iso
+runcmd xorrisofs ${isoargs} -o ${outroot}/images/boot.iso \
+ ${efiargs} -R -J -V '${isolabel}' \
+ -graft-points \
+ .discinfo=${outroot}/.discinfo \
+ ${KERNELDIR}=${outroot}/${KERNELDIR} \
+ ${STAGE2IMG}=${outroot}/${STAGE2IMG} \
+ ${efigraft} ${filegraft}
+treeinfo images-${basearch} boot.iso images/boot.iso
+%endif
diff --git a/70-almalinux/runtime-cleanup.tmpl b/70-almalinux/runtime-cleanup.tmpl
index 5332691..5666d29 100644
--- a/70-almalinux/runtime-cleanup.tmpl
+++ b/70-almalinux/runtime-cleanup.tmpl
@@ -329,8 +329,13 @@ runcmd chroot ${root} find /boot \! -name "vmlinuz*" \
## (broken systemd service links lead to confusing noise at boot)
## NOTE: not checking /var because we want to keep /var/run
## NOTE: Excluding /etc/mtab which links to /proc/self/mounts for systemd
+%if basearch == "riscv64":
+runcmd chroot ${root} find -L /etc -xdev -type l -and \! -name "mtab" \
+ -printf "removing broken symbolic link %p -> %l\n" -delete
+%else:
runcmd chroot ${root} find -L /etc /usr -xdev -type l -and \! -name "mtab" \
-printf "removing broken symbolic link %p -> %l\n" -delete
+%endif
## Remove compiled python files, they are recreated as needed anyway
runcmd find ${root} -name "*.pyo" -type f -delete
diff --git a/70-almalinux/runtime-install.tmpl b/70-almalinux/runtime-install.tmpl
index 2106964..1ad7669 100644
--- a/70-almalinux/runtime-install.tmpl
+++ b/70-almalinux/runtime-install.tmpl
@@ -79,6 +79,12 @@ installpkg glibc-all-langpacks
%if basearch == "s390x":
installpkg lsscsi s390utils-base s390utils-cmsfs-fuse s390utils-hmcdrvfs
%endif
+%if basearch == "riscv64":
+ installpkg efibootmgr
+ installpkg grub2-efi-riscv64-cdboot>=${GRUB2VER}
+ installpkg grub2-tools>=${GRUB2VER}
+ installpkg uboot-tools
+%endif
## yay, plymouth
installpkg plymouth
@@ -140,7 +146,7 @@ installpkg mt-st smartmontools
installpkg hdparm
installpkg rdma-core
installpkg rng-tools
-%if basearch in ("x86_64", "x86_64_v2", "aarch64"):
+%if basearch in ("x86_64", "x86_64_v2", "aarch64", "riscv64"):
installpkg dmidecode
%endif
installpkg nvme-cli