manifest: add xz pipeline for compressing ostree images
The XZ pipeline is added explicitly for ostree raw images for now. It should be changed to support compressing general raw images as well. Co-Authored-By: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
2683474519
commit
f39b3bf6d3
1 changed files with 53 additions and 0 deletions
53
internal/manifest/xz.go
Normal file
53
internal/manifest/xz.go
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package manifest
|
||||
|
||||
import (
|
||||
"github.com/osbuild/osbuild-composer/internal/artifact"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
)
|
||||
|
||||
// The XZ pipeline compresses a raw image file using xz.
|
||||
type XZ struct {
|
||||
Base
|
||||
Filename string
|
||||
|
||||
imgPipeline *RawOSTreeImage
|
||||
}
|
||||
|
||||
// NewXZ creates a new XZ pipeline. imgPipeline is the pipeline producing the
|
||||
// raw image. Filename is the name of the produced archive.
|
||||
func NewXZ(m *Manifest,
|
||||
buildPipeline *Build,
|
||||
imgPipeline *RawOSTreeImage) *XZ {
|
||||
p := &XZ{
|
||||
Base: NewBase(m, "xz", buildPipeline),
|
||||
imgPipeline: imgPipeline,
|
||||
Filename: "image.xz",
|
||||
}
|
||||
if imgPipeline.Base.manifest != m {
|
||||
panic("live image pipeline from different manifest")
|
||||
}
|
||||
buildPipeline.addDependent(p)
|
||||
m.addPipeline(p)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *XZ) serialize() osbuild.Pipeline {
|
||||
pipeline := p.Base.serialize()
|
||||
|
||||
pipeline.AddStage(osbuild.NewXzStage(
|
||||
osbuild.NewXzStageOptions(p.Filename),
|
||||
osbuild.NewFilesInputs(osbuild.NewFilesInputReferencesPipeline(p.imgPipeline.Name(), p.imgPipeline.Filename)),
|
||||
))
|
||||
|
||||
return pipeline
|
||||
}
|
||||
|
||||
func (p *XZ) getBuildPackages() []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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue