Keep the path around after writing the yaml, otherwise compile specs couldn't be found

This commit is contained in:
Ettore Di Giacinto
2019-11-23 16:28:50 +01:00
parent 8f6393e157
commit 3b9337a03b
3 changed files with 27 additions and 5 deletions

View File

@@ -71,18 +71,39 @@ func NewPackageArtifactFromYaml(data []byte) (Artifact, error) {
}
func (a *PackageArtifact) WriteYaml(dst string) error {
a.CompileSpec.GetPackage().SetPath("")
for _, ass := range a.CompileSpec.GetSourceAssertion() {
ass.Package.SetPath("")
}
//p := a.CompileSpec.GetPackage().GetPath()
//a.CompileSpec.GetPackage().SetPath("")
// for _, ass := range a.CompileSpec.GetSourceAssertion() {
// ass.Package.SetPath("")
// }
data, err := yaml.Marshal(a)
if err != nil {
return errors.Wrap(err, "While marshalling for PackageArtifact YAML")
}
mangle, err := NewPackageArtifactFromYaml(data)
if err != nil {
return errors.Wrap(err, "Generated invalid artifact")
}
//p := a.CompileSpec.GetPackage().GetPath()
mangle.GetCompileSpec().GetPackage().SetPath("")
for _, ass := range mangle.GetCompileSpec().GetSourceAssertion() {
ass.Package.SetPath("")
}
data, err = yaml.Marshal(mangle)
if err != nil {
return errors.Wrap(err, "While marshalling for PackageArtifact YAML")
}
err = ioutil.WriteFile(filepath.Join(dst, a.GetCompileSpec().GetPackage().GetFingerPrint()+".metadata.yaml"), data, os.ModePerm)
if err != nil {
return errors.Wrap(err, "While writing PackageArtifact YAML")
}
//a.CompileSpec.GetPackage().SetPath(p)
return nil
}

View File

@@ -437,7 +437,7 @@ func (cs *LuetCompiler) compile(concurrency int, keepPermissions bool, p Compila
Info(pkgTag, " :zap: Building dependency")
compileSpec, err := cs.FromPackage(assertion.Package)
if err != nil {
return nil, errors.New("Error while generating compilespec for " + assertion.Package.GetName())
return nil, errors.Wrap(err, "Error while generating compilespec for "+assertion.Package.GetName())
}
compileSpec.SetOutputPath(p.GetOutputPath())

View File

@@ -266,6 +266,7 @@ func (l *LuetInstaller) installerWorker(i int, wg *sync.WaitGroup, c <-chan Arti
defer wg.Done()
for p := range c {
// TODO: Keep trace of what was added from the tar, and save it into system
err := l.installPackage(p, s)
if err != nil {
//TODO: Uninstall, rollback.