mirror of
https://github.com/mudler/luet.git
synced 2025-09-03 16:25:19 +00:00
Allow to manipulate requires/conflicts/provides
This allows to manipulate requires, conflicts and provides with templating in build time. Signed-off-by: Ettore Di Giacinto <mudler@sabayon.org>
This commit is contained in:
@@ -1256,6 +1256,11 @@ func (cs *LuetCompiler) FromPackage(p pkg.Package) (*compilerspec.LuetCompilatio
|
|||||||
|
|
||||||
cs.inheritSpecBuildOptions(newSpec)
|
cs.inheritSpecBuildOptions(newSpec)
|
||||||
|
|
||||||
|
// Update the package in the compiler database to catch updates from NewLuetCompilationSpec
|
||||||
|
if err := cs.Database.UpdatePackage(newSpec.Package); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed updating new package entry in compiler database")
|
||||||
|
}
|
||||||
|
|
||||||
return newSpec, err
|
return newSpec, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,11 +23,11 @@ import (
|
|||||||
"github.com/mitchellh/hashstructure/v2"
|
"github.com/mitchellh/hashstructure/v2"
|
||||||
options "github.com/mudler/luet/pkg/compiler/types/options"
|
options "github.com/mudler/luet/pkg/compiler/types/options"
|
||||||
|
|
||||||
|
"github.com/ghodss/yaml"
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
"github.com/mudler/luet/pkg/solver"
|
"github.com/mudler/luet/pkg/solver"
|
||||||
"github.com/otiai10/copy"
|
"github.com/otiai10/copy"
|
||||||
dirhash "golang.org/x/mod/sumdb/dirhash"
|
dirhash "golang.org/x/mod/sumdb/dirhash"
|
||||||
yaml "gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type LuetCompilationspecs []LuetCompilationSpec
|
type LuetCompilationspecs []LuetCompilationSpec
|
||||||
@@ -157,11 +157,31 @@ func (cs *LuetCompilationSpec) signature() Signature {
|
|||||||
|
|
||||||
func NewLuetCompilationSpec(b []byte, p pkg.Package) (*LuetCompilationSpec, error) {
|
func NewLuetCompilationSpec(b []byte, p pkg.Package) (*LuetCompilationSpec, error) {
|
||||||
var spec LuetCompilationSpec
|
var spec LuetCompilationSpec
|
||||||
|
var packageDefinition pkg.DefaultPackage
|
||||||
err := yaml.Unmarshal(b, &spec)
|
err := yaml.Unmarshal(b, &spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &spec, err
|
return &spec, err
|
||||||
}
|
}
|
||||||
spec.Package = p.(*pkg.DefaultPackage)
|
err = yaml.Unmarshal(b, &packageDefinition)
|
||||||
|
if err != nil {
|
||||||
|
return &spec, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update requires/conflict/provides
|
||||||
|
// When we have been passed a bytes slice, parse it as a package
|
||||||
|
// and updates requires/conflicts/provides.
|
||||||
|
// This is required in order to allow manipulation of such fields with templating
|
||||||
|
copy := *p.(*pkg.DefaultPackage)
|
||||||
|
spec.Package = ©
|
||||||
|
if len(packageDefinition.GetRequires()) != 0 {
|
||||||
|
spec.Package.Requires(packageDefinition.GetRequires())
|
||||||
|
}
|
||||||
|
if len(packageDefinition.GetConflicts()) != 0 {
|
||||||
|
spec.Package.Conflicts(packageDefinition.GetConflicts())
|
||||||
|
}
|
||||||
|
if len(packageDefinition.GetProvides()) != 0 {
|
||||||
|
spec.Package.SetProvides(packageDefinition.GetProvides())
|
||||||
|
}
|
||||||
return &spec, nil
|
return &spec, nil
|
||||||
}
|
}
|
||||||
func (cs *LuetCompilationSpec) GetSourceAssertion() solver.PackagesAssertions {
|
func (cs *LuetCompilationSpec) GetSourceAssertion() solver.PackagesAssertions {
|
||||||
|
Reference in New Issue
Block a user