osbuild2: add support for new osbuild stages

- org.osbuild.anaconda
    Configures Anaconda.  For now, only enabling kickstart modules is
    supported.

- org.osbuild.buildstamp
    Creates a buildstamp file, which is required by Anaconda.

- org.osbuild.kickstart
    Creates a kickstart file.

- org.osbuild.lorax-script
    Uses lorax template helpers to execute a template.

- org.osbuild.bootiso
    Prepares a bootable file system tree suitable for writing on an ISO
    file system

- org.osbuild.discinfo
    Creates a .discinfo file, used by the Anaconda installer.

- org.osbuild.xorrisofs
    Uses the `xorrisofs` command line utility to an ISO.

- org.osbuild.implantisomd5
    Uses the `implantisomd5` command to implant MD5 checksums into an
    ISO.
This commit is contained in:
Achilleas Koutsou 2021-03-03 16:12:21 +01:00 committed by Tom Gundersen
parent 011559f785
commit bec194dfff
9 changed files with 278 additions and 9 deletions

View file

@ -0,0 +1,16 @@
package osbuild2
type AnacondaStageOptions struct {
// Kickstart modules to enable
KickstartModules []string `json:"kickstart-modules"`
}
func (AnacondaStageOptions) isStageOptions() {}
// Configure basic aspects of the Anaconda installer
func NewAnacondaStage(options *AnacondaStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.anaconda",
Options: options,
}
}

View file

@ -0,0 +1,75 @@
package osbuild2
type BootISOMonoStageOptions struct {
Product Product `json:"product"`
Kernel string `json:"kernel"`
ISOLabel string `json:"isolabel"`
EFI EFI `json:"efi,omitempty"`
ISOLinux ISOLinux `json:"isolinux,omitempty"`
// Additional kernel boot options
KernelOpts string `json:"kernel_opts,omitempty"`
Templates string `json:"templates,omitempty"`
RootFS RootFS `json:"rootfs,omitempty"`
}
type EFI struct {
Architectures []string `json:"architectures"`
Vendor string `json:"vendor"`
}
type ISOLinux struct {
Enabled bool `json:"enabled"`
Debug bool `json:"debug,omitempty"`
}
type RootFS struct {
Compression FSCompression `json:"compression"`
// Size in MiB
Size int `json:"size"`
}
type FSCompression struct {
Method string `json:"method"`
Options FSCompressionOptions `json:"options,omitempty"`
}
type FSCompressionOptions struct {
BCJ string `json:"bcj"`
}
func (BootISOMonoStageOptions) isStageOptions() {}
type BootISOMonoStageInputs struct {
RootFS *BootISOMonoStageInput `json:"rootfs"`
Kernel *BootISOMonoStageInput `json:"kernel,omitempty"`
}
func (BootISOMonoStageInputs) isStageInputs() {}
type BootISOMonoStageInput struct {
inputCommon
References BootISOMonoStageReferences `json:"references"`
}
func (BootISOMonoStageInput) isStageInput() {}
type BootISOMonoStageReferences []string
func (BootISOMonoStageReferences) isReferences() {}
// Assemble a file system tree for a bootable ISO
func NewBootISOMonoStage(options *BootISOMonoStageOptions, inputs *BootISOMonoStageInputs) *Stage {
return &Stage{
Type: "org.osbuild.bootiso.mono",
Options: options,
Inputs: inputs,
}
}

View file

@ -0,0 +1,30 @@
package osbuild2
type BuildstampStageOptions struct {
// Build architecture
Arch string `json:"arch"`
// The product name
Product string `json:"product"`
// The version
Version string `json:"version"`
Final bool `json:"final"`
// The variant of the product
Variant string `json:"variant"`
// The bugurl of the product
BugURL string `json:"bugurl"`
}
func (BuildstampStageOptions) isStageOptions() {}
// Creates a buildstamp file describing the system (required by anaconda)
func NewBuildstampStage(options *BuildstampStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.buildstamp",
Options: options,
}
}

View file

@ -0,0 +1,19 @@
package osbuild2
type DiscinfoStageOptions struct {
// Build architecture
BaseArch string `json:"basearch"`
// The product name
Release string `json:"release"`
}
func (DiscinfoStageOptions) isStageOptions() {}
// Creates a .discinfo file describing a disk
func NewDiscinfoStage(options *DiscinfoStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.discinfo",
Options: options,
}
}

View file

@ -0,0 +1,16 @@
package osbuild2
type Implantisomd5StageOptions struct {
// Path in the ISO where the md5 checksum will be implanted
Filename string `json:"filename"`
}
func (Implantisomd5StageOptions) isStageOptions() {}
// Implant an MD5 checksum in an ISO9660 image
func NewImplantisomd5Stage(options *Implantisomd5StageOptions) *Stage {
return &Stage{
Type: "org.osbuild.implantisomd5",
Options: options,
}
}

View file

@ -0,0 +1,31 @@
package osbuild2
type KickstartStageOptions struct {
// Where to place the kickstart file
Path string `json:"path"`
OSTree OSTreeOptions `json:"ostree,omitempty"`
LiveIMG *LiveIMG `json:"liveimg,omitempty"`
}
type LiveIMG struct {
URL string `json:"url"`
}
type OSTreeOptions struct {
OSName string `json:"osname"`
URL string `json:"url"`
Ref string `json:"ref"`
GPG bool `json:"gpg"`
}
func (KickstartStageOptions) isStageOptions() {}
// Creates an Anaconda kickstart file
func NewKickstartStage(options *KickstartStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.kickstart",
Options: options,
}
}

View file

@ -0,0 +1,28 @@
package osbuild2
type LoraxScriptStageOptions struct {
// Where to put the script
Path string `json:"path"`
// The basic architecture parameter to supply to the template
BaseArch string `json:"basearch,omitempty"`
Product Product `json:"product,omitempty"`
LibDir string `json:"libdir,omitempty"`
}
type Product struct {
Name string `json:"name"`
Version string `json:"version"`
}
func (LoraxScriptStageOptions) isStageOptions() {}
// Run a Lorax template script on the tree
func NewLoraxScriptStage(options *LoraxScriptStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.lorax-script",
Options: options,
}
}

View file

@ -8,15 +8,6 @@ type OSTreePullStageOptions struct {
func (OSTreePullStageOptions) isStageOptions() {}
// A new org.osbuild.ostree.pull stage to pull OSTree commits into an existing repo
func NewOSTreePullStage(options *OSTreePullStageOptions, inputs Inputs) *Stage {
return &Stage{
Type: "org.osbuild.ostree.pull",
Inputs: inputs,
Options: options,
}
}
type OSTreePullStageInput struct {
inputCommon
References OSTreePullStageReferences `json:"references"`
@ -37,3 +28,12 @@ func (OSTreePullStageReferences) isReferences() {}
type OSTreePullStageReference struct {
Ref string `json:"ref"`
}
// A new org.osbuild.ostree.pull stage to pull OSTree commits into an existing repo
func NewOSTreePullStage(options *OSTreePullStageOptions, inputs *OSTreePullStageInputs) *Stage {
return &Stage{
Type: "org.osbuild.ostree.pull",
Inputs: inputs,
Options: options,
}
}

View file

@ -0,0 +1,54 @@
package osbuild2
type XorrisofsStageOptions struct {
// Filename of the ISO to create
Filename string `json:"filename"`
// Volume ID to set
VolID string `json:"volid"`
Boot XorrisofsBoot `json:"boot,omitempty"`
EFI string `json:"efi,omitempty"`
// Install the argument (buildroot) as ISOLINUX isohybrid MBR
IsohybridMBR string `json:"isohybridmbr,omitempty"`
// The ISO 9660 version (limits data size and filenames; min: 1, max: 4)
ISOLevel int `json:"isolevel,omitempty"`
}
type XorrisofsBoot struct {
// Path to the boot image (on the ISO)
Image string `json:"image"`
// Path to the boot catalog file (on the ISO)
Catalog string `json:"catalog"`
}
func (XorrisofsStageOptions) isStageOptions() {}
type XorrisofsStageInputs struct {
Tree *XorrisofsStageInput `json:"tree"`
}
func (XorrisofsStageInputs) isStageInputs() {}
type XorrisofsStageInput struct {
inputCommon
References XorrisofsStageReferences `json:"references"`
}
func (XorrisofsStageInput) isStageInput() {}
type XorrisofsStageReferences []string
func (XorrisofsStageReferences) isReferences() {}
// Assembles a Rock Ridge enhanced ISO 9660 filesystem (iso)
func NewXorrisofsStage(options *XorrisofsStageOptions, inputs *XorrisofsStageInputs) *Stage {
return &Stage{
Type: "org.osbuild.xorrisofs",
Options: options,
Inputs: inputs,
}
}