-
Notifications
You must be signed in to change notification settings - Fork 47
/
tar.go
75 lines (63 loc) · 1.72 KB
/
tar.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
72
73
74
75
package manifest
import (
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/osbuild"
)
// A Tar represents the contents of another pipeline in a tar file
type Tar struct {
Base
filename string
Format osbuild.TarArchiveFormat
RootNode osbuild.TarRootNode
Paths []string
ACLs *bool
SELinux *bool
Xattrs *bool
inputPipeline Pipeline
}
func (p Tar) Filename() string {
return p.filename
}
func (p *Tar) SetFilename(filename string) {
p.filename = filename
}
// NewTar creates a new TarPipeline. The inputPipeline represents the
// filesystem tree which will be the contents of the tar file. The pipelinename
// is the name of the pipeline. The filename is the name of the output tar file.
func NewTar(buildPipeline Build, inputPipeline Pipeline, pipelinename string) *Tar {
p := &Tar{
Base: NewBase(pipelinename, buildPipeline),
inputPipeline: inputPipeline,
filename: "image.tar",
}
// See similar logic in qcow2 to run on the host
if buildPipeline != nil {
buildPipeline.addDependent(p)
} else {
inputPipeline.Manifest().addPipeline(p)
}
return p
}
func (p *Tar) serialize() osbuild.Pipeline {
pipeline := p.Base.serialize()
tarOptions := &osbuild.TarStageOptions{
Filename: p.Filename(),
Format: p.Format,
ACLs: p.ACLs,
SELinux: p.SELinux,
Xattrs: p.Xattrs,
RootNode: p.RootNode,
Paths: p.Paths,
}
tarStage := osbuild.NewTarStage(tarOptions, p.inputPipeline.Name())
pipeline.AddStage(tarStage)
return pipeline
}
func (p *Tar) getBuildPackages(Distro) []string {
return []string{"tar"}
}
func (p *Tar) Export() *artifact.Artifact {
p.Base.export = true
mimeType := "application/x-tar"
return artifact.New(p.Name(), p.Filename(), &mimeType)
}