diff --git a/pkg/blueprint/repository_customizations.go b/pkg/blueprint/repository_customizations.go index f534804cdd..03f9e18ddc 100644 --- a/pkg/blueprint/repository_customizations.go +++ b/pkg/blueprint/repository_customizations.go @@ -12,18 +12,19 @@ import ( ) type RepositoryCustomization struct { - Id string `json:"id" toml:"id"` - BaseURLs []string `json:"baseurls,omitempty" toml:"baseurls,omitempty"` - GPGKeys []string `json:"gpgkeys,omitempty" toml:"gpgkeys,omitempty"` - Metalink string `json:"metalink,omitempty" toml:"metalink,omitempty"` - Mirrorlist string `json:"mirrorlist,omitempty" toml:"mirrorlist,omitempty"` - Name string `json:"name,omitempty" toml:"name,omitempty"` - Priority *int `json:"priority,omitempty" toml:"priority,omitempty"` - Enabled *bool `json:"enabled,omitempty" toml:"enabled,omitempty"` - GPGCheck *bool `json:"gpgcheck,omitempty" toml:"gpgcheck,omitempty"` - RepoGPGCheck *bool `json:"repo_gpgcheck,omitempty" toml:"repo_gpgcheck,omitempty"` - SSLVerify *bool `json:"sslverify,omitempty" toml:"sslverify,omitempty"` - Filename string `json:"filename,omitempty" toml:"filename,omitempty"` + Id string `json:"id" toml:"id"` + BaseURLs []string `json:"baseurls,omitempty" toml:"baseurls,omitempty"` + GPGKeys []string `json:"gpgkeys,omitempty" toml:"gpgkeys,omitempty"` + Metalink string `json:"metalink,omitempty" toml:"metalink,omitempty"` + Mirrorlist string `json:"mirrorlist,omitempty" toml:"mirrorlist,omitempty"` + Name string `json:"name,omitempty" toml:"name,omitempty"` + Priority *int `json:"priority,omitempty" toml:"priority,omitempty"` + Enabled *bool `json:"enabled,omitempty" toml:"enabled,omitempty"` + GPGCheck *bool `json:"gpgcheck,omitempty" toml:"gpgcheck,omitempty"` + RepoGPGCheck *bool `json:"repo_gpgcheck,omitempty" toml:"repo_gpgcheck,omitempty"` + SSLVerify *bool `json:"sslverify,omitempty" toml:"sslverify,omitempty"` + ModuleHotfixes *bool `json:"module_hotfixes,omitempty" toml:"module_hotfixes,omitempty"` + Filename string `json:"filename,omitempty" toml:"filename,omitempty"` } const repoFilenameRegex = "^[\\w.-]{1,250}\\.repo$" @@ -117,16 +118,17 @@ func (repo RepositoryCustomization) customRepoToRepoConfig() rpmmd.RepoConfig { copy(keys, repo.GPGKeys) repoConfig := rpmmd.RepoConfig{ - Id: repo.Id, - BaseURLs: urls, - GPGKeys: keys, - Name: repo.Name, - Metalink: repo.Metalink, - MirrorList: repo.Mirrorlist, - CheckGPG: repo.GPGCheck, - CheckRepoGPG: repo.RepoGPGCheck, - Priority: repo.Priority, - Enabled: repo.Enabled, + Id: repo.Id, + BaseURLs: urls, + GPGKeys: keys, + Name: repo.Name, + Metalink: repo.Metalink, + MirrorList: repo.Mirrorlist, + CheckGPG: repo.GPGCheck, + CheckRepoGPG: repo.RepoGPGCheck, + Priority: repo.Priority, + ModuleHotfixes: repo.ModuleHotfixes, + Enabled: repo.Enabled, } if repo.SSLVerify != nil { diff --git a/pkg/dnfjson/dnfjson.go b/pkg/dnfjson/dnfjson.go index e5123e2180..9f7394bd0b 100644 --- a/pkg/dnfjson/dnfjson.go +++ b/pkg/dnfjson/dnfjson.go @@ -267,6 +267,7 @@ func (s *Solver) reposFromRPMMD(rpmRepos []rpmmd.RepoConfig) ([]repoConfig, erro MirrorList: rr.MirrorList, GPGKeys: rr.GPGKeys, MetadataExpire: rr.MetadataExpire, + ModuleHotfixes: rr.ModuleHotfixes, repoHash: rr.Hash(), } @@ -294,6 +295,7 @@ func (s *Solver) reposFromRPMMD(rpmRepos []rpmmd.RepoConfig) ([]repoConfig, erro dr.SSLClientKey = secrets.SSLClientKey dr.SSLClientCert = secrets.SSLClientCert } + dnfRepos[idx] = dr } return dnfRepos, nil @@ -315,6 +317,7 @@ type repoConfig struct { SSLClientKey string `json:"sslclientkey,omitempty"` SSLClientCert string `json:"sslclientcert,omitempty"` MetadataExpire string `json:"metadata_expire,omitempty"` + ModuleHotfixes *bool `json:"module_hotfixes"` // set the repo hass from `rpmmd.RepoConfig.Hash()` function // rather than re-calculating it repoHash string diff --git a/pkg/dnfjson/dnfjson_test.go b/pkg/dnfjson/dnfjson_test.go index 75a5ad40b9..517c04d8e0 100644 --- a/pkg/dnfjson/dnfjson_test.go +++ b/pkg/dnfjson/dnfjson_test.go @@ -69,7 +69,7 @@ func TestDepsolver(t *testing.T) { } func TestMakeDepsolveRequest(t *testing.T) { - + trueFlag := true baseOS := rpmmd.RepoConfig{ Name: "baseos", BaseURLs: []string{"https://example.org/baseos"}, @@ -86,6 +86,11 @@ func TestMakeDepsolveRequest(t *testing.T) { Name: "user-repo-2", BaseURLs: []string{"https://example.org/user-repo-2"}, } + moduleHotfixRepo := rpmmd.RepoConfig{ + Name: "module-hotfixes", + BaseURLs: []string{"https://example.org/nginx"}, + ModuleHotfixes: &trueFlag, + } tests := []struct { packageSets []rpmmd.PackageSet args []transactionArgs @@ -373,6 +378,42 @@ func TestMakeDepsolveRequest(t *testing.T) { }, err: true, }, + // module hotfixes flag passed + { + packageSets: []rpmmd.PackageSet{ + { + Include: []string{"pkg1"}, + Repositories: []rpmmd.RepoConfig{baseOS, appstream, moduleHotfixRepo}, + }, + }, + args: []transactionArgs{ + { + PackageSpecs: []string{"pkg1"}, + RepoIDs: []string{baseOS.Hash(), appstream.Hash(), moduleHotfixRepo.Hash()}, + }, + }, + wantRepos: []repoConfig{ + { + ID: baseOS.Hash(), + Name: "baseos", + BaseURLs: []string{"https://example.org/baseos"}, + repoHash: "fdc2e5bb6cda8e113308df9396a005b81a55ec00ec29aa0a447952ad4248d803", + }, + { + ID: appstream.Hash(), + Name: "appstream", + BaseURLs: []string{"https://example.org/appstream"}, + repoHash: "71c280f63a779a8bf53961ec2f15d51d052021de024a4e06ae499b8029701808", + }, + { + ID: moduleHotfixRepo.Hash(), + Name: "module-hotfixes", + BaseURLs: []string{"https://example.org/nginx"}, + ModuleHotfixes: &trueFlag, + repoHash: "6ab05f54094ff2a0ee86facecae3e75e4065a01cc8caffbbbeb7505c6bfac283", + }, + }, + }, } solver := NewSolver("", "", "", "", "") for idx, tt := range tests { diff --git a/pkg/osbuild/yum_repos_stage.go b/pkg/osbuild/yum_repos_stage.go index 297811865e..cf2995e250 100644 --- a/pkg/osbuild/yum_repos_stage.go +++ b/pkg/osbuild/yum_repos_stage.go @@ -99,17 +99,18 @@ func repoConfigToYumRepository(repo rpmmd.RepoConfig) YumRepository { } yumRepo := YumRepository{ - Id: repo.Id, - Name: repo.Name, - Mirrorlist: repo.MirrorList, - Metalink: repo.Metalink, - BaseURLs: urls, - GPGKey: keys, - GPGCheck: repo.CheckGPG, - RepoGPGCheck: repo.CheckRepoGPG, - Enabled: repo.Enabled, - Priority: repo.Priority, - SSLVerify: sslVerify, + Id: repo.Id, + Name: repo.Name, + Mirrorlist: repo.MirrorList, + Metalink: repo.Metalink, + BaseURLs: urls, + GPGKey: keys, + GPGCheck: repo.CheckGPG, + RepoGPGCheck: repo.CheckRepoGPG, + Enabled: repo.Enabled, + Priority: repo.Priority, + SSLVerify: sslVerify, + ModuleHotfixes: repo.ModuleHotfixes, } return yumRepo diff --git a/pkg/rpmmd/repository.go b/pkg/rpmmd/repository.go index 6c879ac9bd..31e4ca0e23 100644 --- a/pkg/rpmmd/repository.go +++ b/pkg/rpmmd/repository.go @@ -23,6 +23,7 @@ type repository struct { CheckGPG bool `json:"check_gpg,omitempty"` IgnoreSSL bool `json:"ignore_ssl,omitempty"` RHSM bool `json:"rhsm,omitempty"` + ModuleHotfixes *bool `json:"module_hotfixes,omitempty"` MetadataExpire string `json:"metadata_expire,omitempty"` ImageTypeTags []string `json:"image_type_tags,omitempty"` } @@ -42,6 +43,7 @@ type RepoConfig struct { Priority *int `json:"priority,omitempty"` IgnoreSSL *bool `json:"ignore_ssl,omitempty"` MetadataExpire string `json:"metadata_expire,omitempty"` + ModuleHotfixes *bool `json:"module_hotfixes,omitempty"` RHSM bool `json:"rhsm,omitempty"` Enabled *bool `json:"enabled,omitempty"` ImageTypeTags []string `json:"image_type_tags,omitempty"` @@ -58,6 +60,12 @@ func (r *RepoConfig) Hash() string { bpts := func(b *bool) string { return fmt.Sprintf("%T", b) } + bptsIgnoreNil := func(b *bool) string { + if b == nil { + return "" + } + return bts(*b) + } ats := func(s []string) string { return strings.Join(s, "") } @@ -69,7 +77,8 @@ func (r *RepoConfig) Hash() string { bpts(r.CheckRepoGPG)+ bpts(r.IgnoreSSL)+ r.MetadataExpire+ - bts(r.RHSM)))) + bts(r.RHSM)+ + bptsIgnoreNil(r.ModuleHotfixes)))) } type DistrosRepoConfigs map[string]map[string][]RepoConfig @@ -264,6 +273,7 @@ func loadRepositoriesFromFile(filename string) (map[string][]RepoConfig, error) CheckGPG: &repo.CheckGPG, RHSM: repo.RHSM, MetadataExpire: repo.MetadataExpire, + ModuleHotfixes: repo.ModuleHotfixes, ImageTypeTags: repo.ImageTypeTags, }