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
8 changes: 8 additions & 0 deletions pkg/distro/generic/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/osbuild/image-builder/pkg/customizations/subscription"
"github.com/osbuild/image-builder/pkg/customizations/users"
"github.com/osbuild/image-builder/pkg/distro"
"github.com/osbuild/image-builder/pkg/experimentalflags"
"github.com/osbuild/image-builder/pkg/flatpak"
"github.com/osbuild/image-builder/pkg/image"
"github.com/osbuild/image-builder/pkg/manifest"
Expand Down Expand Up @@ -378,6 +379,13 @@ func osCustomizations(t *imageType, osPackageSet rpmmd.PackageSet, options distr
osc.RPMKeysBinary = tweaks.RPMKeys.BinPath
}

if imageID := experimentalflags.String("image-id"); imageID != "" {
osc.ImageID = imageID
}
if imageVersion := experimentalflags.String("image-version"); imageVersion != "" {
osc.ImageVersion = imageVersion
}

if sshdCust := c.GetSshd(); sshdCust != nil && imageConfig.SshdConfig != nil {
if sshdCust.PasswordAuthentication != nil {
osc.SshdConfig.Config.PasswordAuthentication = sshdCust.PasswordAuthentication
Expand Down
24 changes: 24 additions & 0 deletions pkg/manifest/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ type OSCustomizations struct {

// Use this RPMKeysBinary from the tree instead of the default one
RPMKeysBinary string

// Environmental bits that can be set during the RPM stage to affect
// the installation of certain packages, for example when a distros
// `-release` package uses this to adjust what it writes into
// `os-release` or if we want to adjust `os-release ourselves.
ImageID string
ImageVersion string
}

// OS represents the filesystem tree of the target image. This roughly
Expand Down Expand Up @@ -552,6 +559,7 @@ func (p *OS) serialize() (osbuild.Pipeline, error) {
}

baseRPMOptions := &osbuild.RPMStageOptions{}

if p.OSCustomizations.ExcludeDocs {
baseRPMOptions.Exclude = &osbuild.Exclude{Docs: true}
}
Expand All @@ -574,6 +582,22 @@ func (p *OS) serialize() (osbuild.Pipeline, error) {
}
baseRPMOptions.InstallLangs = p.OSCustomizations.InstallLangs

if len(p.OSCustomizations.ImageID) > 0 {
if baseRPMOptions.GenericEnv == nil {
baseRPMOptions.GenericEnv = make(map[string]string)
}

baseRPMOptions.GenericEnv["IMAGE_ID"] = p.OSCustomizations.ImageID
}

if len(p.OSCustomizations.ImageVersion) > 0 {
if baseRPMOptions.GenericEnv == nil {
baseRPMOptions.GenericEnv = make(map[string]string)
}

baseRPMOptions.GenericEnv["IMAGE_VERSION"] = p.OSCustomizations.ImageVersion
}

bootloader := p.platform.GetBootloader()

bootRoot := "/boot"
Expand Down
Loading