Skip to content

Commit

Permalink
QCOW2 image generation and output test
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Sehnoutka committed Oct 21, 2019
1 parent 0272fb8 commit fd3e398
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __pycache__

/osbuild-composer
/osbuild-worker
/osbuild-pipeline
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
build:
go build -o osbuild-composer ./cmd/osbuild-composer/
go build -o osbuild-worker ./cmd/osbuild-worker/
go build -o osbuild-pipeline ./cmd/osbuild-pipeline/

.PHONY: install
install:
Expand Down
3 changes: 2 additions & 1 deletion internal/blueprint/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
package blueprint

import (
"github.com/osbuild/osbuild-composer/internal/pipeline"
"sort"

"github.com/osbuild/osbuild-composer/internal/pipeline"
)

type InvalidOutputFormatError struct {
Expand Down
13 changes: 12 additions & 1 deletion internal/blueprint/f30_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func addF30FSTabStage(p *pipeline.Pipeline) {
panic("invalid UUID")
}
options := &pipeline.FSTabStageOptions{}
options.AddFilesystem(id, "extf4", "/", "defaults", 1, 1)
options.AddFilesystem(id, "ext4", "/", "defaults", 1, 1)
p.AddStage(pipeline.NewFSTabStage(options))
}

Expand All @@ -89,6 +89,17 @@ func addF30SELinuxStage(p *pipeline.Pipeline) {
}))
}

func addF30LocaleStage(p *pipeline.Pipeline) {
p.AddStage(pipeline.NewLocaleStage(
&pipeline.LocaleStageOptions{
Language: "en_US",
}))
}

func addF30FixBlsStage(p *pipeline.Pipeline) {
p.AddStage(pipeline.NewFixBLSStage())
}

func addF30QemuAssembler(p *pipeline.Pipeline, format string, filename string) {
id, err := uuid.Parse("76a22bf4-f153-4541-b6c7-0332c0dfaeac")
if err != nil {
Expand Down
28 changes: 17 additions & 11 deletions internal/blueprint/pipelines/qcow2_empty_blueprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,26 @@
}
],
"packages": [
"@Core",
"kernel-core",
"@Fedora Cloud Server",
"chrony",
"kernel",
"polkit",
"systemd-udev",
"selinux-policy-targeted",
"grub2-pc",
"spice-vdagent",
"qemu-guest-agent",
"xen-libs",
"langpacks-en"
],
"exclude_packages": [
"dracut-config-rescue",
"etables",
"firewalld",
"gobject-introspection",
"plymouth"
],
"releasever": "30",
"basearch": "x86_64"
}
},
{
"name": "org.osbuild.fix-bls",
"options": {}
},
{
"name": "org.osbuild.locale",
"options": {
Expand All @@ -68,7 +70,7 @@
"filesystems": [
{
"uuid": "76a22bf4-f153-4541-b6c7-0332c0dfaeac",
"vfs_type": "extf4",
"vfs_type": "ext4",
"path": "/",
"options": "defaults",
"freq": 1,
Expand All @@ -90,6 +92,10 @@
"options": {
"file_contexts": "etc/selinux/targeted/contexts/files/file_contexts"
}
},
{
"name": "org.osbuild.fix-bls",
"options": {}
}
],
"assembler": {
Expand All @@ -102,4 +108,4 @@
"size": 3221225472
}
}
}
}
33 changes: 32 additions & 1 deletion internal/blueprint/qcow2_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,42 @@ import "github.com/osbuild/osbuild-composer/internal/pipeline"
type qcow2Output struct{}

func (t *qcow2Output) translate(b *Blueprint) *pipeline.Pipeline {
p := getF30Pipeline()
p := &pipeline.Pipeline{
BuildPipeline: getF30BuildPipeline(),
}

options := &pipeline.DNFStageOptions{
ReleaseVersion: "30",
BaseArchitecture: "x86_64",
}
options.AddRepository(getF30Repository())
packages := [...]string{"kernel-core",
"@Fedora Cloud Server",
"chrony",
"polkit",
"systemd-udev",
"selinux-policy-targeted",
"grub2-pc",
"langpacks-en"}
for _, pkg := range packages {
options.AddPackage(pkg)
}
excludedPackages := [...]string{"dracut-config-rescue",
"etables",
"firewalld",
"gobject-introspection",
"plymouth"}
for _, pkg := range excludedPackages {
options.ExcludePackage(pkg)
}
p.AddStage(pipeline.NewDNFStage(options))
addF30LocaleStage(p)
addF30FSTabStage(p)
addF30GRUB2Stage(p)
addF30SELinuxStage(p)
addF30FixBlsStage(p)
addF30QemuAssembler(p, "qcow2", t.getName())

return p
}

Expand Down
2 changes: 0 additions & 2 deletions internal/jobqueue/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ func TestCreate(t *testing.T) {
id, _ := uuid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff")
store := store.New(nil)
api := jobqueue.New(nil, store)

store.PushCompose(id, &blueprint.Blueprint{}, "tar")

testRoute(t, api, "POST", "/job-queue/v1/jobs", `{}`, http.StatusCreated,
`{"id":"ffffffff-ffff-ffff-ffff-ffffffffffff","pipeline":{"build":{"stages":[{"name":"org.osbuild.dnf","options":{"repos":[{"metalink":"https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever\u0026arch=$basearch","gpgkey":"F1D8 EC98 F241 AAF2 0DF6 9420 EF3C 111F CFC6 59B9","checksum":"sha256:9f596e18f585bee30ac41c11fb11a83ed6b11d5b341c1cb56ca4015d7717cb97"}],"packages":["dnf","e2fsprogs","policycoreutils","qemu-img","systemd","grub2-pc","tar"],"releasever":"30","basearch":"x86_64"}}]},"stages":[{"name":"org.osbuild.dnf","options":{"repos":[{"metalink":"https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever\u0026arch=$basearch","gpgkey":"F1D8 EC98 F241 AAF2 0DF6 9420 EF3C 111F CFC6 59B9","checksum":"sha256:9f596e18f585bee30ac41c11fb11a83ed6b11d5b341c1cb56ca4015d7717cb97"}],"packages":["@Core","chrony","kernel","selinux-policy-targeted","grub2-pc","spice-vdagent","qemu-guest-agent","xen-libs","langpacks-en"],"releasever":"30","basearch":"x86_64"}},{"name":"org.osbuild.fix-bls","options":{}},{"name":"org.osbuild.locale","options":{"language":"en_US"}},{"name":"org.osbuild.selinux","options":{"file_contexts":"etc/selinux/targeted/contexts/files/file_contexts"}}],"assembler":{"name":"org.osbuild.tar","options":{"filename":"image.tar"}}},"targets":[{"name":"org.osbuild.local","options":{"location":"/var/lib/osbuild-composer/outputs/ffffffff-ffff-ffff-ffff-ffffffffffff"}}]}`)
}
Expand Down
6 changes: 6 additions & 0 deletions internal/pipeline/dnf_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package pipeline
type DNFStageOptions struct {
Repositories []*DNFRepository `json:"repos"`
Packages []string `json:"packages"`
ExcludedPackages []string `json:"exclude_packages,omitempty"`
ReleaseVersion string `json:"releasever"`
BaseArchitecture string `json:"basearch"`
}
Expand Down Expand Up @@ -50,6 +51,11 @@ func (options *DNFStageOptions) AddPackage(pkg string) {
options.Packages = append(options.Packages, pkg)
}

// ExcludePackage adds an excluded package to a DNFStageOptions object.
func (options *DNFStageOptions) ExcludePackage(pkg string) {
options.ExcludedPackages = append(options.ExcludedPackages, pkg)
}

// AddRepository adds a repository to a DNFStageOptions object.
func (options *DNFStageOptions) AddRepository(repo *DNFRepository) {
options.Repositories = append(options.Repositories, repo)
Expand Down

0 comments on commit fd3e398

Please sign in to comment.