Skip to content

Commit

Permalink
feat: repart: expand with more options
Browse files Browse the repository at this point in the history
  • Loading branch information
axtloss committed Aug 31, 2024
1 parent 3074a46 commit f472adb
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions finalize-plugins/systemd-repart.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ import (
"github.com/vanilla-os/vib/api"
"os"
"os/exec"
"strings"
)

type SystemdRepart struct {
Name string `json:"name"`
Type string `json:"type"`
Output string `json:"output"`
Size string `json:"size"`
Seed string `json:"seed"`
Name string `json:"name"`
Type string `json:"type"`
Output string `json:"output"`
Json string `json:"json"`
SpecOutput string `json:"spec_output"`
Size string `json:"size"`
Seed string `json:"seed"`
Split bool `json:"split"`
DeferPartitions []string `json:"defer_partitions"`
}

//export PlugInfo
Expand Down Expand Up @@ -51,20 +56,40 @@ func FinalizeBuild(moduleInterface *C.char, extraData *C.char) *C.char {
if err != nil {
return C.CString(fmt.Sprintf("ERROR: %s", err.Error()))
}
cmd := exec.Command(
repart,

if len(strings.TrimSpace(module.Json)) == 0 {
module.Json = "off"
}

args := []string{
"--definitions=definitions",
"--empty=create",
fmt.Sprintf("--size=%s", module.Size),
"--dry-run=no",
"--discard=no",
"--offline=true",
"--no-pager",
fmt.Sprintf("--split=%t", module.Split),
fmt.Sprintf("--seed=%s", module.Seed),
fmt.Sprintf("--root=%s", data.FS),
module.Output,
fmt.Sprintf("--json=%s", module.Json),
}

if len(module.DeferPartitions) > 0 {
args = append(args, fmt.Sprintf("--defer-partitions=%s", strings.Join(module.DeferPartitions, ",")))
}

cmd := exec.Command(
repart,
args...,
)
cmd.Stdout = os.Stdout
jsonFile, err := os.Create(module.SpecOutput)
if err != nil {
return C.CString(fmt.Sprintf("ERROR: %s", err.Error()))
}
defer jsonFile.Close()
cmd.Stdout = jsonFile
cmd.Stderr = os.Stderr
cmd.Dir = data.Recipe.ParentPath

Expand Down

0 comments on commit f472adb

Please sign in to comment.