Skip to content

Fix the UKI stub path on ARM64. #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions toolkit/tools/pkg/imagecustomizerlib/customizeuki.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func prepareUki(ctx context.Context, buildDir string, uki *imagecustomizerapi.Uk
}

// Copy UKI-specific files such as kernel, initramfs, and UKI stub file.
err = copyUkiFiles(buildDir, kernelToInitramfs, imageChroot)
err = copyUkiFiles(buildDir, kernelToInitramfs, imageChroot, bootConfig)
if err != nil {
return fmt.Errorf("failed to copy UKI files:\n%w", err)
}
Expand Down Expand Up @@ -183,10 +183,12 @@ func createUkiDirectories(buildDir string, imageChroot *safechroot.Chroot) error
return nil
}

func copyUkiFiles(buildDir string, kernelToInitramfs map[string]string, imageChroot *safechroot.Chroot) error {
func copyUkiFiles(buildDir string, kernelToInitramfs map[string]string, imageChroot *safechroot.Chroot,
bootConfig BootFilesArchConfig,
) error {
filesToCopy := map[string]string{
filepath.Join(imageChroot.RootDir(), "/usr/lib/systemd/boot/efi/linuxx64.efi.stub"): filepath.Join(buildDir, UkiBuildDir, "linuxx64.efi.stub"),
filepath.Join(imageChroot.RootDir(), "/etc/os-release"): filepath.Join(buildDir, UkiBuildDir, "os-release"),
filepath.Join(imageChroot.RootDir(), bootConfig.ukiEfiStubBinaryPath): filepath.Join(buildDir, UkiBuildDir, bootConfig.ukiEfiStubBinary),
filepath.Join(imageChroot.RootDir(), "/etc/os-release"): filepath.Join(buildDir, UkiBuildDir, "os-release"),
}

for kernel, initramfs := range kernelToInitramfs {
Expand Down Expand Up @@ -305,6 +307,11 @@ func createUki(ctx context.Context, uki *imagecustomizerapi.Uki, buildDir string

var err error

_, bootConfig, err := getBootArchConfig()
if err != nil {
return err
}

loopback, err := safeloopback.NewLoopback(buildImageFile)
if err != nil {
return fmt.Errorf("failed to connect to image file to provision UKI:\n%w", err)
Expand Down Expand Up @@ -340,7 +347,6 @@ func createUki(ctx context.Context, uki *imagecustomizerapi.Uki, buildDir string
defer bootPartitionMount.Close()

osSubreleaseFullPath := filepath.Join(buildDir, UkiBuildDir, "os-release")
stubPath := filepath.Join(buildDir, UkiBuildDir, "linuxx64.efi.stub")
cmdlineFilePath := filepath.Join(buildDir, UkiBuildDir, KernelCmdlineArgsJson)

// Get mapped kernels and initramfs.
Expand All @@ -350,7 +356,7 @@ func createUki(ctx context.Context, uki *imagecustomizerapi.Uki, buildDir string
}

for kernel, initramfs := range kernelToInitramfs {
err := buildUki(kernel, initramfs, cmdlineFilePath, osSubreleaseFullPath, stubPath, buildDir,
err := buildUki(kernel, initramfs, cmdlineFilePath, osSubreleaseFullPath, bootConfig.ukiEfiStubBinaryPath, buildDir,
systemBootPartitionTmpDir,
)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions toolkit/tools/pkg/imagecustomizerlib/liveosisoutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
const (
osEspBootloaderDir = "/boot/efi/EFI/BOOT"
isoBootloaderDir = "/efi/boot"
ukiEfiStubDir = "/usr/lib/systemd/boot/efi/"

bootx64Binary = "bootx64.efi"
bootAA64Binary = "bootaa64.efi"
Expand All @@ -29,6 +30,9 @@ const (
systemdBootx64Binary = "systemd-bootx64.efi"
systemdBootAA64Binary = "systemd-bootaa64.efi"

ukiEfiStubx64Binary = "linuxx64.efi.stub"
ukiEfiStubAA64Binary = "linuxaa64.efi.stub"

grubCfgDir = "/boot/grub2"
isoGrubCfg = "grub.cfg"
isoGrubCfgPath = grubCfgDir + "/" + isoGrubCfg
Expand Down Expand Up @@ -78,6 +82,8 @@ type BootFilesArchConfig struct {
osEspGrubNoPrefixBinaryPath string
isoBootBinaryPath string
isoGrubBinaryPath string
ukiEfiStubBinary string
ukiEfiStubBinaryPath string
}

var (
Expand All @@ -92,6 +98,8 @@ var (
osEspGrubNoPrefixBinaryPath: osEspBootloaderDir + "/" + grubx64NoPrefixBinary,
isoBootBinaryPath: isoBootloaderDir + "/" + bootx64Binary,
isoGrubBinaryPath: isoBootloaderDir + "/" + grubx64Binary,
ukiEfiStubBinary: ukiEfiStubx64Binary,
ukiEfiStubBinaryPath: ukiEfiStubDir + "/" + ukiEfiStubx64Binary,
},
"arm64": {
bootBinary: bootAA64Binary,
Expand All @@ -103,6 +111,8 @@ var (
osEspGrubNoPrefixBinaryPath: osEspBootloaderDir + "/" + grubAA64NoPrefixBinary,
isoBootBinaryPath: isoBootloaderDir + "/" + bootAA64Binary,
isoGrubBinaryPath: isoBootloaderDir + "/" + grubAA64Binary,
ukiEfiStubBinary: ukiEfiStubAA64Binary,
ukiEfiStubBinaryPath: ukiEfiStubDir + "/" + ukiEfiStubAA64Binary,
},
}
)
Expand Down
Loading