From faf6eb1c6772378bb55cc447f3fffea468f8387e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 19 Aug 2013 22:38:32 -0700 Subject: [PATCH] post-processor/vagrant: show file being compressed [GH-314] --- CHANGELOG.md | 3 +++ post-processor/vagrant/aws.go | 2 +- post-processor/vagrant/util.go | 8 +++++++- post-processor/vagrant/virtualbox.go | 2 +- post-processor/vagrant/vmware.go | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47995620..163408e4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## 0.3.4 (unreleased) +IMPROVEMENTS: +* post-processor/vagrant: the file being compressed will be shown + in the UI [GH-314] ## 0.3.3 (August 19, 2013) diff --git a/post-processor/vagrant/aws.go b/post-processor/vagrant/aws.go index 92a55a5ff..6915fa5fe 100644 --- a/post-processor/vagrant/aws.go +++ b/post-processor/vagrant/aws.go @@ -134,7 +134,7 @@ func (p *AWSBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact } // Compress the directory to the given output path - if err := DirToBox(outputPath, dir); err != nil { + if err := DirToBox(outputPath, dir, ui); err != nil { err = fmt.Errorf("error creating box: %s", err) return nil, false, err } diff --git a/post-processor/vagrant/util.go b/post-processor/vagrant/util.go index 72cf83a5e..86742abe5 100644 --- a/post-processor/vagrant/util.go +++ b/post-processor/vagrant/util.go @@ -4,6 +4,8 @@ import ( "archive/tar" "compress/gzip" "encoding/json" + "fmt" + "github.com/mitchellh/packer/packer" "io" "log" "os" @@ -42,7 +44,7 @@ func CopyContents(dst, src string) error { // DirToBox takes the directory and compresses it into a Vagrant-compatible // box. This function does not perform checks to verify that dir is // actually a proper box. This is an expected precondition. -func DirToBox(dst, dir string) error { +func DirToBox(dst, dir string, ui packer.Ui) error { log.Printf("Turning dir into box: %s => %s", dir, dst) dstF, err := os.Create(dst) if err != nil { @@ -90,6 +92,10 @@ func DirToBox(dst, dir string) error { return err } + if ui != nil { + ui.Message(fmt.Sprintf("Compressing: %s", header.Name)) + } + if err := tarWriter.WriteHeader(header); err != nil { return err } diff --git a/post-processor/vagrant/virtualbox.go b/post-processor/vagrant/virtualbox.go index 521de7173..3eab82175 100644 --- a/post-processor/vagrant/virtualbox.go +++ b/post-processor/vagrant/virtualbox.go @@ -143,7 +143,7 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac // Compress the directory to the given output path ui.Message(fmt.Sprintf("Compressing box...")) - if err := DirToBox(outputPath, dir); err != nil { + if err := DirToBox(outputPath, dir, ui); err != nil { return nil, false, err } diff --git a/post-processor/vagrant/vmware.go b/post-processor/vagrant/vmware.go index 3a18624e5..7d04ac991 100644 --- a/post-processor/vagrant/vmware.go +++ b/post-processor/vagrant/vmware.go @@ -119,7 +119,7 @@ func (p *VMwareBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artif // Compress the directory to the given output path ui.Message(fmt.Sprintf("Compressing box...")) - if err := DirToBox(outputPath, dir); err != nil { + if err := DirToBox(outputPath, dir, ui); err != nil { return nil, false, err }