diff --git a/pkg/package/package.go b/pkg/package/package.go index 3f17fc45..434a8c5c 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -54,6 +54,9 @@ type Package interface { Yaml() ([]byte, error) Explain() + + SetPath(string) + GetPath() string } type PackageSet interface { @@ -96,6 +99,8 @@ type DefaultPackage struct { PackageRequires []*DefaultPackage `json:"requires"` // Affects YAML field names too. PackageConflicts []*DefaultPackage `json:"conflicts"` // Affects YAML field names too. IsSet bool `json:"set"` // Affects YAML field names too. + + Path string `json:"-"` // primary key with auto increment } // State represent the package state @@ -112,6 +117,15 @@ func (p *DefaultPackage) GetFingerPrint() string { return fmt.Sprintf("%s-%s-%s", p.Name, p.Category, p.Version) } +// GetPath returns the path where the definition file was found +func (p *DefaultPackage) GetPath() string { + return p.Path +} + +func (p *DefaultPackage) SetPath(s string) { + p.Path = s +} + // AddUse adds a use to a package func (p *DefaultPackage) AddUse(use string) { for _, v := range p.UseFlags { diff --git a/pkg/tree/recipes.go b/pkg/tree/recipes.go index bcc68187..383696eb 100644 --- a/pkg/tree/recipes.go +++ b/pkg/tree/recipes.go @@ -28,7 +28,9 @@ import ( pkg "github.com/mudler/luet/pkg/package" ) -const DefinitionFile = "definition.yaml" +const ( + DefinitionFile = "definition.yaml" +) func NewGeneralRecipe() Builder { return &Recipe{} } @@ -89,6 +91,9 @@ func (r *Recipe) Load(path string) error { if err != nil { return err } + + pack.SetPath(filepath.Dir(path)) + _, err = r.Tree().GetPackageSet().CreatePackage(&pack) if err != nil { return err