From 7f391a94aad3a6c6ae6e005a353ce0d6266aee1d Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 15 Sep 2016 23:16:21 +0300 Subject: [PATCH] unbreak glob pattern in floppy_files Signed-off-by: Vasiliy Tolstov --- common/floppy_config.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/common/floppy_config.go b/common/floppy_config.go index 3914bbd06..5a68816ed 100644 --- a/common/floppy_config.go +++ b/common/floppy_config.go @@ -3,6 +3,8 @@ package common import ( "fmt" "os" + "path/filepath" + "strings" "github.com/mitchellh/packer/template/interpolate" ) @@ -14,13 +16,19 @@ type FloppyConfig struct { func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error { var errs []error + var err error if c.FloppyFiles == nil { c.FloppyFiles = make([]string, 0) } for _, path := range c.FloppyFiles { - if _, err := os.Stat(path); err != nil { + if strings.IndexAny(path, "*?[") >= 0 { + _, err = filepath.Glob(path) + } else { + _, err = os.Stat(path) + } + if err != nil { errs = append(errs, fmt.Errorf("Bad Floppy disk file '%s': %s", path, err)) } } @@ -30,7 +38,12 @@ func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error { } for _, path := range c.FloppyDirectories { - if _, err := os.Stat(path); err != nil { + if strings.IndexAny(path, "*?[") >= 0 { + _, err = filepath.Glob(path) + } else { + _, err = os.Stat(path) + } + if err != nil { errs = append(errs, fmt.Errorf("Bad Floppy disk directory '%s': %s", path, err)) } }