diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 0b336c64e..59b2fbed1 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -403,7 +403,9 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &StepMountExtra{ ChrootMounts: b.config.ChrootMounts, }, - &StepCopyFiles{}, + &StepCopyFiles{ + Files: b.config.CopyFiles, + }, &StepChrootProvision{}, &StepEarlyCleanup{}, &StepSnapshot{}, diff --git a/builder/amazon/chroot/step_copy_files.go b/builder/amazon/chroot/step_copy_files.go index 78625a8d3..af5766386 100644 --- a/builder/amazon/chroot/step_copy_files.go +++ b/builder/amazon/chroot/step_copy_files.go @@ -17,20 +17,20 @@ import ( // copy_files_cleanup CleanupFunc - A function to clean up the copied files // early. type StepCopyFiles struct { + Files []string files []string } func (s *StepCopyFiles) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packer.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) stderr := new(bytes.Buffer) - s.files = make([]string, 0, len(config.CopyFiles)) - if len(config.CopyFiles) > 0 { + s.files = make([]string, 0, len(s.Files)) + if len(s.Files) > 0 { ui.Say("Copying files from host to chroot...") - for _, path := range config.CopyFiles { + for _, path := range s.Files { ui.Message(path) chrootPath := filepath.Join(mountPath, path) log.Printf("Copying '%s' to '%s'", path, chrootPath) diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index 24a128ce2..37f486c0e 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -30,6 +30,7 @@ type Config struct { MountPath string `mapstructure:"mount_path"` PostMountCommands []string `mapstructure:"post_mount_commands"` ChrootMounts [][]string `mapstructure:"chroot_mounts"` + CopyFiles []string `mapstructure:"copy_files"` OSDiskSizeGB int32 `mapstructure:"osdisk_size_gb"` OSDiskStorageAccountType string `mapstructure:"osdisk_storageaccounttype"` @@ -160,6 +161,10 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &chroot.StepMountExtra{ ChrootMounts: b.config.ChrootMounts, }, + &chroot.StepCopyFiles{ + Files: b.config.CopyFiles, + }, + &chroot.StepChrootProvision{}, ) // Run!