summaryrefslogtreecommitdiffstats
path: root/vagrant/lib
diff options
context:
space:
mode:
authorDavid Isaac Wolinsky <isaac.wolinsky@gmail.com>2013-12-09 23:13:39 -0500
committerTails developers <amnesia@boum.org>2013-12-21 12:16:25 +0000
commit3d093c8e481a244320a74781ea12e57cedbd9d8c (patch)
treee008f8168e0d58c93d3b07e26964537fb671f1e1 /vagrant/lib
parent4d81fa4d9890fd89ebfed9bbd26873ebbd22c17d (diff)
fixes for vagrant v2 (1.3.5) - Version tested via vagrant_version: vagrant_old - Moved the box checksum as a define since the newer vagrant doesn't pass the env to the downloader - Added the insertion of the Debian keys because it was failing to build otherwise
Diffstat (limited to 'vagrant/lib')
-rw-r--r--vagrant/lib/tails_build_settings.rb3
-rw-r--r--vagrant/lib/vagrant_verified_download.rb34
-rw-r--r--vagrant/lib/vagrant_version.rb22
3 files changed, 46 insertions, 13 deletions
diff --git a/vagrant/lib/tails_build_settings.rb b/vagrant/lib/tails_build_settings.rb
index e2e48ea..8e88030 100644
--- a/vagrant/lib/tails_build_settings.rb
+++ b/vagrant/lib/tails_build_settings.rb
@@ -26,3 +26,6 @@ VM_MEMORY_FOR_RAM_BUILDS = 6 * 1024 + 512 # 6.5 GB
# Virtual machine memory size for on-disk builds
VM_MEMORY_FOR_DISK_BUILDS = 1024 # 1 GB
+
+# Checksum for BOX
+BOX_CHECKSUM = 'ffb3f68f55a3458e007b9abed3eac057f71c518713fcdf982b78f8b59e28318e'
diff --git a/vagrant/lib/vagrant_verified_download.rb b/vagrant/lib/vagrant_verified_download.rb
index 976aa47..994142a 100644
--- a/vagrant/lib/vagrant_verified_download.rb
+++ b/vagrant/lib/vagrant_verified_download.rb
@@ -15,22 +15,30 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'digest'
+require 'vagrant/util/downloader'
-# The following will monkeypatch Vagrant (successfuly tested against Vagrant
-# 1.0.2) in order to verify the checksum of a downloaded box.
-module Vagrant
- class Config::VMConfig
- attr_accessor :box_checksum
+def check(path)
+ checksum = Digest::SHA256.new.file(path).hexdigest
+ if checksum != BOX_CHECKSUM
+ raise Errors::BoxVerificationFailed.new
end
+end
- class Action::Box::Download
- alias :unverified_download :download
- def download
- unverified_download
-
- checksum = Digest::SHA256.new.file(@temp_path).hexdigest
- if checksum != @env['global_config'].vm.box_checksum
- raise Errors::BoxVerificationFailed.new
+module Vagrant
+ if vagrant_old
+ class Action::Box::Download
+ alias :unverified_download :download
+ def download
+ unverified_download
+ check(@temp_path)
+ end
+ end
+ else
+ class Util::Downloader
+ alias :unverified_download! :download!
+ def download!
+ unverified_download!
+ check(@destination)
end
end
end
diff --git a/vagrant/lib/vagrant_version.rb b/vagrant/lib/vagrant_version.rb
new file mode 100644
index 0000000..655e309
--- /dev/null
+++ b/vagrant/lib/vagrant_version.rb
@@ -0,0 +1,22 @@
+# Tails: The Amnesic Incognito Live System
+# Copyright © 2012 Tails developers <tails@boum.org>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+require 'vagrant/version'
+
+def vagrant_old
+ version = Vagrant::VERSION.split(".")
+ return version[1].to_i < 3
+end