From b11b2739a9474f3103f45cff995e4c8f45c047d3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 29 Jun 2013 12:46:05 -0700 Subject: [PATCH] post-processor/vagrant: rename OVF to box.ovf [GH-64] --- CHANGELOG.md | 1 + post-processor/vagrant/virtualbox.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4729df975..83459425b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/post-processor/vagrant/virtualbox.go b/post-processor/vagrant/virtualbox.go index 376fce917..005a05c3e 100644 --- a/post-processor/vagrant/virtualbox.go +++ b/post-processor/vagrant/virtualbox.go @@ -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 }}"