From dbd6f1f48c206f7616deddb4e7a164c6e658ecb0 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 3 Mar 2022 23:20:17 +0100 Subject: [PATCH] distro: add GPGKeyFiles option to ImageConfig Add a new option `GPGKeyFiles` to ImageConfig that indicates which files containing GPG keys should be imported into rpm. For now it will be used by the osPipeline in rhel{86,90} to set the corresponding option in the `org.osbuild.rpm` stage. --- internal/distro/image_config.go | 6 ++++++ internal/distro/rhel86/pipelines.go | 4 +++- internal/distro/rhel90/pipelines.go | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/distro/image_config.go b/internal/distro/image_config.go index 72de9aa01..ae840c01f 100644 --- a/internal/distro/image_config.go +++ b/internal/distro/image_config.go @@ -20,6 +20,9 @@ type ImageConfig struct { DefaultTarget string Sysconfig []*osbuild2.SysconfigStageOptions + // List of files from which to import GPG keys into the RPM database + GPGKeyFiles []string + // for RHSM configuration, we need to potentially distinguish the case // when the user want the image to be subscribed on first boot and when not RHSMConfig map[RHSMSubscriptionStatus]*osbuild2.RHSMStageOptions @@ -72,6 +75,9 @@ func (c *ImageConfig) InheritFrom(parentConfig *ImageConfig) *ImageConfig { if finalConfig.Sysconfig == nil { finalConfig.Sysconfig = parentConfig.Sysconfig } + if finalConfig.GPGKeyFiles == nil { + finalConfig.GPGKeyFiles = parentConfig.GPGKeyFiles + } if finalConfig.RHSMConfig == nil { finalConfig.RHSMConfig = parentConfig.RHSMConfig } diff --git a/internal/distro/rhel86/pipelines.go b/internal/distro/rhel86/pipelines.go index b28c33489..cdcbd87d5 100644 --- a/internal/distro/rhel86/pipelines.go +++ b/internal/distro/rhel86/pipelines.go @@ -371,7 +371,9 @@ func osPipeline(t *imageType, p.AddStage(osbuild.NewOSTreePasswdStage("org.osbuild.source", options.OSTree.Parent)) } - p.AddStage(osbuild.NewRPMStage(rpmStageOptions(repos), osbuild.NewRpmStageSourceFilesInputs(packages))) + rpmOptions := rpmStageOptions(repos) + rpmOptions.GPGKeysFromTree = imageConfig.GPGKeyFiles + p.AddStage(osbuild.NewRPMStage(rpmOptions, osbuild.NewRpmStageSourceFilesInputs(packages))) // If the /boot is on a separate partition, the prefix for the BLS stage must be "" if pt == nil || pt.FindMountable("/boot") == nil { diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go index debb33e7e..c0b9974f6 100644 --- a/internal/distro/rhel90/pipelines.go +++ b/internal/distro/rhel90/pipelines.go @@ -363,7 +363,9 @@ func osPipeline(t *imageType, p.AddStage(osbuild.NewOSTreePasswdStage("org.osbuild.source", options.OSTree.Parent)) } - p.AddStage(osbuild.NewRPMStage(rpmStageOptions(repos), osbuild.NewRpmStageSourceFilesInputs(packages))) + rpmOptions := rpmStageOptions(repos) + rpmOptions.GPGKeysFromTree = imageConfig.GPGKeyFiles + p.AddStage(osbuild.NewRPMStage(rpmOptions, osbuild.NewRpmStageSourceFilesInputs(packages))) // If the /boot is on a separate partition, the prefix for the BLS stage must be "" if pt == nil || pt.FindMountable("/boot") == nil {