mirror of
https://github.com/mudler/luet.git
synced 2025-08-17 14:56:46 +00:00
parent
917d0935ad
commit
0bacdc75f2
@ -37,6 +37,8 @@ type LuetRepository struct {
|
|||||||
Verify bool `json:"verify,omitempty" yaml:"verify,omitempty" mapstructure:"verify"`
|
Verify bool `json:"verify,omitempty" yaml:"verify,omitempty" mapstructure:"verify"`
|
||||||
Arch string `json:"arch,omitempty" yaml:"arch,omitempty" mapstructure:"arch"`
|
Arch string `json:"arch,omitempty" yaml:"arch,omitempty" mapstructure:"arch"`
|
||||||
|
|
||||||
|
ReferenceID string `json:"reference,omitempty" yaml:"reference,omitempty" mapstructure:"reference"`
|
||||||
|
|
||||||
// Incremented value that identify revision of the repository in a user-friendly way.
|
// Incremented value that identify revision of the repository in a user-friendly way.
|
||||||
Revision int `json:"revision,omitempty" yaml:"-" mapstructure:"-"`
|
Revision int `json:"revision,omitempty" yaml:"-" mapstructure:"-"`
|
||||||
// Epoch time in seconds
|
// Epoch time in seconds
|
||||||
|
@ -772,6 +772,14 @@ func (r *LuetSystemRepository) SyncBuildMetadata(ctx *types.Context, path string
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *LuetSystemRepository) referenceID() string {
|
||||||
|
repositoryReferenceID := REPOSITORY_SPECFILE
|
||||||
|
if r.ReferenceID != "" {
|
||||||
|
repositoryReferenceID = r.ReferenceID
|
||||||
|
}
|
||||||
|
return repositoryReferenceID
|
||||||
|
}
|
||||||
|
|
||||||
func (r *LuetSystemRepository) Sync(ctx *types.Context, force bool) (*LuetSystemRepository, error) {
|
func (r *LuetSystemRepository) Sync(ctx *types.Context, force bool) (*LuetSystemRepository, error) {
|
||||||
var repoUpdated bool = false
|
var repoUpdated bool = false
|
||||||
var treefs, metafs string
|
var treefs, metafs string
|
||||||
@ -782,10 +790,12 @@ func (r *LuetSystemRepository) Sync(ctx *types.Context, force bool) (*LuetSystem
|
|||||||
return nil, errors.New("no client could be generated from repository")
|
return nil, errors.New("no client could be generated from repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositoryReferenceID := r.referenceID()
|
||||||
|
|
||||||
// Retrieve remote repository.yaml for retrieve revision and date
|
// Retrieve remote repository.yaml for retrieve revision and date
|
||||||
file, err := c.DownloadFile(REPOSITORY_SPECFILE)
|
file, err := c.DownloadFile(repositoryReferenceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "while downloading "+REPOSITORY_SPECFILE)
|
return nil, errors.Wrap(err, "while downloading "+repositoryReferenceID)
|
||||||
}
|
}
|
||||||
|
|
||||||
repobasedir := ctx.Config.GetSystem().GetRepoDatabaseDirPath(r.GetName())
|
repobasedir := ctx.Config.GetSystem().GetRepoDatabaseDirPath(r.GetName())
|
||||||
@ -799,7 +809,7 @@ func (r *LuetSystemRepository) Sync(ctx *types.Context, force bool) (*LuetSystem
|
|||||||
|
|
||||||
if r.Cached {
|
if r.Cached {
|
||||||
if !force {
|
if !force {
|
||||||
localRepo, _ := r.ReadSpecFile(filepath.Join(repobasedir, REPOSITORY_SPECFILE))
|
localRepo, _ := r.ReadSpecFile(filepath.Join(repobasedir, repositoryReferenceID))
|
||||||
if localRepo != nil {
|
if localRepo != nil {
|
||||||
if localRepo.GetRevision() == downloadedRepoMeta.GetRevision() &&
|
if localRepo.GetRevision() == downloadedRepoMeta.GetRevision() &&
|
||||||
localRepo.GetLastUpdate() == downloadedRepoMeta.GetLastUpdate() {
|
localRepo.GetLastUpdate() == downloadedRepoMeta.GetLastUpdate() {
|
||||||
@ -850,9 +860,9 @@ func (r *LuetSystemRepository) Sync(ctx *types.Context, force bool) (*LuetSystem
|
|||||||
|
|
||||||
if r.Cached {
|
if r.Cached {
|
||||||
// Copy updated repository.yaml file to repo dir now that the tree is synced.
|
// Copy updated repository.yaml file to repo dir now that the tree is synced.
|
||||||
err = fileHelper.CopyFile(file, filepath.Join(repobasedir, REPOSITORY_SPECFILE))
|
err = fileHelper.CopyFile(file, filepath.Join(repobasedir, repositoryReferenceID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Error on update "+REPOSITORY_SPECFILE)
|
return nil, errors.Wrap(err, "Error on update "+repositoryReferenceID)
|
||||||
}
|
}
|
||||||
// Remove previous tree
|
// Remove previous tree
|
||||||
os.RemoveAll(treefs)
|
os.RemoveAll(treefs)
|
||||||
|
Loading…
Reference in New Issue
Block a user