mirror of
https://github.com/mudler/luet.git
synced 2025-09-17 23:58:48 +00:00
Source packages metadata to update repository tree
This allows to generate trees with `create-repo` by just having the metadata files, making tree(s) an optional requirement.
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
artifact "github.com/mudler/luet/pkg/compiler/types/artifact"
|
artifact "github.com/mudler/luet/pkg/compiler/types/artifact"
|
||||||
@@ -297,6 +298,37 @@ func GenerateRepository(name, descr, t string, urls []string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load packages from metadata files if not present already.
|
||||||
|
var ff = func(currentpath string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only those which are metadata
|
||||||
|
if !strings.HasSuffix(info.Name(), pkg.PackageMetaSuffix) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
dat, err := ioutil.ReadFile(currentpath)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
art, err := artifact.NewPackageArtifactFromYaml(dat)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if _, err := runtimeTree.FindPackage(art.CompileSpec.Package); err != nil && art.CompileSpec.Package.Name != "" {
|
||||||
|
Debug("Added", art.CompileSpec.Package.HumanReadableString(), "from metadata files")
|
||||||
|
runtimeTree.CreatePackage(art.CompileSpec.Package)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Best effort
|
||||||
|
filepath.Walk(src, ff)
|
||||||
|
|
||||||
repo := &LuetSystemRepository{
|
repo := &LuetSystemRepository{
|
||||||
LuetRepository: config.NewLuetRepository(name, t, descr, urls, priority, true, false),
|
LuetRepository: config.NewLuetRepository(name, t, descr, urls, priority, true, false),
|
||||||
Tree: tree.NewInstallerRecipe(runtimeTree),
|
Tree: tree.NewInstallerRecipe(runtimeTree),
|
||||||
|
@@ -124,6 +124,8 @@ type Package interface {
|
|||||||
JSON() ([]byte, error)
|
JSON() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PackageMetaSuffix = "metadata.yaml"
|
||||||
|
|
||||||
type Tree interface {
|
type Tree interface {
|
||||||
GetPackageSet() PackageDatabase
|
GetPackageSet() PackageDatabase
|
||||||
Prelude() string // A tree might have a prelude to be able to consume a tree
|
Prelude() string // A tree might have a prelude to be able to consume a tree
|
||||||
@@ -246,7 +248,7 @@ func (t *DefaultPackage) JSON() ([]byte, error) {
|
|||||||
|
|
||||||
// GetMetadataFilePath returns the canonical name of an artifact metadata file
|
// GetMetadataFilePath returns the canonical name of an artifact metadata file
|
||||||
func (d *DefaultPackage) GetMetadataFilePath() string {
|
func (d *DefaultPackage) GetMetadataFilePath() string {
|
||||||
return d.GetFingerPrint() + ".metadata.yaml"
|
return fmt.Sprintf("%s.%s", d.GetFingerPrint(), PackageMetaSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultPackage represent a standard package definition
|
// DefaultPackage represent a standard package definition
|
||||||
|
Reference in New Issue
Block a user