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

Move to use kairos-release #198

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 10 additions & 4 deletions pkg/action/build-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,19 @@ 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
// 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"))
// read the kairos-release from the rootfs to know if we are creating a ubuntu based iso
var flavor string
flavor, err = sdk.OSRelease("FLAVOR", filepath.Join(rootdir, "etc/kairos-release"))
if err != nil {
b.cfg.Logger.Warnf("Failed reading os-release from %s: %v", filepath.Join(rootdir, "etc/os-release"), err)
// fallback to os-release
flavor, err = sdk.OSRelease("FLAVOR", filepath.Join(rootdir, "etc/os-release"))
if err != nil {
b.cfg.Logger.Warnf("Failed reading os-release from %s and %s: %v", filepath.Join(rootdir, "etc/kairos-release"), filepath.Join(rootdir, "etc/os-release"), err)
return err
}
}
b.cfg.Logger.Infof("Detected Flavor: %s", flavor)
if err == nil && strings.Contains(strings.ToLower(flavor), "ubuntu") {
if 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 {
Expand Down
9 changes: 7 additions & 2 deletions pkg/action/build-uki.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,14 @@
}

func findKairosVersion(sourceDir string) (string, error) {
osReleaseBytes, err := os.ReadFile(filepath.Join(sourceDir, "etc", "os-release"))
var osReleaseBytes []byte
osReleaseBytes, err := os.ReadFile(filepath.Join(sourceDir, "etc", "kairos-release"))
Dismissed Show dismissed Hide dismissed
if err != nil {
return "", fmt.Errorf("reading os-release file: %w", err)
// fallback to os-release
osReleaseBytes, err = os.ReadFile(filepath.Join(sourceDir, "etc", "os-release"))
Dismissed Show dismissed Hide dismissed
if err != nil {
return "", fmt.Errorf("reading kairos-release file: %w", err)
}
}

re := regexp.MustCompile("(?m)^KAIROS_RELEASE=\"(.*)\"")
Expand Down