Commit e0adf3b6 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon/chroot: unmount in reverse

parent 8cc3743d
......@@ -72,12 +72,16 @@ func (s *StepMountExtra) Cleanup(state map[string]interface{}) {
config := state["config"].(*Config)
ui := state["ui"].(packer.Ui)
for _, path := range s.mounts {
for i := len(s.mounts) - 1; i >= 0; i-- {
path := s.mounts[i]
unmountCommand := fmt.Sprintf("%s %s", config.UnmountCommand, path)
stderr := new(bytes.Buffer)
cmd := exec.Command("/bin/sh", "-c", unmountCommand)
cmd.Stderr = stderr
if err := cmd.Run(); err != nil {
ui.Error(fmt.Sprintf(
"Error unmounting root device: %s", err))
"Error unmounting device: %s\nStderr: %s", err, stderr.String()))
return
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment