From 2b3daeff6a8b19ee4cb0ac4a85dbfa579e705851 Mon Sep 17 00:00:00 2001 From: "yan.yihao 10263201" Date: Sun, 15 Jun 2025 14:48:29 +0800 Subject: [PATCH] add riscv64 support for lorax-templates-anolis --- ...4-support-for-lorax-templates-anolis.patch | 366 ++++++++++++++++++ lorax-templates-anolis.spec | 6 +- 2 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 1021-add-riscv64-support-for-lorax-templates-anolis.patch diff --git a/1021-add-riscv64-support-for-lorax-templates-anolis.patch b/1021-add-riscv64-support-for-lorax-templates-anolis.patch new file mode 100644 index 0000000..f82408a --- /dev/null +++ b/1021-add-riscv64-support-for-lorax-templates-anolis.patch @@ -0,0 +1,366 @@ +diff -urN a/80-anolis/config_files/riscv64/boot.msg b/80-anolis/config_files/riscv64/boot.msg +--- a/80-anolis/config_files/riscv64/boot.msg 1970-01-01 08:00:00.000000000 +0800 ++++ b/80-anolis/config_files/riscv64/boot.msg 2025-06-19 15:03:30.855906428 +0800 +@@ -0,0 +1,5 @@ ++ ++splash.lss ++ ++ - Press the 0107 key to begin the installation process. ++ +diff -urN a/80-anolis/config_files/riscv64/grub2-efi.cfg b/80-anolis/config_files/riscv64/grub2-efi.cfg +--- a/80-anolis/config_files/riscv64/grub2-efi.cfg 1970-01-01 08:00:00.000000000 +0800 ++++ b/80-anolis/config_files/riscv64/grub2-efi.cfg 2025-06-19 15:03:30.855906428 +0800 +@@ -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 -urN a/80-anolis/efi.tmpl b/80-anolis/efi.tmpl +--- a/80-anolis/efi.tmpl 2025-06-19 15:03:12.871568933 +0800 ++++ b/80-anolis/efi.tmpl 2025-06-19 15:03:30.855906428 +0800 +@@ -7,7 +7,7 @@ + + mkdir ${EFIBOOTDIR} + mkdir ${EFIBOOTDIR}/fonts/ +-%if efiarch64 and efiarch64 != 'LOONGARCH64': ++%if efiarch64 and efiarch64 != 'LOONGARCH64' and efiarch64 != 'riscv64': + install boot/efi/EFI/*/shim${efiarch64|lower}.efi ${EFIBOOTDIR}/BOOT${efiarch64}.EFI + install boot/efi/EFI/*/mm${efiarch64|lower}.efi ${EFIBOOTDIR}/ + install boot/efi/EFI/*/gcd${efiarch64|lower}.efi ${EFIBOOTDIR}/grub${efiarch64|lower}.efi +@@ -22,6 +22,10 @@ + install boot/efi/EFI/*/grubloongarch64.efi ${EFIBOOTDIR}/BOOTLOONGARCH.EFI + install boot/efi/EFI/*/grubloongarch64.efi ${EFIBOOTDIR}/grub${efiarch64|lower}.efi + %endif ++%if efiarch64 == 'riscv64': ++install boot/efi/EFI/*/gcd${efiarch64|lower}.efi ${EFIBOOTDIR}/BOOT${efiarch64}.EFI ++install boot/efi/EFI/*/gcd${efiarch64|lower}.efi ${EFIBOOTDIR}/grub${efiarch64|lower}.efi ++%endif + install boot/grub2/fonts/unicode.pf2 ${EFIBOOTDIR}/fonts/ + + ## actually make the EFI images +diff -urN a/80-anolis/live/config_files/riscv64/grub2-efi.cfg b/80-anolis/live/config_files/riscv64/grub2-efi.cfg +--- a/80-anolis/live/config_files/riscv64/grub2-efi.cfg 1970-01-01 08:00:00.000000000 +0800 ++++ b/80-anolis/live/config_files/riscv64/grub2-efi.cfg 2025-06-19 15:03:30.855906428 +0800 +@@ -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 -urN a/80-anolis/live/live-install.tmpl b/80-anolis/live/live-install.tmpl +--- a/80-anolis/live/live-install.tmpl 2025-06-19 15:03:12.815564768 +0800 ++++ b/80-anolis/live/live-install.tmpl 2025-06-19 15:03:30.856906502 +0800 +@@ -28,3 +28,7 @@ + %if basearch == "s390x": + installpkg s390utils-base + %endif ++%if basearch == "riscv64": ++ installpkg efibootmgr ++ installpkg grub2-efi-riscv64-cdboot ++%endif +diff -urN a/80-anolis/live/riscv64.tmpl b/80-anolis/live/riscv64.tmpl +--- a/80-anolis/live/riscv64.tmpl 1970-01-01 08:00:00.000000000 +0800 ++++ b/80-anolis/live/riscv64.tmpl 2025-06-19 15:03:30.856906502 +0800 +@@ -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 -urN a/80-anolis/riscv64.tmpl b/80-anolis/riscv64.tmpl +--- a/80-anolis/riscv64.tmpl 1970-01-01 08:00:00.000000000 +0800 ++++ b/80-anolis/riscv64.tmpl 2025-06-19 15:03:30.856906502 +0800 +@@ -0,0 +1,86 @@ ++<%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/" ++ ++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 -urN a/80-anolis/runtime-cleanup.tmpl b/80-anolis/runtime-cleanup.tmpl +--- a/80-anolis/runtime-cleanup.tmpl 2025-06-19 15:03:12.850567371 +0800 ++++ b/80-anolis/runtime-cleanup.tmpl 2025-06-19 15:04:14.557981994 +0800 +@@ -317,7 +317,11 @@ + ## (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 /usr -xdev -type l -and \! -name "mtab" \ ++%else: ++runcmd chroot ${root} find -L /etc -xdev -type l -and \! -name "mtab" \ ++%endif + -printf "removing broken symbolic link %p -> %l\n" -delete + + ## Remove compiled python files, they are recreated as needed anyway +diff -urN a/80-anolis/runtime-install.tmpl b/80-anolis/runtime-install.tmpl +--- a/80-anolis/runtime-install.tmpl 2025-06-19 15:03:12.846567074 +0800 ++++ b/80-anolis/runtime-install.tmpl 2025-06-19 15:03:30.857906577 +0800 +@@ -80,6 +80,12 @@ + installpkg efibootmgr + installpkg avahi-libs avahi-glib + %endif ++%if basearch == "riscv64": ++ installpkg efibootmgr ++ installpkg grub2-efi-riscv64-cdboot ++ installpkg grub2-tools ++ installpkg uboot-tools ++%endif + + + ## yay, plymouth +@@ -141,7 +147,7 @@ + installpkg pciutils usbutils ipmitool + installpkg mt-st smartmontools + installpkg hdparm +-%if basearch not in ("aarch64", "ppc64le", "s390x"): ++%if basearch not in ("aarch64", "ppc64le", "s390x", "riscv64"): + installpkg pcmciautils + %endif + ## see bug #1483278 +@@ -149,7 +155,7 @@ + installpkg libmlx4 rdma-core + %endif + installpkg rng-tools +-%if basearch in ("i386", "x86_64", "aarch64"): ++%if basearch in ("i386", "x86_64", "aarch64", "riscv64"): + installpkg dmidecode + %endif + diff --git a/lorax-templates-anolis.spec b/lorax-templates-anolis.spec index 2607080..1591f01 100644 --- a/lorax-templates-anolis.spec +++ b/lorax-templates-anolis.spec @@ -1,4 +1,4 @@ -%define anolis_release 23 +%define anolis_release 24 Name: lorax-templates-anolis Version: 37.0 @@ -32,6 +32,7 @@ Patch1017: 1017-add-ls2k500sfb.ko-for-loongarch64.patch Patch1018: 1018-Set-data-source-for-EFI-System-Partition-on-loongarch64.patch Patch1019: 1019-add-inst.xtimeout-1200.patch Patch1020: 1020-enable-systemd-resolved-by-default.patch +Patch1021: 1021-add-riscv64-support-for-lorax-templates-anolis.patch # Where are these supposed to end up? %define templatedir %{_datadir}/lorax/templates.d/80-anolis @@ -56,6 +57,9 @@ cp -a 80-anolis/* $RPM_BUILD_ROOT/%{templatedir} %{templatedir}/* %changelog +* Fri Jun 13 2025 Yihao Yan - 37.0-1.24 +- add riscv64 support for lorax-templates-anolis + * Wed Oct 30 2024 Chang Gao - 37.0-1.23 - Enable systemd-resolved by default. Resolve: #5859 -- Gitee