osbuild2: add stages for raw images and grub iso

Add the new stages included in osbuild 30 that can be used to
deploy an OSTree commit as well as the grub iso stage that
is used to configure grub2 (efi) for isos.
Bump the spec file requirement accordingly.

Co-Developed-by: Achilleas Koutsou <achilleas@koutsou.net>
Co-Developed-by: Christian Kellner <christian@kellner.me>
This commit is contained in:
Antonio Murdaca 2021-08-20 10:15:11 +02:00 committed by Tom Gundersen
parent 14b5e98be8
commit 4fdf4dbd01
10 changed files with 236 additions and 2 deletions

View file

@ -0,0 +1,30 @@
package osbuild2
type GrubISOStageOptions struct {
Product Product `json:"product"`
Kernel ISOKernel `json:"kernel"`
ISOLabel string `json:"isolabel"`
Architectures []string `json:"architectures,omitempty"`
Vendor string `json:"vendor,omitempty"`
}
func (GrubISOStageOptions) isStageOptions() {}
type ISOKernel struct {
Dir string `json:"dir"`
// Additional kernel boot options
Opts []string `json:"opts,omitempty"`
}
// Assemble a file system tree for a bootable ISO
func NewGrubISOStage(options *GrubISOStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.grub2.iso",
Options: options,
}
}

View file

@ -0,0 +1,24 @@
package osbuild2
import "os"
// Options for the org.osbuild.ostree.config stage.
type MkdirStageOptions struct {
Paths []Path `json:"paths"`
}
type Path struct {
Path string `json:"path"`
Mode os.FileMode `json:"mode,omitempty"`
}
func (MkdirStageOptions) isStageOptions() {}
// A new org.osbuild.ostree.init stage to create an OSTree repository
func NewMkdirStage(options *MkdirStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.mkdir",
Options: options,
}
}

View file

@ -0,0 +1,28 @@
package osbuild2
// Options for the org.osbuild.ostree.config stage.
type OSTreeConfigStageOptions struct {
// Location of the ostree repo
Repo string `json:"repo"`
Config *OSTreeConfig `json:"config,omitempty"`
}
func (OSTreeConfigStageOptions) isStageOptions() {}
type OSTreeConfig struct {
// Options concerning the sysroot
Sysroot *SysrootOptions `json:"sysroot,omitempty"`
}
type SysrootOptions struct {
ReadOnly *bool `json:"readonly,omitempty"`
}
// A new org.osbuild.ostree.init stage to create an OSTree repository
func NewOSTreeConfigStage(options *OSTreeConfigStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.ostree.config",
Options: options,
}
}

View file

@ -0,0 +1,50 @@
package osbuild2
import (
"encoding/json"
"fmt"
)
// Options for the org.osbuild.ostree.deploy stage.
type OSTreeDeployStageOptions struct {
OsName string `json:"osname"`
Ref string `json:"ref"`
Mounts []string `json:"mounts"`
Rootfs Rootfs `json:"rootfs"`
KernelOpts []string `json:"kernel_opts"`
}
type Rootfs struct {
// Identify the root file system by label
Label string `json:"label,omitempty"`
// Identify the root file system by UUID
UUID string `json:"uuid,omitempty"`
}
func (OSTreeDeployStageOptions) isStageOptions() {}
// A new org.osbuild.ostree.init stage to create an OSTree repository
func NewOSTreeDeployStage(options *OSTreeDeployStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.ostree.deploy",
Options: options,
}
}
// alias for custom marshaller
type ostreeDeployStageOptions OSTreeDeployStageOptions
func (options OSTreeDeployStageOptions) MarshalJSON() ([]byte, error) {
rootfs := options.Rootfs
if (len(rootfs.UUID) == 0 && len(rootfs.Label) == 0) || (len(rootfs.UUID) != 0 && len(rootfs.Label) != 0) {
return nil, fmt.Errorf("exactly one of UUID or Label must be specified")
}
aliasOptions := ostreeDeployStageOptions(options)
return json.Marshal(aliasOptions)
}

View file

@ -0,0 +1,24 @@
package osbuild2
// Options for the org.osbuild.ostree.fillvar stage.
type OSTreeFillvarStageOptions struct {
Deployment OSTreeDeployment `json:"deployment"`
}
type OSTreeDeployment struct {
OSName string `json:"osname"`
Ref string `json:"ref"`
Serial *int `json:"serial,omitempty"`
}
func (OSTreeFillvarStageOptions) isStageOptions() {}
// A new org.osbuild.ostree.init stage to create an OSTree repository
func NewOSTreeFillvarStage(options *OSTreeFillvarStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.ostree.fillvar",
Options: options,
}
}

View file

@ -0,0 +1,8 @@
package osbuild2
// A new org.osbuild.ostree.init stage to create an OSTree repository
func OSTreeInitFsStage() *Stage {
return &Stage{
Type: "org.osbuild.ostree.init-fs",
}
}

View file

@ -0,0 +1,17 @@
package osbuild2
// Options for the org.osbuild.ostree.os-init stage.
type OSTreeOsInitStageOptions struct {
// Name of the OS
OSName string `json:"osname"`
}
func (OSTreeOsInitStageOptions) isStageOptions() {}
// A new org.osbuild.ostree.init stage to create an OSTree repository
func NewOSTreeOsInitStage(options *OSTreeOsInitStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.ostree.os-init",
Options: options,
}
}

View file

@ -0,0 +1,36 @@
package osbuild2
// Configure OSTree remotes for a repository
// Options for the org.osbuild.ostree.remotes stage.
type OSTreeRemotesStageOptions struct {
// Location of the ostree repo
Repo string `json:"repo"`
// Configure remotes for the system repository
Remotes []OSTreeRemote `json:"remotes,omitempty"`
}
func (OSTreeRemotesStageOptions) isStageOptions() {}
type OSTreeRemote struct {
// Identifier for the remote
Name string `json:"name"`
// URL of the repository.
URL string `json:"url"`
// Configured branches for the remote
Branches []string `json:"branches,omitempty"`
// GPG keys to verify the commits
GPGKeys []string `json:"secrets,omitempty"`
}
// A new org.osbuild.ostree.remotes stage to configure remotes
func NewOSTreeRemotesStage(options *OSTreeRemotesStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.ostree.remotes",
Options: options,
}
}

View file

@ -0,0 +1,17 @@
package osbuild2
// Options for the org.osbuild.ostree.selinux stage.
type OSTreeSelinuxStageOptions struct {
// shared with ostree.fillvar
Deployment OSTreeDeployment `json:"deployment"`
}
func (OSTreeSelinuxStageOptions) isStageOptions() {}
// A new org.osbuild.ostree.init stage to create an OSTree repository
func NewOSTreeSelinuxStage(options *OSTreeSelinuxStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.ostree.selinux",
Options: options,
}
}

View file

@ -279,8 +279,8 @@ The core osbuild-composer binary. This is suitable both for spawning in containe
Summary: The worker for osbuild-composer
Requires: systemd
Requires: qemu-img
Requires: osbuild >= 29
Requires: osbuild-ostree >= 29
Requires: osbuild >= 30
Requires: osbuild-ostree >= 30
# remove in F34
Obsoletes: golang-github-osbuild-composer-worker < %{version}-%{release}