Skip to content

Commit

Permalink
Try to get the flavor on EFI installs
Browse files Browse the repository at this point in the history
If somehow our KAIROS_X keys are gone from the system due to something
removing them like an upgrade, we wont be able to identify the flavors
and we need it if its an ubuntu machine as we do a workaround for EFI
installs, otherwise you get a broken grub.

This tries to infer the flavor form the os-release ID field which will
exist and check if its ubuntu.

Signed-off-by: Itxaka <itxaka@kairos.io>
  • Loading branch information
Itxaka committed Oct 1, 2024
1 parent 0f85a2c commit 6ecb16b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/utils/grub.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ func (g Grub) Install(target, rootDir, bootDir, grubConf, tty string, efi bool,
if err != nil {
g.config.Logger.Warnf("Failed reading os-release from %s: %v", filepath.Join(cnst.ActiveDir, "etc/os-release"), err)
}
if flavor == "" {
// If os-release is gone with our vars, we dont know what flavor are we in, we should know if we are on ubuntu as we need
// a workaround for the grub efi install
// So lets try to get the info from the normal keys shipped with the os
flavorFromId, err := utils.OSRelease("ID", filepath.Join(cnst.ActiveDir, "etc/os-release"))
if err != nil {
g.config.Logger.Logger.Err(err).Msg("Getting flavor")
}
if strings.Contains(strings.ToLower(flavorFromId), "ubuntu") {
flavor = "ubuntu"
}
}
g.config.Logger.Debugf("Detected Flavor: %s", flavor)
// Copy needed files for efi boot
// This seems like a chore while we could provide a package for those bundled files as they are just a shim and a grub efi
Expand Down

0 comments on commit 6ecb16b

Please sign in to comment.