Skip to content

Commit 41fff77

Browse files
committed
Update: Bootmode pointer
1 parent 00d265a commit 41fff77

3 files changed

Lines changed: 24 additions & 19 deletions

File tree

alteriso5/config/profile.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"os"
66
"path"
7+
"slices"
78

89
"github.com/FascodeNet/alterlinux/alteriso5/config/pkg"
910
"github.com/FascodeNet/alterlinux/alteriso5/work/boot"
@@ -13,7 +14,7 @@ type Profile struct {
1314
Base string
1415
InstallDir string `json:"install_dir"`
1516
BootModesStr []string `json:"bootmodes"`
16-
BootModes []boot.Mode
17+
BootModes []*boot.Mode
1718
ISOName string `json:"iso_name"`
1819
ISOLabel string `json:"iso_label"`
1920
UseAlterSysLinux bool `json:"use_alter_syslinux"`
@@ -46,3 +47,7 @@ func ReadProfile(dir string) (*Profile, error) {
4647
func (p *Profile) GetPkgList(arch string) ([]string, error) {
4748
return pkg.GetPkgList(p.Base, arch)
4849
}
50+
51+
func (p *Profile) HasBootMode(b *boot.Mode) bool {
52+
return slices.Contains(p.BootModesStr, b.String())
53+
}

alteriso5/work/boot/bootmode.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ type Mode struct {
88
}
99

1010
var (
11-
BiosSyslinuxMbr Mode = Mode{"bios.syslinux.mbr", nil}
12-
BiosSyslinuxElTorito Mode = Mode{"bios.syslinux.eltorito", nil}
13-
UefiIa32SystemdBootEsp Mode = Mode{"uefi-ia32.systemd-boot.esp", nil}
14-
UefiX64SystemdBootEsp Mode = Mode{"uefi-x64.systemd-boot.esp", nil}
15-
UefiIa32SystemdBootElTorito Mode = Mode{"uefi-ia32.systemd-boot.eltorito", nil}
16-
UefiX64SystemdBootElTorito Mode = Mode{"uefi-x64.systemd-boot.eltorito", nil}
17-
UefiX64GrubEsp Mode = Mode{"uefi-x64.grub.esp", nil}
18-
UefiIa32GrubEsp Mode = Mode{"uefi-ia32.grub.esp", nil}
19-
UefiX64GrubElTorito Mode = Mode{"uefi-x64.grub.eltorito", nil}
20-
UefiIa32GrubElTorito Mode = Mode{"uefi-ia32.grub.eltorito", nil}
11+
BiosSyslinuxMbr *Mode = &Mode{"bios.syslinux.mbr", nil}
12+
BiosSyslinuxElTorito *Mode = &Mode{"bios.syslinux.eltorito", nil}
13+
UefiIa32SystemdBootEsp *Mode = &Mode{"uefi-ia32.systemd-boot.esp", nil}
14+
UefiX64SystemdBootEsp *Mode = &Mode{"uefi-x64.systemd-boot.esp", nil}
15+
UefiIa32SystemdBootElTorito *Mode = &Mode{"uefi-ia32.systemd-boot.eltorito", nil}
16+
UefiX64SystemdBootElTorito *Mode = &Mode{"uefi-x64.systemd-boot.eltorito", nil}
17+
UefiX64GrubEsp *Mode = &Mode{"uefi-x64.grub.esp", nil}
18+
UefiIa32GrubEsp *Mode = &Mode{"uefi-ia32.grub.esp", nil}
19+
UefiX64GrubElTorito *Mode = &Mode{"uefi-x64.grub.eltorito", nil}
20+
UefiIa32GrubElTorito *Mode = &Mode{"uefi-ia32.grub.eltorito", nil}
2121

22-
Modes = []Mode{
22+
Modes = []*Mode{
2323
BiosSyslinuxMbr,
2424
BiosSyslinuxElTorito,
2525
UefiIa32SystemdBootEsp,
@@ -46,17 +46,17 @@ func (m *Mode) Validate() error {
4646

4747
var ErrInvalidMode = errors.New("invalid boot mode")
4848

49-
func getModeFromStr(mode string) (Mode, error) {
49+
func getModeFromStr(mode string) (*Mode, error) {
5050
for _, m := range Modes {
5151
if m.name == mode {
5252
return m, nil
5353
}
5454
}
55-
return Mode{}, ErrInvalidMode
55+
return nil, ErrInvalidMode
5656
}
5757

58-
func GetModes(modes ...string) ([]Mode, error) {
59-
r := []Mode{}
58+
func GetModes(modes ...string) ([]*Mode, error) {
59+
r := []*Mode{}
6060
for _, mode := range modes {
6161
m, err := getModeFromStr(mode)
6262
if err != nil {

alteriso5/work/boot/xorriso.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ type xorriso struct {
1515
}
1616

1717
type xorrisoArg struct {
18-
bootMode Mode
18+
bootMode *Mode
1919
args func(o *xorriso) []string
2020
}
2121

2222
func (x *xorriso) addArgs(arg ...*xorrisoArg) {
2323
x.args = append(x.args, arg...)
2424
}
2525

26-
func (x *xorriso) Args(bootmode ...Mode) *[]string {
26+
func (x *xorriso) Args(bootmode ...*Mode) *[]string {
2727
var args []string
2828

2929
args = append(args, xorrisoCommonArgs.args(x)...)
@@ -38,7 +38,7 @@ func (x *xorriso) Args(bootmode ...Mode) *[]string {
3838
return &args
3939
}
4040

41-
func (x *xorriso) Build(dir string, out string, bootmode ...Mode) error {
41+
func (x *xorriso) Build(dir string, out string, bootmode ...*Mode) error {
4242
x.fsDir = dir
4343
x.out = out
4444

0 commit comments

Comments
 (0)