diff --git a/cmd/osbuild-store-dump/main.go b/cmd/osbuild-store-dump/main.go index c2ac01ab30..da8ac7b137 100644 --- a/cmd/osbuild-store-dump/main.go +++ b/cmd/osbuild-store-dump/main.go @@ -24,7 +24,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/weldrtypes" ) -func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d distro.Distro, cacheDir string, repos []rpmmd.RepoConfig) (manifest.OSBuildManifest, []rpmmd.PackageSpec) { +func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d distro.Distro, cacheDir string, repos []rpmmd.RepoConfig) (manifest.OSBuildManifest, rpmmd.PackageList) { manifest, _, err := t.Manifest(&bp, distro.ImageOptions{}, repos, nil) if err != nil { panic(err) @@ -182,7 +182,7 @@ func main() { awsTarget, }, id1, - weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(packages), + weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(packages), ) if err != nil { panic(err) @@ -197,7 +197,7 @@ func main() { awsTarget, }, id2, - weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(packages), + weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(packages), ) if err != nil { panic(err) diff --git a/cmd/osbuild-worker/jobimpl-depsolve.go b/cmd/osbuild-worker/jobimpl-depsolve.go index 71b5cb61b2..97c07d36e1 100644 --- a/cmd/osbuild-worker/jobimpl-depsolve.go +++ b/cmd/osbuild-worker/jobimpl-depsolve.go @@ -59,7 +59,7 @@ type DepsolveJobImpl struct { // in repos are used for all package sets, whereas the repositories in // packageSetsRepos are only used for the package set with the same name // (matching map keys). -func (impl *DepsolveJobImpl) depsolve(packageSets map[string][]rpmmd.PackageSet, modulePlatformID, arch, releasever string, sbomType sbom.StandardType) (map[string][]rpmmd.PackageSpec, map[string][]rpmmd.RepoConfig, map[string]worker.SbomDoc, error) { +func (impl *DepsolveJobImpl) depsolve(packageSets map[string][]rpmmd.PackageSet, modulePlatformID, arch, releasever string, sbomType sbom.StandardType) (map[string]worker.DepsolvedPackageList, map[string][]rpmmd.RepoConfig, map[string]worker.SbomDoc, error) { solver := impl.Solver.NewWithConfig(modulePlatformID, releasever, arch, "") if impl.RepositoryMTLSConfig != nil && impl.RepositoryMTLSConfig.Proxy != nil { err := solver.SetProxy(impl.RepositoryMTLSConfig.Proxy.String()) @@ -68,7 +68,7 @@ func (impl *DepsolveJobImpl) depsolve(packageSets map[string][]rpmmd.PackageSet, } } - depsolvedSets := make(map[string][]rpmmd.PackageSpec) + depsolvedSets := make(map[string]worker.DepsolvedPackageList) repoConfigs := make(map[string][]rpmmd.RepoConfig) var sbomDocs map[string]worker.SbomDoc if sbomType != sbom.StandardTypeNone { @@ -79,7 +79,7 @@ func (impl *DepsolveJobImpl) depsolve(packageSets map[string][]rpmmd.PackageSet, if err != nil { return nil, nil, nil, err } - depsolvedSets[name] = res.Packages + depsolvedSets[name] = worker.DepsolvedPackageListFromRPMMDList(res.Packages) repoConfigs[name] = res.Repos if sbomType != sbom.StandardTypeNone { sbomDocs[name] = worker.SbomDoc(*res.SBOM) diff --git a/go.mod b/go.mod index cc3e3bf245..c05c1611a5 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/oapi-codegen/runtime v1.1.2 github.com/openshift-online/ocm-sdk-go v0.1.478 github.com/osbuild/blueprint v1.16.0 - github.com/osbuild/images v0.202.0 + github.com/osbuild/images v0.204.0 github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d github.com/prometheus/client_golang v1.23.2 github.com/segmentio/ksuid v1.0.4 diff --git a/go.sum b/go.sum index 3483ea52b8..3eeff68bb7 100644 --- a/go.sum +++ b/go.sum @@ -520,8 +520,8 @@ github.com/oracle/oci-go-sdk/v54 v54.0.0 h1:CDLjeSejv2aDpElAJrhKpi6zvT/zhZCZuXch github.com/oracle/oci-go-sdk/v54 v54.0.0/go.mod h1:+t+yvcFGVp+3ZnztnyxqXfQDsMlq8U25faBLa+mqCMc= github.com/osbuild/blueprint v1.16.0 h1:f/kHih+xpeJ1v7wtIfzdHPZTsiXsqKeDQ1+rrue6298= github.com/osbuild/blueprint v1.16.0/go.mod h1:HPlJzkEl7q5g8hzaGksUk7ifFAy9QFw9LmzhuFOAVm4= -github.com/osbuild/images v0.202.0 h1:OPvfmr5RJHcOJgU8Win6kHyoCNQZEiILlgIDI64/YIM= -github.com/osbuild/images v0.202.0/go.mod h1:xkXfw5CIy0bVNTNdB6GXiewu/IzBgpofkItDJPAzGA4= +github.com/osbuild/images v0.204.0 h1:vP/48Y/wqm0uFPXApZpOIJXKc0SAYeqjt1HCaUyUQ5M= +github.com/osbuild/images v0.204.0/go.mod h1:YhhDsTY4IARBvPCrDFqD4tMfiBtwoZ8jC5nPqXfBZ+M= github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d h1:r9BFPDv0uuA9k1947Jybcxs36c/pTywWS1gjeizvtcQ= github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d/go.mod h1:zR1iu/hOuf+OQNJlk70tju9IqzzM4ycq0ectkFBm94U= github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= diff --git a/internal/cloudapi/v2/depsolve.go b/internal/cloudapi/v2/depsolve.go index 41c1d368bd..d253b7c23f 100644 --- a/internal/cloudapi/v2/depsolve.go +++ b/internal/cloudapi/v2/depsolve.go @@ -17,7 +17,7 @@ import ( "github.com/osbuild/osbuild-composer/internal/worker" ) -func (request *DepsolveRequest) Depsolve(df *distrofactory.Factory, rr *reporegistry.RepoRegistry, workers *worker.Server) ([]rpmmd.PackageSpec, error) { +func (request *DepsolveRequest) Depsolve(df *distrofactory.Factory, rr *reporegistry.RepoRegistry, workers *worker.Server) (rpmmd.PackageList, error) { // Convert the requested blueprint to a composer blueprint bp, err := ConvertRequestBP(request.Blueprint) if err != nil { @@ -144,5 +144,6 @@ func (request *DepsolveRequest) Depsolve(df *distrofactory.Factory, rr *reporegi } } - return result.PackageSpecs["os"], nil + packages := result.PackageSpecs["os"].ToRPMMDList() + return packages, nil } diff --git a/internal/cloudapi/v2/handler.go b/internal/cloudapi/v2/handler.go index f9ea63117e..c6f50fe15b 100644 --- a/internal/cloudapi/v2/handler.go +++ b/internal/cloudapi/v2/handler.go @@ -1389,7 +1389,7 @@ func uploadStatusFromJobStatus(js *worker.JobStatus, je *clienterrors.Error) Upl } // PostDepsolveBlueprint depsolves the packages in a blueprint and returns -// the results as a list of rpmmd.PackageSpecs +// the results as a list of rpmmd.PackageList func (h *apiHandlers) PostDepsolveBlueprint(ctx echo.Context) error { var request DepsolveRequest err := ctx.Bind(&request) @@ -1406,14 +1406,14 @@ func (h *apiHandlers) PostDepsolveBlueprint(ctx echo.Context) error { return ctx.JSON(http.StatusOK, DepsolveResponse{ - Packages: packageSpecToPackageMetadata(deps), + Packages: rpmmdPackageToPackageMetadata(deps), }) } -// packageSpecToPackageMetadata converts the rpmmd.PackageSpec to PackageMetadata +// rpmmdPackageToPackageMetadata converts the rpmmd.PackageList to PackageMetadata // This is used to return package information from the blueprint depsolve request // using the common PackageMetadata format from the openapi schema. -func packageSpecToPackageMetadata(pkgspecs []rpmmd.PackageSpec) []PackageMetadataCommon { +func rpmmdPackageToPackageMetadata(pkgspecs rpmmd.PackageList) []PackageMetadataCommon { packages := make([]PackageMetadataCommon, 0) for _, rpm := range pkgspecs { // Set epoch if it is not 0 @@ -1430,7 +1430,7 @@ func packageSpecToPackageMetadata(pkgspecs []rpmmd.PackageSpec) []PackageMetadat Release: rpm.Release, Epoch: epoch, Arch: rpm.Arch, - Checksum: common.ToPtr(rpm.Checksum), + Checksum: common.ToPtr(rpm.Checksum.String()), }, ) } diff --git a/internal/cloudapi/v2/server.go b/internal/cloudapi/v2/server.go index 86528db6f2..13b483eae1 100644 --- a/internal/cloudapi/v2/server.go +++ b/internal/cloudapi/v2/server.go @@ -683,7 +683,7 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w depsolveResultsInTheRightFormat := map[string]depsolvednf.DepsolveResult{} for plName, res := range depsolveResults.PackageSpecs { r := depsolveResultsInTheRightFormat[plName] - r.Packages = res + r.Packages = res.ToRPMMDList() depsolveResultsInTheRightFormat[plName] = r } for plName, res := range depsolveResults.RepoConfigs { diff --git a/internal/cloudapi/v2/v2_multi_tenancy_test.go b/internal/cloudapi/v2/v2_multi_tenancy_test.go index b62c39cb87..a00d652e74 100644 --- a/internal/cloudapi/v2/v2_multi_tenancy_test.go +++ b/internal/cloudapi/v2/v2_multi_tenancy_test.go @@ -16,7 +16,6 @@ import ( "github.com/osbuild/osbuild-composer/pkg/jobqueue" "github.com/osbuild/images/pkg/distro/test_distro" - "github.com/osbuild/images/pkg/rpmmd" v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2" "github.com/osbuild/osbuild-composer/internal/test" "github.com/osbuild/osbuild-composer/internal/worker" @@ -180,16 +179,19 @@ func runNextJob(t *testing.T, jobs []uuid.UUID, workerServer *worker.Server, org // the manifest generation job would fail on empty depsolved package list. // This would make the ComposeManifests endpoint return an error. case worker.JobTypeDepsolve: - dummyPackage := rpmmd.PackageSpec{ - Name: "pkg1", - Version: "1.33", - Release: "2.fc30", - Arch: "x86_64", - Checksum: "sha256:e50ddb78a37f5851d1a5c37a4c77d59123153c156e628e064b9daa378f45a2fe", - RemoteLocation: "https://pkg1.example.com/1.33-2.fc30.x86_64.rpm", + dummyPackage := worker.DepsolvedPackage{ + Name: "pkg1", + Version: "1.33", + Release: "2.fc30", + Arch: "x86_64", + Checksum: &worker.DepsolvedPackageChecksum{ + Type: "sha256", + Value: "e50ddb78a37f5851d1a5c37a4c77d59123153c156e628e064b9daa378f45a2fe", + }, + RemoteLocations: []string{"https://pkg1.example.com/1.33-2.fc30.x86_64.rpm"}, } depsolveJobResult := &worker.DepsolveJobResult{ - PackageSpecs: map[string][]rpmmd.PackageSpec{ + PackageSpecs: map[string]worker.DepsolvedPackageList{ // Used when depsolving a manifest "build": {dummyPackage}, "os": {dummyPackage}, diff --git a/internal/cloudapi/v2/v2_test.go b/internal/cloudapi/v2/v2_test.go index 8ff48abd85..50ee3084c4 100644 --- a/internal/cloudapi/v2/v2_test.go +++ b/internal/cloudapi/v2/v2_test.go @@ -92,16 +92,19 @@ func mockDepsolve(t *testing.T, workerServer *worker.Server, wg *sync.WaitGroup, if err != nil { continue } - dummyPackage := rpmmd.PackageSpec{ - Name: "pkg1", - Version: "1.33", - Release: "2.fc30", - Arch: "x86_64", - Checksum: "sha256:e50ddb78a37f5851d1a5c37a4c77d59123153c156e628e064b9daa378f45a2fe", - RemoteLocation: "https://pkg1.example.com/1.33-2.fc30.x86_64.rpm", + dummyPackage := worker.DepsolvedPackage{ + Name: "pkg1", + Version: "1.33", + Release: "2.fc30", + Arch: "x86_64", + Checksum: &worker.DepsolvedPackageChecksum{ + Type: "sha256", + Value: "e50ddb78a37f5851d1a5c37a4c77d59123153c156e628e064b9daa378f45a2fe", + }, + RemoteLocations: []string{"https://pkg1.example.com/1.33-2.fc30.x86_64.rpm"}, } dJR := &worker.DepsolveJobResult{ - PackageSpecs: map[string][]rpmmd.PackageSpec{ + PackageSpecs: map[string]worker.DepsolvedPackageList{ // Used when depsolving a manifest "build": {dummyPackage}, "os": {dummyPackage}, diff --git a/internal/mocks/depsolvednf/mock_data.go b/internal/mocks/depsolvednf/mock_data.go index ffe2ba9460..01f1f3b8e2 100644 --- a/internal/mocks/depsolvednf/mock_data.go +++ b/internal/mocks/depsolvednf/mock_data.go @@ -86,9 +86,9 @@ func BaseSearchResultsMap() map[string]rpmmd.PackageList { } } -// BaseDepsolveResult is the expected list of dependencies (as rpmmd.PackageSpec) from -func BaseDepsolveResult(repoID string) []rpmmd.PackageSpec { - return []rpmmd.PackageSpec{ +// BaseDepsolveResult is the expected list of dependencies (as rpmmd.PackageList) from +func BaseDepsolveResult(repoID string) rpmmd.PackageList { + return rpmmd.PackageList{ { Name: "dep-package3", Epoch: 7, @@ -96,8 +96,14 @@ func BaseDepsolveResult(repoID string) []rpmmd.PackageSpec { Release: "1.fc30", Arch: "x86_64", CheckGPG: true, - Checksum: "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - RepoID: repoID, + Checksum: rpmmd.Checksum{ + Type: "sha256", + Value: "62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", + }, + RemoteLocations: []string{ + "https://pkg3.example.com/3.0.3-1.fc30.x86_64.rpm", + }, + RepoID: repoID, }, { Name: "dep-package1", @@ -106,8 +112,14 @@ func BaseDepsolveResult(repoID string) []rpmmd.PackageSpec { Release: "2.fc30", Arch: "x86_64", CheckGPG: true, - Checksum: "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - RepoID: repoID, + Checksum: rpmmd.Checksum{ + Type: "sha256", + Value: "fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", + }, + RemoteLocations: []string{ + "https://pkg1.example.com/1.33-2.fc30.x86_64.rpm", + }, + RepoID: repoID, }, { Name: "dep-package2", @@ -116,8 +128,14 @@ func BaseDepsolveResult(repoID string) []rpmmd.PackageSpec { Release: "1.fc30", Arch: "x86_64", CheckGPG: true, - Checksum: "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - RepoID: repoID, + Checksum: rpmmd.Checksum{ + Type: "sha256", + Value: "5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", + }, + RemoteLocations: []string{ + "https://pkg2.example.com/2.9-1.fc30.x86_64.rpm", + }, + RepoID: repoID, }, } } diff --git a/internal/weldr/api.go b/internal/weldr/api.go index 397faef7ca..c10f43075f 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -1113,7 +1113,7 @@ func (api *API) modulesListHandler(writer http.ResponseWriter, request *http.Req return } - packageInfos := packages.ToPackageInfos() + packageInfos := RPMMDPackageListToPackageInfos(packages) total := uint(len(packageInfos)) start := min(offset, total) @@ -1313,7 +1313,7 @@ func (api *API) modulesInfoHandler(writer http.ResponseWriter, request *http.Req statusResponseError(writer, http.StatusBadRequest, errors) return } - packageInfos[i].Dependencies = weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(res.Packages) + packageInfos[i].Dependencies = weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(res.Packages) } if err := solver.CleanCache(); err != nil { // log and ignore @@ -1404,7 +1404,7 @@ func (api *API) projectsDepsolveHandler(writer http.ResponseWriter, request *htt // log and ignore log.Printf("Error during rpm repo cache cleanup: %s", err.Error()) } - err = json.NewEncoder(writer).Encode(reply{Projects: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(res.Packages)}) + err = json.NewEncoder(writer).Encode(reply{Projects: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(res.Packages)}) common.PanicOnError(err) } @@ -1548,8 +1548,8 @@ func (api *API) blueprintsDepsolveHandler(writer http.ResponseWriter, request *h } type entry struct { - Blueprint blueprint.Blueprint `json:"blueprint"` - Dependencies []rpmmd.PackageSpec `json:"dependencies"` + Blueprint blueprint.Blueprint `json:"blueprint"` + Dependencies []weldrtypes.DepsolvedPackageInfo `json:"dependencies"` } type reply struct { Blueprints []entry `json:"blueprints"` @@ -1593,7 +1593,7 @@ func (api *API) blueprintsDepsolveHandler(writer http.ResponseWriter, request *h ID: "BlueprintsError", Msg: fmt.Sprintf("%s: %s", name, err.Error()), }) - dependencies = []rpmmd.PackageSpec{} + dependencies = []weldrtypes.DepsolvedPackageInfo{} } blueprints = append(blueprints, entry{*blueprint, dependencies}) @@ -1609,7 +1609,7 @@ func (api *API) blueprintsDepsolveHandler(writer http.ResponseWriter, request *h // expandBlueprintGlobs will expand package name globs and versions using the depsolve results // The result is a sorted list of Package structs with the full package name and version // It will return an error if it cannot find a non-glob package name in the dependency list -func expandBlueprintGlobs(dependencies []rpmmd.PackageSpec, packages []blueprint.Package) ([]blueprint.Package, error) { +func expandBlueprintGlobs(dependencies []weldrtypes.DepsolvedPackageInfo, packages []blueprint.Package) ([]blueprint.Package, error) { newPackages := make(map[string]blueprint.Package) for _, pkg := range packages { @@ -1622,9 +1622,9 @@ func expandBlueprintGlobs(dependencies []rpmmd.PackageSpec, packages []blueprint // Packages should not be missing from the depsolve results return nil, fmt.Errorf("%s missing from depsolve results", pkg.Name) } - newPackages[dependencies[i].GetNEVRA()] = blueprint.Package{ + newPackages[dependencies[i].NEVRA()] = blueprint.Package{ Name: dependencies[i].Name, - Version: dependencies[i].GetEVRA(), + Version: dependencies[i].EVRA(), } } else { // Add all the packages matching the glob @@ -1635,9 +1635,9 @@ func expandBlueprintGlobs(dependencies []rpmmd.PackageSpec, packages []blueprint for _, d := range dependencies { if g.Match(d.Name) { - newPackages[d.GetNEVRA()] = blueprint.Package{ + newPackages[d.NEVRA()] = blueprint.Package{ Name: d.Name, - Version: d.GetEVRA(), + Version: d.EVRA(), } } } @@ -2637,7 +2637,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request return } - var packages []rpmmd.PackageSpec + var packages rpmmd.PackageList // TODO: introduce a way to query these from the manifest / image type // BUG: installer/container image types will have empty package sets if packages = depsolved["packages"].Packages; len(packages) == 0 { @@ -2665,7 +2665,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request return } - weldrPackages := weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(packages) + weldrPackages := weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(packages) if testMode == "1" { // Create a failed compose err = api.store.PushTestCompose(composeID, mf, imageType, bp, size, targets, false, weldrPackages) @@ -3612,7 +3612,7 @@ func (api *API) allRepositories(distroName, arch string) ([]rpmmd.RepoConfig, er return repos, nil } -func (api *API) depsolveBlueprint(bp blueprint.Blueprint) ([]rpmmd.PackageSpec, error) { +func (api *API) depsolveBlueprint(bp blueprint.Blueprint) ([]weldrtypes.DepsolvedPackageInfo, error) { // Depsolve using the host distro if none has been specified if bp.Distro == "" { bp.Distro = api.hostDistroName @@ -3642,7 +3642,7 @@ func (api *API) depsolveBlueprint(bp blueprint.Blueprint) ([]rpmmd.PackageSpec, // log and ignore log.Printf("Error during rpm repo cache cleanup: %s", err.Error()) } - return res.Packages, nil + return weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(res.Packages), nil } func (api *API) uploadsScheduleHandler(writer http.ResponseWriter, request *http.Request, params httprouter.Params) { diff --git a/internal/weldr/api_test.go b/internal/weldr/api_test.go index 8faaa4bd3e..d3c55e4a13 100644 --- a/internal/weldr/api_test.go +++ b/internal/weldr/api_test.go @@ -1072,7 +1072,7 @@ func TestCompose(t *testing.T) { }, }, }, - Packages: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), + Packages: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), } expectedComposeLocalAndAws := &weldrtypes.Compose{ @@ -1119,7 +1119,7 @@ func TestCompose(t *testing.T) { }, }, }, - Packages: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), + Packages: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), } expectedComposeOSTree := &weldrtypes.Compose{ @@ -1149,7 +1149,7 @@ func TestCompose(t *testing.T) { }, }, }, - Packages: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), + Packages: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), } ostreeOptionsOther := ostree.ImageOptions{ImageRef: otherRef, URL: ostreeRepoOther.Server.URL} @@ -1187,7 +1187,7 @@ func TestCompose(t *testing.T) { }, }, }, - Packages: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), + Packages: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), } // For 2nd distribution @@ -1232,7 +1232,7 @@ func TestCompose(t *testing.T) { }, }, }, - Packages: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID2)), + Packages: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID2)), } getSolverFn := getBaseMockDepsolveDNFSolverFn(testRepoID) @@ -2065,14 +2065,14 @@ func TestProjectsDepsolve(t *testing.T) { getBaseMockDepsolveDNFSolverFn(testRepoID), "/api/v0/projects/depsolve/fish", http.StatusOK, - fmt.Sprintf(`{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720","check_gpg":true,"repo_id":"%[1]s"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893","check_gpg":true,"repo_id":"%[1]s"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2","check_gpg":true,"repo_id":"%[1]s"}]}`, testRepoID), + fmt.Sprintf(`{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720","check_gpg":true,"remote_location":"https://pkg3.example.com/3.0.3-1.fc30.x86_64.rpm","repo_id":"%[1]s"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893","check_gpg":true,"remote_location":"https://pkg1.example.com/1.33-2.fc30.x86_64.rpm","repo_id":"%[1]s"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2","check_gpg":true,"remote_location":"https://pkg2.example.com/2.9-1.fc30.x86_64.rpm","repo_id":"%[1]s"}]}`, testRepoID), }, { rpmmd_mock.BaseFixture, getBaseMockDepsolveDNFSolverFn(testRepoID2), "/api/v0/projects/depsolve/fish?distro=test-distro-2", http.StatusOK, - fmt.Sprintf(`{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720","check_gpg":true,"repo_id":"%[1]s"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893","check_gpg":true,"repo_id":"%[1]s"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2","check_gpg":true,"repo_id":"%[1]s"}]}`, testRepoID2), + fmt.Sprintf(`{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720","check_gpg":true,"remote_location":"https://pkg3.example.com/3.0.3-1.fc30.x86_64.rpm","repo_id":"%[1]s"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893","check_gpg":true,"remote_location":"https://pkg1.example.com/1.33-2.fc30.x86_64.rpm","repo_id":"%[1]s"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2","check_gpg":true,"remote_location":"https://pkg2.example.com/2.9-1.fc30.x86_64.rpm","repo_id":"%[1]s"}]}`, testRepoID2), }, { rpmmd_mock.BadDepsolve, @@ -2544,7 +2544,7 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) { }, }, }, - Packages: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), + Packages: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), } expectedComposeLocal2 := &weldrtypes.Compose{ @@ -2574,7 +2574,7 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) { }, }, }, - Packages: weldrtypes.RPMMDPackageSpecListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), + Packages: weldrtypes.RPMMDPackageListToDepsolvedPackageInfoList(depsolvednf_mock.BaseDepsolveResult(testRepoID)), } var cases = []struct { @@ -2732,7 +2732,7 @@ func TestExpandBlueprintNoGlob(t *testing.T) { {Name: "grub2", Version: "*"}, } // Sorted list of dependencies - dependencies := []rpmmd.PackageSpec{ + dependencies := []weldrtypes.DepsolvedPackageInfo{ { Name: "grub2", Epoch: 1, @@ -2773,7 +2773,7 @@ func TestExpandBlueprintError(t *testing.T) { {Name: "dep-package0", Version: "*"}, } // Sorted list of dependencies - dependencies := []rpmmd.PackageSpec{ + dependencies := []weldrtypes.DepsolvedPackageInfo{ { Name: "openssh-server", Epoch: 0, @@ -2802,7 +2802,7 @@ func TestExpandBlueprintGlobs(t *testing.T) { {Name: "test-*", Version: "*"}, } // Sorted list of dependencies - dependencies := []rpmmd.PackageSpec{ + dependencies := []weldrtypes.DepsolvedPackageInfo{ { Name: "openssh-clients", Epoch: 0, diff --git a/internal/weldr/json.go b/internal/weldr/json.go index aaebe2ae22..e21a31635b 100644 --- a/internal/weldr/json.go +++ b/internal/weldr/json.go @@ -73,8 +73,8 @@ type BlueprintsDepsolveV0 struct { Errors []ResponseError `json:"errors"` } type depsolveEntry struct { - Blueprint blueprint.Blueprint `json:"blueprint"` - Dependencies []rpmmd.PackageSpec `json:"dependencies"` + Blueprint blueprint.Blueprint `json:"blueprint"` + Dependencies []weldrtypes.DepsolvedPackageInfo `json:"dependencies"` } // BlueprintsFreezeV0 is the response to /blueprints/freeze/ request diff --git a/internal/weldr/responses_test.go b/internal/weldr/responses_test.go index c88bf9738f..f14ba35fd4 100644 --- a/internal/weldr/responses_test.go +++ b/internal/weldr/responses_test.go @@ -70,36 +70,15 @@ const freezeTestResponse = ` } ` -const depsolveTestResponse = ` -{ - "blueprints": [ - { - "blueprint": { - "name": "test", - "description": "Test", - "version": "0.0.1", - "packages": [ - { - "name": "dep-package1", - "version": "*" - } - ], - "enabled_modules": [], - "groups": [], - "modules": [ - { - "name": "dep-package3", - "version": "*" - } - ] - }, - "dependencies": [ +func depsolveDependenciesPartialResponse(repoID string) string { + return fmt.Sprintf(`[ { "name": "dep-package3", "epoch": 7, "version": "3.0.3", "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", + "remote_location": "https://pkg3.example.com/3.0.3-1.fc30.x86_64.rpm", + "repo_id": "%[1]s", "arch": "x86_64", "check_gpg": true, "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720" @@ -109,7 +88,8 @@ const depsolveTestResponse = ` "epoch": 0, "version": "1.33", "release": "2.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", + "remote_location": "https://pkg1.example.com/1.33-2.fc30.x86_64.rpm", + "repo_id": "%[1]s", "arch": "x86_64", "check_gpg": true, "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893" @@ -119,17 +99,45 @@ const depsolveTestResponse = ` "epoch": 0, "version": "2.9", "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", + "remote_location": "https://pkg2.example.com/2.9-1.fc30.x86_64.rpm", + "repo_id": "%[1]s", "arch": "x86_64", "check_gpg": true, "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2" } ] +`, repoID) +} + +var depsolveTestResponse = fmt.Sprintf(` +{ + "blueprints": [ + { + "blueprint": { + "name": "test", + "description": "Test", + "version": "0.0.1", + "packages": [ + { + "name": "dep-package1", + "version": "*" + } + ], + "enabled_modules": [], + "groups": [], + "modules": [ + { + "name": "dep-package3", + "version": "*" + } + ] + }, + "dependencies": %s } ], "errors": [] } -` +`, depsolveDependenciesPartialResponse(testRepoID)) var depsolvePackageNotExistErrorAPIResponse = fmt.Sprintf(` { @@ -1363,7 +1371,7 @@ const projectsInfoPackage16Response = ` } ` -const modulesInfoResponse = ` +var modulesInfoResponse = fmt.Sprintf(` { "modules": [ { @@ -1406,38 +1414,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package1", @@ -1479,38 +1456,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package10", @@ -1552,38 +1498,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package11", @@ -1625,38 +1540,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package12", @@ -1698,38 +1582,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package13", @@ -1771,38 +1624,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package14", @@ -1844,38 +1666,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package15", @@ -1917,38 +1708,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package16", @@ -1990,46 +1750,15 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] - }, - { - "name": "package17", - "summary": "pkg17 sum", - "description": "pkg17 desc", - "homepage": "https://pkg17.example.com", - "upstream_vcs": "UPSTREAM_VCS", - "builds": [ + "dependencies": %[1]s + }, + { + "name": "package17", + "summary": "pkg17 sum", + "description": "pkg17 desc", + "homepage": "https://pkg17.example.com", + "upstream_vcs": "UPSTREAM_VCS", + "builds": [ { "arch": "x86_64", "build_time": "2007-06-02T15:04:05", @@ -2063,38 +1792,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package18", @@ -2136,38 +1834,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package19", @@ -2209,38 +1876,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package2", @@ -2282,38 +1918,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package20", @@ -2355,38 +1960,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package21", @@ -2428,38 +2002,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package3", @@ -2501,38 +2044,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package4", @@ -2574,38 +2086,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package5", @@ -2647,38 +2128,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package6", @@ -2720,38 +2170,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package7", @@ -2793,38 +2212,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package8", @@ -2866,38 +2254,7 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s }, { "name": "package9", @@ -2939,44 +2296,13 @@ const modulesInfoResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "arch": "x86_64", - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "arch": "x86_64", - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2", - "check_gpg": true, - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e" - } - ] + "dependencies": %[1]s } ] } -` +`, depsolveDependenciesPartialResponse(testRepoID)) -const modulesInfoFilteredResponse = ` +var modulesInfoFilteredResponse = fmt.Sprintf(` { "modules": [ { @@ -3019,38 +2345,7 @@ const modulesInfoFilteredResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2" - } - ] + "dependencies": %[1]s }, { "name": "package2", @@ -3092,38 +2387,7 @@ const modulesInfoFilteredResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2" - } - ] + "dependencies": %[1]s }, { "name": "package20", @@ -3165,38 +2429,7 @@ const modulesInfoFilteredResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2" - } - ] + "dependencies": %[1]s }, { "name": "package21", @@ -3238,44 +2471,13 @@ const modulesInfoFilteredResponse = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "repo_id": "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2" - } - ] + "dependencies": %[1]s } ] } -` +`, depsolveDependenciesPartialResponse(testRepoID)) -const modulesInfoPackage16Response = ` +var modulesInfoPackage16Response = fmt.Sprintf(` { "modules": [ { @@ -3318,42 +2520,11 @@ const modulesInfoPackage16Response = ` "metadata": {} } ], - "dependencies": [ - { - "name": "dep-package3", - "epoch": 7, - "version": "3.0.3", - "release": "1.fc30", - "repo_id": "0a99a351a0031411571ddfacc8a131862cfc389d5516400d0cdbc9340a6ec423", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720" - }, - { - "name": "dep-package1", - "epoch": 0, - "version": "1.33", - "release": "2.fc30", - "repo_id": "0a99a351a0031411571ddfacc8a131862cfc389d5516400d0cdbc9340a6ec423", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893" - }, - { - "name": "dep-package2", - "epoch": 0, - "version": "2.9", - "release": "1.fc30", - "repo_id": "0a99a351a0031411571ddfacc8a131862cfc389d5516400d0cdbc9340a6ec423", - "arch": "x86_64", - "check_gpg": true, - "checksum": "sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2" - } - ] + "dependencies": %s } ] } -` +`, depsolveDependenciesPartialResponse(testRepoID2)) const projectsListResponse = ` { diff --git a/internal/weldrtypes/package.go b/internal/weldrtypes/package.go index 3456ee2f8f..9e75f477b6 100644 --- a/internal/weldrtypes/package.go +++ b/internal/weldrtypes/package.go @@ -1,6 +1,10 @@ package weldrtypes -import "github.com/osbuild/images/pkg/rpmmd" +import ( + "fmt" + + "github.com/osbuild/images/pkg/rpmmd" +) // DepsolvedPackageInfo is the API representation of a package that has been depsolved. type DepsolvedPackageInfo struct { @@ -24,27 +28,41 @@ type DepsolvedPackageInfo struct { RepoID string `json:"repo_id,omitempty"` } -func RPMMDPackageSpecToDepsolvedPackageInfo(pkg rpmmd.PackageSpec) DepsolvedPackageInfo { - return DepsolvedPackageInfo{ - Name: pkg.Name, - Epoch: pkg.Epoch, - Version: pkg.Version, - Release: pkg.Release, - Arch: pkg.Arch, - RemoteLocation: pkg.RemoteLocation, - Checksum: pkg.Checksum, - Secrets: pkg.Secrets, - CheckGPG: pkg.CheckGPG, - IgnoreSSL: pkg.IgnoreSSL, - Path: pkg.Path, - RepoID: pkg.RepoID, +func (d DepsolvedPackageInfo) EVRA() string { + if d.Epoch == 0 { + return fmt.Sprintf("%s-%s.%s", d.Version, d.Release, d.Arch) + } + return fmt.Sprintf("%d:%s-%s.%s", d.Epoch, d.Version, d.Release, d.Arch) +} + +func (d DepsolvedPackageInfo) NEVRA() string { + return fmt.Sprintf("%s-%s", d.Name, d.EVRA()) +} + +func RPMMDPackageToDepsolvedPackageInfo(pkg rpmmd.Package) DepsolvedPackageInfo { + p := DepsolvedPackageInfo{ + Name: pkg.Name, + Epoch: pkg.Epoch, + Version: pkg.Version, + Release: pkg.Release, + Arch: pkg.Arch, + Checksum: pkg.Checksum.String(), + Secrets: pkg.Secrets, + CheckGPG: pkg.CheckGPG, + IgnoreSSL: pkg.IgnoreSSL, + Path: pkg.Location, + RepoID: pkg.RepoID, + } + if len(pkg.RemoteLocations) > 0 { + p.RemoteLocation = pkg.RemoteLocations[0] } + return p } -func RPMMDPackageSpecListToDepsolvedPackageInfoList(pkgs []rpmmd.PackageSpec) []DepsolvedPackageInfo { +func RPMMDPackageListToDepsolvedPackageInfoList(pkgs rpmmd.PackageList) []DepsolvedPackageInfo { results := make([]DepsolvedPackageInfo, len(pkgs)) for i, pkg := range pkgs { - results[i] = RPMMDPackageSpecToDepsolvedPackageInfo(pkg) + results[i] = RPMMDPackageToDepsolvedPackageInfo(pkg) } return results } diff --git a/internal/weldrtypes/package_test.go b/internal/weldrtypes/package_test.go new file mode 100644 index 0000000000..76e67c0f35 --- /dev/null +++ b/internal/weldrtypes/package_test.go @@ -0,0 +1,34 @@ +package weldrtypes + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +var packageList = []DepsolvedPackageInfo{ + { + Name: "tmux", + Epoch: 0, + Version: "3.3a", + Release: "3.fc38", + Arch: "x86_64", + }, + { + Name: "grub2", + Epoch: 1, + Version: "2.06", + Release: "94.fc38", + Arch: "noarch", + }, +} + +func TestDepsolvedPackageInfoGetEVRA(t *testing.T) { + require.Equal(t, "3.3a-3.fc38.x86_64", packageList[0].EVRA()) + require.Equal(t, "1:2.06-94.fc38.noarch", packageList[1].EVRA()) +} + +func TestDepsolvedPackageInfoGetNEVRA(t *testing.T) { + require.Equal(t, "tmux-3.3a-3.fc38.x86_64", packageList[0].NEVRA()) + require.Equal(t, "grub2-1:2.06-94.fc38.noarch", packageList[1].NEVRA()) +} diff --git a/internal/worker/json.go b/internal/worker/json.go index 24af557d8a..b463ccf430 100644 --- a/internal/worker/json.go +++ b/internal/worker/json.go @@ -2,12 +2,16 @@ package worker import ( "encoding/json" + "fmt" "runtime/debug" + "strings" + "time" "github.com/osbuild/images/pkg/manifest" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/images/pkg/sbom" + "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" "golang.org/x/exp/slices" @@ -180,7 +184,7 @@ func (pn *PipelineNames) All() []string { // DepsolveJob defines the parameters of one or more depsolve jobs. Each named // list of package sets defines a separate job. Lists with multiple package // sets are depsolved in a chain, combining the results of sequential depsolves -// into a single PackageSpec list in the result. Each PackageSet defines the +// into a single PackageList in the result. Each PackageSet defines the // repositories it will be depsolved against. type DepsolveJob struct { PackageSets map[string][]rpmmd.PackageSet `json:"grouped_package_sets"` @@ -199,10 +203,385 @@ type SbomDoc struct { Document json.RawMessage `json:"document"` } +type DepsolvedPackageChecksum struct { + Type string `json:"type"` + Value string `json:"value"` +} + +func (c *DepsolvedPackageChecksum) UnmarshalJSON(data []byte) error { + var rawChecksum interface{} + err := json.Unmarshal(data, &rawChecksum) + if err != nil { + return err + } + switch rawChecksum := rawChecksum.(type) { + case nil: + // explicit "checksum": null, leave it as nil. This should not happen, but it is better to be safe. + case string: + checksumParts := strings.Split(rawChecksum, ":") + if len(checksumParts) != 2 { + return fmt.Errorf("invalid checksum format: %q", rawChecksum) + } + *c = DepsolvedPackageChecksum{ + Type: checksumParts[0], + Value: checksumParts[1], + } + case map[string]interface{}: + if _, ok := rawChecksum["type"]; !ok { + return fmt.Errorf("checksum type is required, got %+v", rawChecksum) + } + if _, ok := rawChecksum["value"]; !ok { + return fmt.Errorf("checksum value is required, got %+v", rawChecksum) + } + *c = DepsolvedPackageChecksum{ + Type: rawChecksum["type"].(string), + Value: rawChecksum["value"].(string), + } + default: + return fmt.Errorf("unsupported checksum type: %T", rawChecksum) + } + + return nil +} + +func (c *DepsolvedPackageChecksum) MarshalJSON() ([]byte, error) { + if c == nil { + return json.Marshal(nil) + } + // For backward compatibility reason, keep the string representation of the checksum. + // TODO: switch to the struct after a few releases. (added on 2025-10-08) + return json.Marshal(fmt.Sprintf("%s:%s", c.Type, c.Value)) +} + +type DepsolvedPackageRelDep struct { + Name string `json:"name"` + Relationship string `json:"relationship,omitempty"` + Version string `json:"version,omitempty"` +} + +type DepsolvedPackageRelDepList []DepsolvedPackageRelDep + +func (d DepsolvedPackageRelDepList) ToRPMMDList() rpmmd.RelDepList { + results := make(rpmmd.RelDepList, len(d)) + for i, relDep := range d { + results[i] = rpmmd.RelDep(relDep) + } + return results +} + +func DepsolvedPackageRelDepListFromRPMMDList(relDeps rpmmd.RelDepList) DepsolvedPackageRelDepList { + results := make(DepsolvedPackageRelDepList, len(relDeps)) + for i, relDep := range relDeps { + results[i] = DepsolvedPackageRelDep(relDep) + } + return results +} + +// DepsolvedPackage is the DTO for rpmmd.Package. +type DepsolvedPackage struct { + Name string `json:"name"` + Epoch uint `json:"epoch"` + Version string `json:"version,omitempty"` + Release string `json:"release,omitempty"` + Arch string `json:"arch,omitempty"` + + Group string `json:"group,omitempty"` + + DownloadSize uint64 `json:"download_size,omitempty"` + InstallSize uint64 `json:"install_size,omitempty"` + + License string `json:"license,omitempty"` + SourceRpm string `json:"source_rpm,omitempty"` + + BuildTime *time.Time `json:"build_time,omitempty"` + Packager string `json:"packager,omitempty"` + Vendor string `json:"vendor,omitempty"` + + URL string `json:"url,omitempty"` + + Summary string `json:"summary,omitempty"` + Description string `json:"description,omitempty"` + + Provides DepsolvedPackageRelDepList `json:"provides,omitempty"` + Requires DepsolvedPackageRelDepList `json:"requires,omitempty"` + RequiresPre DepsolvedPackageRelDepList `json:"requires_pre,omitempty"` + Conflicts DepsolvedPackageRelDepList `json:"conflicts,omitempty"` + Obsoletes DepsolvedPackageRelDepList `json:"obsoletes,omitempty"` + RegularRequires DepsolvedPackageRelDepList `json:"regular_requires,omitempty"` + + Recommends DepsolvedPackageRelDepList `json:"recommends,omitempty"` + Suggests DepsolvedPackageRelDepList `json:"suggests,omitempty"` + Enhances DepsolvedPackageRelDepList `json:"enhances,omitempty"` + Supplements DepsolvedPackageRelDepList `json:"supplements,omitempty"` + + Files []string `json:"files,omitempty"` + + BaseURL string `json:"base_url,omitempty"` + Location string `json:"location,omitempty"` + RemoteLocations []string `json:"remote_locations,omitempty"` + + Checksum *DepsolvedPackageChecksum `json:"checksum,omitempty"` + HeaderChecksum *DepsolvedPackageChecksum `json:"header_checksum,omitempty"` + + RepoID string `json:"repo_id,omitempty"` + + Reason string `json:"reason,omitempty"` + + Secrets string `json:"secrets,omitempty"` + CheckGPG bool `json:"check_gpg,omitempty"` + IgnoreSSL bool `json:"ignore_ssl,omitempty"` +} + +// UnmarshalJSON is used to unmarshal the DepsolvedPackage from JSON. +// This handles the case when old composer-worker and new composer-worker-server +// are used. +func (d *DepsolvedPackage) UnmarshalJSON(data []byte) error { + type aliasType DepsolvedPackage + type compatType struct { + aliasType + + // TODO: remove this after a few releases (added on 2025-10-08) + // The type was changed to rpmmd.Package, but the fields were kept for backwards compatibility. + /* Legacy type before the rpmmd RPM package consolidation + + type DepsolvedPackage struct { + Name string `json:"name"` + Epoch uint `json:"epoch"` + Version string `json:"version,omitempty"` + Release string `json:"release,omitempty"` + Arch string `json:"arch,omitempty"` + RemoteLocation string `json:"remote_location,omitempty"` + Checksum string `json:"checksum,omitempty"` + Secrets string `json:"secrets,omitempty"` + CheckGPG bool `json:"check_gpg,omitempty"` + IgnoreSSL bool `json:"ignore_ssl,omitempty"` + + Path string `json:"path,omitempty"` + RepoID string `json:"repo_id,omitempty"` + } + + */ + // Path is now called Location in rpmmd.Package. + Path string `json:"path,omitempty"` // obsolete + // RemoteLocation is now called RemoteLocations in rpmmd.Package and is a slice. + RemoteLocation string `json:"remote_location,omitempty"` // obsolete + } + + var compat compatType + err := json.Unmarshal(data, &compat) + if err != nil { + return err + } + + // Handle Path vs. Location. + if compat.aliasType.Location == "" && compat.Path != "" { + compat.aliasType.Location = compat.Path + } + // Handle RemoteLocation vs. RemoteLocations. + if compat.aliasType.RemoteLocations == nil && compat.RemoteLocation != "" { + compat.aliasType.RemoteLocations = []string{compat.RemoteLocation} + } + + *d = DepsolvedPackage(compat.aliasType) + + return nil +} + +// MarshalJSON is used to marshal the DepsolvedPackage to JSON. +// This handles the case when old composer-worker-server and new composer-worker +// are used. +func (d DepsolvedPackage) MarshalJSON() ([]byte, error) { + type aliasType DepsolvedPackage + type compatType struct { + aliasType + + // TODO: remove this after a few releases (added on 2025-10-08) + // The type was changed to rpmmd.Package, but the fields were kept for backwards compatibility. + /* Legacy type before the rpmmd RPM package consolidation + + type DepsolvedPackage struct { + Name string `json:"name"` + Epoch uint `json:"epoch"` + Version string `json:"version,omitempty"` + Release string `json:"release,omitempty"` + Arch string `json:"arch,omitempty"` + RemoteLocation string `json:"remote_location,omitempty"` + Checksum string `json:"checksum,omitempty"` + Secrets string `json:"secrets,omitempty"` + CheckGPG bool `json:"check_gpg,omitempty"` + IgnoreSSL bool `json:"ignore_ssl,omitempty"` + + Path string `json:"path,omitempty"` + RepoID string `json:"repo_id,omitempty"` + } + + */ + // Path is now called Location in rpmmd.Package. + Path string `json:"path,omitempty"` // obsolete + // RemoteLocation is now called RemoteLocations in rpmmd.Package and is a slice. + RemoteLocation string `json:"remote_location,omitempty"` // obsolete + } + + var compat compatType + compat.aliasType = aliasType(d) + + // Handle Path vs. Location. + compat.Path = compat.aliasType.Location + + // Handle RemoteLocation vs. RemoteLocations. + if len(compat.aliasType.RemoteLocations) > 0 { + compat.RemoteLocation = compat.aliasType.RemoteLocations[0] + } + + return json.Marshal(compat) +} + +func (d DepsolvedPackage) ToRPMMD() rpmmd.Package { + p := rpmmd.Package{ + Name: d.Name, + Epoch: d.Epoch, + Version: d.Version, + Release: d.Release, + Arch: d.Arch, + + Group: d.Group, + + DownloadSize: d.DownloadSize, + InstallSize: d.InstallSize, + + License: d.License, + + SourceRpm: d.SourceRpm, + + Packager: d.Packager, + Vendor: d.Vendor, + + URL: d.URL, + + Summary: d.Summary, + Description: d.Description, + + Provides: d.Provides.ToRPMMDList(), + Requires: d.Requires.ToRPMMDList(), + RequiresPre: d.RequiresPre.ToRPMMDList(), + Conflicts: d.Conflicts.ToRPMMDList(), + Obsoletes: d.Obsoletes.ToRPMMDList(), + RegularRequires: d.RegularRequires.ToRPMMDList(), + + Recommends: d.Recommends.ToRPMMDList(), + Suggests: d.Suggests.ToRPMMDList(), + Enhances: d.Enhances.ToRPMMDList(), + Supplements: d.Supplements.ToRPMMDList(), + + Files: d.Files, + + BaseURL: d.BaseURL, + Location: d.Location, + RemoteLocations: d.RemoteLocations, + + RepoID: d.RepoID, + + Reason: d.Reason, + + Secrets: d.Secrets, + CheckGPG: d.CheckGPG, + IgnoreSSL: d.IgnoreSSL, + } + + if d.BuildTime != nil { + p.BuildTime = *d.BuildTime + } + + if d.Checksum != nil { + p.Checksum = rpmmd.Checksum(*d.Checksum) + } + + if d.HeaderChecksum != nil { + p.HeaderChecksum = rpmmd.Checksum(*d.HeaderChecksum) + } + + return p +} + +type DepsolvedPackageList []DepsolvedPackage + +func (d DepsolvedPackageList) ToRPMMDList() rpmmd.PackageList { + results := make(rpmmd.PackageList, len(d)) + for i, pkg := range d { + results[i] = pkg.ToRPMMD() + } + return results +} + +func DepsolvedPackageFromRPMMD(pkg rpmmd.Package) DepsolvedPackage { + return DepsolvedPackage{ + Name: pkg.Name, + Epoch: pkg.Epoch, + Version: pkg.Version, + Release: pkg.Release, + Arch: pkg.Arch, + + Group: pkg.Group, + + DownloadSize: pkg.DownloadSize, + InstallSize: pkg.InstallSize, + + License: pkg.License, + + SourceRpm: pkg.SourceRpm, + + BuildTime: &pkg.BuildTime, + Packager: pkg.Packager, + Vendor: pkg.Vendor, + + URL: pkg.URL, + + Summary: pkg.Summary, + Description: pkg.Description, + + Provides: DepsolvedPackageRelDepListFromRPMMDList(pkg.Provides), + Requires: DepsolvedPackageRelDepListFromRPMMDList(pkg.Requires), + RequiresPre: DepsolvedPackageRelDepListFromRPMMDList(pkg.RequiresPre), + Conflicts: DepsolvedPackageRelDepListFromRPMMDList(pkg.Conflicts), + Obsoletes: DepsolvedPackageRelDepListFromRPMMDList(pkg.Obsoletes), + RegularRequires: DepsolvedPackageRelDepListFromRPMMDList(pkg.RegularRequires), + + Recommends: DepsolvedPackageRelDepListFromRPMMDList(pkg.Recommends), + Suggests: DepsolvedPackageRelDepListFromRPMMDList(pkg.Suggests), + Enhances: DepsolvedPackageRelDepListFromRPMMDList(pkg.Enhances), + Supplements: DepsolvedPackageRelDepListFromRPMMDList(pkg.Supplements), + + Files: pkg.Files, + + BaseURL: pkg.BaseURL, + Location: pkg.Location, + RemoteLocations: pkg.RemoteLocations, + + Checksum: common.ToPtr(DepsolvedPackageChecksum(pkg.Checksum)), + HeaderChecksum: common.ToPtr(DepsolvedPackageChecksum(pkg.HeaderChecksum)), + + RepoID: pkg.RepoID, + + Reason: pkg.Reason, + + Secrets: pkg.Secrets, + CheckGPG: pkg.CheckGPG, + IgnoreSSL: pkg.IgnoreSSL, + } +} + +func DepsolvedPackageListFromRPMMDList(pkgs rpmmd.PackageList) DepsolvedPackageList { + results := make(DepsolvedPackageList, len(pkgs)) + for i, pkg := range pkgs { + results[i] = DepsolvedPackageFromRPMMD(pkg) + } + return results +} + type DepsolveJobResult struct { - PackageSpecs map[string][]rpmmd.PackageSpec `json:"package_specs"` - SbomDocs map[string]SbomDoc `json:"sbom_docs,omitempty"` - RepoConfigs map[string][]rpmmd.RepoConfig `json:"repo_configs"` + PackageSpecs map[string]DepsolvedPackageList `json:"package_specs"` + SbomDocs map[string]SbomDoc `json:"sbom_docs,omitempty"` + RepoConfigs map[string][]rpmmd.RepoConfig `json:"repo_configs"` JobResult } diff --git a/internal/worker/json_test.go b/internal/worker/json_test.go index 11b4793c3a..fb2e05604e 100644 --- a/internal/worker/json_test.go +++ b/internal/worker/json_test.go @@ -1,11 +1,16 @@ package worker import ( + "encoding/json" + "errors" "fmt" "testing" + "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" ) @@ -402,3 +407,458 @@ func TestOSBuildJobExports(t *testing.T) { }) } } + +func TestDepsolvedPackageChecksumUnmarshalJSON(t *testing.T) { + testCases := []struct { + name string + json string + depsolvedPackageChecksum DepsolvedPackageChecksum + expectedError error + }{ + { + name: "struct", + json: `{"type":"sha256","value":"17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"}`, + depsolvedPackageChecksum: DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + expectedError: nil, + }, + { + name: "string", + json: `"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"`, + depsolvedPackageChecksum: DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + expectedError: nil, + }, + { + name: "null", + json: `null`, + depsolvedPackageChecksum: DepsolvedPackageChecksum{}, + }, + { + name: "empty", + json: `":"`, + depsolvedPackageChecksum: DepsolvedPackageChecksum{}, + }, + { + name: "invalid string", + json: `"17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"`, + expectedError: errors.New("invalid checksum format: \"17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76\""), + }, + { + name: "invalid type", + json: `[{"type":"sha256","value":"17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"}]`, + expectedError: errors.New("unsupported checksum type: []interface {}"), + }, + { + name: "invalid struct type", + json: `{"typo":"sha256","value":"17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"}`, + expectedError: errors.New("checksum type is required, got map[typo:sha256 value:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76]"), + }, + { + name: "invalid struct value", + json: `{"type":"sha256","typo":"17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"}`, + expectedError: errors.New("checksum value is required, got map[type:sha256 typo:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76]"), + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + var depsolvedPackageChecksum DepsolvedPackageChecksum + err := json.Unmarshal([]byte(testCase.json), &depsolvedPackageChecksum) + if testCase.expectedError != nil { + require.Error(t, err) + assert.EqualValues(t, testCase.expectedError, err) + } else { + require.NoError(t, err) + assert.EqualValues(t, testCase.depsolvedPackageChecksum, depsolvedPackageChecksum) + } + }) + } +} + +func TestDepsolvedPackageChecksumMarshalJSON(t *testing.T) { + testCases := []struct { + name string + depsolvedPackageChecksum *DepsolvedPackageChecksum + json string + }{ + { + name: "nil", + depsolvedPackageChecksum: nil, + json: `null`, + }, + { + name: "empty", + depsolvedPackageChecksum: &DepsolvedPackageChecksum{}, + json: `":"`, + }, + { + name: "basic", + depsolvedPackageChecksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + json: `"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"`, + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + json, err := json.Marshal(testCase.depsolvedPackageChecksum) + require.NoError(t, err) + assert.EqualValues(t, testCase.json, string(json)) + }) + } +} + +func TestDepsolvedPackageUnmarshalJSON(t *testing.T) { + testCases := []struct { + name string + json string + depsolvedPackage DepsolvedPackage + }{ + { + name: "minimal", + json: `{"name":"test"}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + }, + }, + // Test old worker response + { + name: "legacy-rpmmd-packagespec", + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","remote_location":"https://example.com/rpms/test.rpm","checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"path":"rpms/test.rpm","repo_id":"test-repo-id"}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + }, + { + name: "basic from new worker with single remote location", + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","remote_location":"https://example.com/rpms/test.rpm","remote_locations":["https://example.com/rpms/test.rpm"],"checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"location":"rpms/test.rpm","path":"rpms/test.rpm","repo_id":"test-repo-id"}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + }, + { + name: "basic from new worker with multiple remote locations", + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","remote_location":"https://example.com/rpms/test.rpm","remote_locations":["https://example.com/rpms/test.rpm","http://example.com/rpms/test.rpm"],"checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"location":"rpms/test.rpm","path":"rpms/test.rpm","repo_id":"test-repo-id"}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm", "http://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + }, + { + name: "basic from new worker - new properties not overwritten by old properties", + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","remote_location":"should-not-override","remote_locations":["https://example.com/rpms/test.rpm","http://example.com/rpms/test.rpm"],"checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"location":"rpms/test.rpm","path":"should-not-override","repo_id":"test-repo-id"}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm", "http://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + }, + { + name: "basic new, without backward compatibility", + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","remote_locations":["https://example.com/rpms/test.rpm"],"checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"location":"rpms/test.rpm","repo_id":"test-repo-id"}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + }, + { + name: "basic after the checksum change to struct", + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","remote_locations":["https://example.com/rpms/test.rpm"],"checksum":{"type":"sha256","value":"17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76"},"secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"location":"rpms/test.rpm","repo_id":"test-repo-id"}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + }, + { + name: "checksum-null", + json: `{"name": "test","checksum": null}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + }, + }, + { + name: "full", + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","group":"test-group","download_size":100,"install_size":100,"license":"test-license","source_rpm":"test-source-rpm","build_time":"2021-01-01T00:00:00Z","packager":"test-packager","vendor":"test-vendor","url":"https://example.com/test_project","summary":"test-summary","description":"test-description","provides":[{"name":"test-provide","relationship":"\u003e=","version":"1.0.0"},{"name":"test-provide2"}],"requires":[{"name":"test-require","relationship":"\u003e=","version":"1.0.0"}],"requires_pre":[{"name":"test-require-pre","relationship":"\u003e=","version":"1.0.0"}],"conflicts":[{"name":"test-conflict","relationship":"\u003e=","version":"1.0.0"}],"obsoletes":[{"name":"test-obsolete","relationship":"\u003e=","version":"1.0.0"}],"regular_requires":[{"name":"test-regular-require","relationship":"\u003e=","version":"1.0.0"}],"recommends":[{"name":"test-recommend","relationship":"\u003e=","version":"1.0.0"}],"suggests":[{"name":"test-suggest","relationship":"\u003e=","version":"1.0.0"}],"enhances":[{"name":"test-enhance","relationship":"\u003e=","version":"1.0.0"}],"supplements":[{"name":"test-supplement","relationship":"\u003e=","version":"1.0.0"}],"files":["/usr/bin/test","/usr/lib/test","/usr/share/test","/usr/share/man/test","/usr/share/doc/test","/usr/share/doc/test.gz","/usr/share/doc/test.gz.sig"],"base_url":"https://example.com/test_project/repository","location":"rpms/test.rpm","remote_locations":["https://example.com/test_project/repository/rpms/test.rpm","http://example.com/test_project/repository/rpms/test.rpm"],"checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","header_checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","repo_id":"test-repo-id","reason":"test-reason","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true}`, + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + Group: "test-group", + DownloadSize: 100, + InstallSize: 100, + License: "test-license", + SourceRpm: "test-source-rpm", + BuildTime: common.ToPtr(time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC)), + Packager: "test-packager", + Vendor: "test-vendor", + URL: "https://example.com/test_project", + Summary: "test-summary", + Description: "test-description", + Provides: []DepsolvedPackageRelDep{ + { + Name: "test-provide", + Relationship: ">=", + Version: "1.0.0", + }, + { + Name: "test-provide2", + }, + }, + Requires: []DepsolvedPackageRelDep{ + { + Name: "test-require", + Relationship: ">=", + Version: "1.0.0", + }, + }, + RequiresPre: []DepsolvedPackageRelDep{ + { + Name: "test-require-pre", + Relationship: ">=", + Version: "1.0.0", + }, + }, + Conflicts: []DepsolvedPackageRelDep{ + { + Name: "test-conflict", + Relationship: ">=", + Version: "1.0.0", + }, + }, + Obsoletes: []DepsolvedPackageRelDep{ + { + Name: "test-obsolete", + Relationship: ">=", + Version: "1.0.0", + }, + }, + RegularRequires: []DepsolvedPackageRelDep{ + { + Name: "test-regular-require", + Relationship: ">=", + Version: "1.0.0", + }, + }, + Recommends: []DepsolvedPackageRelDep{ + { + Name: "test-recommend", + Relationship: ">=", + Version: "1.0.0", + }, + }, + Suggests: []DepsolvedPackageRelDep{ + { + Name: "test-suggest", + Relationship: ">=", + Version: "1.0.0", + }, + }, + Enhances: []DepsolvedPackageRelDep{ + { + Name: "test-enhance", + Relationship: ">=", + Version: "1.0.0", + }, + }, + Supplements: []DepsolvedPackageRelDep{ + { + Name: "test-supplement", + Relationship: ">=", + Version: "1.0.0", + }, + }, + Files: []string{ + "/usr/bin/test", + "/usr/lib/test", + "/usr/share/test", + "/usr/share/man/test", + "/usr/share/doc/test", + "/usr/share/doc/test.gz", + "/usr/share/doc/test.gz.sig", + }, + BaseURL: "https://example.com/test_project/repository", + Location: "rpms/test.rpm", + RemoteLocations: []string{ + "https://example.com/test_project/repository/rpms/test.rpm", + "http://example.com/test_project/repository/rpms/test.rpm", + }, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + HeaderChecksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + RepoID: "test-repo-id", + Reason: "test-reason", + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + }, + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + var depsolvedPackage DepsolvedPackage + err := json.Unmarshal([]byte(testCase.json), &depsolvedPackage) + require.NoError(t, err) + assert.EqualValues(t, testCase.depsolvedPackage, depsolvedPackage) + }) + } +} + +func TestDepsolvedPackageMarshalJSON(t *testing.T) { + testCases := []struct { + name string + depsolvedPackage DepsolvedPackage + json string + }{ + { + name: "minimal", + depsolvedPackage: DepsolvedPackage{ + Name: "test", + }, + json: `{"name":"test","epoch":0}`, + }, + { + name: "basic", + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","location":"rpms/test.rpm","remote_locations":["https://example.com/rpms/test.rpm"],"checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","repo_id":"test-repo-id","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"path":"rpms/test.rpm","remote_location":"https://example.com/rpms/test.rpm"}`, + }, + { + name: "basic with multiple remote locations", + depsolvedPackage: DepsolvedPackage{ + Name: "test", + Epoch: 1, + Version: "1.0.0", + Release: "1", + Arch: "x86_64", + RemoteLocations: []string{"https://example.com/rpms/test.rpm", "http://example.com/rpms/test.rpm"}, + Checksum: &DepsolvedPackageChecksum{ + Type: "sha256", + Value: "17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76", + }, + Secrets: "org.osbuild.rhsm", + CheckGPG: true, + IgnoreSSL: true, + Location: "rpms/test.rpm", + RepoID: "test-repo-id", + }, + json: `{"name":"test","epoch":1,"version":"1.0.0","release":"1","arch":"x86_64","location":"rpms/test.rpm","remote_locations":["https://example.com/rpms/test.rpm","http://example.com/rpms/test.rpm"],"checksum":"sha256:17e682f060b5f8e47ea04c5c4855908b0a5ad612022260fe50e11ecb0cc0ab76","repo_id":"test-repo-id","secrets":"org.osbuild.rhsm","check_gpg":true,"ignore_ssl":true,"path":"rpms/test.rpm","remote_location":"https://example.com/rpms/test.rpm"}`, + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + json, err := json.Marshal(testCase.depsolvedPackage) + require.NoError(t, err) + assert.EqualValues(t, testCase.json, string(json)) + }) + } +} diff --git a/vendor/github.com/osbuild/images/data/distrodefs/distros.yaml b/vendor/github.com/osbuild/images/data/distrodefs/distros.yaml index e23cf59066..008ad3ea82 100644 --- a/vendor/github.com/osbuild/images/data/distrodefs/distros.yaml +++ b/vendor/github.com/osbuild/images/data/distrodefs/distros.yaml @@ -214,6 +214,7 @@ distros: - "xccdf_org.ssgproject.content_profile_anssi_bp28_high" - "xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary" - "xccdf_org.ssgproject.content_profile_anssi_bp28_minimal" + - "xccdf_org.ssgproject.content_profile_bsi" - "xccdf_org.ssgproject.content_profile_ccn_advanced" - "xccdf_org.ssgproject.content_profile_ccn_basic" - "xccdf_org.ssgproject.content_profile_ccn_intermediate" diff --git a/vendor/github.com/osbuild/images/data/distrodefs/fedora/imagetypes.yaml b/vendor/github.com/osbuild/images/data/distrodefs/fedora/imagetypes.yaml index e11a5d5309..6d714a4ffb 100644 --- a/vendor/github.com/osbuild/images/data/distrodefs/fedora/imagetypes.yaml +++ b/vendor/github.com/osbuild/images/data/distrodefs/fedora/imagetypes.yaml @@ -480,8 +480,8 @@ disk_sizes: default_required_partition_sizes: &default_required_dir_sizes - "/": 1_073_741_824 # 1 * datasizes.GiB - "/usr": 2_147_483_648 # 2 * datasizes.GiB + "/": "1 GiB" + "/usr": "2 GiB" partitioning: ids: @@ -493,18 +493,6 @@ - &efi_system_partition_guid "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" - &filesystem_data_guid "0FC63DAF-8483-4772-8E79-3D69D8477DE4" - &xboot_ldr_partition_guid "BC13C2FF-59E6-4262-A352-B275FD6F7172" - # static UUIDs for partitions and filesystems - # NOTE(akoutsou): These are unnecessary and have stuck around since the - # beginning where (I believe) the goal was to have predictable, - # reproducible partition tables. They might be removed soon in favour of - # proper, random UUIDs, with reproducibility being controlled by fixing - # rng seeds. - uuids: - - &bios_boot_partition_uuid "FAC7F1FB-3E8D-4137-A512-961DE09A5549" - - &root_partition_uuid "6264D520-3FB9-423F-8AB8-7A0A8E3D3562" - - &data_partition_uuid "CB07C243-BC44-4717-853E-28852021225B" - - &efi_system_partition_uuid "68B2905B-DF3E-4FB3-80FA-49D1E773AA33" - - &efi_filesystem_uuid "7B77-95E7" # the invidual partitions for easier composibility partitions: @@ -512,15 +500,12 @@ size: "1 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &default_partition_table_part_efi size: "200 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -529,7 +514,6 @@ - &default_partition_table_part_boot size: "2 GiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "ext4" @@ -541,7 +525,6 @@ - &default_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: &default_partition_table_part_root_payload type: "ext4" @@ -554,11 +537,9 @@ - &iot_base_partition_table_part_efi size: "501 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "umask=0077,shortname=winnt" @@ -567,7 +548,6 @@ - &iot_base_partition_table_part_boot size: "2 GiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "ext4" @@ -579,7 +559,6 @@ - &iot_base_partition_table_part_root size: "2569 MiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: &iot_base_partition_table_part_root_payload type: "ext4" @@ -669,7 +648,6 @@ x86_64: uuid: "D209C89E-EA5E-4FBD-B161-B461CCE297E0" type: "gpt" - start_offset: "8 MiB" partitions: - *default_partition_table_part_efi - &minimal_raw_partition_table_part_boot @@ -720,7 +698,6 @@ - *iot_base_partition_table_part_efi - size: "2 GiB" type: *xboot_ldr_partition_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "ext4" @@ -730,7 +707,6 @@ fstab_freq: 1 fstab_passno: 1 - type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "luks" payload: label: "crypt_root" @@ -894,7 +870,7 @@ image_types: mime_type: "application/x-tar" environment: *kvm_env bootable: true - default_size: 5_368_709_120 # 5 * datasizes.GibiByte + default_size: "5 GiB" image_func: "disk" exports: ["archive"] required_partition_sizes: *default_required_dir_sizes @@ -955,7 +931,7 @@ image_types: mime_type: "application/x-qemu-disk" environment: *kvm_env bootable: true - default_size: 5_368_709_120 # 5 * datasizes.GibiByte + default_size: "5 GiB" image_func: "disk" exports: ["qcow2"] required_partition_sizes: *default_required_dir_sizes @@ -1055,7 +1031,7 @@ image_types: filename: "disk.vmdk" mime_type: "application/x-vmdk" bootable: true - default_size: 2_147_483_648 # 2 * datasizes.GibiByte + default_size: "2 GiB" image_func: "disk" exports: ["vmdk"] required_partition_sizes: *default_required_dir_sizes @@ -1304,7 +1280,7 @@ image_types: filename: "image.raw.xz" compression: "xz" mime_type: "application/xz" - default_size: 6_442_450_944 # 6 * datasizes.GibiByte + default_size: "6 GiB" bootable: true image_func: "iot" ostree: @@ -1382,7 +1358,7 @@ image_types: name_aliases: ["iot-qcow2-image"] filename: "image.qcow2" mime_type: "application/x-qemu-disk" - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" bootable: true image_func: "iot" ostree: @@ -1558,7 +1534,7 @@ image_types: compression: "xz" mime_type: "application/xz" bootable: true - default_size: 2_147_483_648 # 2 * datasizes.GibiByte + default_size: "2 GiB" image_func: "disk" exports: ["xz"] required_partition_sizes: *default_required_dir_sizes @@ -1637,9 +1613,12 @@ image_types: "riscv64 specific pkgs for minimal-raw-xz": when: arch: "riscv64" + version_less_than: "42" append: include: - # missing from @core in riscv64 + # missing from @core in riscv64 but only + # in Fedora 41, they've been subsequently + # added in 42 and up - "dnf5" - "policycoreutils" - "selinux-policy-targeted" @@ -1678,6 +1657,8 @@ image_types: image_config: <<: *image_config_iot_enabled_services locale: "en_US.UTF-8" + # iot-installer is not using the default ostree kernel options + kernel_options: package_sets: installer: - *anaconda_pkgset @@ -2036,7 +2017,7 @@ image_types: mime_type: "application/x-iso9660-image" bootable: true boot_iso: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "iot_simplified_installer" iso_label: "IoT" variant: "IoT" diff --git a/vendor/github.com/osbuild/images/data/distrodefs/rhel-10/imagetypes.yaml b/vendor/github.com/osbuild/images/data/distrodefs/rhel-10/imagetypes.yaml index ed574b12dd..443af2301d 100644 --- a/vendor/github.com/osbuild/images/data/distrodefs/rhel-10/imagetypes.yaml +++ b/vendor/github.com/osbuild/images/data/distrodefs/rhel-10/imagetypes.yaml @@ -32,8 +32,8 @@ disk_sizes: default_required_partition_sizes: &default_required_dir_sizes - "/": 1_073_741_824 # 1 * datasizes.GiB - "/usr": 2_147_483_648 # 2 * datasizes.GiB + "/": "1 GiB" + "/usr": "2 GiB" platforms: x86_64_uefi_platform: &x86_64_uefi_platform @@ -236,7 +236,7 @@ - key: "vm.max_map_count" value: "2147483647" dnf_config: - set_release_ver_var: true + set_releasever_var: true sap_image_config: &sap_image_config <<: *sapapps_image_config @@ -398,36 +398,20 @@ - &xboot_ldr_partition_guid "BC13C2FF-59E6-4262-A352-B275FD6F7172" - &lvm_partition_guid "E6D6D379-F507-44C2-A23C-238F2A3DF928" - &root_partition_x86_64_guid "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709" - # static UUIDs for partitions and filesystems - # NOTE(akoutsou): These are unnecessary and have stuck around since the - # beginning where (I believe) the goal was to have predictable, - # reproducible partition tables. They might be removed soon in favour of - # proper, random UUIDs, with reproducibility being controlled by fixing - # rng seeds. - uuids: - - &bios_boot_partition_uuid "FAC7F1FB-3E8D-4137-A512-961DE09A5549" - - &root_partition_uuid "6264D520-3FB9-423F-8AB8-7A0A8E3D3562" - - &data_partition_uuid "CB07C243-BC44-4717-853E-28852021225B" - - &efi_system_partition_uuid "68B2905B-DF3E-4FB3-80FA-49D1E773AA33" - - &efi_filesystem_uuid "7B77-95E7" default_partition_tables: &default_partition_tables x86_64: - uuid: "D209C89E-EA5E-4FBD-B161-B461CCE297E0" type: "gpt" partitions: - size: "1 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &default_partition_table_part_efi size: "200 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -436,7 +420,6 @@ - &default_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: &default_partition_table_part_root_payload type: "xfs" @@ -446,13 +429,11 @@ fstab_freq: 0 fstab_passno: 0 aarch64: &default_partition_table_aarch64 - uuid: "D209C89E-EA5E-4FBD-B161-B461CCE297E0" type: "gpt" partitions: - *default_partition_table_part_efi - *default_partition_table_part_root ppc64le: - uuid: "0x14fc63d2" type: "dos" partitions: - size: "4 MiB" @@ -465,7 +446,6 @@ <<: *default_partition_table_part_root_payload label: "" s390x: - uuid: "0x14fc63d2" type: "dos" partitions: - <<: *default_partition_table_part_root_ppc64le @@ -793,6 +773,7 @@ - "customizations.cacerts" - "customizations.directories" - "customizations.disk" + - "customizations.dnf" - "customizations.files" - "customizations.filesystem" - "customizations.partitioning_mode" @@ -918,7 +899,7 @@ image_types: # note that unlike fedora rhel does not use the environment.KVM # for unknown reasons bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "disk" exports: ["qcow2"] required_partition_sizes: *default_required_dir_sizes @@ -1026,7 +1007,7 @@ image_types: filename: "vagrant-libvirt.box" mime_type: "application/x-tar" bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "disk" exports: ["archive"] required_partition_sizes: *default_required_dir_sizes @@ -1077,7 +1058,7 @@ image_types: name_aliases: [] filename: "disk.vhd" mime_type: "application/x-vhd" - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" exports: ["vpc"] # note that unlike fedora no "environment.Azure" is used here for # unknown reasons @@ -1126,18 +1107,15 @@ image_types: filename: "disk.vhd.xz" partition_table: x86_64: - uuid: "D209C89E-EA5E-4FBD-B161-B461CCE297E0" type: "gpt" size: "64 GiB" partitions: - &azure_rhui_part_boot_efi size: "500 MiB" type: *efi_system_partition_guid - UUID: *efi_system_partition_uuid payload_type: "filesystem" payload: type: "vfat" - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" fstab_freq: 0 @@ -1146,7 +1124,6 @@ image_types: - &azure_rhui_part_boot size: "1 GiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -1157,10 +1134,8 @@ image_types: - size: "2 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &azure_rhui_part_lvm type: *lvm_partition_guid - uuid: *root_partition_uuid payload_type: "lvm" payload: name: "rootvg" @@ -1207,7 +1182,6 @@ image_types: mountpoint: "/var" fstab_options: "defaults" aarch64: - uuid: "D209C89E-EA5E-4FBD-B161-B461CCE297E0" type: "gpt" size: "64 GiB" partitions: @@ -1278,6 +1252,7 @@ image_types: - "minimal" - "customizations.cacerts" - "customizations.directories" + - "customizations.dnf" - "customizations.files" - "customizations.firewall" - "customizations.user" @@ -1296,7 +1271,7 @@ image_types: filename: "disk.vmdk" mime_type: "application/x-vmdk" bootable: true - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" image_func: "disk" exports: ["vmdk"] required_partition_sizes: *default_required_dir_sizes @@ -1341,7 +1316,7 @@ image_types: image_func: "disk" exports: ["image"] bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" required_partition_sizes: *default_required_dir_sizes platforms: - <<: *x86_64_bios_platform @@ -1705,6 +1680,7 @@ image_types: - "enabled_modules" - "minimal" - "containers" + - "customizations.dnf" - "customizations.directories" - "customizations.files" - "customizations.firewall" @@ -1883,6 +1859,7 @@ image_types: - "minimal" - "customizations.installer" - "customizations.cacerts" + - "customizations.dnf" - "customizations.directories" - "customizations.files" - "customizations.firewall" @@ -1910,7 +1887,7 @@ image_types: image_func: "disk" exports: ["archive"] bootable: true - default_size: 21_474_836_480 # 20 * datasizes.GibiByte + default_size: "20 GiB" required_partition_sizes: *default_required_dir_sizes platforms: - <<: *x86_64_uefi_platform @@ -1934,9 +1911,9 @@ image_types: keymap: "us" dnf_config: options: - - config: - main: - ipresolve: "4" + config: + main: + ipresolve: "4" dnf_automatic_config: config: commands: @@ -2066,7 +2043,7 @@ image_types: mime_type: "application/xz" exports: ["xz"] compression: "xz" - default_size: 34_359_738_368 # 32 * datasizes.GibiByte + default_size: "32 GiB" platforms: - arch: "x86_64" bootloader: "uki" @@ -2080,16 +2057,13 @@ image_types: - "uki-direct" partition_table: x86_64: - uuid: "D209C89E-EA5E-4FBD-B161-B461CCE297E0" type: "gpt" partitions: - size: "512 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -2145,6 +2119,7 @@ image_types: - "customizations.cacerts" - "customizations.directories" - "customizations.disk" + - "customizations.dnf" - "customizations.files" - "customizations.filesystem" - "customizations.partitioning_mode" diff --git a/vendor/github.com/osbuild/images/data/distrodefs/rhel-7/imagetypes.yaml b/vendor/github.com/osbuild/images/data/distrodefs/rhel-7/imagetypes.yaml index 39884c6309..022af9c62b 100644 --- a/vendor/github.com/osbuild/images/data/distrodefs/rhel-7/imagetypes.yaml +++ b/vendor/github.com/osbuild/images/data/distrodefs/rhel-7/imagetypes.yaml @@ -57,18 +57,6 @@ - &filesystem_data_guid "0FC63DAF-8483-4772-8E79-3D69D8477DE4" - &xboot_ldr_partition_guid "BC13C2FF-59E6-4262-A352-B275FD6F7172" - &lvm_partition_guid "E6D6D379-F507-44C2-A23C-238F2A3DF928" - # static UUIDs for partitions and filesystems - # NOTE(akoutsou): These are unnecessary and have stuck around since the - # beginning where (I believe) the goal was to have predictable, - # reproducible partition tables. They might be removed soon in favour of - # proper, random UUIDs, with reproducibility being controlled by fixing - # rng seeds. - uuids: - - &bios_boot_partition_uuid "FAC7F1FB-3E8D-4137-A512-961DE09A5549" - - &root_partition_uuid "6264D520-3FB9-423F-8AB8-7A0A8E3D3562" - - &data_partition_uuid "CB07C243-BC44-4717-853E-28852021225B" - - &efi_system_partition_uuid "68B2905B-DF3E-4FB3-80FA-49D1E773AA33" - - &efi_filesystem_uuid "7B77-95E7" default_partition_tables: &default_partition_tables x86_64: @@ -79,15 +67,12 @@ size: "1 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &default_partition_table_part_efi size: "200 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -96,7 +81,6 @@ - &default_partition_table_part_boot size: "500 MiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -108,7 +92,6 @@ - &default_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: &default_partition_table_part_root_payload type: "xfs" @@ -126,7 +109,6 @@ - *bios_boot_partition - size: 6_442_450_944 # 6144 * datasizes.MebiByte type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: <<: *default_partition_table_part_root_payload @@ -139,11 +121,9 @@ - &azure_rhui_part_boot_efi size: 524_288_000 # 500 * datasizes.MebiByte type: *efi_system_partition_guid - UUID: *efi_system_partition_uuid payload_type: "filesystem" payload: type: "vfat" - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" fstab_freq: 0 @@ -151,7 +131,6 @@ - &azure_rhui_part_boot size: "500 MiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -162,10 +141,8 @@ - size: "2 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &azure_rhui_part_lvm type: *lvm_partition_guid - uuid: *root_partition_uuid payload_type: "lvm" payload: name: "rootvg" @@ -214,8 +191,8 @@ disk_sizes: default_required_partition_sizes: &default_required_dir_sizes - "/": 1_073_741_824 # 1 * datasizes.GiB - "/usr": 2_147_483_648 # 2 * datasizes.GiB + "/": "1 GiB" + "/usr": "2 GiB" platforms: x86_64_bios_platform: &x86_64_bios_platform @@ -285,7 +262,7 @@ image_types: filename: "disk.vhd.xz" mime_type: "application/xz" image_func: "disk" - default_size: 68_719_476_736 # 64 * datasizes.GibiByte + default_size: "64 GiB" exports: ["xz"] compression: "xz" bootable: true @@ -445,7 +422,7 @@ image_types: exports: ["xz"] compression: "xz" bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" required_partition_sizes: *default_required_dir_sizes platforms: - <<: *x86_64_bios_platform @@ -596,7 +573,7 @@ image_types: filename: "disk.qcow2" mime_type: "application/x-qemu-disk" bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "disk" exports: ["qcow2"] required_partition_sizes: *default_required_dir_sizes diff --git a/vendor/github.com/osbuild/images/data/distrodefs/rhel-8/imagetypes.yaml b/vendor/github.com/osbuild/images/data/distrodefs/rhel-8/imagetypes.yaml index 8c9f013959..835d641e84 100644 --- a/vendor/github.com/osbuild/images/data/distrodefs/rhel-8/imagetypes.yaml +++ b/vendor/github.com/osbuild/images/data/distrodefs/rhel-8/imagetypes.yaml @@ -353,7 +353,7 @@ - key: "vm.max_map_count" value: "2147483647" dnf_config: - set_release_ver_var: false + set_releasever_var: false conditions: &conditions_sap_image_config "rhel-8.9 and below needs to set the release ver in dnf config": when: @@ -361,7 +361,7 @@ shallow_merge: dnf_config: # E4S/EUS - set_release_ver_var: true + set_releasever_var: true sap_pkgset: &sap_pkgset include: @@ -767,8 +767,8 @@ disk_sizes: default_required_partition_sizes: &default_required_dir_sizes - "/": 1_073_741_824 # 1 * datasizes.GiB - "/usr": 2_147_483_648 # 2 * datasizes.GiB + "/": "1 GiB" + "/usr": "2 GiB" platforms: x86_64_uefi_platform: &x86_64_uefi_platform @@ -959,33 +959,18 @@ - &filesystem_data_guid "0FC63DAF-8483-4772-8E79-3D69D8477DE4" - &xboot_ldr_partition_guid "BC13C2FF-59E6-4262-A352-B275FD6F7172" - &lvm_partition_guid "E6D6D379-F507-44C2-A23C-238F2A3DF928" - # static UUIDs for partitions and filesystems - # NOTE(akoutsou): These are unnecessary and have stuck around since the - # beginning where (I believe) the goal was to have predictable, - # reproducible partition tables. They might be removed soon in favour of - # proper, random UUIDs, with reproducibility being controlled by fixing - # rng seeds. - uuids: - - &bios_boot_partition_uuid "FAC7F1FB-3E8D-4137-A512-961DE09A5549" - - &root_partition_uuid "6264D520-3FB9-423F-8AB8-7A0A8E3D3562" - - &data_partition_uuid "CB07C243-BC44-4717-853E-28852021225B" - - &efi_system_partition_uuid "68B2905B-DF3E-4FB3-80FA-49D1E773AA33" - - &efi_filesystem_uuid "7B77-95E7" partitions: - &default_partition_table_part_bios size: "1 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &default_partition_table_part_efi size: "100 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -994,7 +979,6 @@ - &default_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: &default_partition_table_part_root_payload type: "xfs" @@ -1007,7 +991,6 @@ - &ec2_partition_table_part_boot size: "1 GiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -1062,11 +1045,9 @@ - &edge_base_partition_table_part_efi size: "127 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -1075,7 +1056,6 @@ - &edge_base_partition_table_part_boot size: "384 MiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -1087,7 +1067,6 @@ - &edge_base_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "luks" payload: label: "crypt_root" @@ -1115,7 +1094,6 @@ partitions: - <<: *edge_base_partition_table_part_efi type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid - *edge_base_partition_table_part_boot - *edge_base_partition_table_part_root @@ -1128,11 +1106,9 @@ - &ec2_partition_table_part_efi size: "200 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -1141,7 +1117,6 @@ - &ec2_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -1192,11 +1167,9 @@ - &azure_rhui_part_boot_efi size: 524_288_000 # 500 * datasizes.MebiByte type: *efi_system_partition_guid - UUID: *efi_system_partition_uuid payload_type: "filesystem" payload: type: "vfat" - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" fstab_freq: 0 @@ -1204,7 +1177,6 @@ - &azure_rhui_part_boot size: 524_288_000 # 500 * datasizes.MebiByte type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -1215,10 +1187,8 @@ - size: 2_097_152 # 2 * datasizes.MebiByte bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &azure_rhui_part_lvm type: *lvm_partition_guid - uuid: *root_partition_uuid payload_type: "lvm" payload: name: "rootvg" @@ -1289,6 +1259,7 @@ - "customizations.cacerts" - "customizations.directories" - "customizations.disk" + - "customizations.dnf" - "customizations.files" - "customizations.filesystem" - "customizations.partitioning_mode" @@ -1316,6 +1287,7 @@ - "enabled_modules" - "minimal" - "containers" + - "customizations.dnf" - "customizations.directories" - "customizations.files" - "customizations.fips" @@ -1337,6 +1309,7 @@ - "customizations.files" - "customizations.directories" - "customizations.disk" + - "customizations.dnf" - "customizations.filesystem" - "customizations.partitioning_mode" - "customizations.fips" @@ -1428,7 +1401,7 @@ image_types: image_func: "disk" exports: ["image"] bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" required_partition_sizes: *default_required_dir_sizes platforms: - <<: *x86_64_bios_platform @@ -1578,7 +1551,7 @@ image_types: # note that unlike fedora rhel does not use the environment.KVM # for unknown reasons bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "disk" exports: ["qcow2"] required_partition_sizes: *default_required_dir_sizes @@ -1626,7 +1599,7 @@ image_types: filename: "disk.vhd" mime_type: "application/x-vhd" image_func: "disk" - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" exports: ["vpc"] bootable: true # note that unlike fedora no "environment.Azure" is used here for @@ -1786,7 +1759,7 @@ image_types: filename: "disk.vhd.xz" mime_type: "application/xz" image_func: "disk" - default_size: 68_719_476_736 # 64 * datasizes.GibiByte + default_size: "64 GiB" exports: ["xz"] compression: "xz" bootable: true @@ -1987,6 +1960,7 @@ image_types: - "minimal" - "customizations.installer" - "customizations.cacerts" + - "customizations.dnf" - "customizations.directories" - "customizations.files" - "customizations.firewall" @@ -2033,6 +2007,7 @@ image_types: - "containers" - "enabled_modules" - "minimal" + - "customizations.dnf" - "customizations.cacerts" - "customizations.directories" - "customizations.files" @@ -2278,7 +2253,7 @@ image_types: filename: "image.raw.xz" compression: "xz" mime_type: "application/xz" - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" rpm_ostree: true bootable: true image_func: "iot" @@ -2315,7 +2290,7 @@ image_types: use_syslinux: true # NOTE: RHEL 8 only supports the older Anaconda configs use_legacy_anaconda_config: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "iot_simplified_installer" iso_label: "edge" variant: "edge" @@ -2419,6 +2394,7 @@ image_types: - "customizations.fips" - "customizations.files" - "customizations.directories" + - "customizations.dnf" required_blueprint_options: - "customizations.installation_device" @@ -2445,7 +2421,7 @@ image_types: filename: "disk.vmdk" mime_type: "application/x-vmdk" bootable: true - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" image_func: "disk" exports: ["vmdk"] required_partition_sizes: *default_required_dir_sizes @@ -2493,7 +2469,7 @@ image_types: image_func: "disk" exports: ["archive"] bootable: true - default_size: 21_474_836_480 # 20 * datasizes.GibiByte + default_size: "20 GiB" # The configuration for non-RHUI images does not touch the RHSM configuration at all. # https://issues.redhat.com/browse/COMPOSER-2157 image_config: &gce_image_config @@ -2516,9 +2492,9 @@ image_types: keymap: "us" dnf_config: options: - - config: - main: - ipresolve: "4" + config: + main: + ipresolve: "4" dnf_automatic_config: config: commands: @@ -2630,7 +2606,7 @@ image_types: # we have to reset the aliases otherwise this type # will inherit the name aliases causing a conflict name_aliases: [] - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" image_config: kernel_options: - "ro" @@ -2785,6 +2761,7 @@ image_types: - "enabled_modules" - "minimal" - "containers" + - "customizations.dnf" - "customizations.directories" - "customizations.files" - "customizations.firewall" @@ -2803,7 +2780,7 @@ image_types: mime_type: "application/xz" compression: "xz" bootable: true - default_size: 2_147_483_648 # 2 * datasizes.GibiByte + default_size: "2 GiB" image_func: "disk" exports: ["xz"] required_partition_sizes: *default_required_dir_sizes diff --git a/vendor/github.com/osbuild/images/data/distrodefs/rhel-9/imagetypes.yaml b/vendor/github.com/osbuild/images/data/distrodefs/rhel-9/imagetypes.yaml index f347beb55d..1ebc09058d 100644 --- a/vendor/github.com/osbuild/images/data/distrodefs/rhel-9/imagetypes.yaml +++ b/vendor/github.com/osbuild/images/data/distrodefs/rhel-9/imagetypes.yaml @@ -32,8 +32,8 @@ disk_sizes: default_required_partition_sizes: &default_required_dir_sizes - "/": 1_073_741_824 # 1 * datasizes.GiB - "/usr": 2_147_483_648 # 2 * datasizes.GiB + "/": "1 GiB" + "/usr": "2 GiB" platforms: x86_64_uefi_platform: &x86_64_uefi_platform @@ -413,7 +413,7 @@ - key: "vm.max_map_count" value: "2147483647" dnf_config: - set_release_ver_var: true + set_releasever_var: true sap_image_config: &sap_image_config <<: *sapapps_image_config @@ -735,33 +735,18 @@ - &xboot_ldr_partition_guid "BC13C2FF-59E6-4262-A352-B275FD6F7172" - &lvm_partition_guid "E6D6D379-F507-44C2-A23C-238F2A3DF928" - &root_partition_x86_64_guid "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709" - # static UUIDs for partitions and filesystems - # NOTE(akoutsou): These are unnecessary and have stuck around since the - # beginning where (I believe) the goal was to have predictable, - # reproducible partition tables. They might be removed soon in favour of - # proper, random UUIDs, with reproducibility being controlled by fixing - # rng seeds. - uuids: - - &bios_boot_partition_uuid "FAC7F1FB-3E8D-4137-A512-961DE09A5549" - - &root_partition_uuid "6264D520-3FB9-423F-8AB8-7A0A8E3D3562" - - &data_partition_uuid "CB07C243-BC44-4717-853E-28852021225B" - - &efi_system_partition_uuid "68B2905B-DF3E-4FB3-80FA-49D1E773AA33" - - &efi_filesystem_uuid "7B77-95E7" partitions: - &default_partition_table_part_bios size: "1 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &default_partition_table_part_efi size: "200 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -770,7 +755,6 @@ - &default_partition_table_part_boot size: "1 GiB" type: *xboot_ldr_partition_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: &default_partition_table_part_boot_payload type: "xfs" @@ -782,7 +766,6 @@ - &default_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: &default_partition_table_part_root_payload type: "xfs" @@ -871,11 +854,9 @@ - &edge_base_partition_table_part_efi size: "127 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -884,7 +865,6 @@ - &edge_base_partition_table_part_boot size: "384 MiB" type: *xboot_ldr_partition_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -896,7 +876,6 @@ - &edge_base_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "luks" payload: label: "crypt_root" @@ -1268,6 +1247,7 @@ - "customizations.cacerts" - "customizations.directories" - "customizations.disk" + - "customizations.dnf" - "customizations.files" - "customizations.filesystem" - "customizations.partitioning_mode" @@ -1295,6 +1275,7 @@ - "enabled_modules" - "minimal" - "containers" + - "customizations.dnf" - "customizations.directories" - "customizations.files" - "customizations.fips" @@ -1316,6 +1297,7 @@ - "customizations.files" - "customizations.directories" - "customizations.disk" + - "customizations.dnf" - "customizations.filesystem" - "customizations.partitioning_mode" - "customizations.fips" @@ -1435,7 +1417,7 @@ image_types: # note that unlike fedora rhel does not use the environment.KVM # for unknown reasons bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "disk" exports: ["qcow2"] required_partition_sizes: *default_required_dir_sizes @@ -1546,7 +1528,7 @@ image_types: filename: "vagrant-libvirt.box" mime_type: "application/x-tar" bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "disk" exports: ["archive"] required_partition_sizes: *default_required_dir_sizes @@ -1598,7 +1580,7 @@ image_types: name_aliases: [] filename: "disk.vhd" mime_type: "application/x-vhd" - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" exports: ["vpc"] platforms: - <<: *x86_64_bios_platform @@ -1659,11 +1641,9 @@ image_types: - &azure_rhui_part_boot_efi size: "500 MiB" type: *efi_system_partition_guid - UUID: *efi_system_partition_uuid payload_type: "filesystem" payload: type: "vfat" - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" fstab_freq: 0 @@ -1672,7 +1652,6 @@ image_types: - &azure_rhui_part_boot size: "1 GiB" type: *filesystem_data_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: type: "xfs" @@ -1684,10 +1663,8 @@ image_types: size: "2 MiB" bootable: true type: *bios_boot_partition_guid - uuid: *bios_boot_partition_uuid - &azure_rhui_part_lvm type: *lvm_partition_guid - uuid: *root_partition_uuid payload_type: "lvm" payload: name: "rootvg" @@ -1803,6 +1780,7 @@ image_types: - "containers" - "enabled_modules" - "minimal" + - "customizations.dnf" - "customizations.cacerts" - "customizations.directories" - "customizations.files" @@ -1823,7 +1801,7 @@ image_types: filename: "disk.vmdk" mime_type: "application/x-vmdk" bootable: true - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" image_func: "disk" exports: ["vmdk"] required_partition_sizes: *default_required_dir_sizes @@ -1868,7 +1846,7 @@ image_types: compression: "xz" image_func: "disk" bootable: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" required_partition_sizes: *default_required_dir_sizes platforms: - <<: *x86_64_bios_platform @@ -2215,6 +2193,7 @@ image_types: - "enabled_modules" - "minimal" - "containers" + - "customizations.dnf" - "customizations.directories" - "customizations.files" - "customizations.firewall" @@ -2299,6 +2278,7 @@ image_types: - "enabled_modules" - "containers" - "minimal" + - "customizations.dnf" - "customizations.installer" - "customizations.cacerts" - "customizations.directories" @@ -2328,7 +2308,7 @@ image_types: image_func: "disk" exports: ["archive"] bootable: true - default_size: 21_474_836_480 # 20 * datasizes.GibiByte + default_size: "20 GiB" required_partition_sizes: *default_required_dir_sizes platforms: - <<: *x86_64_uefi_platform @@ -2353,9 +2333,9 @@ image_types: keymap: "us" dnf_config: options: - - config: - main: - ipresolve: "4" + config: + main: + ipresolve: "4" dnf_automatic_config: config: commands: @@ -2482,7 +2462,7 @@ image_types: mime_type: "application/xz" compression: "xz" bootable: true - default_size: 2_147_483_648 # 2 * datasizes.GibiByte + default_size: "2 GiB" image_func: "disk" exports: ["xz"] required_partition_sizes: *default_required_dir_sizes @@ -2500,11 +2480,9 @@ image_types: - &minimal_raw_partition_table_part_efi size: "200 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "ESP" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -2513,14 +2491,12 @@ image_types: - &minimal_raw_partition_table_part_boot size: "600 MiB" type: *xboot_ldr_partition_guid - uuid: *data_partition_uuid payload_type: "filesystem" payload: <<: *default_partition_table_part_boot_payload - &minimal_raw_partition_table_part_root size: "2 GiB" type: *filesystem_data_guid - uuid: *root_partition_uuid payload_type: "filesystem" payload: <<: *default_partition_table_part_root_payload @@ -2587,7 +2563,7 @@ image_types: # we have to reset the aliases otherwise this type # will inherit the name aliases causing a conflict name_aliases: [] - default_size: 4_294_967_296 # 4 * datasizes.GibiByte + default_size: "4 GiB" platforms: - <<: *x86_64_bios_platform image_format: "qcow2" @@ -2803,7 +2779,7 @@ image_types: compression: "xz" mime_type: "application/xz" exports: ["xz"] - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" rpm_ostree: true bootable: true image_func: "iot" @@ -2897,7 +2873,7 @@ image_types: use_syslinux: true # NOTE: RHEL 8 only supports the older Anaconda configs use_legacy_anaconda_config: true - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" image_func: "iot_simplified_installer" iso_label: "edge" variant: "edge" @@ -2994,6 +2970,7 @@ image_types: <<: *edge_commit_aarch64_pkgset supported_blueprint_options: - "distro" + - "customizations.dnf" - "customizations.installation_device" - "customizations.filesystem" - "customizations.disk" @@ -3012,7 +2989,7 @@ image_types: "edge-ami": &edge_ami filename: "image.raw" mime_type: "application/octet-stream" - default_size: 10_737_418_240 # 10 * datasizes.GibiByte + default_size: "10 GiB" exports: ["image"] rpm_ostree: true bootable: true @@ -3097,7 +3074,7 @@ image_types: mime_type: "application/xz" exports: ["xz"] compression: "xz" - default_size: 34_359_738_368 # 32 * datasizes.GibiByte + default_size: "32 GiB" platforms: - arch: "x86_64" bootloader: "uki" @@ -3116,11 +3093,9 @@ image_types: partitions: - size: "512 MiB" type: *efi_system_partition_guid - uuid: *efi_system_partition_uuid payload_type: "filesystem" payload: type: vfat - uuid: *efi_filesystem_uuid mountpoint: "/boot/efi" label: "EFI-SYSTEM" fstab_options: "defaults,uid=0,gid=0,umask=077,shortname=winnt" @@ -3177,6 +3152,7 @@ image_types: - "customizations.cacerts" - "customizations.directories" - "customizations.disk" + - "customizations.dnf" - "customizations.files" - "customizations.filesystem" - "customizations.partitioning_mode" diff --git a/vendor/github.com/osbuild/images/pkg/cloud/awscloud/awscloud.go b/vendor/github.com/osbuild/images/pkg/cloud/awscloud/awscloud.go index 0fe712956f..c27c198284 100644 --- a/vendor/github.com/osbuild/images/pkg/cloud/awscloud/awscloud.go +++ b/vendor/github.com/osbuild/images/pkg/cloud/awscloud/awscloud.go @@ -233,7 +233,7 @@ func ec2BootMode(bootMode *platform.BootMode) (ec2types.BootModeValues, error) { // The caller can optionally specify the boot mode of the AMI. If the boot // mode is not specified, then the instances launched from this AMI use the // default boot mode value of the instance type. -func (a *AWS) Register(name, bucket, key string, tags [][2]string, shareWith []string, architecture arch.Arch, bootMode *platform.BootMode, importRole *string) (string, string, error) { +func (a *AWS) Register(name, bucket, key string, tags []AWSTag, shareWith []string, architecture arch.Arch, bootMode *platform.BootMode, importRole *string) (string, string, error) { rpmArchToEC2Arch := map[arch.Arch]ec2types.ArchitectureValues{ arch.ARCH_X86_64: ec2types.ArchitectureValuesX8664, arch.ARCH_AARCH64: ec2types.ArchitectureValuesArm64, @@ -304,8 +304,8 @@ func (a *AWS) Register(name, bucket, key string, tags [][2]string, shareWith []s } for _, tag := range tags { ec2Tags = append(ec2Tags, ec2types.Tag{ - Key: aws.String(tag[0]), - Value: aws.String(tag[1]), + Key: aws.String(tag.Name), + Value: aws.String(tag.Value), }) } diff --git a/vendor/github.com/osbuild/images/pkg/cloud/awscloud/uploader.go b/vendor/github.com/osbuild/images/pkg/cloud/awscloud/uploader.go index f4df98117c..d5ec4c7c06 100644 --- a/vendor/github.com/osbuild/images/pkg/cloud/awscloud/uploader.go +++ b/vendor/github.com/osbuild/images/pkg/cloud/awscloud/uploader.go @@ -21,7 +21,7 @@ type awsUploader struct { region string bucketName string imageName string - tags [][2]string + tags []AWSTag targetArch arch.Arch bootMode *platform.BootMode } @@ -30,7 +30,12 @@ type UploaderOptions struct { TargetArch arch.Arch // BootMode to set for the AMI. If nil, no explicit boot mode will be set. BootMode *platform.BootMode - Tags [][2]string + Tags []AWSTag +} + +type AWSTag struct { + Name string + Value string } // testing support @@ -39,7 +44,7 @@ type awsClient interface { Buckets() ([]string, error) CheckBucketPermission(string, s3types.Permission) (bool, error) UploadFromReader(io.Reader, string, string) (*s3manager.UploadOutput, error) - Register(name, bucket, key string, tags [][2]string, shareWith []string, architecture arch.Arch, bootMode *platform.BootMode, importRole *string) (string, string, error) + Register(name, bucket, key string, tags []AWSTag, shareWith []string, architecture arch.Arch, bootMode *platform.BootMode, importRole *string) (string, string, error) DeleteObject(string, string) error } diff --git a/vendor/github.com/osbuild/images/pkg/customizations/kickstart/kickstart.go b/vendor/github.com/osbuild/images/pkg/customizations/kickstart/kickstart.go index 8d3842a10e..18574506f5 100644 --- a/vendor/github.com/osbuild/images/pkg/customizations/kickstart/kickstart.go +++ b/vendor/github.com/osbuild/images/pkg/customizations/kickstart/kickstart.go @@ -2,6 +2,7 @@ package kickstart import ( "fmt" + "strings" "github.com/osbuild/blueprint/pkg/blueprint" "github.com/osbuild/images/pkg/customizations/users" @@ -89,5 +90,40 @@ func (options Options) Validate() error { return fmt.Errorf("kickstart users and/or groups are not compatible with user-supplied kickstart content") } } + + // This check repeats the same checks that are made in the kickstart stage + // constructor. Repeating it here catches it earlier in the pipeline + // generation, before serialization starts. + for _, user := range options.Users { + if user.Name == "root" { + // return an error if any other field is set (except SSH) + unsupportedOptionsSet := make([]string, 0, 7) + if user.ExpireDate != nil { + unsupportedOptionsSet = append(unsupportedOptionsSet, "expiredate") + } + if user.ForcePasswordReset != nil { + unsupportedOptionsSet = append(unsupportedOptionsSet, "force_password_reset") + } + if user.GID != nil { + unsupportedOptionsSet = append(unsupportedOptionsSet, "gid") + } + if user.Groups != nil { + unsupportedOptionsSet = append(unsupportedOptionsSet, "groups") + } + if user.Home != nil { + unsupportedOptionsSet = append(unsupportedOptionsSet, "home") + } + if user.Shell != nil { + unsupportedOptionsSet = append(unsupportedOptionsSet, "shell") + } + if user.UID != nil { + unsupportedOptionsSet = append(unsupportedOptionsSet, "uid") + } + if len(unsupportedOptionsSet) > 0 { + return fmt.Errorf("unsupported kickstart options for user \"root\": %s", strings.Join(unsupportedOptionsSet, ", ")) + } + } + } + return nil } diff --git a/vendor/github.com/osbuild/images/pkg/datasizes/parse.go b/vendor/github.com/osbuild/images/pkg/datasizes/parse.go index 4ca32dd62f..2320e8602f 100644 --- a/vendor/github.com/osbuild/images/pkg/datasizes/parse.go +++ b/vendor/github.com/osbuild/images/pkg/datasizes/parse.go @@ -1,7 +1,6 @@ package datasizes import ( - "encoding/json" "fmt" "regexp" "strconv" @@ -55,26 +54,3 @@ func Parse(size string) (uint64, error) { // unknown units. return 0, fmt.Errorf("unknown data size units in string: %s", size) } - -// ParseSizeInJSONMapping will process the given JSON data, assuming it -// contains a mapping. It will convert the value of the given field to a size -// in bytes using the Parse function if the field exists and is a string. -func ParseSizeInJSONMapping(field string, data []byte) ([]byte, error) { - var mapping map[string]any - if err := json.Unmarshal(data, &mapping); err != nil { - return nil, fmt.Errorf("failed to unmarshal JSON data: %w", err) - } - - if rawSize, ok := mapping[field]; ok { - // If the size is a string, parse it and replace the value in the map - if sizeStr, ok := rawSize.(string); ok { - size, err := Parse(sizeStr) - if err != nil { - return nil, fmt.Errorf("failed to parse size field named %q to bytes: %w", field, err) - } - mapping[field] = size - } - } - - return json.Marshal(mapping) -} diff --git a/vendor/github.com/osbuild/images/pkg/datasizes/size.go b/vendor/github.com/osbuild/images/pkg/datasizes/size.go index 3394669f4b..c25fbd42bb 100644 --- a/vendor/github.com/osbuild/images/pkg/datasizes/size.go +++ b/vendor/github.com/osbuild/images/pkg/datasizes/size.go @@ -4,6 +4,8 @@ import ( "bytes" "encoding/json" "fmt" + + "github.com/osbuild/images/internal/common" ) // Size is a wrapper around uint64 with support for reading from string @@ -45,6 +47,10 @@ func (si *Size) UnmarshalJSON(data []byte) error { return nil } +func (si *Size) UnmarshalYAML(unmarshal func(any) error) error { + return common.UnmarshalYAMLviaJSON(si, unmarshal) +} + // decodeSize takes an integer or string representing a data size (with a data // suffix) and returns the uint64 representation. func decodeSize(size any) (uint64, error) { diff --git a/vendor/github.com/osbuild/images/pkg/depsolvednf/depsolvednf.go b/vendor/github.com/osbuild/images/pkg/depsolvednf/depsolvednf.go index a203a61ac1..292d20f04d 100644 --- a/vendor/github.com/osbuild/images/pkg/depsolvednf/depsolvednf.go +++ b/vendor/github.com/osbuild/images/pkg/depsolvednf/depsolvednf.go @@ -167,7 +167,7 @@ type Solver struct { // DepsolveResult contains the results of a depsolve operation. type DepsolveResult struct { - Packages []rpmmd.PackageSpec + Packages rpmmd.PackageList Modules []rpmmd.ModuleSpec Repos []rpmmd.RepoConfig SBOM *sbom.Document @@ -277,7 +277,7 @@ func (s *Solver) FetchMetadata(repos []rpmmd.RepoConfig) (rpmmd.PackageList, err return pkgs, nil } - result, err := run(s.depsolveDNFCmd, req, s.Stderr) + rawRes, err := run(s.depsolveDNFCmd, req, s.Stderr) if err != nil { return nil, err } @@ -290,11 +290,13 @@ func (s *Solver) FetchMetadata(repos []rpmmd.RepoConfig) (rpmmd.PackageList, err } s.cache.updateInfo() - var pkgs rpmmd.PackageList - if err := json.Unmarshal(result, &pkgs); err != nil { + var res dumpResult + if err := json.Unmarshal(rawRes, &res); err != nil { return nil, err } + pkgs := res.toRPMMD() + sortID := func(pkg rpmmd.Package) string { return fmt.Sprintf("%s-%s-%s", pkg.Name, pkg.Version, pkg.Release) } @@ -323,7 +325,7 @@ func (s *Solver) SearchMetadata(repos []rpmmd.RepoConfig, packages []string) (rp return pkgs, nil } - result, err := run(s.depsolveDNFCmd, req, s.Stderr) + rawRes, err := run(s.depsolveDNFCmd, req, s.Stderr) if err != nil { return nil, err } @@ -336,11 +338,13 @@ func (s *Solver) SearchMetadata(repos []rpmmd.RepoConfig, packages []string) (rp } s.cache.updateInfo() - var pkgs rpmmd.PackageList - if err := json.Unmarshal(result, &pkgs); err != nil { + var res searchResult + if err := json.Unmarshal(rawRes, &res); err != nil { return nil, err } + pkgs := res.toRPMMD() + sortID := func(pkg rpmmd.Package) string { return fmt.Sprintf("%s-%s-%s", pkg.Name, pkg.Version, pkg.Release) } @@ -580,10 +584,10 @@ func (s *Solver) makeSearchRequest(repos []rpmmd.RepoConfig, packages []string) // convert internal a list of PackageSpecs and map of repoConfig to the rpmmd // equivalents and attach key and subscription information based on the // repository configs. -func (result depsolveResult) toRPMMD(rhsm map[string]bool) ([]rpmmd.PackageSpec, []rpmmd.ModuleSpec, []rpmmd.RepoConfig) { +func (result depsolveResult) toRPMMD(rhsm map[string]bool) (rpmmd.PackageList, []rpmmd.ModuleSpec, []rpmmd.RepoConfig) { pkgs := result.Packages repos := result.Repos - rpmDependencies := make([]rpmmd.PackageSpec, len(pkgs)) + rpmDependencies := make(rpmmd.PackageList, len(pkgs)) for i, dep := range pkgs { repo, ok := repos[dep.RepoID] if !ok { @@ -595,11 +599,19 @@ func (result depsolveResult) toRPMMD(rhsm map[string]bool) ([]rpmmd.PackageSpec, rpmDependencies[i].Version = dep.Version rpmDependencies[i].Release = dep.Release rpmDependencies[i].Arch = dep.Arch - rpmDependencies[i].RemoteLocation = dep.RemoteLocation - rpmDependencies[i].Checksum = dep.Checksum + rpmDependencies[i].RemoteLocations = []string{dep.RemoteLocation} + + depChecksum := strings.Split(dep.Checksum, ":") + if len(depChecksum) != 2 { + panic(fmt.Sprintf("invalid checksum format for package %s: %s", dep.Name, dep.Checksum)) + } + rpmDependencies[i].Checksum = rpmmd.Checksum{ + Type: depChecksum[0], + Value: depChecksum[1], + } rpmDependencies[i].CheckGPG = repo.GPGCheck rpmDependencies[i].RepoID = dep.RepoID - rpmDependencies[i].Path = dep.Path + rpmDependencies[i].Location = dep.Path if verify := repo.SSLVerify; verify != nil { rpmDependencies[i].IgnoreSSL = !*verify } @@ -752,8 +764,8 @@ type transactionArgs struct { InstallWeakDeps bool `json:"install_weak_deps"` } -type packageSpecs []PackageSpec -type moduleSpecs map[string]ModuleSpec +type packageSpecs []packageSpec +type moduleSpecs map[string]moduleSpec type depsolveResult struct { Packages packageSpecs `json:"packages"` @@ -767,8 +779,46 @@ type depsolveResult struct { SBOM json.RawMessage `json:"sbom,omitempty"` } +// legacyPackageList represents the old 'PackageList' structure, which +// was used for both dump and search results. It is kept here for unmarshaling +// the results. +type legacyPackageList []struct { + Name string `json:"name"` + Summary string `json:"summary"` + Description string `json:"description"` + URL string `json:"url"` + Epoch uint `json:"epoch"` + Version string `json:"version"` + Release string `json:"release"` + Arch string `json:"arch"` + BuildTime time.Time `json:"build_time"` + License string `json:"license"` +} + +type dumpResult = legacyPackageList +type searchResult = legacyPackageList + +func (pl legacyPackageList) toRPMMD() rpmmd.PackageList { + rpmPkgs := make(rpmmd.PackageList, len(pl)) + for i, p := range pl { + rpmPkgs[i] = rpmmd.Package{ + Name: p.Name, + Summary: p.Summary, + Description: p.Description, + URL: p.URL, + Epoch: p.Epoch, + Version: p.Version, + Release: p.Release, + Arch: p.Arch, + BuildTime: p.BuildTime, + License: p.License, + } + } + return rpmPkgs +} + // Package specification -type PackageSpec struct { +type packageSpec struct { Name string `json:"name"` Epoch uint `json:"epoch"` Version string `json:"version,omitempty"` @@ -778,28 +828,27 @@ type PackageSpec struct { Path string `json:"path,omitempty"` RemoteLocation string `json:"remote_location,omitempty"` Checksum string `json:"checksum,omitempty"` - Secrets string `json:"secrets,omitempty"` } // Module specification -type ModuleSpec struct { - ModuleConfigFile ModuleConfigFile `json:"module-file"` - FailsafeFile ModuleFailsafeFile `json:"failsafe-file"` +type moduleSpec struct { + ModuleConfigFile moduleConfigFile `json:"module-file"` + FailsafeFile moduleFailsafeFile `json:"failsafe-file"` } -type ModuleConfigFile struct { +type moduleConfigFile struct { Path string `json:"path"` - Data ModuleConfigData `json:"data"` + Data moduleConfigData `json:"data"` } -type ModuleConfigData struct { +type moduleConfigData struct { Name string `json:"name"` Stream string `json:"stream"` Profiles []string `json:"profiles"` State string `json:"state"` } -type ModuleFailsafeFile struct { +type moduleFailsafeFile struct { Path string `json:"path"` Data string `json:"data"` } diff --git a/vendor/github.com/osbuild/images/pkg/disk/btrfs.go b/vendor/github.com/osbuild/images/pkg/disk/btrfs.go index b71f123271..3d472337ed 100644 --- a/vendor/github.com/osbuild/images/pkg/disk/btrfs.go +++ b/vendor/github.com/osbuild/images/pkg/disk/btrfs.go @@ -60,7 +60,7 @@ func (b *Btrfs) GetItemCount() uint { func (b *Btrfs) GetChild(n uint) Entity { return &b.Subvolumes[n] } -func (b *Btrfs) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { +func (b *Btrfs) CreateMountpoint(mountpoint, defaultFs string, size datasizes.Size) (Entity, error) { if defaultFs != "btrfs" { return nil, fmt.Errorf("only btrfs mountpoints are supported with btrfs subvolumes not %q", defaultFs) } @@ -82,7 +82,7 @@ func (b *Btrfs) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Ent return &b.Subvolumes[len(b.Subvolumes)-1], nil } -func (b *Btrfs) AlignUp(size uint64) uint64 { +func (b *Btrfs) AlignUp(size datasizes.Size) datasizes.Size { return size // No extra alignment necessary for subvolumes } @@ -96,12 +96,12 @@ func (b *Btrfs) GenUUID(rng *rand.Rand) { } } -func (b *Btrfs) MetadataSize() uint64 { +func (b *Btrfs) MetadataSize() datasizes.Size { return 0 } -func (b *Btrfs) minSize(size uint64) uint64 { - var subvolsum uint64 +func (b *Btrfs) minSize(size datasizes.Size) datasizes.Size { + var subvolsum datasizes.Size for _, sv := range b.Subvolumes { subvolsum += sv.Size } @@ -115,23 +115,18 @@ func (b *Btrfs) minSize(size uint64) uint64 { } type BtrfsSubvolume struct { - Name string `json:"name" yaml:"name"` - Size uint64 `json:"size" yaml:"size"` - Mountpoint string `json:"mountpoint,omitempty" yaml:"mountpoint,omitempty"` - GroupID uint64 `json:"group_id,omitempty" yaml:"group_id,omitempty"` - Compress string `json:"compress,omitempty" yaml:"compress,omitempty"` - ReadOnly bool `json:"read_only,omitempty" yaml:"read_only,omitempty"` + Name string `json:"name" yaml:"name"` + Size datasizes.Size `json:"size" yaml:"size"` + Mountpoint string `json:"mountpoint,omitempty" yaml:"mountpoint,omitempty"` + GroupID uint64 `json:"group_id,omitempty" yaml:"group_id,omitempty"` + Compress string `json:"compress,omitempty" yaml:"compress,omitempty"` + ReadOnly bool `json:"read_only,omitempty" yaml:"read_only,omitempty"` // UUID of the parent volume UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"` } func (sv *BtrfsSubvolume) UnmarshalJSON(data []byte) (err error) { - data, err = datasizes.ParseSizeInJSONMapping("size", data) - if err != nil { - return fmt.Errorf("error parsing size in btrfs subvolume: %w", err) - } - type aliasStruct BtrfsSubvolume var alias aliasStruct if err := jsonUnmarshalStrict(data, &alias); err != nil { @@ -160,14 +155,14 @@ func (bs *BtrfsSubvolume) Clone() Entity { } } -func (bs *BtrfsSubvolume) GetSize() uint64 { +func (bs *BtrfsSubvolume) GetSize() datasizes.Size { if bs == nil { return 0 } return bs.Size } -func (bs *BtrfsSubvolume) EnsureSize(s uint64) bool { +func (bs *BtrfsSubvolume) EnsureSize(s datasizes.Size) bool { if s > bs.Size { bs.Size = s return true diff --git a/vendor/github.com/osbuild/images/pkg/disk/disk.go b/vendor/github.com/osbuild/images/pkg/disk/disk.go index eb96bb640f..6bb331fc97 100644 --- a/vendor/github.com/osbuild/images/pkg/disk/disk.go +++ b/vendor/github.com/osbuild/images/pkg/disk/disk.go @@ -31,6 +31,7 @@ import ( "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/arch" + "github.com/osbuild/images/pkg/datasizes" ) const ( @@ -40,7 +41,7 @@ const ( // Default grain size in bytes. The grain controls how sizes of certain // entities are rounded. For example, by default, partition sizes are // rounded to the next MiB. - DefaultGrainBytes = uint64(1048576) // 1 MiB + DefaultGrainBytes = datasizes.Size(1048576) // 1 MiB // GUIDs (partition types) for partitions on GPT disks // The SD_GPT name next to each constant is the partition type shown in @@ -341,10 +342,10 @@ type Container interface { type Sizeable interface { // EnsureSize will resize the entity to the given size in case // it is currently smaller. Returns if the size was changed. - EnsureSize(size uint64) bool + EnsureSize(size datasizes.Size) bool // GetSize returns the size of the entity in bytes. - GetSize() uint64 + GetSize() datasizes.Size } // A Mountable entity is an entity that can be mounted. @@ -378,11 +379,11 @@ type FSTabEntity interface { // mountpoint. The defaultFs is only a hint and can be ignored by // e.g. btrfs subvolumes. type MountpointCreator interface { - CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) + CreateMountpoint(mountpoint, defaultFs string, size datasizes.Size) (Entity, error) // AlignUp will align the given bytes according to the // requirements of the container type. - AlignUp(size uint64) uint64 + AlignUp(size datasizes.Size) datasizes.Size } // A UniqueEntity is an entity that can be uniquely identified via a UUID. @@ -399,7 +400,7 @@ type VolumeContainer interface { // MetadataSize returns the size of the container's metadata (in // bytes), i.e. the storage space that needs to be reserved for // the container itself, in contrast to the data it contains. - MetadataSize() uint64 + MetadataSize() datasizes.Size // minSize returns the size for the VolumeContainer that is either the // provided desired size value or the sum of all children if that is @@ -409,7 +410,7 @@ type VolumeContainer interface { // VolumeContainer's size, or its parent size, will be able to hold the // VolumeContainer if it is created with the exact size returned by the // function. - minSize(size uint64) uint64 + minSize(size datasizes.Size) datasizes.Size } // FSSpec for a filesystem (UUID and Label); the first field of fstab(5) diff --git a/vendor/github.com/osbuild/images/pkg/disk/luks.go b/vendor/github.com/osbuild/images/pkg/disk/luks.go index f35bc8a867..99aae60f48 100644 --- a/vendor/github.com/osbuild/images/pkg/disk/luks.go +++ b/vendor/github.com/osbuild/images/pkg/disk/luks.go @@ -112,7 +112,7 @@ func (lc *LUKSContainer) GenUUID(rng *rand.Rand) { } } -func (lc *LUKSContainer) MetadataSize() uint64 { +func (lc *LUKSContainer) MetadataSize() datasizes.Size { if lc == nil { return 0 } @@ -121,7 +121,7 @@ func (lc *LUKSContainer) MetadataSize() uint64 { return 16 * datasizes.MiB } -func (lc *LUKSContainer) minSize(size uint64) uint64 { +func (lc *LUKSContainer) minSize(size datasizes.Size) datasizes.Size { // since a LUKS container can contain pretty much any payload, but we only // care about the ones that have a size, or contain children with sizes minSize := lc.MetadataSize() diff --git a/vendor/github.com/osbuild/images/pkg/disk/lvm.go b/vendor/github.com/osbuild/images/pkg/disk/lvm.go index 8cf1e85841..753ecccc56 100644 --- a/vendor/github.com/osbuild/images/pkg/disk/lvm.go +++ b/vendor/github.com/osbuild/images/pkg/disk/lvm.go @@ -75,7 +75,7 @@ func (vg *LVMVolumeGroup) GetChild(n uint) Entity { return &vg.LogicalVolumes[n] } -func (vg *LVMVolumeGroup) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { +func (vg *LVMVolumeGroup) CreateMountpoint(mountpoint, defaultFs string, size datasizes.Size) (Entity, error) { if defaultFs == "btrfs" { return nil, fmt.Errorf("btrfs under lvm is not supported") } @@ -110,7 +110,7 @@ func (vg *LVMVolumeGroup) genLVName(base string) (string, error) { // CreateLogicalVolume creates a new logical volume on the volume group. If a // name is not provided, a valid one is generated based on the payload // mountpoint. If a name is provided, it is used directly without validating. -func (vg *LVMVolumeGroup) CreateLogicalVolume(lvName string, size uint64, payload Entity) (*LVMLogicalVolume, error) { +func (vg *LVMVolumeGroup) CreateLogicalVolume(lvName string, size datasizes.Size, payload Entity) (*LVMLogicalVolume, error) { if vg == nil { panic("LVMVolumeGroup.CreateLogicalVolume: nil entity") } @@ -143,7 +143,7 @@ func (vg *LVMVolumeGroup) CreateLogicalVolume(lvName string, size uint64, payloa return &vg.LogicalVolumes[len(vg.LogicalVolumes)-1], nil } -func alignUp(size uint64) uint64 { +func alignUp(size datasizes.Size) datasizes.Size { if size%LVMDefaultExtentSize != 0 { size += LVMDefaultExtentSize - size%LVMDefaultExtentSize } @@ -151,11 +151,11 @@ func alignUp(size uint64) uint64 { return size } -func (vg *LVMVolumeGroup) AlignUp(size uint64) uint64 { +func (vg *LVMVolumeGroup) AlignUp(size datasizes.Size) datasizes.Size { return alignUp(size) } -func (vg *LVMVolumeGroup) MetadataSize() uint64 { +func (vg *LVMVolumeGroup) MetadataSize() datasizes.Size { if vg == nil { return 0 } @@ -167,8 +167,8 @@ func (vg *LVMVolumeGroup) MetadataSize() uint64 { return 1 * datasizes.MiB } -func (vg *LVMVolumeGroup) minSize(size uint64) uint64 { - var lvsum uint64 +func (vg *LVMVolumeGroup) minSize(size datasizes.Size) datasizes.Size { + var lvsum datasizes.Size for _, lv := range vg.LogicalVolumes { lvsum += lv.Size } @@ -192,9 +192,9 @@ func (vg *LVMVolumeGroup) UnmarshalJSON(data []byte) error { } type LVMLogicalVolume struct { - Name string `json:"name,omitempty" yaml:"name,omitempty"` - Size uint64 `json:"size,omitempty" yaml:"size,omitempty"` - Payload Entity `json:"payload,omitempty" yaml:"payload,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` + Size datasizes.Size `json:"size,omitempty" yaml:"size,omitempty"` + Payload Entity `json:"payload,omitempty" yaml:"payload,omitempty"` } func (lv *LVMLogicalVolume) Clone() Entity { @@ -222,14 +222,14 @@ func (lv *LVMLogicalVolume) GetChild(n uint) Entity { return lv.Payload } -func (lv *LVMLogicalVolume) GetSize() uint64 { +func (lv *LVMLogicalVolume) GetSize() datasizes.Size { if lv == nil { return 0 } return lv.Size } -func (lv *LVMLogicalVolume) EnsureSize(s uint64) bool { +func (lv *LVMLogicalVolume) EnsureSize(s datasizes.Size) bool { if lv == nil { panic("LVMLogicalVolume.EnsureSize: nil entity") } @@ -251,11 +251,6 @@ func lvname(path string) string { } func (lv *LVMLogicalVolume) UnmarshalJSON(data []byte) (err error) { - data, err = datasizes.ParseSizeInJSONMapping("size", data) - if err != nil { - return fmt.Errorf("error parsing size in LVM LV: %w", err) - } - // keep in sync with lvm.go,partition.go,luks.go type alias LVMLogicalVolume var withoutPayload struct { diff --git a/vendor/github.com/osbuild/images/pkg/disk/partition.go b/vendor/github.com/osbuild/images/pkg/disk/partition.go index 79991cf80d..572e66f8f3 100644 --- a/vendor/github.com/osbuild/images/pkg/disk/partition.go +++ b/vendor/github.com/osbuild/images/pkg/disk/partition.go @@ -13,7 +13,7 @@ type Partition struct { // Start of the partition in bytes Start uint64 `json:"start,omitempty" yaml:"start,omitempty"` // Size of the partition in bytes - Size uint64 `json:"size" yaml:"size"` + Size datasizes.Size `json:"size" yaml:"size"` // Partition type, e.g. 0x83 for MBR or a UUID for gpt Type string `json:"type,omitempty" yaml:"type,omitempty"` // `Legacy BIOS bootable` (GPT) or `active` (DOS) flag @@ -72,7 +72,7 @@ func (p *Partition) GetChild(n uint) Entity { // fitTo resizes a partition to be either the given the size or the size of its // payload if that is larger. The payload can be larger if it is a container // with sized children. -func (p *Partition) fitTo(size uint64) { +func (p *Partition) fitTo(size datasizes.Size) { payload, isVC := p.Payload.(VolumeContainer) if isVC { if payloadMinSize := payload.minSize(size); payloadMinSize > size { @@ -82,13 +82,13 @@ func (p *Partition) fitTo(size uint64) { p.Size = size } -func (p *Partition) GetSize() uint64 { +func (p *Partition) GetSize() datasizes.Size { return p.Size } // Ensure the partition has at least the given size. Will do nothing // if the partition is already larger. Returns if the size changed. -func (p *Partition) EnsureSize(s uint64) bool { +func (p *Partition) EnsureSize(s datasizes.Size) bool { if s > p.Size { p.Size = s return true @@ -132,11 +132,6 @@ func (p *Partition) MarshalJSON() ([]byte, error) { } func (p *Partition) UnmarshalJSON(data []byte) (err error) { - data, err = datasizes.ParseSizeInJSONMapping("size", data) - if err != nil { - return fmt.Errorf("error parsing size in partition: %w", err) - } - // keep in sync with lvm.go,partition.go,luks.go type alias Partition var withoutPayload struct { diff --git a/vendor/github.com/osbuild/images/pkg/disk/partition_table.go b/vendor/github.com/osbuild/images/pkg/disk/partition_table.go index 522e08199e..b013d002c3 100644 --- a/vendor/github.com/osbuild/images/pkg/disk/partition_table.go +++ b/vendor/github.com/osbuild/images/pkg/disk/partition_table.go @@ -18,7 +18,7 @@ import ( type PartitionTable struct { // Size of the disk (in bytes). - Size uint64 `json:"size,omitempty" yaml:"size,omitempty"` + Size datasizes.Size `json:"size,omitempty" yaml:"size,omitempty"` // Unique identifier of the partition table (GPT only). UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"` // Partition table type, e.g. dos, gpt. @@ -30,11 +30,17 @@ type PartitionTable struct { // Extra space at the end of the partition table (sectors) ExtraPadding uint64 `json:"extra_padding,omitempty" yaml:"extra_padding,omitempty"` // Starting offset of the first partition in the table (in bytes) - StartOffset uint64 `json:"start_offset,omitempty" yaml:"start_offset,omitempty"` + StartOffset Offset `json:"start_offset,omitempty" yaml:"start_offset,omitempty"` } var _ = MountpointCreator(&PartitionTable{}) +// Offset describes the offset as a "size", this allows us to reuse +// the datasize.Size json/toml/yaml loaders to specify the offset +// as a nice string. We still make it a distinct type for readability +// (as `StartOffset datasize.Size` would be weird). +type Offset = datasizes.Size + // DefaultBootPartitionSize is the default size of the /boot partition if it // needs to be auto-created. This happens if the custom partitioning don't // specify one, but the image requires one to boot (/ is on btrfs, or an LV). @@ -93,7 +99,7 @@ const DefaultBootPartitionSize = 1 * datasizes.GiB // containing the root filesystem is grown to fill any left over space on the // partition table. Logical Volumes are not grown to fill the space in the // Volume Group since they are trivial to grow on a live system. -func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.FilesystemCustomization, imageSize uint64, mode partition.PartitioningMode, architecture arch.Arch, requiredSizes map[string]uint64, defaultFs string, rng *rand.Rand) (*PartitionTable, error) { +func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.FilesystemCustomization, imageSize datasizes.Size, mode partition.PartitioningMode, architecture arch.Arch, requiredSizes map[string]datasizes.Size, defaultFs string, rng *rand.Rand) (*PartitionTable, error) { newPT := basePT.Clone().(*PartitionTable) if basePT.features().LVM && (mode == partition.RawPartitioningMode || mode == partition.BtrfsPartitioningMode) { @@ -143,9 +149,9 @@ func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.Filesyste // If no separate requiredSizes are given then we use our defaults if requiredSizes == nil { - requiredSizes = map[string]uint64{ - "/": 1073741824, - "/usr": 2147483648, + requiredSizes = map[string]datasizes.Size{ + "/": 1 * datasizes.GiB, + "/usr": 2 * datasizes.GiB, } } @@ -163,13 +169,6 @@ func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.Filesyste } func (pt *PartitionTable) UnmarshalJSON(data []byte) (err error) { - for _, field := range []string{"size", "start_offset"} { - data, err = datasizes.ParseSizeInJSONMapping(field, data) - if err != nil { - return fmt.Errorf("error parsing %q in partition table: %w", field, err) - } - } - type aliasStruct PartitionTable var alias aliasStruct if err := jsonUnmarshalStrict(data, &alias); err != nil { @@ -218,7 +217,7 @@ func (pt *PartitionTable) Clone() Entity { // AlignUp will round up the given size value to the default grain if not // already aligned. -func (pt *PartitionTable) AlignUp(size uint64) uint64 { +func (pt *PartitionTable) AlignUp(size datasizes.Size) datasizes.Size { grain := DefaultGrainBytes if size%grain == 0 { // already aligned: return unchanged @@ -285,13 +284,13 @@ func (pt *PartitionTable) GetChild(n uint) Entity { return &pt.Partitions[n] } -func (pt *PartitionTable) GetSize() uint64 { +func (pt *PartitionTable) GetSize() datasizes.Size { return pt.Size } -func (pt *PartitionTable) EnsureSize(s uint64) bool { +func (pt *PartitionTable) EnsureSize(s datasizes.Size) bool { if s > pt.Size { - pt.Size = s + pt.Size = datasizes.Size(s) return true } return false @@ -316,11 +315,11 @@ func (pt *PartitionTable) findDirectoryEntityPath(dir string) []Entity { // and resizes the appropriate partitions such that they are at least the size // of the sum of their subdirectories plus their own sizes. // The function will panic if any of the directory paths are invalid. -func (pt *PartitionTable) EnsureDirectorySizes(dirSizeMap map[string]uint64) { +func (pt *PartitionTable) EnsureDirectorySizes(dirSizeMap map[string]datasizes.Size) { type mntSize struct { entPath []Entity - newSize uint64 + newSize datasizes.Size } // add up the required size for each directory grouped by their mountpoints @@ -345,7 +344,7 @@ func (pt *PartitionTable) EnsureDirectorySizes(dirSizeMap map[string]uint64) { } } -func (pt *PartitionTable) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { +func (pt *PartitionTable) CreateMountpoint(mountpoint, defaultFs string, size datasizes.Size) (Entity, error) { filesystem := Filesystem{ Type: defaultFs, Mountpoint: mountpoint, @@ -416,13 +415,13 @@ func (pt *PartitionTable) ForEachEntity(cb EntityCallback) error { return forEachEntity(pt, []Entity{}, cb) } -func (pt *PartitionTable) HeaderSize() uint64 { +func (pt *PartitionTable) HeaderSize() datasizes.Size { // always reserve one extra sector for the GPT header // this also ensure we have enough space for the MBR header := pt.SectorsToBytes(1) if pt.Type == PT_DOS { - return header + return datasizes.Size(header) } // calculate the space we need for @@ -438,7 +437,7 @@ func (pt *PartitionTable) HeaderSize() uint64 { // name exceeds 72 bytes header += parts * 128 - return header + return datasizes.Size(header) } // Apply filesystem customization to the partition table. If create is false, @@ -451,7 +450,8 @@ func (pt *PartitionTable) applyCustomization(mountpoints []blueprint.FilesystemC newMountpoints := []blueprint.FilesystemCustomization{} for _, mnt := range mountpoints { - size := clampFSSize(mnt.Mountpoint, mnt.MinSize) + // TODO: make blueprint.MinSize type datasize.Size too + size := clampFSSize(mnt.Mountpoint, datasizes.Size(mnt.MinSize)) if path := entityPath(pt, mnt.Mountpoint); len(path) != 0 { size = alignEntityBranch(path, size) resizeEntityBranch(path, size) @@ -471,18 +471,18 @@ func (pt *PartitionTable) applyCustomization(mountpoints []blueprint.FilesystemC // partitions. Adjusts the overall size of image to either the supplied value // in `size` or to the sum of all partitions if that is larger. Will grow the // root partition if there is any empty space. Returns the updated start point. -func (pt *PartitionTable) relayout(size uint64) uint64 { +func (pt *PartitionTable) relayout(size datasizes.Size) uint64 { // always reserve one extra sector for the GPT header header := pt.HeaderSize() - footer := uint64(0) + footer := datasizes.Size(0) // The GPT header is also at the end of the partition table if pt.Type == PT_GPT { footer = header } - start := pt.AlignUp(header) - start += pt.StartOffset + start := pt.AlignUp(header).Uint64() + start += pt.StartOffset.Uint64() size = pt.AlignUp(size) var rootIdx = -1 @@ -497,7 +497,7 @@ func (pt *PartitionTable) relayout(size uint64) uint64 { partition.Start = start partition.fitTo(partition.Size) partition.Size = pt.AlignUp(partition.Size) - start += partition.Size + start += partition.Size.Uint64() } if rootIdx < 0 { @@ -509,21 +509,21 @@ func (pt *PartitionTable) relayout(size uint64) uint64 { root.fitTo(root.Size) // add the extra padding specified in the partition table - footer += pt.ExtraPadding + footer += datasizes.Size(pt.ExtraPadding) // If the sum of all partitions is bigger then the specified size, // we use that instead. Grow the partition table size if needed. - end := pt.AlignUp(root.Start + footer + root.Size) + end := pt.AlignUp(datasizes.Size(root.Start) + footer + root.Size) if end > size { size = end } if size > pt.Size { - pt.Size = size + pt.Size = datasizes.Size(size) } // If there is space left in the partition table, grow root - root.Size = pt.Size - root.Start + root.Size = pt.Size - datasizes.Size(root.Start) // Finally we shrink the last partition, i.e. the root partition, // to leave space for the footer, e.g. the secondary GPT header. @@ -534,7 +534,7 @@ func (pt *PartitionTable) relayout(size uint64) uint64 { return start } -func (pt *PartitionTable) createFilesystem(mountpoint, defaultFs string, size uint64) error { +func (pt *PartitionTable) createFilesystem(mountpoint, defaultFs string, size datasizes.Size) error { rootPath := entityPath(pt, "/") if rootPath == nil { panic("no root mountpoint for PartitionTable") @@ -653,10 +653,10 @@ func (pt *PartitionTable) FindMountable(mountpoint string) Mountable { return path[0].(Mountable) } -func clampFSSize(mountpoint string, size uint64) uint64 { +func clampFSSize(mountpoint string, size datasizes.Size) datasizes.Size { // set a minimum size of 1GB for all mountpoints // with the exception for '/boot' (= 500 MB) - var minSize uint64 = 1073741824 + var minSize datasizes.Size = 1073741824 if mountpoint == "/boot" { minSize = 524288000 @@ -668,7 +668,7 @@ func clampFSSize(mountpoint string, size uint64) uint64 { return size } -func alignEntityBranch(path []Entity, size uint64) uint64 { +func alignEntityBranch(path []Entity, size datasizes.Size) datasizes.Size { if len(path) == 0 { return size } @@ -685,7 +685,7 @@ func alignEntityBranch(path []Entity, size uint64) uint64 { // resizeEntityBranch resizes the first entity in the specified path to be at // least the specified size and then grows every entity up the path to the // PartitionTable accordingly. -func resizeEntityBranch(path []Entity, size uint64) { +func resizeEntityBranch(path []Entity, size datasizes.Size) { if len(path) == 0 { return } @@ -693,7 +693,7 @@ func resizeEntityBranch(path []Entity, size uint64) { element := path[0] if c, ok := element.(Container); ok { - containerSize := uint64(0) + containerSize := datasizes.Size(0) for idx := uint(0); idx < c.GetItemCount(); idx++ { if s, ok := c.GetChild(idx).(Sizeable); ok { containerSize += s.GetSize() @@ -945,7 +945,7 @@ func (pt *PartitionTable) GetBuildPackages() []string { // GetMountpointSize takes a mountpoint and returns the size of the entity this // mountpoint belongs to. -func (pt *PartitionTable) GetMountpointSize(mountpoint string) (uint64, error) { +func (pt *PartitionTable) GetMountpointSize(mountpoint string) (datasizes.Size, error) { path := entityPath(pt, mountpoint) if path == nil { return 0, fmt.Errorf("cannot find mountpoint %s", mountpoint) @@ -1205,7 +1205,7 @@ func mkBIOSBoot(ptType PartitionTableType) (Partition, error) { }, nil } -func mkESP(size uint64, ptType PartitionTableType) (Partition, error) { +func mkESP(size datasizes.Size, ptType PartitionTableType) (Partition, error) { partType, err := getPartitionTypeIDfor(ptType, "esp", arch.ARCH_UNSET) if err != nil { return Partition{}, fmt.Errorf("error creating EFI system partition: %w", err) @@ -1251,7 +1251,7 @@ type CustomPartitionTableOptions struct { // directory requirements are additive, meaning the minimum size for a // mountpoint's partition is the sum of all the required directory sizes it // will contain. - RequiredMinSizes map[string]uint64 + RequiredMinSizes map[string]datasizes.Size // Architecture of the hardware that will use the partition table. This is // used to select appropriate partition types for GPT formatted disks to @@ -1385,7 +1385,8 @@ func NewCustomPartitionTable(customizations *blueprint.DiskCustomization, option pt.EnsureDirectorySizes(options.RequiredMinSizes) } - pt.relayout(customizations.MinSize) + // TODO: make blueprint MinSize of type datatypes.Size too + pt.relayout(datasizes.Size(customizations.MinSize)) pt.GenerateUUIDs(rng) // One thing not caught by the customization validation is if a final "dos" @@ -1473,10 +1474,11 @@ func addPlainPartition(pt *PartitionTable, partition blueprint.PartitionCustomiz } newpart := Partition{ - Type: partType, - UUID: partition.PartUUID, - Label: partition.PartLabel, - Size: partition.MinSize, + Type: partType, + UUID: partition.PartUUID, + Label: partition.PartLabel, + // TODO: make disk customization MinSize type datasizes.Size + Size: datasizes.Size(partition.MinSize), Payload: payload, } pt.Partitions = append(pt.Partitions, newpart) @@ -1531,7 +1533,7 @@ func addLVMPartition(pt *PartitionTable, partition blueprint.PartitionCustomizat FSTabOptions: "defaults", // TODO: add customization } } - if _, err := newvg.CreateLogicalVolume(lv.Name, lv.MinSize, newfs); err != nil { + if _, err := newvg.CreateLogicalVolume(lv.Name, datasizes.Size(lv.MinSize), newfs); err != nil { return fmt.Errorf("error creating logical volume %q (%s): %w", lv.Name, lv.Mountpoint, err) } } @@ -1550,7 +1552,7 @@ func addLVMPartition(pt *PartitionTable, partition blueprint.PartitionCustomizat Type: partType, UUID: partition.PartUUID, Label: partition.PartLabel, - Size: partition.MinSize, + Size: datasizes.Size(partition.MinSize), Bootable: false, Payload: newvg, } @@ -1587,7 +1589,7 @@ func addBtrfsPartition(pt *PartitionTable, partition blueprint.PartitionCustomiz Label: partition.PartLabel, Bootable: false, Payload: newvol, - Size: partition.MinSize, + Size: datasizes.Size(partition.MinSize), } pt.Partitions = append(pt.Partitions, newpart) diff --git a/vendor/github.com/osbuild/images/pkg/distro/bootc/partition.go b/vendor/github.com/osbuild/images/pkg/distro/bootc/partition.go index 98952ac17f..1c54672f51 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/bootc/partition.go +++ b/vendor/github.com/osbuild/images/pkg/distro/bootc/partition.go @@ -7,14 +7,14 @@ import ( "github.com/osbuild/blueprint/pkg/blueprint" + "github.com/osbuild/images/pkg/datasizes" "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/disk/partition" "github.com/osbuild/images/pkg/pathpolicy" - "github.com/osbuild/images/pkg/platform" ) const ( - DEFAULT_SIZE = uint64(10 * GibiByte) + DEFAULT_SIZE = datasizes.Size(10 * GibiByte) // As a baseline heuristic we double the size of // the input container to support in-place updates. @@ -147,7 +147,7 @@ func (t *BootcImageType) genPartitionTableDiskCust(basept *disk.PartitionTable, partOptions := &disk.CustomPartitionTableOptions{ PartitionTableType: basept.Type, // XXX: not setting/defaults will fail to boot with btrfs/lvm - BootMode: platform.BOOT_HYBRID, + BootMode: t.BootMode(), DefaultFSType: defaultFSType, RequiredMinSizes: requiredMinSizes, Architecture: t.arch.arch, @@ -208,7 +208,7 @@ func checkMountpoints(filesystems []blueprint.FilesystemCustomization, policy *p // // Note that a custom "/usr" is not supported in image mode so splitting // rootfsMinSize between / and /usr is not a concern. -func calcRequiredDirectorySizes(distCust *blueprint.DiskCustomization, rootfsMinSize uint64) (map[string]uint64, error) { +func calcRequiredDirectorySizes(distCust *blueprint.DiskCustomization, rootfsMinSize uint64) (map[string]datasizes.Size, error) { // XXX: this has *way* too much low-level knowledge about the // inner workings of blueprint.DiskCustomizations plus when // a new type it needs to get added here too, think about @@ -231,8 +231,8 @@ func calcRequiredDirectorySizes(distCust *blueprint.DiskCustomization, rootfsMin } } // ensure rootfsMinSize is respected - return map[string]uint64{ - "/": max(rootfsMinSize, mounts["/"]), + return map[string]datasizes.Size{ + "/": datasizes.Size(max(rootfsMinSize, mounts["/"])), }, nil } diff --git a/vendor/github.com/osbuild/images/pkg/distro/defs/loader.go b/vendor/github.com/osbuild/images/pkg/distro/defs/loader.go index d1625fc858..4f2dc4c76f 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/defs/loader.go +++ b/vendor/github.com/osbuild/images/pkg/distro/defs/loader.go @@ -19,6 +19,7 @@ import ( "github.com/osbuild/images/internal/environment" "github.com/osbuild/images/pkg/arch" "github.com/osbuild/images/pkg/customizations/oscap" + "github.com/osbuild/images/pkg/datasizes" "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/disk/partition" "github.com/osbuild/images/pkg/distro" @@ -372,11 +373,11 @@ type ImageTypeYAML struct { // XXX: rhel-8 uses this UseOstreeRemotes bool `yaml:"use_ostree_remotes"` - DefaultSize uint64 `yaml:"default_size"` + DefaultSize datasizes.Size `yaml:"default_size"` // the image func name: disk,container,live-installer,... - Image string `yaml:"image_func"` - Exports []string `yaml:"exports"` - RequiredPartitionSizes map[string]uint64 `yaml:"required_partition_sizes"` + Image string `yaml:"image_func"` + Exports []string `yaml:"exports"` + RequiredPartitionSizes map[string]datasizes.Size `yaml:"required_partition_sizes"` InternalPlatforms []platform.Data `yaml:"platforms"` PlatformsOverride *platformsOverride `yaml:"platforms_override"` diff --git a/vendor/github.com/osbuild/images/pkg/distro/generic/images.go b/vendor/github.com/osbuild/images/pkg/distro/generic/images.go index a7a53b9890..24c49bd70b 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/generic/images.go +++ b/vendor/github.com/osbuild/images/pkg/distro/generic/images.go @@ -24,6 +24,16 @@ import ( "github.com/osbuild/images/pkg/rpmmd" ) +func kernelOptions(t *imageType, c *blueprint.Customizations) []string { + imageConfig := t.getDefaultImageConfig() + + kernelOptions := imageConfig.KernelOptions + if bpKernel := c.GetKernel(); bpKernel.Append != "" { + kernelOptions = append(kernelOptions, bpKernel.Append) + } + return kernelOptions +} + func osCustomizations(t *imageType, osPackageSet rpmmd.PackageSet, options distro.ImageOptions, containers []container.SourceSpec, bp *blueprint.Blueprint) (manifest.OSCustomizations, error) { c := bp.Customizations osc := manifest.OSCustomizations{} @@ -40,13 +50,7 @@ func osCustomizations(t *imageType, osPackageSet rpmmd.PackageSet, options distr if imageConfig.DefaultKernelName != nil { osc.KernelName = *imageConfig.DefaultKernelName } - - // XXX: keep in sync with the identical copy in rhel/images.go - kernelOptions := imageConfig.KernelOptions - if bpKernel := c.GetKernel(); bpKernel.Append != "" { - kernelOptions = append(kernelOptions, bpKernel.Append) - } - osc.KernelOptionsAppend = kernelOptions + osc.KernelOptionsAppend = kernelOptions(t, c) if imageConfig.KernelOptionsBootloader != nil { osc.KernelOptionsBootloader = *imageConfig.KernelOptionsBootloader } @@ -265,6 +269,25 @@ func osCustomizations(t *imageType, osPackageSet rpmmd.PackageSet, options distr osc.RHSMConfig = osc.RHSMConfig.Update(bpRhsmConfig) } + dnfConfig, err := imageConfig.DNFConfigOptions(t.arch.distro.OsVersion()) + if err != nil { + panic(fmt.Errorf("error creating dnf configs: %w", err)) + } + if bpDnf := c.GetDNF(); bpDnf != nil && bpDnf.Config != nil { + if dnfConfig == nil { + dnfConfig = &osbuild.DNFConfigStageOptions{} + } + if bpDnf.Config.SetReleaseVer { + // NOTE: currently this is either a no-op or an append (i.e. it + // will never change the value of an existing releasever), but will + // become useful if we ever support adding custom variables through + // the blueprint + dnfConfig.UpdateVar("releasever", t.arch.distro.OsVersion()) + } + } + + osc.DNFConfig = dnfConfig + osc.ShellInit = imageConfig.ShellInit osc.Grub2Config = imageConfig.Grub2Config osc.Sysconfig = imageConfig.SysconfigStageOptions() @@ -280,7 +303,6 @@ func osCustomizations(t *imageType, osPackageSet rpmmd.PackageSet, options distr osc.Tmpfilesd = imageConfig.Tmpfilesd osc.PamLimitsConf = imageConfig.PamLimitsConf osc.Sysctld = imageConfig.Sysctld - osc.DNFConfig = imageConfig.DNFConfigOptions(t.arch.distro.OsVersion()) osc.DNFAutomaticConfig = imageConfig.DNFAutomaticConfig osc.YUMConfig = imageConfig.YumConfig osc.SshdConfig = imageConfig.SshdConfig @@ -390,6 +412,7 @@ func installerCustomizations(t *imageType, c *blueprint.Customizations) (manifes isc.EnabledAnacondaModules = append(isc.EnabledAnacondaModules, installerCust.Modules.Enable...) isc.DisabledAnacondaModules = append(isc.DisabledAnacondaModules, installerCust.Modules.Disable...) } + isc.KernelOptionsAppend = kernelOptions(t, c) return isc, nil } @@ -625,7 +648,7 @@ func imageInstallerImage(t *imageType, img.InstallerCustomizations.EnabledAnacondaModules = append(img.InstallerCustomizations.EnabledAnacondaModules, anaconda.ModuleUsers) if img.Kickstart.Unattended { - img.InstallerCustomizations.AdditionalKernelOpts = append(img.InstallerCustomizations.AdditionalKernelOpts, installerConfig.KickstartUnattendedExtraKernelOpts...) + img.InstallerCustomizations.KernelOptionsAppend = append(installerConfig.KickstartUnattendedExtraKernelOpts, img.InstallerCustomizations.KernelOptionsAppend...) } img.RootfsCompression = "xz" // This also triggers using the bcj filter @@ -769,7 +792,6 @@ func iotInstallerImage(t *imageType, img.Kickstart.Timezone, _ = customizations.GetTimezoneSettings() img.InstallerCustomizations, err = installerCustomizations(t, bp.Customizations) - if err != nil { return nil, err } @@ -889,28 +911,11 @@ func iotSimplifiedInstallerImage(t *imageType, } } } - - installerConfig, err := t.getDefaultInstallerConfig() + img.InstallerCustomizations, err = installerCustomizations(t, bp.Customizations) if err != nil { return nil, err } - - if installerConfig != nil { - img.AdditionalDracutModules = append(img.AdditionalDracutModules, installerConfig.AdditionalDracutModules...) - img.AdditionalDrivers = append(img.AdditionalDrivers, installerConfig.AdditionalDrivers...) - } - - // XXX: move to use InstallerCustomizations too - d := t.arch.distro - img.Product = d.Product() - img.Variant = t.ImageTypeYAML.Variant img.OSName = t.OSTree.Name - img.OSVersion = d.OsVersion() - - img.ISOLabel, err = t.ISOLabel() - if err != nil { - return nil, err - } return img, nil } diff --git a/vendor/github.com/osbuild/images/pkg/distro/generic/imagetype.go b/vendor/github.com/osbuild/images/pkg/distro/generic/imagetype.go index 11146431ad..a4bb296fa7 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/generic/imagetype.go +++ b/vendor/github.com/osbuild/images/pkg/distro/generic/imagetype.go @@ -123,7 +123,7 @@ func (t *imageType) Size(size uint64) uint64 { size = (size/datasizes.MebiByte + 1) * datasizes.MebiByte } if size == 0 { - size = t.ImageTypeYAML.DefaultSize + size = t.ImageTypeYAML.DefaultSize.Uint64() } return size } @@ -187,7 +187,7 @@ func (t *imageType) getPartitionTable(customizations *blueprint.Customizations, } mountpoints := customizations.GetFilesystems() - return disk.NewPartitionTable(basePartitionTable, mountpoints, imageSize, options.PartitioningMode, t.platform.GetArch(), t.ImageTypeYAML.RequiredPartitionSizes, defaultFsType.String(), rng) + return disk.NewPartitionTable(basePartitionTable, mountpoints, datasizes.Size(imageSize), options.PartitioningMode, t.platform.GetArch(), t.ImageTypeYAML.RequiredPartitionSizes, defaultFsType.String(), rng) } func (t *imageType) getDefaultImageConfig() *distro.ImageConfig { diff --git a/vendor/github.com/osbuild/images/pkg/distro/image_config.go b/vendor/github.com/osbuild/images/pkg/distro/image_config.go index acd7f9906c..87757cb753 100644 --- a/vendor/github.com/osbuild/images/pkg/distro/image_config.go +++ b/vendor/github.com/osbuild/images/pkg/distro/image_config.go @@ -178,8 +178,8 @@ func shallowMerge[T any](child *T, parent *T) *T { } type DNFConfig struct { - Options []*osbuild.DNFConfigStageOptions - SetReleaseVerVar *bool `yaml:"set_release_ver_var"` + Options *osbuild.DNFConfigStageOptions + SetReleaseverVar *bool `yaml:"set_releasever_var"` } // InheritFrom inherits unset values from the provided parent configuration and @@ -191,36 +191,39 @@ func (c *ImageConfig) InheritFrom(parentConfig *ImageConfig) *ImageConfig { return shallowMerge(c, parentConfig) } -func (c *ImageConfig) DNFConfigOptions(osVersion string) []*osbuild.DNFConfigStageOptions { +func (c *ImageConfig) DNFConfigOptions(osVersion string) (*osbuild.DNFConfigStageOptions, error) { if c.DNFConfig == nil { - return nil + return nil, nil } - if c.DNFConfig.SetReleaseVerVar == nil || !*c.DNFConfig.SetReleaseVerVar { - return c.DNFConfig.Options + + if c.DNFConfig.SetReleaseverVar == nil || !*c.DNFConfig.SetReleaseverVar { + // without the set_releasever_var option enabled, we don't need to do + // anything else + return c.DNFConfig.Options, nil } - // We currently have no use-case where we set both a custom - // DNFConfig and DNFSetReleaseVerVar. If we have one this needs - // to change and we need to decide if we want two dnf - // configurations or if we want to merge the variable into all - // existing once (exactly once) and we need to consider what to - // do about potentially conflicting (manually set) "releasever" - // values by the user. - if c.DNFConfig.SetReleaseVerVar != nil && c.DNFConfig.Options != nil { - err := fmt.Errorf("internal error: currently DNFConfig and DNFSetReleaseVerVar cannot be used together, please reporting this as a feature request") - panic(err) + // Beyond this point, c.DNFConfig.SetReleaseverVar is assumed to be true + + options := c.DNFConfig.Options + if options == nil { + options = &osbuild.DNFConfigStageOptions{} } - return []*osbuild.DNFConfigStageOptions{ - osbuild.NewDNFConfigStageOptions( - []osbuild.DNFVariable{ - { - Name: "releasever", - Value: osVersion, - }, - }, - nil, - ), + // The set_releasever_var option is set, which creates the 'releasever' + // variable: check if 'releasever' is already set in the + // options.variables, and return an error if there's a conflict. + for _, v := range options.Variables { + if v.Name == "releasever" { + return nil, fmt.Errorf("dnf_config.set_releasever_var is enabled and conflicts with the releasever variable set in dnf_config.options.variables with value: %s", v.Value) + } } + + releaseVer := osbuild.DNFVariable{ + Name: "releasever", + Value: osVersion, + } + options.Variables = append(options.Variables, releaseVer) + + return options, nil } type Sysconfig struct { diff --git a/vendor/github.com/osbuild/images/pkg/image/anaconda_container_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_container_installer.go index 40a52be5b4..a7c933da77 100644 --- a/vendor/github.com/osbuild/images/pkg/image/anaconda_container_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_container_installer.go @@ -100,10 +100,12 @@ func (img *AnacondaContainerInstaller) InstantiateManifest(m *manifest.Manifest, img.Kickstart.Path = osbuild.KickstartPathOSBuild } - bootTreePipeline.KernelOpts = []string{fmt.Sprintf("inst.stage2=hd:LABEL=%s", img.InstallerCustomizations.ISOLabel), fmt.Sprintf("inst.ks=hd:LABEL=%s:%s", img.InstallerCustomizations.ISOLabel, img.Kickstart.Path)} + kernelOpts := []string{fmt.Sprintf("inst.stage2=hd:LABEL=%s", img.InstallerCustomizations.ISOLabel), fmt.Sprintf("inst.ks=hd:LABEL=%s:%s", img.InstallerCustomizations.ISOLabel, img.Kickstart.Path)} if anacondaPipeline.InstallerCustomizations.FIPS { - bootTreePipeline.KernelOpts = append(bootTreePipeline.KernelOpts, "fips=1") + kernelOpts = append(kernelOpts, "fips=1") } + kernelOpts = append(kernelOpts, img.InstallerCustomizations.KernelOptionsAppend...) + bootTreePipeline.KernelOpts = kernelOpts isoTreePipeline := manifest.NewAnacondaInstallerISOTree(buildPipeline, anacondaPipeline, rootfsImagePipeline, bootTreePipeline) isoTreePipeline.PartitionTable = efiBootPartitionTable(rng) diff --git a/vendor/github.com/osbuild/images/pkg/image/anaconda_live_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_live_installer.go index 58443e9b96..e92592ac84 100644 --- a/vendor/github.com/osbuild/images/pkg/image/anaconda_live_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_live_installer.go @@ -85,7 +85,7 @@ func (img *AnacondaLiveInstaller) InstantiateManifest(m *manifest.Manifest, "rhgb", } - kernelOpts = append(kernelOpts, img.InstallerCustomizations.AdditionalKernelOpts...) + kernelOpts = append(kernelOpts, img.InstallerCustomizations.KernelOptionsAppend...) bootTreePipeline.KernelOpts = kernelOpts diff --git a/vendor/github.com/osbuild/images/pkg/image/anaconda_net_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_net_installer.go index 6b20de982f..fe4caff14b 100644 --- a/vendor/github.com/osbuild/images/pkg/image/anaconda_net_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_net_installer.go @@ -84,7 +84,7 @@ func (img *AnacondaNetInstaller) InstantiateManifest(m *manifest.Manifest, if anacondaPipeline.InstallerCustomizations.FIPS { kernelOpts = append(kernelOpts, "fips=1") } - kernelOpts = append(kernelOpts, img.InstallerCustomizations.AdditionalKernelOpts...) + kernelOpts = append(kernelOpts, img.InstallerCustomizations.KernelOptionsAppend...) bootTreePipeline.KernelOpts = kernelOpts isoTreePipeline := manifest.NewAnacondaInstallerISOTree(buildPipeline, anacondaPipeline, rootfsImagePipeline, bootTreePipeline) @@ -95,7 +95,7 @@ func (img *AnacondaNetInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.RootfsCompression = img.RootfsCompression isoTreePipeline.RootfsType = img.InstallerCustomizations.ISORootfsType - isoTreePipeline.KernelOpts = img.InstallerCustomizations.AdditionalKernelOpts + isoTreePipeline.KernelOpts = img.InstallerCustomizations.KernelOptionsAppend if anacondaPipeline.InstallerCustomizations.FIPS { isoTreePipeline.KernelOpts = append(isoTreePipeline.KernelOpts, "fips=1") } diff --git a/vendor/github.com/osbuild/images/pkg/image/anaconda_ostree_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_ostree_installer.go index f7c8a94c11..979296c45b 100644 --- a/vendor/github.com/osbuild/images/pkg/image/anaconda_ostree_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_ostree_installer.go @@ -100,10 +100,12 @@ func (img *AnacondaOSTreeInstaller) InstantiateManifest(m *manifest.Manifest, if img.Kickstart.Path == "" { img.Kickstart.Path = osbuild.KickstartPathOSBuild } - bootTreePipeline.KernelOpts = []string{fmt.Sprintf("inst.stage2=hd:LABEL=%s", img.InstallerCustomizations.ISOLabel), fmt.Sprintf("inst.ks=hd:LABEL=%s:%s", img.InstallerCustomizations.ISOLabel, img.Kickstart.Path)} + kernelOpts := []string{fmt.Sprintf("inst.stage2=hd:LABEL=%s", img.InstallerCustomizations.ISOLabel), fmt.Sprintf("inst.ks=hd:LABEL=%s:%s", img.InstallerCustomizations.ISOLabel, img.Kickstart.Path)} if anacondaPipeline.InstallerCustomizations.FIPS { - bootTreePipeline.KernelOpts = append(bootTreePipeline.KernelOpts, "fips=1") + kernelOpts = append(kernelOpts, "fips=1") } + kernelOpts = append(kernelOpts, img.InstallerCustomizations.KernelOptionsAppend...) + bootTreePipeline.KernelOpts = kernelOpts var subscriptionPipeline *manifest.Subscription if img.Subscription != nil { diff --git a/vendor/github.com/osbuild/images/pkg/image/anaconda_tar_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_tar_installer.go index c92ecf608b..4c4e77f822 100644 --- a/vendor/github.com/osbuild/images/pkg/image/anaconda_tar_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_tar_installer.go @@ -19,7 +19,7 @@ import ( ) func efiBootPartitionTable(rng *rand.Rand) *disk.PartitionTable { - var efibootImageSize uint64 = 20 * datasizes.MebiByte + efibootImageSize := datasizes.Size(20 * datasizes.MebiByte) return &disk.PartitionTable{ Size: efibootImageSize, Partitions: []disk.Partition{ @@ -125,8 +125,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, if img.OSCustomizations.FIPS { kernelOpts = append(kernelOpts, "fips=1") } - kernelOpts = append(kernelOpts, img.InstallerCustomizations.AdditionalKernelOpts...) - kernelOpts = append(kernelOpts, img.OSCustomizations.KernelOptionsAppend...) + kernelOpts = append(kernelOpts, img.InstallerCustomizations.KernelOptionsAppend...) bootTreePipeline.KernelOpts = kernelOpts osPipeline := manifest.NewOS(buildPipeline, img.platform, repos) @@ -145,8 +144,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.RootfsType = img.InstallerCustomizations.ISORootfsType isoTreePipeline.OSPipeline = osPipeline - isoTreePipeline.KernelOpts = img.InstallerCustomizations.AdditionalKernelOpts - isoTreePipeline.KernelOpts = append(isoTreePipeline.KernelOpts, img.OSCustomizations.KernelOptionsAppend...) + isoTreePipeline.KernelOpts = img.InstallerCustomizations.KernelOptionsAppend if img.OSCustomizations.FIPS { isoTreePipeline.KernelOpts = append(isoTreePipeline.KernelOpts, "fips=1") } diff --git a/vendor/github.com/osbuild/images/pkg/image/ostree_simplified_installer.go b/vendor/github.com/osbuild/images/pkg/image/ostree_simplified_installer.go index 03599f4d49..10c028c66c 100644 --- a/vendor/github.com/osbuild/images/pkg/image/ostree_simplified_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/ostree_simplified_installer.go @@ -21,25 +21,15 @@ type OSTreeSimplifiedInstaller struct { // Raw image that will be created and embedded rawImage *OSTreeDiskImage - OSCustomizations manifest.OSCustomizations - Environment environment.Environment + OSCustomizations manifest.OSCustomizations + Environment environment.Environment + InstallerCustomizations manifest.InstallerCustomizations ExtraBasePackages rpmmd.PackageSet - ISOLabel string - // ISO label template (architecture-free) ISOLabelTmpl string - // Product string for ISO buildstamp - Product string - - // OSVersion string for ISO buildstamp - OSVersion string - - // Variant string for ISO buildstamp - Variant string - // OSName for ostree deployment OSName string @@ -52,9 +42,6 @@ type OSTreeSimplifiedInstaller struct { // Ignition embedded configuration options IgnitionEmbedded *ignition.EmbeddedOptions - - AdditionalDracutModules []string - AdditionalDrivers []string } func NewOSTreeSimplifiedInstaller(platform platform.Platform, filename string, rawImage *OSTreeDiskImage, installDevice string) *OSTreeSimplifiedInstaller { @@ -83,8 +70,8 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, img.platform, repos, "kernel", - img.Product, - img.OSVersion, + img.InstallerCustomizations.Product, + img.InstallerCustomizations.OSVersion, ) coiPipeline.ExtraPackages = img.ExtraBasePackages.Include coiPipeline.ExcludePackages = img.ExtraBasePackages.Exclude @@ -92,20 +79,20 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, coiPipeline.FDO = img.FDO coiPipeline.Ignition = img.IgnitionEmbedded coiPipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64) - coiPipeline.Variant = img.Variant - coiPipeline.AdditionalDracutModules = img.AdditionalDracutModules - coiPipeline.AdditionalDrivers = img.AdditionalDrivers + coiPipeline.Variant = img.InstallerCustomizations.Variant + coiPipeline.AdditionalDracutModules = img.InstallerCustomizations.AdditionalDracutModules + coiPipeline.AdditionalDrivers = img.InstallerCustomizations.AdditionalDrivers var isoLabel string - if len(img.ISOLabel) > 0 { - isoLabel = img.ISOLabel + if len(img.InstallerCustomizations.ISOLabel) > 0 { + isoLabel = img.InstallerCustomizations.ISOLabel } else { // TODO: replace isoLabelTmpl with more high-level properties isoLabel = fmt.Sprintf(img.ISOLabelTmpl, img.platform.GetArch()) } - bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion) + bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.InstallerCustomizations.Product, img.InstallerCustomizations.OSVersion) bootTreePipeline.Platform = img.platform bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor() bootTreePipeline.ISOLabel = isoLabel @@ -136,7 +123,16 @@ func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest, kernelOpts = append(kernelOpts, "fdo.di_mfg_string_type_mac_iface="+img.FDO.DiMfgStringTypeMacIface) } } - + // Note that we do not use the + // InstallerCustomizations.KernelOptionsAppend here because + // InstallerCustomizations.KernelOptionsAppend also picks up + // the kernel options from the imageConfig but we only set + // those in the rawImage.OSTreeDeploymentCustomizations and + // not in the bootTreePipeline. Its unclear if we should change + // this or not. Its inconsistent with the other installers but + // then simplifiedInstaler is special. + // + // kernelOpts = append(kernelOpts, img.InstallerCustomizations.KernelOptionsAppend...) bootTreePipeline.KernelOpts = kernelOpts // enable ISOLinux on x86_64 only diff --git a/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer.go b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer.go index b19b4af00e..138ddda3b0 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer.go @@ -51,7 +51,7 @@ type AnacondaInstaller struct { platform platform.Platform repos []rpmmd.RepoConfig - packageSpecs []rpmmd.PackageSpec + packageSpecs rpmmd.PackageList kernelName string kernelVer string @@ -182,7 +182,7 @@ func (p *AnacondaInstaller) getPackageSetChain(Distro) ([]rpmmd.PackageSet, erro }, nil } -func (p *AnacondaInstaller) getPackageSpecs() []rpmmd.PackageSpec { +func (p *AnacondaInstaller) getPackageSpecs() rpmmd.PackageList { return p.packageSpecs } @@ -192,11 +192,11 @@ func (p *AnacondaInstaller) serializeStart(inputs Inputs) error { } p.packageSpecs = inputs.Depsolved.Packages if p.kernelName != "" { - kernelPkg, err := rpmmd.GetPackage(p.packageSpecs, p.kernelName) + kernelPkg, err := p.packageSpecs.Package(p.kernelName) if err != nil { return fmt.Errorf("AnacondaInstaller: %w", err) } - p.kernelVer = kernelPkg.GetEVRA() + p.kernelVer = kernelPkg.EVRA() } p.repos = append(p.repos, inputs.Depsolved.Repos...) return nil diff --git a/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer_iso_tree.go b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer_iso_tree.go index 03c1caa88a..ce605da2a9 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer_iso_tree.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer_iso_tree.go @@ -543,7 +543,7 @@ func (p *AnacondaInstallerISOTree) serialize() (osbuild.Pipeline, error) { case p.OSPipeline != nil: tarPayloadStages, err := p.tarPayloadStages() if err != nil { - return osbuild.Pipeline{}, fmt.Errorf("cannot create ostree container stages: %w", err) + return osbuild.Pipeline{}, fmt.Errorf("cannot create tar payload stages: %w", err) } pipeline.AddStages(tarPayloadStages...) default: diff --git a/vendor/github.com/osbuild/images/pkg/manifest/build.go b/vendor/github.com/osbuild/images/pkg/manifest/build.go index 092fe36817..ffe441b2cc 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/build.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/build.go @@ -35,7 +35,7 @@ type BuildrootFromPackages struct { runner runner.Runner dependents []Pipeline repos []rpmmd.RepoConfig - packageSpecs []rpmmd.PackageSpec + packageSpecs rpmmd.PackageList containerBuildable bool @@ -150,7 +150,7 @@ func (p *BuildrootFromPackages) getPackageSetChain(distro Distro) ([]rpmmd.Packa }, nil } -func (p *BuildrootFromPackages) getPackageSpecs() []rpmmd.PackageSpec { +func (p *BuildrootFromPackages) getPackageSpecs() rpmmd.PackageList { return p.packageSpecs } diff --git a/vendor/github.com/osbuild/images/pkg/manifest/commit_server_tree.go b/vendor/github.com/osbuild/images/pkg/manifest/commit_server_tree.go index 77d0cf3d70..34f411a390 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/commit_server_tree.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/commit_server_tree.go @@ -25,7 +25,7 @@ type OSTreeCommitServer struct { platform platform.Platform repos []rpmmd.RepoConfig - packageSpecs []rpmmd.PackageSpec + packageSpecs rpmmd.PackageList commitPipeline *OSTreeCommit nginxConfigPath string listenPort string @@ -76,7 +76,7 @@ func (p *OSTreeCommitServer) getBuildPackages(Distro) ([]string, error) { return packages, nil } -func (p *OSTreeCommitServer) getPackageSpecs() []rpmmd.PackageSpec { +func (p *OSTreeCommitServer) getPackageSpecs() rpmmd.PackageList { return p.packageSpecs } diff --git a/vendor/github.com/osbuild/images/pkg/manifest/coreos_installer.go b/vendor/github.com/osbuild/images/pkg/manifest/coreos_installer.go index ee6113ce91..a8b479381e 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/coreos_installer.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/coreos_installer.go @@ -25,7 +25,7 @@ type CoreOSInstaller struct { platform platform.Platform repos []rpmmd.RepoConfig - packageSpecs []rpmmd.PackageSpec + packageSpecs rpmmd.PackageList kernelName string kernelVer string product string @@ -138,7 +138,7 @@ func (p *CoreOSInstaller) getPackageSetChain(Distro) ([]rpmmd.PackageSet, error) }, nil } -func (p *CoreOSInstaller) getPackageSpecs() []rpmmd.PackageSpec { +func (p *CoreOSInstaller) getPackageSpecs() rpmmd.PackageList { return p.packageSpecs } @@ -148,11 +148,11 @@ func (p *CoreOSInstaller) serializeStart(inputs Inputs) error { } p.packageSpecs = inputs.Depsolved.Packages if p.kernelName != "" { - kernelPkg, err := rpmmd.GetPackage(p.packageSpecs, p.kernelName) + kernelPkg, err := p.packageSpecs.Package(p.kernelName) if err != nil { return fmt.Errorf("CoreOSInstaller: %w", err) } - p.kernelVer = kernelPkg.GetEVRA() + p.kernelVer = kernelPkg.EVRA() } p.repos = append(p.repos, inputs.Depsolved.Repos...) return nil diff --git a/vendor/github.com/osbuild/images/pkg/manifest/empty.go b/vendor/github.com/osbuild/images/pkg/manifest/empty.go index ac6c207d3f..7855e5c7ad 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/empty.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/empty.go @@ -21,7 +21,7 @@ type ContentTest struct { commits []ostree.SourceSpec // resolved content - packageSpecs []rpmmd.PackageSpec + packageSpecs rpmmd.PackageList containerSpecs []container.Spec commitSpecs []ostree.CommitSpec @@ -80,7 +80,7 @@ func (p *ContentTest) getOSTreeCommitSources() []ostree.SourceSpec { return p.commits } -func (p *ContentTest) getPackageSpecs() []rpmmd.PackageSpec { +func (p *ContentTest) getPackageSpecs() rpmmd.PackageList { return p.packageSpecs } diff --git a/vendor/github.com/osbuild/images/pkg/manifest/installer.go b/vendor/github.com/osbuild/images/pkg/manifest/installer.go index d4f907d0ec..4b8bb6b9ea 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/installer.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/installer.go @@ -5,7 +5,7 @@ package manifest type InstallerCustomizations struct { FIPS bool - AdditionalKernelOpts []string + KernelOptionsAppend []string EnabledAnacondaModules []string DisabledAnacondaModules []string diff --git a/vendor/github.com/osbuild/images/pkg/manifest/os.go b/vendor/github.com/osbuild/images/pkg/manifest/os.go index ea9e9eeb55..1c4f7596e0 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/os.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/os.go @@ -129,7 +129,7 @@ type OSCustomizations struct { Tmpfilesd []*osbuild.TmpfilesdStageOptions PamLimitsConf []*osbuild.PamLimitsConfStageOptions Sysctld []*osbuild.SysctldStageOptions - DNFConfig []*osbuild.DNFConfigStageOptions + DNFConfig *osbuild.DNFConfigStageOptions DNFAutomaticConfig *osbuild.DNFAutomaticConfigStageOptions YUMConfig *osbuild.YumConfigStageOptions YUMRepos []*osbuild.YumReposStageOptions @@ -226,7 +226,7 @@ type OS struct { // content-related fields repos []rpmmd.RepoConfig - packageSpecs []rpmmd.PackageSpec + packageSpecs rpmmd.PackageList moduleSpecs []rpmmd.ModuleSpec containerSpecs []container.Spec ostreeParentSpec *ostree.CommitSpec @@ -411,7 +411,7 @@ func (p *OS) getBuildPackages(distro Distro) ([]string, error) { packages = append(packages, "python3-pyyaml") } } - if len(p.OSCustomizations.DNFConfig) > 0 || p.OSCustomizations.RHSMConfig != nil || p.OSCustomizations.WSLConfig != nil || p.OSCustomizations.WSLDistributionConfig != nil { + if p.OSCustomizations.DNFConfig != nil || p.OSCustomizations.RHSMConfig != nil || p.OSCustomizations.WSLConfig != nil || p.OSCustomizations.WSLDistributionConfig != nil { packages = append(packages, "python3-iniparse") } @@ -469,7 +469,7 @@ func (p *OS) getOSTreeCommits() []ostree.CommitSpec { return []ostree.CommitSpec{*p.ostreeParentSpec} } -func (p *OS) getPackageSpecs() []rpmmd.PackageSpec { +func (p *OS) getPackageSpecs() rpmmd.PackageList { return p.packageSpecs } @@ -493,11 +493,11 @@ func (p *OS) serializeStart(inputs Inputs) error { } if p.OSCustomizations.KernelName != "" { - kernelPkg, err := rpmmd.GetPackage(p.packageSpecs, p.OSCustomizations.KernelName) + kernelPkg, err := p.packageSpecs.Package(p.OSCustomizations.KernelName) if err != nil { return fmt.Errorf("OS: %w", err) } - p.kernelVer = kernelPkg.GetEVRA() + p.kernelVer = kernelPkg.EVRA() } p.repos = append(p.repos, inputs.Depsolved.Repos...) @@ -690,7 +690,7 @@ func (p *OS) serialize() (osbuild.Pipeline, error) { pipeline.AddStage(osbuild.NewSysctldStage(sysctldConfig)) } - for _, dnfConfig := range p.OSCustomizations.DNFConfig { + if dnfConfig := p.OSCustomizations.DNFConfig; dnfConfig != nil { pipeline.AddStage(osbuild.NewDNFConfigStage(dnfConfig)) } @@ -1057,7 +1057,7 @@ func grubStage(p *OS, pt *disk.PartitionTable, kernelOptions []string) *osbuild. Nick: p.OSNick, } - _, err := rpmmd.GetPackage(p.packageSpecs, "dracut-config-rescue") + _, err := p.packageSpecs.Package("dracut-config-rescue") hasRescue := err == nil return osbuild.NewGrub2LegacyStage( osbuild.NewGrub2LegacyStageOptions( @@ -1170,8 +1170,8 @@ func findESPMountpoint(pt *disk.PartitionTable) (string, error) { // (v25.3+) or if the uki-direct package is not included in the package list. // // [1] https://gitlab.com/kraxel/virt-firmware/-/commit/ca385db4f74a4d542455b9d40c91c8448c7be90c -func maybeAddHMACandDirStage(packages []rpmmd.PackageSpec, espMountpoint, kernelVer string) ([]*osbuild.Stage, error) { - ukiDirect, err := rpmmd.GetPackage(packages, "uki-direct") +func maybeAddHMACandDirStage(packages rpmmd.PackageList, espMountpoint, kernelVer string) ([]*osbuild.Stage, error) { + ukiDirect, err := packages.Package("uki-direct") if err != nil { // the uki-direct package isn't in the list: no override necessary return nil, nil diff --git a/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go b/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go index 982c2a93f3..027b1d815b 100644 --- a/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go @@ -56,7 +56,7 @@ type Pipeline interface { // getPackageSpecs returns the list of specifications for packages that // will be installed to the pipeline tree. - getPackageSpecs() []rpmmd.PackageSpec + getPackageSpecs() rpmmd.PackageList // getContainerSpecs returns the list of specifications for the containers // that will be installed to the pipeline tree. getContainerSpecs() []container.Spec @@ -136,8 +136,8 @@ func (p Base) getOSTreeCommitSources() []ostree.SourceSpec { return nil } -func (p Base) getPackageSpecs() []rpmmd.PackageSpec { - return []rpmmd.PackageSpec{} +func (p Base) getPackageSpecs() rpmmd.PackageList { + return nil } func (p Base) getOSTreeCommits() []ostree.CommitSpec { diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/curl_source.go b/vendor/github.com/osbuild/images/pkg/osbuild/curl_source.go index c98398ca86..32f1c9e1d4 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/curl_source.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/curl_source.go @@ -31,12 +31,15 @@ func NewCurlSource() *CurlSource { } } -func NewCurlPackageItem(pkg rpmmd.PackageSpec) (CurlSourceItem, error) { - if !curlDigestPattern.MatchString(pkg.Checksum) { +func NewCurlPackageItem(pkg rpmmd.Package) (CurlSourceItem, error) { + if !curlDigestPattern.MatchString(pkg.Checksum.String()) { return nil, fmt.Errorf("curl package source item with name %q has invalid digest %q", pkg.Name, pkg.Checksum) } + if len(pkg.RemoteLocations) == 0 { + return nil, fmt.Errorf("curl source: package %q has no remote locations", pkg.Name) + } item := new(CurlSourceOptions) - item.URL = pkg.RemoteLocation + item.URL = pkg.RemoteLocations[0] switch pkg.Secrets { case "org.osbuild.rhsm": item.Secrets = &URLSecrets{ @@ -53,12 +56,12 @@ func NewCurlPackageItem(pkg rpmmd.PackageSpec) (CurlSourceItem, error) { // AddPackage adds a pkg to the curl source to download. Will return an error // if any of the supplied options are invalid or missing. -func (source *CurlSource) AddPackage(pkg rpmmd.PackageSpec) error { +func (source *CurlSource) AddPackage(pkg rpmmd.Package) error { item, err := NewCurlPackageItem(pkg) if err != nil { return err } - source.Items[pkg.Checksum] = item + source.Items[pkg.Checksum.String()] = item return nil } diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/device.go b/vendor/github.com/osbuild/images/pkg/osbuild/device.go index bd625a04a9..1d4e4b2de4 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/device.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/device.go @@ -198,7 +198,7 @@ func getDevices(path []disk.Entity, filename string, lockLoopback bool) (map[str lbopt := LoopbackDeviceOptions{ Filename: filename, Start: pt.BytesToSectors(e.Start), - Size: pt.BytesToSectors(e.Size), + Size: pt.BytesToSectors(e.Size.Uint64()), SectorSize: nil, Lock: lockLoopback, } diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/disk.go b/vendor/github.com/osbuild/images/pkg/osbuild/disk.go index 6b014ae257..94634e1df0 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/disk.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/disk.go @@ -71,7 +71,7 @@ func sfdiskStageOptions(pt *disk.PartitionTable) *SfdiskStageOptions { partitions[idx] = SfdiskPartition{ Bootable: p.Bootable, Start: pt.BytesToSectors(p.Start), - Size: pt.BytesToSectors(p.Size), + Size: pt.BytesToSectors(p.Size.Uint64()), Type: p.Type, UUID: p.UUID, Name: p.Label, @@ -95,7 +95,7 @@ func sgdiskStageOptions(pt *disk.PartitionTable) *SgdiskStageOptions { partitions[idx] = SgdiskPartition{ Bootable: p.Bootable, Start: pt.BytesToSectors(p.Start), - Size: pt.BytesToSectors(p.Size), + Size: pt.BytesToSectors(p.Size.Uint64()), Type: p.Type, Name: p.Label, Attrs: p.Attrs, diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/dnf4_versionlock.go b/vendor/github.com/osbuild/images/pkg/osbuild/dnf4_versionlock.go index eef69939e9..fcc12e1e14 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/dnf4_versionlock.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/dnf4_versionlock.go @@ -40,23 +40,23 @@ func NewDNF4VersionlockStage(options *DNF4VersionlockOptions) *Stage { // - dnf4 is not in the package specs: we only support the feature in dnf4 for now. // - The python3-dnf-plugin-versionlock package is not in the package specs: // the plugin is required for the lock to be effective. -func GenDNF4VersionlockStageOptions(lockPackageNames []string, packageSpecs []rpmmd.PackageSpec) (*DNF4VersionlockOptions, error) { +func GenDNF4VersionlockStageOptions(lockPackageNames []string, packageSpecs rpmmd.PackageList) (*DNF4VersionlockOptions, error) { // check that dnf4 and the plugin are included in the package specs - dnf, err := rpmmd.GetPackage(packageSpecs, "dnf") + dnf, err := packageSpecs.Package("dnf") if err != nil { return nil, fmt.Errorf("%s: dnf version locking enabled for an image that does not contain dnf: %w", dnf4VersionlockType, err) } if common.VersionGreaterThanOrEqual(dnf.Version, "5") { return nil, fmt.Errorf("%s: dnf version locking enabled for an image that includes dnf version %s: the feature requires dnf4", dnf4VersionlockType, dnf.Version) } - if _, err := rpmmd.GetPackage(packageSpecs, "python3-dnf-plugin-versionlock"); err != nil { + if _, err := packageSpecs.Package("python3-dnf-plugin-versionlock"); err != nil { return nil, fmt.Errorf("%s: dnf version locking enabled for an image that does not contain the versionlock plugin: %w", dnf4VersionlockType, err) } pkgNEVRs := make([]string, len(lockPackageNames)) for idx, pkgName := range lockPackageNames { - pkg, err := rpmmd.GetPackage(packageSpecs, pkgName) + pkg, err := packageSpecs.Package(pkgName) if err != nil { return nil, fmt.Errorf("%s: package %q not found in package list", dnf4VersionlockType, pkgName) } diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/dnf_config_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/dnf_config_stage.go index 23d511fdd7..06f7fbd8ad 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/dnf_config_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/dnf_config_stage.go @@ -66,3 +66,26 @@ type DNFConfig struct { type DNFConfigMain struct { IPResolve string `json:"ip_resolve,omitempty"` } + +// UpdateVar inserts or updates a dnf variable. If a variable with the same +// name already exists, it is updated to the new value. Otherwise, it is +// appended to the existing list. +func (options *DNFConfigStageOptions) UpdateVar(name, value string) { + if options == nil { + panic(fmt.Errorf("UpdateVar() call on nil DNFConfigStageOptions")) + } + + newVar := DNFVariable{ + Name: name, + Value: value, + } + + for idx, v := range options.Variables { + if v.Name == name { + options.Variables[idx] = newVar + return + } + } + + options.Variables = append(options.Variables, newVar) +} diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/kickstart_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/kickstart_stage.go index 52ce7b033c..caef867cdb 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/kickstart_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/kickstart_stage.go @@ -3,6 +3,7 @@ package osbuild import ( "fmt" "path/filepath" + "regexp" "strings" "github.com/osbuild/images/pkg/customizations/fsnode" @@ -10,6 +11,7 @@ import ( ) const ( + kickstartStageType = "org.osbuild.kickstart" KickstartPathInteractiveDefaults = "/usr/share/anaconda/interactive-defaults.ks" KickstartPathOSBuild = "/osbuild.ks" ) @@ -132,7 +134,7 @@ func (KickstartStageOptions) isStageOptions() {} // Creates an Anaconda kickstart file func NewKickstartStage(options *KickstartStageOptions) *Stage { return &Stage{ - Type: "org.osbuild.kickstart", + Type: kickstartStageType, Options: options, } } @@ -214,6 +216,11 @@ func NewKickstartStageOptions( userCustomizations []users.User, groupCustomizations []users.Group) (*KickstartStageOptions, error) { + invalidPathRegex := regexp.MustCompile(invalidPathRegex) + if invalidPathRegex.FindAllString(path, -1) != nil { + return nil, fmt.Errorf("%s: kickstart path %q is invalid", kickstartStageType, path) + } + var users map[string]UsersStageOptionsUser if usersOptions, err := NewUsersStageOptions(userCustomizations, false); err != nil { return nil, err @@ -228,7 +235,7 @@ func NewKickstartStageOptions( rootpw, err := adjustRootUserOptions(users) if err != nil { - return nil, fmt.Errorf("org.osbuild.kickstart: %w", err) + return nil, fmt.Errorf("%s: %w", kickstartStageType, err) } return &KickstartStageOptions{ diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/librepo_source.go b/vendor/github.com/osbuild/images/pkg/osbuild/librepo_source.go index 2028956b5c..4a0cb992f1 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/librepo_source.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/librepo_source.go @@ -26,7 +26,7 @@ func NewLibrepoSource() *LibrepoSource { // AddPackage adds the given *depsolved* pkg to the downloading. It // needs the *depsovled* repoConfig so that the repoID of the two can // be matched up -func (source *LibrepoSource) AddPackage(pkg rpmmd.PackageSpec, repos []rpmmd.RepoConfig) error { +func (source *LibrepoSource) AddPackage(pkg rpmmd.Package, repos []rpmmd.RepoConfig) error { pkgRepo, err := findRepoById(repos, pkg.RepoID) if err != nil { return fmt.Errorf("cannot find repo-id for pkg %v: %v", pkg.Name, err) @@ -59,10 +59,10 @@ func (source *LibrepoSource) AddPackage(pkg rpmmd.PackageSpec, repos []rpmmd.Rep } item := &LibrepoSourceItem{ - Path: pkg.Path, + Path: pkg.Location, MirrorID: pkgRepo.Id, } - source.Items[pkg.Checksum] = item + source.Items[pkg.Checksum.String()] = item return nil } diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/rpm_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/rpm_stage.go index 0f9a728191..9286e826db 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/rpm_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/rpm_stage.go @@ -108,21 +108,21 @@ func (pkgmd RPMPackageMetadata) Signature() *string { func (RPMStageMetadata) isStageMetadata() {} -func NewRpmStageSourceFilesInputs(specs []rpmmd.PackageSpec) *RPMStageInputs { - input := NewFilesInput(pkgRefs(specs)) +func NewRpmStageSourceFilesInputs(pkgs rpmmd.PackageList) *RPMStageInputs { + input := NewFilesInput(pkgRefs(pkgs)) return &RPMStageInputs{Packages: input} } -func pkgRefs(specs []rpmmd.PackageSpec) FilesInputRef { - refs := make([]FilesInputSourceArrayRefEntry, len(specs)) - for idx, pkg := range specs { +func pkgRefs(pkgs rpmmd.PackageList) FilesInputRef { + refs := make([]FilesInputSourceArrayRefEntry, len(pkgs)) + for idx, pkg := range pkgs { var pkgMetadata FilesInputRefMetadata if pkg.CheckGPG { pkgMetadata = &RPMStageReferenceMetadata{ CheckGPG: pkg.CheckGPG, } } - refs[idx] = NewFilesInputSourceArrayRefEntry(pkg.Checksum, pkgMetadata) + refs[idx] = NewFilesInputSourceArrayRefEntry(pkg.Checksum.String(), pkgMetadata) } return NewFilesInputSourceArrayRef(refs) } diff --git a/vendor/github.com/osbuild/images/pkg/osbuild/source.go b/vendor/github.com/osbuild/images/pkg/osbuild/source.go index eb4142993c..a76c84bfd2 100644 --- a/vendor/github.com/osbuild/images/pkg/osbuild/source.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/source.go @@ -81,7 +81,7 @@ func (sources *Sources) UnmarshalJSON(data []byte) error { return nil } -func (sources Sources) addPackagesCurl(packages []rpmmd.PackageSpec) error { +func (sources Sources) addPackagesCurl(packages rpmmd.PackageList) error { curl := NewCurlSource() for _, pkg := range packages { err := curl.AddPackage(pkg) @@ -93,7 +93,7 @@ func (sources Sources) addPackagesCurl(packages []rpmmd.PackageSpec) error { return nil } -func (sources Sources) addPackagesLibrepo(packages []rpmmd.PackageSpec, rpmRepos []rpmmd.RepoConfig) error { +func (sources Sources) addPackagesLibrepo(packages rpmmd.PackageList, rpmRepos []rpmmd.RepoConfig) error { librepo := NewLibrepoSource() for _, pkg := range packages { err := librepo.AddPackage(pkg, rpmRepos) diff --git a/vendor/github.com/osbuild/images/pkg/rpmmd/module.go b/vendor/github.com/osbuild/images/pkg/rpmmd/module.go new file mode 100644 index 0000000000..8cb2cd00f8 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/rpmmd/module.go @@ -0,0 +1,23 @@ +package rpmmd + +type ModuleSpec struct { + ModuleConfigFile ModuleConfigFile `json:"module-file"` + FailsafeFile ModuleFailsafeFile `json:"failsafe-file"` +} + +type ModuleConfigFile struct { + Path string `json:"path"` + Data ModuleConfigData `json:"data"` +} + +type ModuleConfigData struct { + Name string `json:"name"` + Stream string `json:"stream"` + Profiles []string `json:"profiles"` + State string `json:"state"` +} + +type ModuleFailsafeFile struct { + Path string `json:"path"` + Data string `json:"data"` +} diff --git a/vendor/github.com/osbuild/images/pkg/rpmmd/package.go b/vendor/github.com/osbuild/images/pkg/rpmmd/package.go new file mode 100644 index 0000000000..9ec63d92ef --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/rpmmd/package.go @@ -0,0 +1,168 @@ +package rpmmd + +import ( + "fmt" + "time" +) + +// RelDep represents an RPM dependency with a name, an optional relationship +// operator and an optional version. +type RelDep struct { + // Name is the name of the dependency, e.g. "openssl-libs". + Name string + // Relationship to the version, e.g. "=", ">", ">=", etc. (optional) + Relationship string + // Version of the dependency, e.g. "3.0.1", etc. (optional) + Version string +} + +type RelDepList []RelDep + +// Checksum represents a checksum with its type +type Checksum struct { + // Type is the type of checksum, e.g. "sha256", "sha512", "md5", etc. + Type string + // Value is the checksum value, e.g. "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" for sha256. + Value string +} + +func (c Checksum) String() string { + return fmt.Sprintf("%s:%s", c.Type, c.Value) +} + +// RPM package representation +// +// Based on libdnf5: https://github.com/rpm-software-management/dnf5/blob/main/include/libdnf5/rpm/package.hpp +// DNF4 version: https://github.com/rpm-software-management/libdnf/blob/dnf-4-master/libdnf/hy-package.h +// +// Some fields that are not relevant for us, or that can be deduced from existing fields, are omitted, specifically: +// - Various EVR or NEVRA getter methods, which would use existing fields +// - get_source_name() - RPM package source package name +// - get_debugsource_name() - RPM package debugsource package name +// - get_debuginfo_name_of_source() - RPM package debuginfo package name for the source package +// - get_debuginfo_name() - RPM package debuginfo package name +// - get_prereq_ignoreinst() +// - get_depends() - RPM package dependencies (requires + enhances + suggests + supplements + recommends) +// - get_changelogs() +// - get_hdr_end() +// - get_media_number() +// - get_package_path() - Path to the RPM package on the local file system +// - is_available_locally() +// - is_installed() +// - is_excluded() +// - get_from_repo_id() - For an installed package, return id of repo from the package was installed +// - get_install_time() +// - get_rpmdbid() +type Package struct { + Name string + Epoch uint + Version string + Release string + Arch string + + // RPM package Group + Group string + + // File size of the RPM package + DownloadSize uint64 + // Size the RPM package should occupy after installing on disk + // NB: The actual size on disk may vary based on block size and filesystem overhead. + InstallSize uint64 + + License string + + // RPM package source package filename + SourceRpm string + + BuildTime time.Time + Packager string + Vendor string + + // RPM package URL (project home address) + URL string + + Summary string + Description string + + // Regular dependencies + Provides RelDepList + Requires RelDepList // RegularRequires + PreRequires + RequiresPre RelDepList + Conflicts RelDepList + Obsoletes RelDepList + RegularRequires RelDepList + + // Weak dependencies + Recommends RelDepList + Suggests RelDepList + Enhances RelDepList + Supplements RelDepList + + // List of files and directories the RPM package contains + Files []string + + // Repodata + // RPM package baseurl from repodata + BaseURL string + // RPM package relative path/location from repodata + Location string + // RPM package remote location where the package can be download from + RemoteLocations []string + + // Checksum object representing RPM package checksum and its type + Checksum Checksum + // Checksum object representing RPM package header checksum and its type. + HeaderChecksum Checksum + + // Repository ID this package belongs to + // XXX: We should should eventually hold a reference to the RepoConfig + RepoID string + + // Resolved reason why a package was / would be installed. + Reason string + + // Convenience values coming from the respective repository config + Secrets string + CheckGPG bool + IgnoreSSL bool +} + +// EVRA returns the package's Epoch:Version-Release.Arch string. +// If the package Epoch is 0, it is omitted and only Version-Release.Arch is returned. +func (p Package) EVRA() string { + if p.Epoch == 0 { + return fmt.Sprintf("%s-%s.%s", p.Version, p.Release, p.Arch) + } + return fmt.Sprintf("%d:%s-%s.%s", p.Epoch, p.Version, p.Release, p.Arch) +} + +type PackageList []Package + +func (pl PackageList) Package(packageName string) (*Package, error) { + for _, pkg := range pl { + if pkg.Name == packageName { + return &pkg, nil + } + } + return nil, fmt.Errorf("package %q not found in the Package list", packageName) +} + +// The inputs to depsolve, a set of packages to include and a set of packages +// to exclude. The Repositories are used when depsolving this package set in +// addition to the base repositories. +type PackageSet struct { + Include []string + Exclude []string + EnabledModules []string + Repositories []RepoConfig + InstallWeakDeps bool +} + +// Append the Include and Exclude package list from another PackageSet and +// return the result. +func (ps PackageSet) Append(other PackageSet) PackageSet { + ps.Include = append(ps.Include, other.Include...) + ps.Exclude = append(ps.Exclude, other.Exclude...) + ps.EnabledModules = append(ps.EnabledModules, other.EnabledModules...) + return ps +} diff --git a/vendor/github.com/osbuild/images/pkg/rpmmd/repository.go b/vendor/github.com/osbuild/images/pkg/rpmmd/repository.go index 7eb5b6449f..85c6c5dc1c 100644 --- a/vendor/github.com/osbuild/images/pkg/rpmmd/repository.go +++ b/vendor/github.com/osbuild/images/pkg/rpmmd/repository.go @@ -6,11 +6,7 @@ import ( "fmt" "io" "os" - "sort" "strings" - "time" - - "github.com/gobwas/glob" ) type repository struct { @@ -90,162 +86,6 @@ func (r *RepoConfig) Hash() string { type DistrosRepoConfigs map[string]map[string][]RepoConfig -type PackageList []Package - -type Package struct { - Name string - Summary string - Description string - URL string - Epoch uint - Version string - Release string - Arch string - BuildTime time.Time - License string -} - -func (pkg Package) ToPackageBuild() PackageBuild { - // Convert the time to the API time format - return PackageBuild{ - Arch: pkg.Arch, - BuildTime: pkg.BuildTime.Format("2006-01-02T15:04:05"), - Epoch: pkg.Epoch, - Release: pkg.Release, - Changelog: "CHANGELOG_NEEDED", // the same value as lorax-composer puts here - BuildConfigRef: "BUILD_CONFIG_REF", // the same value as lorax-composer puts here - BuildEnvRef: "BUILD_ENV_REF", // the same value as lorax-composer puts here - Source: PackageSource{ - License: pkg.License, - Version: pkg.Version, - SourceRef: "SOURCE_REF", // the same value as lorax-composer puts here - }, - } -} - -func (pkg Package) ToPackageInfo() PackageInfo { - return PackageInfo{ - Name: pkg.Name, - Summary: pkg.Summary, - Description: pkg.Description, - Homepage: pkg.URL, - UpstreamVCS: "UPSTREAM_VCS", // the same value as lorax-composer puts here - Builds: []PackageBuild{pkg.ToPackageBuild()}, - Dependencies: nil, - } -} - -// The inputs to depsolve, a set of packages to include and a set of packages -// to exclude. The Repositories are used when depsolving this package set in -// addition to the base repositories. -type PackageSet struct { - Include []string - Exclude []string - EnabledModules []string - Repositories []RepoConfig - InstallWeakDeps bool -} - -// Append the Include and Exclude package list from another PackageSet and -// return the result. -func (ps PackageSet) Append(other PackageSet) PackageSet { - ps.Include = append(ps.Include, other.Include...) - ps.Exclude = append(ps.Exclude, other.Exclude...) - ps.EnabledModules = append(ps.EnabledModules, other.EnabledModules...) - return ps -} - -// TODO: the public API of this package should not be reused for serialization. -type PackageSpec struct { - Name string `json:"name"` - Epoch uint `json:"epoch"` - Version string `json:"version,omitempty"` - Release string `json:"release,omitempty"` - Arch string `json:"arch,omitempty"` - RemoteLocation string `json:"remote_location,omitempty"` - Checksum string `json:"checksum,omitempty"` - Secrets string `json:"secrets,omitempty"` - CheckGPG bool `json:"check_gpg,omitempty"` - IgnoreSSL bool `json:"ignore_ssl,omitempty"` - - Path string `json:"path,omitempty"` - RepoID string `json:"repo_id,omitempty"` -} - -type PackageSource struct { - License string `json:"license"` - Version string `json:"version"` - SourceRef string `json:"source_ref"` - Metadata struct{} `json:"metadata"` // it's just an empty struct in lorax-composer -} - -type PackageBuild struct { - Arch string `json:"arch"` - BuildTime string `json:"build_time"` - Epoch uint `json:"epoch"` - Release string `json:"release"` - Source PackageSource `json:"source"` - Changelog string `json:"changelog"` - BuildConfigRef string `json:"build_config_ref"` - BuildEnvRef string `json:"build_env_ref"` - Metadata struct{} `json:"metadata"` // it's just an empty struct in lorax-composer -} - -type PackageInfo struct { - Name string `json:"name"` - Summary string `json:"summary"` - Description string `json:"description"` - Homepage string `json:"homepage"` - UpstreamVCS string `json:"upstream_vcs"` - Builds []PackageBuild `json:"builds"` - Dependencies []PackageSpec `json:"dependencies,omitempty"` -} - -type ModuleSpec struct { - ModuleConfigFile ModuleConfigFile `json:"module-file"` - FailsafeFile ModuleFailsafeFile `json:"failsafe-file"` -} - -type ModuleConfigFile struct { - Path string `json:"path"` - Data ModuleConfigData `json:"data"` -} - -type ModuleConfigData struct { - Name string `json:"name"` - Stream string `json:"stream"` - Profiles []string `json:"profiles"` - State string `json:"state"` -} - -type ModuleFailsafeFile struct { - Path string `json:"path"` - Data string `json:"data"` -} - -// GetEVRA returns the package's Epoch:Version-Release.Arch string -func (ps *PackageSpec) GetEVRA() string { - if ps.Epoch == 0 { - return fmt.Sprintf("%s-%s.%s", ps.Version, ps.Release, ps.Arch) - } - return fmt.Sprintf("%d:%s-%s.%s", ps.Epoch, ps.Version, ps.Release, ps.Arch) -} - -// GetNEVRA returns the package's Name-Epoch:Version-Release.Arch string -func (ps *PackageSpec) GetNEVRA() string { - return fmt.Sprintf("%s-%s", ps.Name, ps.GetEVRA()) -} - -func GetPackage(pkgs []PackageSpec, packageName string) (PackageSpec, error) { - for _, pkg := range pkgs { - if pkg.Name == packageName { - return pkg, nil - } - } - - return PackageSpec{}, fmt.Errorf("package %q not found in the PackageSpec list", packageName) -} - func LoadRepositoriesFromFile(filename string) (map[string][]RepoConfig, error) { f, err := os.Open(filename) if err != nil { @@ -299,55 +139,3 @@ func LoadRepositoriesFromReader(r io.Reader) (map[string][]RepoConfig, error) { return repoConfigs, nil } - -func (packages PackageList) Search(globPatterns ...string) (PackageList, error) { - var globs []glob.Glob - - for _, globPattern := range globPatterns { - g, err := glob.Compile(globPattern) - if err != nil { - return nil, err - } - - globs = append(globs, g) - } - - var foundPackages PackageList - - for _, pkg := range packages { - for _, g := range globs { - if g.Match(pkg.Name) { - foundPackages = append(foundPackages, pkg) - break - } - } - } - - sort.Slice(packages, func(i, j int) bool { - return packages[i].Name < packages[j].Name - }) - - return foundPackages, nil -} - -func (packages PackageList) ToPackageInfos() []PackageInfo { - resultsNames := make(map[string]int) - var results []PackageInfo - - for _, pkg := range packages { - if index, ok := resultsNames[pkg.Name]; ok { - foundPkg := &results[index] - - foundPkg.Builds = append(foundPkg.Builds, pkg.ToPackageBuild()) - } else { - newIndex := len(results) - resultsNames[pkg.Name] = newIndex - - packageInfo := pkg.ToPackageInfo() - - results = append(results, packageInfo) - } - } - - return results -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4d872eb46a..fe4bec7529 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -961,7 +961,7 @@ github.com/oracle/oci-go-sdk/v54/workrequests ## explicit; go 1.23.9 github.com/osbuild/blueprint/internal/common github.com/osbuild/blueprint/pkg/blueprint -# github.com/osbuild/images v0.202.0 +# github.com/osbuild/images v0.204.0 ## explicit; go 1.23.9 github.com/osbuild/images/data/dependencies github.com/osbuild/images/data/distrodefs