Switch to yaml and preparation for repository functionality #3

Merged
EnumDev merged 5 commits from develop into master 2024-09-09 08:40:28 +00:00
Showing only changes of commit 7d577a8dc2 - Show all commits

View File

@ -310,6 +310,9 @@ func ReadPackageInfo(contents string, defaultValues bool) (*PackageInfo, error)
return nil, errors.New("this package contains no type")
}
}
for i := 0; i < len(pkgInfo.Keep); i++ {
pkgInfo.Keep[i] = strings.TrimPrefix(pkgInfo.Keep[i], "/")
}
return &pkgInfo, nil
}
@ -368,14 +371,32 @@ func extractPackage(pkgInfo *PackageInfo, verbose bool, filename, rootDir string
}
}
case tar.TypeReg:
skip := false
if _, err := os.Stat(extractFilename); err == nil {
if slices.Contains(pkgInfo.Keep, trimmedName) {
for _, k := range pkgInfo.Keep {
if strings.HasSuffix(k, "/") {
if strings.HasPrefix(trimmedName, k) {
if verbose {
fmt.Println("Skipping File: " + extractFilename + "(File is configured to be kept during installs/updates)")
fmt.Println("Skipping File: " + extractFilename + " (Containing directory is set to be kept during installs/updates)")
}
files = append(files, trimmedName)
files = append(files, strings.TrimPrefix(header.Name, "files/"))
skip = true
continue
}
} else {
if trimmedName == k {
if verbose {
fmt.Println("Skipping File: " + extractFilename + " (File is configured to be kept during installs/updates)")
}
files = append(files, strings.TrimPrefix(header.Name, "files/"))
skip = true
continue
}
}
}
}
if skip {
continue
}
err := os.Remove(extractFilename)
if err != nil && !os.IsNotExist(err) {