-
Notifications
You must be signed in to change notification settings - Fork 28
/
xorriso.go
55 lines (42 loc) · 941 Bytes
/
xorriso.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package boot
import (
"log/slog"
"os"
"os/exec"
)
var Xorriso = xorriso{}
type xorriso struct {
fsDir string
out string
args []*xorrisoArg
}
type xorrisoArg struct {
bootMode *Mode
args func(o *xorriso) []string
}
func (x *xorriso) addArgs(arg ...*xorrisoArg) {
x.args = append(x.args, arg...)
}
func (x *xorriso) Args(bootmode ...*Mode) *[]string {
var args []string
args = append(args, xorrisoCommonArgs.args(x)...)
for _, arg := range x.args {
for _, mode := range bootmode {
if arg.bootMode.String() == mode.String() {
args = append(args, arg.args(x)...)
}
}
}
return &args
}
func (x *xorriso) Build(dir string, out string, bootmode ...*Mode) error {
x.fsDir = dir
x.out = out
args := x.Args(bootmode...)
cmd := exec.Command("xorriso", *args...)
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
slog.Debug("Running xorriso", "args", cmd.Args)
return cmd.Run()
}