The plain `Path` name was a bit unfortunate, since it was specific to the `mkdir` stage, but it was used outside of the `osbuild` package as `osbuild.Path` which was making a wrong impression of it being a generic path structure. This is not true. Rename the structure to contain the stage name. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
package manifest
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
|
)
|
|
|
|
type ISORootfsImg struct {
|
|
Base
|
|
|
|
Size uint64
|
|
|
|
installerPipeline Pipeline
|
|
}
|
|
|
|
func NewISORootfsImg(m *Manifest, buildPipeline *Build, installerPipeline Pipeline) *ISORootfsImg {
|
|
p := &ISORootfsImg{
|
|
Base: NewBase(m, "rootfs-image", buildPipeline),
|
|
installerPipeline: installerPipeline,
|
|
}
|
|
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.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
|
|
}
|