@ -1,8 +1,6 @@
package shell_local
import (
"runtime"
sl "github.com/hashicorp/packer/common/shell-local"
"github.com/hashicorp/packer/packer"
)
@ -21,20 +19,16 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
if err != nil {
return err
}
if len ( p . config . ExecuteCommand ) == 0 && runtime . GOOS != "windows" {
// Backwards compatibility from before post-processor merge with
// provisioner. Don't need to default separately for windows becuase the
// post-processor never worked for windows before the merge with the
// provisioner code, so the provisioner defaults are fine.
p . config . ExecuteCommand = [ ] string { "sh" , "-c" , ` chmod +x " {{ .Script }} "; {{ .Vars }} " {{ .Script }} " ` }
} else if len ( p . config . ExecuteCommand ) == 1 {
// Backwards compatibility -- before merge, post-processor didn't have
// configurable call to shell program, meaning users may not have
// defined this in their call. If users are still using the old way of
// defining ExecuteCommand (e.g. just supplying a single string that is
// now being interpolated as a slice with one item), then assume we need
// to prepend this call still, and use the one that the post-processor
// defaulted to before.
if len ( p . config . ExecuteCommand ) == 1 {
// Backwards compatibility -- before we merged the shell-local
// post-processor and provisioners, the post-processor accepted
// execute_command as a string rather than a slice of strings. It didn't
// have a configurable call to shell program, automatically prepending
// the user-supplied execute_command string with "sh -c". If users are
// still using the old way of defining ExecuteCommand (by supplying a
// single string rather than a slice of strings) then we need to
// prepend this command with the call that the post-processor defaulted
// to before.
p . config . ExecuteCommand = append ( [ ] string { "sh" , "-c" } , p . config . ExecuteCommand ... )
}