check if ./.ww4/exludes exist and use if

This commit is contained in:
Christian Goll
2022-01-31 15:05:11 +01:00
parent 255d8c9252
commit 2e44c51554

View File

@@ -48,10 +48,15 @@ func Build(name string, buildForce bool) error {
} else {
wwlog.Printf(wwlog.VERBOSE, "Using PIGZ to compress the container: %s\n", compressor)
}
wwlog.Printf(wwlog.DEBUG, "Building VNFS image: '%s' -> '%s'\n", rootfsPath, imagePath)
cmd := fmt.Sprintf("cd %s; find . | cpio --quiet -o -H newc | %s -c > \"%s\"", rootfsPath, compressor, imagePath)
var cmd string
_, err = os.Stat(path.Join(rootfsPath, "./.ww4/exclude"))
if os.IsNotExist(err) {
wwlog.Printf(wwlog.DEBUG, "Building VNFS image: '%s' -> '%s'\n", rootfsPath, imagePath)
cmd = fmt.Sprintf("cd %s; find . | cpio --quiet -o -H newc | %s -c > \"%s\"", rootfsPath, compressor, imagePath)
} else {
wwlog.Printf(wwlog.DEBUG, "Building VNFS image with excludes: '%s' -> '%s'\n", rootfsPath, imagePath)
cmd = fmt.Sprintf("cd %s; find . | grep -v -f .ww4/exclude | cpio --quiet -o -H newc | %s -c > \"%s\"", rootfsPath, compressor, imagePath)
}
wwlog.Printf(wwlog.DEBUG, "RUNNING: %s\n", cmd)
err = exec.Command("/bin/sh", "-c", cmd).Run()
if err != nil {