Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions pkg/distro/defs/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,39 @@ image_types:
})
}

func TestDefsDistroImageConfigSystemdBoot(t *testing.T) {
fakeDistroYaml := `
distros:
- name: test-distro-1
vendor: test-vendor
defs_path: test-distro-1/
image_config:
default:
systemd_boot:
random-seed: "no"
make-entry-directory: "yes"
entry-token: "os-id"
`

fakeImageTypeYaml := `
image_types:
test_type:
filename: foo
`
baseDir := makeFakeDistrosYAML(t, fakeDistroYaml, fakeImageTypeYaml)
restore := defs.MockDataFS(baseDir)
defer restore()
dist, err := defs.NewDistroYAML("test-distro-1")
assert.NoError(t, err)
assert.Equal(t, &distro.ImageConfig{
SystemdBoot: &osbuild.SystemdBootConfig{
RandomSeed: "no",
MakeEntryDirectory: "yes",
EntryToken: "os-id",
},
}, dist.ImageConfig())
}

func TestDefsPartitionTableErrorsNotForImageType(t *testing.T) {
badDistroYamlMissingPartitionTable := `
image_types:
Expand Down
2 changes: 2 additions & 0 deletions pkg/distro/generic/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ func osCustomizations(t *imageType, osPackageSet rpmmd.PackageSet, options distr
osc.NoBLS = *imageConfig.NoBLS
}

osc.SystemdBoot = imageConfig.SystemdBoot

ca, err := c.GetCACerts()
if err != nil {
panic(fmt.Sprintf("unexpected error checking CA certs: %v", err))
Expand Down
2 changes: 2 additions & 0 deletions pkg/distro/image_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ type ImageConfig struct {
// instead of BLS. Required for legacy systems like RHEL 7.
NoBLS *bool `yaml:"no_bls,omitempty"`

SystemdBoot *osbuild.SystemdBootConfig `yaml:"systemd_boot,omitempty"`

// OSTree specific configuration

// Read only sysroot and boot
Expand Down
2 changes: 2 additions & 0 deletions pkg/manifest/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ type OSCustomizations struct {
// instead of BLS. Required for legacy systems like RHEL 7.
NoBLS bool

SystemdBoot *osbuild.SystemdBootConfig

// InstallWeakDeps enables installation of weak dependencies for packages
// that are statically defined for the pipeline.
// Defaults to True.
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifest/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ func (p *RawImage) serialize() (osbuild.Pipeline, error) {
// an error it's empty and the stage options will omit it
opts.BootPath, _ = findXBootLDRMountpoint(p.treePipeline.PartitionTable)

if cfg := p.treePipeline.OSCustomizations.SystemdBoot; cfg != nil {
opts.RandomSeed = cfg.RandomSeed
opts.MakeEntryDirectory = cfg.MakeEntryDirectory
opts.EntryToken = cfg.EntryToken
}

pipeline.AddStage(osbuild.NewBootctlInstallRootStage(opts, bootctlDevices, bootctlMounts))
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/osbuild/bootctl_install_root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package osbuild

type SystemdBootConfig struct {
RandomSeed string `json:"random-seed,omitempty" yaml:"random-seed,omitempty"`
MakeEntryDirectory string `json:"make-entry-directory,omitempty" yaml:"make-entry-directory,omitempty"`
EntryToken string `json:"entry-token,omitempty" yaml:"entry-token,omitempty"`
}

type BootctlInstallRootStageOptions struct {
Root string `json:"root"`
ESPPath string `json:"esp-path,omitempty"`
Expand Down
Loading