-
Notifications
You must be signed in to change notification settings - Fork 50
/
xz.go
55 lines (44 loc) · 1.22 KB
/
xz.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 manifest
import (
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/osbuild"
)
// The XZ pipeline compresses a raw image file using xz.
type XZ struct {
Base
filename string
imgPipeline FilePipeline
}
func (p XZ) Filename() string {
return p.filename
}
func (p *XZ) SetFilename(filename string) {
p.filename = filename
}
// NewXZ creates a new XZ pipeline. imgPipeline is the pipeline producing the
// raw image that will be xz compressed.
func NewXZ(buildPipeline Build, imgPipeline FilePipeline) *XZ {
p := &XZ{
Base: NewBase("xz", buildPipeline),
filename: "image.xz",
imgPipeline: imgPipeline,
}
buildPipeline.addDependent(p)
return p
}
func (p *XZ) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
pipeline.AddStage(osbuild.NewXzStage(
osbuild.NewXzStageOptions(p.Filename()),
osbuild.NewXzStageInputs(osbuild.NewFilesInputPipelineObjectRef(p.imgPipeline.Name(), p.imgPipeline.Export().Filename(), nil)),
))
return pipeline
}
func (p *XZ) getBuildPackages(Distro) []string {
return []string{"xz"}
}
func (p *XZ) Export() *artifact.Artifact {
p.Base.export = true
mimeType := "application/xz"
return artifact.New(p.Name(), p.Filename(), &mimeType)
}