diff --git a/pkg/config/config.go b/pkg/config/config.go index 89312a43..5e290c27 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -56,7 +56,14 @@ type LuetRepository struct { Priority int `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority"` Enable bool `json:"enable" yaml:"enable" mapstructure:"enable"` Authentication map[string]string `json:"auth,omitempty" yaml:"auth,omitempty" mapstructure:"auth,omitempty"` - TreePath string `json:"tree_path,omitempty" yaml::"tree_path,omitempty" mapstructure:"tree_path"` + TreePath string `json:"tree_path,omitempty" yaml:"tree_path,omitempty" mapstructure:"tree_path"` + + // Serialized options not used in repository configuration + + // Incremented value that identify revision of the repository in a user-friendly way. + Revision int `json:"revision,omitempty" yaml:"-,omitempty" mapstructure:"-,omitempty"` + // Epoch time in seconds + LastUpdate string `json:"last_update,omitempty" yaml:"-,omitempty" mapstructure:"-,omitempty"` } func NewLuetRepository(name, t, descr string, urls []string, priority int, enable bool) *LuetRepository { diff --git a/pkg/installer/repository.go b/pkg/installer/repository.go index fa712c3e..f861e323 100644 --- a/pkg/installer/repository.go +++ b/pkg/installer/repository.go @@ -21,7 +21,9 @@ import ( "path/filepath" "regexp" "sort" + "strconv" "strings" + "time" "github.com/mudler/luet/pkg/installer/client" @@ -49,6 +51,8 @@ type LuetSystemRepositorySerialized struct { Priority int `json:"priority"` Index []*compiler.PackageArtifact `json:"index"` Type string `json:"type"` + Revision int `json:"revision,omitempty"` + LastUpdate string `json:"last_update,omitempty"` } func GenerateRepository(name, descr, t string, urls []string, priority int, src, treeDir string, db pkg.PackageDatabase) (Repository, error) { @@ -98,6 +102,12 @@ func NewLuetSystemRepositoryFromYaml(data []byte, db pkg.PackageDatabase) (Repos true, ), } + if p.Revision > 0 { + r.Revision = p.Revision + } + if p.LastUpdate != "" { + r.LastUpdate = p.LastUpdate + } i := compiler.ArtifactIndex{} for _, ii := range p.Index { i = append(i, ii) @@ -185,6 +195,8 @@ func (r *LuetSystemRepository) Write(dst string) error { return err } r.Index = r.Index.CleanPath() + r.LastUpdate = strconv.FormatInt(time.Now().Unix(), 10) + r.Revision++ data, err := yaml.Marshal(r) if err != nil {