Commit 9129a588 authored by Tails developers's avatar Tails developers

Merge remote-tracking branch 'davidiw/bugfix' into stable

parents 08334183 0a3db54f
...@@ -25,6 +25,7 @@ require 'uri' ...@@ -25,6 +25,7 @@ require 'uri'
$:.unshift File.expand_path('../vagrant/lib', __FILE__) $:.unshift File.expand_path('../vagrant/lib', __FILE__)
require 'tails_build_settings' require 'tails_build_settings'
require 'vagrant_version'
# Path to the directory which holds our Vagrantfile # Path to the directory which holds our Vagrantfile
VAGRANT_PATH = File.expand_path('../vagrant', __FILE__) VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
...@@ -41,23 +42,40 @@ EXTERNAL_HTTP_PROXY = ENV['http_proxy'] ...@@ -41,23 +42,40 @@ EXTERNAL_HTTP_PROXY = ENV['http_proxy']
# In-VM proxy URL # In-VM proxy URL
INTERNEL_HTTP_PROXY = "http://#{VIRTUAL_MACHINE_HOSTNAME}:3142" INTERNEL_HTTP_PROXY = "http://#{VIRTUAL_MACHINE_HOSTNAME}:3142"
def current_vm_memory def primary_vm
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic) env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
uuid = env.primary_vm.uuid if vagrant_old
info = env.primary_vm.driver.execute 'showvminfo', uuid, '--machinereadable' return env.primary_vm
else
name = env.primary_machine_name
return env.machine(name, env.default_provider)
end
end
def primary_vm_state
if vagrant_old
return primary_vm.state
else
return primary_vm.state.id
end
end
def current_vm_memory
vm = primary_vm
uuid = vm.uuid
info = vm.driver.execute 'showvminfo', uuid, '--machinereadable'
$1.to_i if info =~ /^memory=(\d+)/ $1.to_i if info =~ /^memory=(\d+)/
end end
def current_vm_cpus def current_vm_cpus
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic) vm = primary_vm
uuid = env.primary_vm.uuid uuid = vm.uuid
info = env.primary_vm.driver.execute 'showvminfo', uuid, '--machinereadable' info = vm.driver.execute 'showvminfo', uuid, '--machinereadable'
$1.to_i if info =~ /^cpus=(\d+)/ $1.to_i if info =~ /^cpus=(\d+)/
end end
def vm_running? def vm_running?
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic) primary_vm_state == :running
env.primary_vm.state == :running
end end
def enough_free_memory? def enough_free_memory?
...@@ -197,9 +215,12 @@ desc 'Build Tails' ...@@ -197,9 +215,12 @@ desc 'Build Tails'
task :build => ['parse_build_options', 'ensure_clean_repository', 'validate_http_proxy', 'vm:up'] do task :build => ['parse_build_options', 'ensure_clean_repository', 'validate_http_proxy', 'vm:up'] do
exported_env = EXPORTED_VARIABLES.select { |k| ENV[k] }. exported_env = EXPORTED_VARIABLES.select { |k| ENV[k] }.
collect { |k| "#{k}='#{ENV[k]}'" }.join(' ') collect { |k| "#{k}='#{ENV[k]}'" }.join(' ')
if vagrant_old
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH) chan = primary_vm.channel
status = env.primary_vm.channel.execute("#{exported_env} build-tails", else
chan = primary_vm.communicate
end
status = chan.execute("#{exported_env} build-tails",
:error_check => false) do |fd, data| :error_check => false) do |fd, data|
(fd == :stdout ? $stdout : $stderr).write data (fd == :stdout ? $stdout : $stderr).write data
end end
...@@ -214,8 +235,7 @@ end ...@@ -214,8 +235,7 @@ end
namespace :vm do namespace :vm do
desc 'Start the build virtual machine' desc 'Start the build virtual machine'
task :up => ['parse_build_options', 'validate_http_proxy'] do task :up => ['parse_build_options', 'validate_http_proxy'] do
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic) case primary_vm_state
case env.primary_vm.state
when :not_created when :not_created
# Do not use non-existant in-VM proxy to download the basebox # Do not use non-existant in-VM proxy to download the basebox
if ENV['http_proxy'] == INTERNEL_HTTP_PROXY if ENV['http_proxy'] == INTERNEL_HTTP_PROXY
...@@ -268,6 +288,7 @@ namespace :vm do ...@@ -268,6 +288,7 @@ namespace :vm do
abort 'The virtual machine needs to be reloaded to change the number of CPUs. Aborting.' abort 'The virtual machine needs to be reloaded to change the number of CPUs. Aborting.'
end end
end end
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
result = env.cli('up') result = env.cli('up')
abort "'vagrant up' failed" unless result abort "'vagrant up' failed" unless result
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# vi: set ft=ruby : # vi: set ft=ruby :
# #
# Tails: The Amnesic Incognito Live System # Tails: The Amnesic Incognito Live System
# Copyright © 2012 Tails developers <[email protected]>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
...@@ -19,6 +18,7 @@ ...@@ -19,6 +18,7 @@
# Monkey-patched Vagrant! # Monkey-patched Vagrant!
$:.unshift File.expand_path('../lib', __FILE__) $:.unshift File.expand_path('../lib', __FILE__)
require 'vagrant_version'
require 'vagrant_verified_download' require 'vagrant_verified_download'
require 'tails_build_settings' require 'tails_build_settings'
...@@ -30,16 +30,31 @@ end ...@@ -30,16 +30,31 @@ end
cpus = ENV['TAILS_BUILD_CPUS'] cpus = ENV['TAILS_BUILD_CPUS']
Vagrant::Config.run do |config| if vagrant_old
config.vm.box = 'tails' Vagrant::Config.run do |config|
config.vm.box = 'tails'
config.vm.box_url = 'http://dl.amnesia.boum.org/tails/project/vagrant/squeeze.box'
config.vm.box_url = 'http://dl.amnesia.boum.org/tails/project/vagrant/squeeze.box' config.vm.provision :shell, :inline => "http_proxy='#{ENV['http_proxy']}' /vagrant/provision/setup-tails-builder"
config.vm.box_checksum = '8951d257fc4751437812477df81d55670ebcc0b57c525c248cf2284a89540ca3'
config.vm.provision :shell, :inline => "http_proxy='#{ENV['http_proxy']}' /vagrant/provision/setup-tails-builder" config.vm.share_folder 'amnesia', '/amnesia.git', '../.git'
config.vm.share_folder 'amnesia', '/amnesia.git', '../.git' config.vm.customize ['modifyvm', :id, '--memory', mem_size]
config.vm.customize ['modifyvm', :id, '--cpus', cpus] unless cpus.nil?
end
else
Vagrant.configure("2") do |config|
config.vm.box = 'tails'
config.vm.box_url = 'http://dl.amnesia.boum.org/tails/project/vagrant/squeeze.box'
config.vm.provision "shell",
inline: "sudo http_proxy='#{ENV['http_proxy']}' /vagrant/provision/setup-tails-builder"
config.vm.synced_folder '../.git', '/amnesia.git'
config.vm.customize ['modifyvm', :id, '--memory', mem_size] config.vm.provider :virtualbox do |vb|
config.vm.customize ['modifyvm', :id, '--cpus', cpus] unless cpus.nil? vb.customize ['modifyvm', :id, '--memory', mem_size]
vb.customize ['modifyvm', :id, '--cpus', cpus] unless cpus.nil?
end
end
end end
...@@ -6,9 +6,9 @@ d-i console-keymaps-at/keymap select us ...@@ -6,9 +6,9 @@ d-i console-keymaps-at/keymap select us
d-i netcfg/choose_interface select auto d-i netcfg/choose_interface select auto
d-i netcfg/get_domain string vagrantup.com d-i netcfg/get_domain string vagrantup.com
# Use cdn.debian.net to select closest mirror # Use http.debian.net to select closest mirror
d-i mirror/country string manual d-i mirror/country string manual
d-i mirror/http/hostname string cdn.debian.net d-i mirror/http/hostname string http.debian.net
d-i mirror/http/directory string /debian d-i mirror/http/directory string /debian
d-i mirror/http/proxy string <%= ENV['http_proxy'] %> d-i mirror/http/proxy string <%= ENV['http_proxy'] %>
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# -*- mode: ruby -*- # -*- mode: ruby -*-
# vi: set ft=ruby : # vi: set ft=ruby :
#
# Tails: The Amnesic Incognito Live System
# Copyright © 2012 Tails developers <[email protected]>
#
# 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/>.
# Hostname of the virtual machine (must be in /etc/hosts) # Hostname of the virtual machine (must be in /etc/hosts)
VIRTUAL_MACHINE_HOSTNAME = 'squeeze.vagrantup.com' VIRTUAL_MACHINE_HOSTNAME = 'squeeze.vagrantup.com'
...@@ -26,3 +10,6 @@ VM_MEMORY_FOR_RAM_BUILDS = 6 * 1024 + 512 # 6.5 GB ...@@ -26,3 +10,6 @@ VM_MEMORY_FOR_RAM_BUILDS = 6 * 1024 + 512 # 6.5 GB
# Virtual machine memory size for on-disk builds # Virtual machine memory size for on-disk builds
VM_MEMORY_FOR_DISK_BUILDS = 1024 # 1 GB VM_MEMORY_FOR_DISK_BUILDS = 1024 # 1 GB
# Checksum for BOX
BOX_CHECKSUM = '8951d257fc4751437812477df81d55670ebcc0b57c525c248cf2284a89540ca3'
# Tails: The Amnesic Incognito Live System
# Copyright © 2012 Tails developers <[email protected]>
#
# 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 'digest' require 'digest'
require 'vagrant/util/downloader'
require 'vagrant/errors'
# The following will monkeypatch Vagrant (successfuly tested against Vagrant def check(path)
# 1.0.2) in order to verify the checksum of a downloaded box. checksum = Digest::SHA256.new.file(path).hexdigest
module Vagrant if checksum != BOX_CHECKSUM
class Config::VMConfig raise Vagrant::Errors::BoxVerificationFailed.new
attr_accessor :box_checksum
end end
end
class Action::Box::Download module Vagrant
alias :unverified_download :download if vagrant_old
def download class Action::Box::Download
unverified_download alias :unverified_download :download
def download
checksum = Digest::SHA256.new.file(@temp_path).hexdigest unverified_download
if checksum != @env['global_config'].vm.box_checksum check(@temp_path)
raise Errors::BoxVerificationFailed.new end
end
else
class Util::Downloader
alias :unverified_download! :download!
def download!
unverified_download!
check(@destination)
end end
end end
end end
......
require 'vagrant/version'
def vagrant_old
version = Vagrant::VERSION.split(".")
return version[1].to_i < 2
end
...@@ -18,7 +18,7 @@ if [ -d /home/vagrant/ikiwiki ]; then ...@@ -18,7 +18,7 @@ if [ -d /home/vagrant/ikiwiki ]; then
fi fi
# Add unstable repository for ikiwiki, and pin it low # Add unstable repository for ikiwiki, and pin it low
echo 'deb http://cdn.debian.net/debian unstable main' > /etc/apt/sources.list.d/unstable.list echo 'deb http://http.debian.net/debian unstable main' > /etc/apt/sources.list.d/unstable.list
sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/unstable <<EOF sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/unstable <<EOF
Package: * Package: *
Pin: release a=unstable Pin: release a=unstable
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment