From 2e44c51554f1d2b797b630d51ff76b0e04262d38 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Mon, 31 Jan 2022 15:05:11 +0100 Subject: [PATCH] check if ./.ww4/exludes exist and use if --- internal/pkg/container/build.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/pkg/container/build.go b/internal/pkg/container/build.go index b2bad80c..7003c1bc 100644 --- a/internal/pkg/container/build.go +++ b/internal/pkg/container/build.go @@ -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 {