2013-07-31 01:25:33 -04:00
|
|
|
package chroot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2018-01-19 19:18:44 -05:00
|
|
|
"log"
|
2013-07-31 01:25:33 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// StepEarlyUnflock unlocks the flock.
|
|
|
|
type StepEarlyUnflock struct{}
|
|
|
|
|
2018-01-22 18:31:41 -05:00
|
|
|
func (s *StepEarlyUnflock) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
2013-08-31 15:58:55 -04:00
|
|
|
cleanup := state.Get("flock_cleanup").(Cleanup)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
2013-07-31 01:25:33 -04:00
|
|
|
|
|
|
|
log.Println("Unlocking file lock...")
|
|
|
|
if err := cleanup.CleanupFunc(state); err != nil {
|
|
|
|
err := fmt.Errorf("Error unlocking file lock: %s", err)
|
2013-08-31 15:58:55 -04:00
|
|
|
state.Put("error", err)
|
2013-07-31 01:25:33 -04:00
|
|
|
ui.Error(err.Error())
|
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2013-08-31 15:58:55 -04:00
|
|
|
func (s *StepEarlyUnflock) Cleanup(state multistep.StateBag) {}
|