Commit b11b2739 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

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

parent 38a41867
...@@ -4,6 +4,7 @@ BUG FIXES: ...@@ -4,6 +4,7 @@ BUG FIXES:
* amazon-ebs: Sleep between checking instance state to avoid * amazon-ebs: Sleep between checking instance state to avoid
RequestLimitExceeded [GH-50] RequestLimitExceeded [GH-50]
* vagrant: Rename VirtualBox ovf to "box.ovf" [GH-64]
## 0.1.1 (June 28, 2013) ## 0.1.1 (June 28, 2013)
......
...@@ -111,6 +111,12 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac ...@@ -111,6 +111,12 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac
return nil, err 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 // Compress the directory to the given output path
ui.Message(fmt.Sprintf("Compressing box...")) ui.Message(fmt.Sprintf("Compressing box..."))
if err := DirToBox(outputPath, dir); err != nil { if err := DirToBox(outputPath, dir); err != nil {
...@@ -156,6 +162,21 @@ func (p *VBoxBoxPostProcessor) findBaseMacAddress(a packer.Artifact) (string, er ...@@ -156,6 +162,21 @@ func (p *VBoxBoxPostProcessor) findBaseMacAddress(a packer.Artifact) (string, er
return string(matches[1]), nil 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 = ` var defaultVBoxVagrantfile = `
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.base_mac = "{{ .BaseMacAddress }}" config.vm.base_mac = "{{ .BaseMacAddress }}"
......
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