mirror of
https://github.com/rocky-linux/peridot.git
synced 2024-11-18 11:21:25 +00:00
Finalize SCL feature
This commit is contained in:
parent
949ab935e6
commit
77fb4ac65b
@ -662,17 +662,17 @@ func (c *Controller) BuildArchActivity(ctx context.Context, projectId string, pa
|
||||
return err
|
||||
}
|
||||
|
||||
var pkgGroup []string = DefaultBuildPkgGroup
|
||||
var pkgGroup = DefaultBuildPkgGroup
|
||||
|
||||
if len(project.BuildStagePackages) != 0 {
|
||||
pkgGroup = project.BuildStagePackages
|
||||
}
|
||||
if len(project.BuildStagePackages) != 0 {
|
||||
pkgGroup = project.BuildStagePackages
|
||||
}
|
||||
|
||||
if len(pkgEo.DependsOn) != 0 {
|
||||
for _, pkg := range pkgEo.DependsOn {
|
||||
pkgGroup = append(pkgGroup, pkg)
|
||||
}
|
||||
}
|
||||
if len(pkgEo.DependsOn) != 0 {
|
||||
for _, pkg := range pkgEo.DependsOn {
|
||||
pkgGroup = append(pkgGroup, pkg)
|
||||
}
|
||||
}
|
||||
|
||||
hostArch := os.Getenv("REAL_BUILD_ARCH")
|
||||
err = c.writeMockConfig(&project, packageVersion, extraOptions, arch, hostArch, pkgGroup)
|
||||
|
@ -416,16 +416,16 @@ func (c *Controller) BuildSRPMActivity(ctx context.Context, upstreamPrefix strin
|
||||
return fmt.Errorf("could not find spec file: %v", err)
|
||||
}
|
||||
|
||||
var pkgGroup []string = DefaultSrpmBuildPkgGroup
|
||||
var pkgGroup = DefaultSrpmBuildPkgGroup
|
||||
|
||||
if len(project.SrpmStagePackages) != 0 {
|
||||
pkgGroup = project.SrpmStagePackages
|
||||
}
|
||||
if len(pkgEo.DependsOn) != 0 {
|
||||
for _, pkg := range pkgEo.DependsOn {
|
||||
pkgGroup = append(pkgGroup, pkg)
|
||||
}
|
||||
}
|
||||
if len(project.SrpmStagePackages) != 0 {
|
||||
pkgGroup = project.SrpmStagePackages
|
||||
}
|
||||
if len(pkgEo.DependsOn) != 0 {
|
||||
for _, pkg := range pkgEo.DependsOn {
|
||||
pkgGroup = append(pkgGroup, pkg)
|
||||
}
|
||||
}
|
||||
|
||||
hostArch := os.Getenv("REAL_BUILD_ARCH")
|
||||
extraOptions.EnableNetworking = true
|
||||
|
@ -35,6 +35,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"github.com/gobwas/glob"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
@ -454,17 +455,48 @@ func kindCatalogSync(tx peridotdb.Access, req *peridotpb.SyncCatalogRequest, cat
|
||||
func processGroupInstallScopedPackageOptions(tx peridotdb.Access, req *peridotpb.SyncCatalogRequest, groupInstallOptionSet *peridotpb.CatalogGroupInstallOption) (scopedPackages *peridotpb.CatalogGroupInstallScopedPackage, err error) {
|
||||
// handle scoped packages relationships on packages for injection into build root
|
||||
for _, scopedPackage := range groupInstallOptionSet.ScopedPackage {
|
||||
// Search by name to allow globbing to support pkg-*
|
||||
pkgs, err := tx.GetPackagesInProject(&peridotpb.PackageFilters{Name: wrapperspb.String(scopedPackage.Name)}, req.ProjectId.Value, 0, 1)
|
||||
filters := &peridotpb.PackageFilters{NameExact: wrapperspb.String(scopedPackage.Name)}
|
||||
isGlob := false
|
||||
if strings.HasPrefix(scopedPackage.Name, "*") || strings.HasSuffix(scopedPackage.Name, "*") {
|
||||
filters.Name = wrapperspb.String(strings.TrimSuffix(strings.TrimPrefix(scopedPackage.Name, "*"), "*"))
|
||||
filters.NameExact = nil
|
||||
isGlob = true
|
||||
}
|
||||
|
||||
pkgs, err := tx.GetPackagesInProject(filters, req.ProjectId.Value, 0, -1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get package %s: %w", scopedPackage.Name, err)
|
||||
}
|
||||
if len(pkgs) == 0 {
|
||||
return nil, fmt.Errorf("package %s not found in project %s (cannot set scoped package options)", scopedPackage.Name, req.ProjectId.Value)
|
||||
return nil, fmt.Errorf("package %s not found in project %s (scoped package)", scopedPackage.Name, req.ProjectId.Value)
|
||||
}
|
||||
err = tx.SetGroupInstallOptionsForPackage(req.ProjectId.Value, scopedPackage.Name, scopedPackage.DependsOn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to set scoped package options for package %s", scopedPackage.Name)
|
||||
|
||||
var dbPkgs []models.Package
|
||||
if isGlob {
|
||||
for _, p := range pkgs {
|
||||
g, err := glob.Compile(scopedPackage.Name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compile glob %s: %w", scopedPackage.Name, err)
|
||||
}
|
||||
if g.Match(p.Name) {
|
||||
dbPkgs = append(dbPkgs, p)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if scopedPackage.Name != pkgs[0].Name {
|
||||
return nil, fmt.Errorf("package %s not found in project %s (cannot set extra options, not glob)", scopedPackage.Name, req.ProjectId.Value)
|
||||
}
|
||||
dbPkgs = append(dbPkgs, pkgs[0])
|
||||
}
|
||||
if len(dbPkgs) == 0 {
|
||||
return nil, fmt.Errorf("package %s not found in project %s (cannot set extra options, glob)", scopedPackage.Name, req.ProjectId.Value)
|
||||
}
|
||||
|
||||
for _, dbPkg := range dbPkgs {
|
||||
err = tx.SetGroupInstallOptionsForPackage(req.ProjectId.Value, dbPkg.Name, scopedPackage.DependsOn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to set scoped package options for package %s", scopedPackage.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return scopedPackages, nil
|
||||
@ -489,18 +521,18 @@ func kindCatalogGroupInstallOptions(tx peridotdb.Access, req *peridotpb.SyncCata
|
||||
// Proces scoped packages
|
||||
scopedPackages, err := processGroupInstallScopedPackageOptions(tx, req, groupInstallOption.Srpm)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse srpm groupinstall options")
|
||||
return nil, fmt.Errorf("failed to parse srpm groupinstall options: %s", err.Error())
|
||||
}
|
||||
ret.ScopedPackage = append(ret.ScopedPackage, scopedPackages)
|
||||
|
||||
// Process build root packages
|
||||
srpmPackages, err := processGroupInstallOptionSet(groupInstallOption.Srpm)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse srpm groupinstall options: %w", err)
|
||||
return nil, fmt.Errorf("failed to parse srpm groupinstall options: %w", err)
|
||||
}
|
||||
buildPackages, err := processGroupInstallOptionSet(groupInstallOption.Build)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse build groupinstall options: %w", err)
|
||||
return nil, fmt.Errorf("failed to parse build groupinstall options: %w", err)
|
||||
}
|
||||
err = tx.SetBuildRootPackages(req.ProjectId.Value, srpmPackages, buildPackages)
|
||||
|
||||
@ -811,7 +843,7 @@ func (c *Controller) SyncCatalogActivity(req *peridotpb.SyncCatalogRequest) (*pe
|
||||
cg1 := &peridotpb.CatalogGroupInstallOptions{}
|
||||
err = prototext.Unmarshal(bts, cg1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse kind resf.peridot.v1.CatalogExtraOptions: %w", err)
|
||||
return nil, fmt.Errorf("failed to parse kind resf.peridot.v1.CatalogGroupInstallOptions: %w", err)
|
||||
}
|
||||
groupInstallOptions = append(groupInstallOptions, cg1)
|
||||
default:
|
||||
|
@ -335,7 +335,7 @@ func (a *Access) GetExtraOptionsForPackage(projectId string, packageName string)
|
||||
var ret models.ExtraOptions
|
||||
err := a.query.Get(
|
||||
&ret,
|
||||
"select id, created_at, updated_at, project_id, package_name, with_flags, without_flags from extra_package_options where project_id = $1 and package_name = $2",
|
||||
"select id, created_at, updated_at, project_id, package_name, with_flags, without_flags, depends_on from extra_package_options where project_id = $1 and package_name = $2",
|
||||
projectId,
|
||||
packageName,
|
||||
)
|
||||
@ -358,7 +358,7 @@ func (a *Access) SetGroupInstallOptionsForPackage(projectId string, packageName
|
||||
`,
|
||||
projectId,
|
||||
packageName,
|
||||
dependsOn,
|
||||
dependsOn,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
@ -119,5 +119,6 @@ func Bool(b bool) *bool {
|
||||
}
|
||||
|
||||
func Pointer[T any](t T) *T {
|
||||
return &t
|
||||
s := t
|
||||
return &s
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user