From 01b94a57874ecca92a2d0ed9dd2a02459d17df64 Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Mon, 28 Feb 2022 11:00:06 +0100 Subject: [PATCH] RHEL-85: introduce `tarArchivePipeline()` Introduce `tarArchivePipeline()` function returning a pipeline, which creates a Tar archive from another pipeline tree referenced by the pipeline name. Replace `tarStage()` with `osbuild.NewTarStage()` Use the `tarArchivePipeline()` function in respective image type pipelines. Signed-off-by: Tomas Hozza --- internal/distro/rhel85/pipelines.go | 34 +++++++++++------------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/internal/distro/rhel85/pipelines.go b/internal/distro/rhel85/pipelines.go index abce49732..eadcd4cf5 100644 --- a/internal/distro/rhel85/pipelines.go +++ b/internal/distro/rhel85/pipelines.go @@ -460,6 +460,14 @@ func rhelEc2Pipelines(t *imageType, customizations *blueprint.Customizations, op return pipelines, nil } +func tarArchivePipeline(name, inputPipelineName string, tarOptions *osbuild.TarStageOptions) *osbuild.Pipeline { + p := new(osbuild.Pipeline) + p.Name = name + p.Build = "name:build" + p.AddStage(osbuild.NewTarStage(tarOptions, osbuild.NewTarStagePipelineTreeInputs(inputPipelineName))) + return p +} + func tarPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) { pipelines := make([]osbuild.Pipeline, 0) pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey])) @@ -470,12 +478,8 @@ func tarPipelines(t *imageType, customizations *blueprint.Customizations, option } treePipeline.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false))) pipelines = append(pipelines, *treePipeline) - tarPipeline := osbuild.Pipeline{ - Name: "root-tar", - Build: "name:build", - } - tarPipeline.AddStage(tarStage("os", "root.tar.xz")) - pipelines = append(pipelines, tarPipeline) + tarPipeline := tarArchivePipeline("root-tar", treePipeline.Name, &osbuild.TarStageOptions{Filename: "root.tar.xz"}) + pipelines = append(pipelines, *tarPipeline) return pipelines, nil } @@ -531,7 +535,7 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati kernelVer := fmt.Sprintf("%s-%s.%s", kernelPkg.Version, kernelPkg.Release, kernelPkg.Arch) tarPath := "/liveimg.tar" - tarPayloadStages := []*osbuild.Stage{tarStage("os", tarPath)} + tarPayloadStages := []*osbuild.Stage{osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: tarPath}, osbuild.NewTarStagePipelineTreeInputs(treePipeline.Name))} kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, makeISORootPath(tarPath), customizations.GetUsers(), customizations.GetGroups(), "", "") if err != nil { return nil, err @@ -563,12 +567,8 @@ func edgeCommitPipelines(t *imageType, customizations *blueprint.Customizations, if err != nil { return nil, err } - tarPipeline := osbuild.Pipeline{ - Name: "commit-archive", - Build: "name:build", - } - tarPipeline.AddStage(tarStage("ostree-commit", t.Filename())) - pipelines = append(pipelines, tarPipeline) + tarPipeline := tarArchivePipeline("commit-archive", "ostree-commit", &osbuild.TarStageOptions{Filename: t.Filename()}) + pipelines = append(pipelines, *tarPipeline) return pipelines, nil } @@ -842,14 +842,6 @@ func ostreeCommitPipeline(options distro.ImageOptions) *osbuild.Pipeline { return p } -func tarStage(source, filename string) *osbuild.Stage { - tree := new(osbuild.TarStageInput) - tree.Type = "org.osbuild.tree" - tree.Origin = "org.osbuild.pipeline" - tree.References = []string{"name:" + source} - return osbuild.NewTarStage(&osbuild.TarStageOptions{Filename: filename}, &osbuild.TarStageInputs{Tree: tree}) -} - func containerTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, options distro.ImageOptions, c *blueprint.Customizations, nginxConfigPath, listenPort string) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "container-tree"