summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Rakefile58
-rw-r--r--vagrant/Vagrantfile12
-rw-r--r--vagrant/definitions/squeeze/postinstall.sh3
-rw-r--r--vagrant/definitions/squeeze/preseed.cfg.erb (renamed from vagrant/definitions/squeeze/preseed.cfg)2
5 files changed, 65 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 48406b4..9169dc7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,6 @@
/.stage
/source
/vagrant/.vagrant
+/vagrant/definitions/squeeze/preseed.cfg
+/vagrant/iso
+/vagrant/squeeze.box
diff --git a/Rakefile b/Rakefile
index ccef996..0f67a9c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -20,9 +20,6 @@
require 'rubygems'
require 'vagrant'
-# Add Vagrant (monkey-)patch
-require 'vagrant/lib/vagrant_verified_download'
-
# Path to the directory which holds our Vagrantfile
VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
@@ -79,3 +76,58 @@ namespace :vm do
abort "'vagrant destroy' failed" unless result
end
end
+
+namespace :basebox do
+ task :create_preseed_cfg do
+ require 'erb'
+ require 'uri'
+
+ if ENV['http_proxy']
+ proxy_host = URI.parse(ENV['http_proxy']).host
+
+ if ['localhost', '[::1]'].include?(proxy_host) || proxy_host.start_with?('127.0.0.')
+ abort 'Using an HTTP proxy listening on the loopback is doomed to fail.'
+ end
+
+ $stderr.puts "Building basebox using HTTP proxy: #{ENV['http_proxy']}"
+ else
+ $stderr.puts "No HTTP proxy set to build basebox"
+ end
+
+ preseed_cfg_path = File.expand_path('../vagrant/definitions/squeeze/preseed.cfg', __FILE__)
+ template = ERB.new(File.read("#{preseed_cfg_path}.erb"))
+ File.open(preseed_cfg_path, 'w') do |f|
+ f.write template.result
+ end
+ end
+
+ desc 'Create virtual machine template (a.k.a. basebox)'
+ task :create_basebox => [:create_preseed_cfg] do
+ # veewee is pretty stupid regarding path handling
+ Dir.chdir(VAGRANT_PATH) do
+ require 'veewee'
+
+ # Veewee assumes a separate process for each task. So we mimic that.
+
+ env = Vagrant::Environment.new(:ui_class => Vagrant::UI::Basic)
+
+ Process.fork do
+ env.cli('basebox', 'build', 'squeeze')
+ end
+ Process.wait
+ abort "Building the basebox failed (exit code: #{$?.exitstatus})." if $?.exitstatus != 0
+
+ Process.fork do
+ env.cli('basebox', 'validate', 'squeeze')
+ end
+ Process.wait
+ abort "Validating the basebox failed (exit code: #{$?.exitstatus})." if $?.exitstatus != 0
+
+ Process.fork do
+ env.cli('basebox', 'export', 'squeeze')
+ end
+ Process.wait
+ abort "Exporting the basebox failed (exit code: #{$?.exitstatus})." if $?.exitstatus != 0
+ end
+ end
+end
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
index b306dbe..30d4c81 100644
--- a/vagrant/Vagrantfile
+++ b/vagrant/Vagrantfile
@@ -17,15 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# As we need a monkey-patched Vagrant, we need to disable direct usage
-if $PROGRAM_NAME.end_with? 'vagrant'
- STDERR.puts <<-END_OF_MESSAGE.gsub(/^ /, '')
- This Vagrantfile is not meant to be used directly with `vagrant`, but
- through `rake`, using the Rakefile that is present in the root of Tails
- repository.
- END_OF_MESSAGE
- exit 1
-end
+# Monkey-patched Vagrant!
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'vagrant_verified_download'
Vagrant::Config.run do |config|
config.vm.box = 'tails'
diff --git a/vagrant/definitions/squeeze/postinstall.sh b/vagrant/definitions/squeeze/postinstall.sh
index d9149f3..e9b8a5a 100644
--- a/vagrant/definitions/squeeze/postinstall.sh
+++ b/vagrant/definitions/squeeze/postinstall.sh
@@ -38,6 +38,9 @@ echo "pre-up sleep 5" >> /etc/network/interfaces
# Clean downloaded APT packages
apt-get clean
+# Remove HTTP proxy configuration
+sed -e '/http::Proxy/d' -i /etc/apt/apt.conf
+
# Zero out the free space to save space in the final image:
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
diff --git a/vagrant/definitions/squeeze/preseed.cfg b/vagrant/definitions/squeeze/preseed.cfg.erb
index 417a56c..47f0c2b 100644
--- a/vagrant/definitions/squeeze/preseed.cfg
+++ b/vagrant/definitions/squeeze/preseed.cfg.erb
@@ -10,7 +10,7 @@ d-i netcfg/get_domain string vagrantup.com
d-i mirror/country string manual
d-i mirror/http/hostname string cdn.debian.net
d-i mirror/http/directory string /debian
-d-i mirror/http/proxy string
+d-i mirror/http/proxy string <%= ENV['http_proxy'] %>
# Set clock to UTC
d-i clock-setup/utc boolean true