From 98b8d858c4fcb124ed569882d2f1e96f1d49670f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 10 Dec 2011 21:49:00 -0800 Subject: [PATCH] Error message for improperly packaged boxes [GH-198] --- CHANGELOG.md | 1 + lib/vagrant/action/box/unpackage.rb | 6 +++++- lib/vagrant/errors.rb | 5 +++++ templates/locales/en.yml | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f07788846..d08755bcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ power off the system. [GH-575] - Tweaks to SSH to hopefully be more reliable in coming up. - Helpful error message when SCP is unavailable in the guest. [GH-568] + - Error message for improperly packaged box files. [GH-198] ## 0.8.10 (December 10, 2011) diff --git a/lib/vagrant/action/box/unpackage.rb b/lib/vagrant/action/box/unpackage.rb index 0f2f3ebd8..02dad75c6 100644 --- a/lib/vagrant/action/box/unpackage.rb +++ b/lib/vagrant/action/box/unpackage.rb @@ -48,7 +48,11 @@ module Vagrant def decompress Dir.chdir(@env["box_directory"]) do @env[:ui].info I18n.t("vagrant.actions.box.unpackage.extracting") - Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box_directory"].to_s) + begin + Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box_directory"].to_s) + rescue SystemCallError + raise Errors::BoxUnpackageFailure + end end end end diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 1a9b12170..07d8eabc5 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -118,6 +118,11 @@ module Vagrant error_key(:does_not_exist, "vagrant.actions.vm.check_box") end + class BoxUnpackageFailure < VagrantError + status_code(57) + error_key(:untar_failure, "vagrant.actions.box.unpackage") + end + class BoxVerificationFailed < VagrantError status_code(15) error_key(:failed, "vagrant.actions.box.verify") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index c4c432632..1ecc8afe9 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -432,6 +432,10 @@ en: A box already exists under the name of '%{name}'. This may or may not be the same box you are trying to add. Please use another name or remove the previous box then try to add it again. + untar_failure: |- + Failed to untar the box file. This is usually because you're + attempting to add a box that isn't a valid box file. Please + double check that the box file is properly packaged. verify: verifying: "Verifying box..." failed: |-