Skip to content

Commit

Permalink
Enable ARM64 raw image generation (#158)
Browse files Browse the repository at this point in the history
Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka authored Jan 7, 2025
1 parent 0065c4c commit 5c687d2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/ops/rawDiskGeneration.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,25 @@ func roundToNearestSector(size, sector int64) uint64 {
func (r *RawImage) copyShimOrGrub(target, which string) error {
var searchFiles []string
var copyDone bool
var arch string

// Try to get the arch from the source rootfs
arch = runtime.GOARCH
parsedArch, err := sdkUtils.OSRelease("KAIROS_TARGETARCH", filepath.Join(r.Source, "etc/kairos-release"))
if err == nil && parsedArch != "" {
arch = parsedArch
} else {
internal.Log.Logger.Warn().Err(err).Str("arch", runtime.GOARCH).Msg("failed to geta arch from source rootfs, defaulting to use artifacts from runtime arch")
}

if which == "shim" {
searchFiles = sdkUtils.GetEfiShimFiles(runtime.GOARCH)
searchFiles = sdkUtils.GetEfiShimFiles(arch)
} else if which == "grub" {
searchFiles = sdkUtils.GetEfiGrubFiles(runtime.GOARCH)
searchFiles = sdkUtils.GetEfiGrubFiles(arch)
} else {
return fmt.Errorf("invalid which value: %s", which)
}

for _, f := range searchFiles {
_, err := r.config.Fs.Stat(filepath.Join(r.Source, f))
if err != nil {
Expand Down Expand Up @@ -778,7 +790,7 @@ func (r *RawImage) copyShimOrGrub(target, which string) error {
// Copy the shim content to the fallback name so the system boots from fallback. This means that we do not create
// any bootloader entries, so our recent installation has the lower priority if something else is on the bootloader
if which == "shim" {
writeShim := agentConstants.GetFallBackEfi(runtime.GOARCH)
writeShim := agentConstants.GetFallBackEfi(arch)
err = r.config.Fs.WriteFile(filepath.Join(target, "EFI/BOOT/", writeShim), fileContent, agentConstants.FilePerm)
if err != nil {
return fmt.Errorf("could not write file %s at dir %s", writeShim, target)
Expand Down

0 comments on commit 5c687d2

Please sign in to comment.