-
Notifications
You must be signed in to change notification settings - Fork 47
/
iso_rootfs.go
71 lines (60 loc) · 1.78 KB
/
iso_rootfs.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package manifest
import (
"fmt"
"github.com/osbuild/images/pkg/osbuild"
)
type ISORootfsImg struct {
Base
Size uint64
installerPipeline Pipeline
}
func NewISORootfsImg(buildPipeline *Build, installerPipeline Pipeline) *ISORootfsImg {
p := &ISORootfsImg{
Base: NewBase(installerPipeline.Manifest(), "rootfs-image", buildPipeline),
installerPipeline: installerPipeline,
}
buildPipeline.addDependent(p)
installerPipeline.Manifest().addPipeline(p)
return p
}
func (p *ISORootfsImg) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
pipeline.AddStage(osbuild.NewMkdirStage(&osbuild.MkdirStageOptions{
Paths: []osbuild.MkdirStagePath{
{
Path: "/LiveOS",
},
},
}))
pipeline.AddStage(osbuild.NewTruncateStage(&osbuild.TruncateStageOptions{
Filename: "/LiveOS/rootfs.img",
Size: fmt.Sprintf("%d", p.Size),
}))
mkfsStageOptions := &osbuild.MkfsExt4StageOptions{
UUID: "2fe99653-f7ff-44fd-bea8-fa70107524fb",
Label: "Anaconda",
}
lodevice := osbuild.NewLoopbackDevice(
&osbuild.LoopbackDeviceOptions{
Filename: "LiveOS/rootfs.img",
},
)
devName := "device"
devices := osbuild.Devices{devName: *lodevice}
mkfsStage := osbuild.NewMkfsExt4Stage(mkfsStageOptions, devices)
pipeline.AddStage(mkfsStage)
inputName := "tree"
copyStageOptions := &osbuild.CopyStageOptions{
Paths: []osbuild.CopyStagePath{
{
From: fmt.Sprintf("input://%s/", inputName),
To: fmt.Sprintf("mount://%s/", devName),
},
},
}
copyStageInputs := osbuild.NewPipelineTreeInputs(inputName, p.installerPipeline.Name())
copyStageMounts := &osbuild.Mounts{*osbuild.NewExt4Mount(devName, devName, "/")}
copyStage := osbuild.NewCopyStage(copyStageOptions, copyStageInputs, &devices, copyStageMounts)
pipeline.AddStage(copyStage)
return pipeline
}