manifest: new pipeline for building ISO rootfs.img
This commit is contained in:
parent
c0fcbfc5c2
commit
d27bdac369
1 changed files with 71 additions and 0 deletions
71
internal/manifest/iso_rootfs.go
Normal file
71
internal/manifest/iso_rootfs.go
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
package manifest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
)
|
||||
|
||||
type ISORootfsImg struct {
|
||||
Base
|
||||
|
||||
Size uint64
|
||||
|
||||
anacondaPipeline *Anaconda
|
||||
}
|
||||
|
||||
func NewISORootfsImg(m *Manifest, buildPipeline *Build, anacondaPipeline *Anaconda) *ISORootfsImg {
|
||||
p := &ISORootfsImg{
|
||||
Base: NewBase(m, "rootfs-image", buildPipeline),
|
||||
anacondaPipeline: anacondaPipeline,
|
||||
}
|
||||
buildPipeline.addDependent(p)
|
||||
m.addPipeline(p)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ISORootfsImg) serialize() osbuild.Pipeline {
|
||||
pipeline := p.Base.serialize()
|
||||
|
||||
pipeline.AddStage(osbuild.NewMkdirStage(&osbuild.MkdirStageOptions{
|
||||
Paths: []osbuild.Path{
|
||||
{
|
||||
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.anacondaPipeline.Name())
|
||||
copyStageMounts := &osbuild.Mounts{*osbuild.NewExt4Mount(devName, devName, "/")}
|
||||
copyStage := osbuild.NewCopyStage(copyStageOptions, copyStageInputs, &devices, copyStageMounts)
|
||||
pipeline.AddStage(copyStage)
|
||||
return pipeline
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue