Skip to content

Commit 6c59a72

Browse files
committed
Add: Prepare for UEFI
1 parent 20ec5e9 commit 6c59a72

5 files changed

Lines changed: 132 additions & 3 deletions

File tree

alteriso5/work/boot/bootmode.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package boot
2+
3+
import "errors"
4+
5+
type Mode int
6+
7+
var (
8+
BiosSyslinuxMbr Mode = 0
9+
BiosSyslinuxElTorito Mode = 1
10+
UefiIa32SystemdBootEsp Mode = 2
11+
UefiX64SystemdBootEsp Mode = 3
12+
UefiIa32SystemdBootElTorito Mode = 4
13+
UefiX64SystemdBootElTorito Mode = 5
14+
UefiX64GrubEsp Mode = 6
15+
UefiIa32GrubEsp Mode = 7
16+
UefiX64GrubElTorito Mode = 8
17+
UefiIa32GrubElTorito Mode = 9
18+
)
19+
20+
var ErrInvalidMode = errors.New("invalid boot mode")
21+
22+
func getModeFromStr(mode string) (Mode, error) {
23+
switch mode {
24+
case "bios.syslinux.mbr":
25+
return BiosSyslinuxMbr, nil
26+
case "bios.syslinux.eltorito":
27+
return BiosSyslinuxElTorito, nil
28+
case "uefi-ia32.systemd-boot.esp":
29+
return UefiIa32SystemdBootEsp, nil
30+
case "uefi-x64.systemd-boot.esp":
31+
return UefiX64SystemdBootEsp, nil
32+
case "uefi-ia32.systemd-boot.eltorito":
33+
return UefiIa32SystemdBootElTorito, nil
34+
case "uefi-x64.systemd-boot.eltorito":
35+
return UefiX64SystemdBootElTorito, nil
36+
case "uefi-x64.grub.esp":
37+
return UefiX64GrubEsp, nil
38+
case "uefi-ia32.grub.esp":
39+
return UefiIa32GrubEsp, nil
40+
case "uefi-x64.grub.eltorito":
41+
return UefiX64GrubElTorito, nil
42+
case "uefi-ia32.grub.eltorito":
43+
return UefiIa32GrubElTorito, nil
44+
45+
}
46+
return 0, ErrInvalidMode
47+
}
48+
49+
func GetModes(modes ...string) ([]Mode, error) {
50+
r := []Mode{}
51+
for _, mode := range modes {
52+
m, err := getModeFromStr(mode)
53+
if err != nil {
54+
return nil, err
55+
}
56+
r = append(r, m)
57+
}
58+
return r, nil
59+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// SysLinux
13-
var makeSysLinux = NewBuildTask("makeSysLinux", func(w Work) error {
13+
var makeBiosSysLinuxMbr = NewBuildTask("makeBiosSysLinuxMbr", func(w Work) error {
1414
slog.Debug("Setting up SYSLINUX for BIOS booting from a disk...")
1515

1616
// Get directories
@@ -91,3 +91,7 @@ var makeSysLinux = NewBuildTask("makeSysLinux", func(w Work) error {
9191

9292
return nil
9393
})
94+
95+
var makeBiosSysLinuxElTorito = NewBuildTask("makeBiosSysLinuxElTorito", func(w Work) error {
96+
return nil
97+
})
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package work
2+
3+
import "log/slog"
4+
5+
// Prepare configuration files for systemd-boot
6+
var makeCommonSystemdBootConfig *BuildTask = NewBuildTask("makeCommonSystemdBootConfig", func(w Work) error {
7+
return nil
8+
})
9+
10+
var makeCommonSystemdBoot *BuildTask = NewBuildTask("makeCommonSystemdBoot", func(w Work) error {
11+
return nil
12+
})
13+
14+
var makeUefiX64SystemdBootEsp *BuildTask = NewBuildTask("makeUefiX64SystemdBootEsp", func(w Work) error {
15+
slog.Info("Setting up systemd-boot for x64 UEFI booting...")
16+
17+
// Prepare configuration files
18+
if err := w.RunOnce(makeCommonSystemdBootConfig); err != nil {
19+
return err
20+
}
21+
22+
// Prepare a FAT image for the EFI system partition
23+
if err := w.RunOnce(makeCommonSystemdBoot); err != nil {
24+
return err
25+
}
26+
27+
// Copy systemd-boot EFI binary to the default/fallback boot path
28+
29+
// Copy systemd-boot configuration files
30+
31+
// shellx64.efi is picked up automatically when on /
32+
33+
return nil
34+
})
35+
36+
var makeUefiX64SystemdBootElTorito *BuildTask = NewBuildTask("makeUefiX64SystemdBootElTorito", func(w Work) error {
37+
return nil
38+
})

alteriso5/work/task-bootmodes.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
package work
22

3+
import "github.com/FascodeNet/alterlinux/alteriso5/work/boot"
4+
35
// Run each bootmodes
46
var makeBootModes *BuildTask = NewBuildTask("makeBootModes", func(w Work) error {
5-
return w.RunOnce(makeSysLinux)
7+
modes, err := boot.GetModes(w.profile.BootModes...)
8+
if err != nil {
9+
return err
10+
}
11+
12+
for _, mode := range modes {
13+
switch mode {
14+
case boot.BiosSyslinuxMbr:
15+
if err := w.RunOnce(makeBiosSysLinuxMbr); err != nil {
16+
return err
17+
}
18+
case boot.BiosSyslinuxElTorito:
19+
if err := w.RunOnce(makeBiosSysLinuxElTorito); err != nil {
20+
return err
21+
}
22+
case boot.UefiX64SystemdBootEsp:
23+
if err := w.RunOnce(makeUefiX64SystemdBootEsp); err != nil {
24+
return err
25+
}
26+
case boot.UefiX64SystemdBootElTorito:
27+
if err := w.RunOnce(makeUefiX64SystemdBootElTorito); err != nil {
28+
return err
29+
}
30+
}
31+
}
32+
33+
return nil
634
})

profile/profiledef.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"install_dir": "alter",
3-
"bootmodes": ["SysLinux"],
3+
"bootmodes": ["bios.syslinux.mbr"],
44
"use_alter_syslinux": true
55
}

0 commit comments

Comments
 (0)