From f8b9fd8489a5a2e9104b43af274bed00c4d86e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Fri, 21 Aug 2026 00:55:25 -0300 Subject: [PATCH] feat(copycds): publish the grub2 boot loader of the installation media riscv64 nodes boot through UEFI and grub2 only, and xCAT builds no boot loader: /tftpboot/boot/grub2/grub2.riscv64 has to come from the xcat-dep grub2-xcat package or be copied by hand, which is a step an admin only finds out about when a node times out in firmware. The EL riscv64 media carry exactly that image as EFI/BOOT/grubriscv64.efi, so copycd publishes it after a successful media copy, and says so. An image the management node already has is never replaced, and the media of every other architecture is untouched. --- xCAT-server/lib/xcat/plugins/anaconda.pm | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 77d4a2ae7..0af5d40ab 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2091,6 +2091,36 @@ erver, if so, stop it first and try again" ], } } +# EL media that carry the grub2 UEFI image of an architecture xCAT cannot build a +# boot loader for. copycd publishes it so those nodes can net boot without any +# further step; grub2-xcat installs the same image where it is available. +my %MEDIA_GRUB2_LOADERS = (riscv64 => 'grubriscv64.efi'); + +# Publish the grub2 UEFI image of the media under $tftpdir/boot/grub2, unless the +# management node already has one. Returns the path written, or undef. +sub _install_media_grub2_loader { + my ($path, $arch, $callback) = @_; + + my $image = $MEDIA_GRUB2_LOADERS{$arch}; + return unless $image; + my $source = "$path/EFI/BOOT/$image"; + return unless -r $source; + + my $tftpdir = xCAT::TableUtils->getTftpDir(); + return unless $tftpdir; + my $target = "$tftpdir/boot/grub2/grub2.$arch"; + return if -e $target; + + mkpath("$tftpdir/boot/grub2"); + unless (copy($source, $target)) { + $callback->({ data => "Could not install $target from the media: $!" }) if $callback; + return; + } + chmod 0644, $target; + $callback->({ data => "Installed $target from the media" }) if $callback; + return $target; +} + sub copycd { my $request = shift; @@ -2488,6 +2518,7 @@ sub copycd else { $callback->({ data => "Media copy operation successful" }); + _install_media_grub2_loader($path, $arch, $callback); my @ret = xCAT::SvrUtils->update_osdistro_table($distname, $arch, $path, $osdistroname); if ($ret[0] != 0) { $callback->({ data => "Error when updating the osdistro tables: " . $ret[1] });