mirror of
https://github.com/mudler/luet.git
synced 2025-09-01 23:37:07 +00:00
Add support to store the path of the loaded packages
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user