diff --git a/internal/osbuild2/grub_iso_stage.go b/internal/osbuild2/grub_iso_stage.go new file mode 100644 index 000000000..0215a31b7 --- /dev/null +++ b/internal/osbuild2/grub_iso_stage.go @@ -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, + } +} diff --git a/internal/osbuild2/mkdir_stage.go b/internal/osbuild2/mkdir_stage.go new file mode 100644 index 000000000..6a386299f --- /dev/null +++ b/internal/osbuild2/mkdir_stage.go @@ -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, + } +} diff --git a/internal/osbuild2/ostree_config_stage.go b/internal/osbuild2/ostree_config_stage.go new file mode 100644 index 000000000..ead325685 --- /dev/null +++ b/internal/osbuild2/ostree_config_stage.go @@ -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, + } +} diff --git a/internal/osbuild2/ostree_deploy_stage.go b/internal/osbuild2/ostree_deploy_stage.go new file mode 100644 index 000000000..066f626d5 --- /dev/null +++ b/internal/osbuild2/ostree_deploy_stage.go @@ -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) +} diff --git a/internal/osbuild2/ostree_fillvar_stage.go b/internal/osbuild2/ostree_fillvar_stage.go new file mode 100644 index 000000000..8f8d192c4 --- /dev/null +++ b/internal/osbuild2/ostree_fillvar_stage.go @@ -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, + } +} diff --git a/internal/osbuild2/ostree_init_fs_stage.go b/internal/osbuild2/ostree_init_fs_stage.go new file mode 100644 index 000000000..ae04467bd --- /dev/null +++ b/internal/osbuild2/ostree_init_fs_stage.go @@ -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", + } +} diff --git a/internal/osbuild2/ostree_os_init_stage.go b/internal/osbuild2/ostree_os_init_stage.go new file mode 100644 index 000000000..72cb91341 --- /dev/null +++ b/internal/osbuild2/ostree_os_init_stage.go @@ -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, + } +} diff --git a/internal/osbuild2/ostree_remotes_stage.go b/internal/osbuild2/ostree_remotes_stage.go new file mode 100644 index 000000000..f81de2add --- /dev/null +++ b/internal/osbuild2/ostree_remotes_stage.go @@ -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, + } +} diff --git a/internal/osbuild2/ostree_selinux_stage.go b/internal/osbuild2/ostree_selinux_stage.go new file mode 100644 index 000000000..e2a0b27ea --- /dev/null +++ b/internal/osbuild2/ostree_selinux_stage.go @@ -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, + } +} diff --git a/osbuild-composer.spec b/osbuild-composer.spec index 92c9bc9ac..74c0e71b6 100644 --- a/osbuild-composer.spec +++ b/osbuild-composer.spec @@ -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}