Merge pull request #3890 from yoctocloud/floppy

unbreak glob pattern in floppy_files
This commit is contained in:
Rickard von Essen 2016-11-21 20:56:38 +01:00 committed by GitHub
commit b8c09fd2a1
8 changed files with 32 additions and 16 deletions

View File

@ -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))
}
}

View File

@ -118,7 +118,7 @@ builder.
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
- `guest_os_type` (string) - The guest OS type being installed. By default

View File

@ -79,17 +79,20 @@ builder.
five seconds and one minute 30 seconds, respectively. If this isn't
specified, the default is 10 seconds.
- `floppy_files` (array of strings) - A list of files to put onto a floppy
disk that is attached when the VM is booted for the first time. This is most
useful for unattended Windows installs, which look for an `Autounattend.xml`
file on removable media. By default no floppy will be attached. The files
listed in this configuration will all be put into the root directory of the
floppy disk; sub-directories are not supported.
- `floppy_files` (array of strings) - A list of files to place onto a floppy
disk that is attached when the VM is booted. This is most useful for
unattended Windows installs, which look for an `Autounattend.xml` file on
removable media. By default, no floppy will be attached. All files listed in
this setting get placed into the root directory of the floppy and the floppy
is attached as the first floppy device. Currently, no support exists for
creating sub-directories on the floppy. Wildcard characters (\*, ?,
and \[\]) are allowed. Directory names are also allowed, which will add all
the files found in the directory to the floppy.
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
- `output_directory` (string) - This is the path to the directory where the

View File

@ -167,7 +167,7 @@ Linux server and have not enabled X11 forwarding (`ssh -X`).
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
- `format` (string) - Either "qcow2" or "raw", this specifies the output

View File

@ -153,7 +153,7 @@ builder.
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize its
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
- `format` (string) - Either "ovf" or "ova", this specifies the output format

View File

@ -135,7 +135,7 @@ builder.
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
- `format` (string) - Either "ovf" or "ova", this specifies the output format

View File

@ -128,7 +128,7 @@ builder.
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
- `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is

View File

@ -86,7 +86,7 @@ builder.
- `floppy_dirs` (array of strings) - A list of directories to place onto
the floppy disk recursively. This is similar to the `floppy_files` option
except that the directory structure is preserved. This is useful for when
your floppy disk includes drivers or if you just want to organize it's
your floppy disk includes drivers or if you just want to organize it's
contents as a hierarchy. Wildcard characters (\*, ?, and \[\]) are allowed.
- `fusion_app_path` (string) - Path to "VMware Fusion.app". By default this is
@ -259,4 +259,4 @@ Ubuntu 12.04 installer:
"keyboard-configuration/variant=USA console-setup/ask_detect=false ",
"initrd=/install/initrd.gz -- <enter>"
]
```
```