Fix release:os-package

This commit is contained in:
kolaente 2020-09-02 22:04:25 +02:00
parent d85bf0681f
commit e1502fe872
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 17 additions and 6 deletions

View File

@ -528,28 +528,39 @@ func (Release) Check() error {
// Creates a folder for each
func (Release) OsPackage() error {
p := RootPath + "/" + DIST + "/release/"
return filepath.Walk(p, func(path string, info os.FileInfo, err error) error {
if strings.Contains(info.Name(), ".sha256") {
// We first put all files in a map to then iterate over it since the walk function would otherwise also iterate
// over the newly created files, creating some kind of endless loop.
bins := make(map[string]os.FileInfo)
if err := filepath.Walk(p, func(path string, info os.FileInfo, err error) error {
if strings.Contains(info.Name(), ".sha256") || info.IsDir() {
return nil
}
bins[path] = info
return nil
}); err != nil {
return err
}
for path, info := range bins {
folder := p + info.Name() + "-full/"
if err := os.Mkdir(folder, 0755); err != nil {
return err
}
if err := os.Rename(p+info.Name()+".sha256", folder+info.Name()+".sha256"); err != nil {
return err
}
if err := os.Rename(path, folder+info.Name()); err != nil {
return err
}
if err := copyFile(RootPath+"/config.yml.sample", folder+"config.yml.sample"); err != nil {
return err
}
if err := copyFile(RootPath+"/LICENSE", folder+"LICENSE"); err != nil {
return err
}
return nil
})
}
return nil
}
func (Release) Zip() {