Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Do the grub fix only on ubuntu based systems
Browse files Browse the repository at this point in the history
Also do the efi part first before the squashfs so we fail faster

Signed-off-by: Itxaka <itxaka@kairos.io>
  • Loading branch information
Itxaka committed Jan 12, 2024
1 parent 9d5189b commit 66788af
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions pkg/action/build-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,18 @@ func (b BuildISOAction) prepareISORoot(isoDir string, rootDir string, uefiDir st
return err
}

b.cfg.Logger.Info("Creating squashfs...")
err = utils.CreateSquashFS(b.cfg.Runner, b.cfg.Logger, rootDir, filepath.Join(isoDir, constants.IsoRootFile), constants.GetDefaultSquashfsOptions())
b.cfg.Logger.Info("Creating EFI image...")
err = b.createEFI(rootDir, isoDir)
if err != nil {
return err
}

b.cfg.Logger.Info("Creating EFI image...")
err = b.createEFI(rootDir, isoDir)
b.cfg.Logger.Info("Creating squashfs...")
err = utils.CreateSquashFS(b.cfg.Runner, b.cfg.Logger, rootDir, filepath.Join(isoDir, constants.IsoRootFile), constants.GetDefaultSquashfsOptions())
if err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -185,16 +186,24 @@ func (b BuildISOAction) createEFI(rootdir string, isoDir string) error {
}
// Ubuntu efi searches for the grub.cfg file under /EFI/ubuntu/grub.cfg while we store it under /boot/grub2/grub.cfg
// workaround this by copying it there as well
// TODO: Should we symlink all the distros folders to our single grub.cfg?
err = utils.MkdirAll(b.cfg.Fs, filepath.Join(isoDir, "EFI/ubuntu/"), constants.DirPerm)
// read the os-release from the rootfs to know if we are creating a ubuntu based iso
FLAVOR, err := sdk.OSRelease("FLAVOR", filepath.Join(rootdir, "etc/os-release"))
if err != nil {
b.cfg.Logger.Errorf("Failed writing grub.cfg: %v", err)
return err
}
err = b.cfg.Fs.WriteFile(filepath.Join(isoDir, "EFI/ubuntu/", constants.GrubCfg), []byte(constants.GrubEfiCfg), constants.FilePerm)
if err != nil {
b.cfg.Logger.Errorf("Failed writing grub.cfg: %v", err)
return err
b.cfg.Logger.Infof("Detected Flavor: %s", FLAVOR)
if err == nil && strings.Contains(strings.ToLower(FLAVOR), "ubuntu") {
b.cfg.Logger.Infof("Ubuntu based ISO detected, copying grub.cfg to /EFI/ubuntu/grub.cfg")
err = utils.MkdirAll(b.cfg.Fs, filepath.Join(isoDir, "EFI/ubuntu/"), constants.DirPerm)
if err != nil {
b.cfg.Logger.Errorf("Failed writing grub.cfg: %v", err)
return err
}
err = b.cfg.Fs.WriteFile(filepath.Join(isoDir, "EFI/ubuntu/", constants.GrubCfg), []byte(constants.GrubEfiCfg), constants.FilePerm)
if err != nil {
b.cfg.Logger.Errorf("Failed writing grub.cfg: %v", err)
return err
}
}

// Calculate EFI image size based on artifacts
Expand Down

0 comments on commit 66788af

Please sign in to comment.