post-processor/vagrant: rename OVF to box.ovf [GH-64]

This commit is contained in:
Mitchell Hashimoto 2013-06-29 12:46:05 -07:00
parent 38a41867a7
commit b11b2739a9
2 changed files with 22 additions and 0 deletions

View File

@ -4,6 +4,7 @@ BUG FIXES:
* amazon-ebs: Sleep between checking instance state to avoid
RequestLimitExceeded [GH-50]
* vagrant: Rename VirtualBox ovf to "box.ovf" [GH-64]
## 0.1.1 (June 28, 2013)

View File

@ -111,6 +111,12 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac
return nil, err
}
// Rename the OVF file to box.ovf, as required by Vagrant
ui.Message("Renaming the OVF to box.ovf...")
if err := p.renameOVF(dir); err != nil {
return nil, err
}
// Compress the directory to the given output path
ui.Message(fmt.Sprintf("Compressing box..."))
if err := DirToBox(outputPath, dir); err != nil {
@ -156,6 +162,21 @@ func (p *VBoxBoxPostProcessor) findBaseMacAddress(a packer.Artifact) (string, er
return string(matches[1]), nil
}
func (p *VBoxBoxPostProcessor) renameOVF(dir string) error {
log.Println("Looking for OVF to rename...")
matches, err := filepath.Glob(filepath.Join(dir, "*.ovf"))
if err != nil {
return err
}
if len(matches) > 1 {
return errors.New("More than one OVF file in VirtualBox artifact.")
}
log.Printf("Renaming: '%s' => box.ovf", matches[0])
return os.Rename(matches[0], filepath.Join(dir, "box.ovf"))
}
var defaultVBoxVagrantfile = `
Vagrant.configure("2") do |config|
config.vm.base_mac = "{{ .BaseMacAddress }}"