summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-05-14 20:56:59 +0200
committerTails developers <amnesia@boum.org>2012-05-16 13:30:41 +0200
commitf7652e5671ee43a6c32461ae06b9d1b8be06c916 (patch)
treec183c1d5e5c3c0658e8a703eab2a86441cb31131
parent55c016f2c7907f9865043bf6bc681c16df50cdbe (diff)
vagrant: Add suport for HTTP proxy build settings
We support three options: external proxy, a proxy inside the virtual machine and no proxy at all. The first and the last are both trivial to implement. For the in-VM proxy, we install and configure apt-cacher-ng during provisioning. We do that all the time to support different proxy options once the VM is started. The custom apt-cacher-ng configuration is required to support downloads of `.o` and `.tar.bz2` files by the firmware installers.
-rw-r--r--Rakefile18
-rw-r--r--vagrant/provision/assets/acng.conf12
-rwxr-xr-xvagrant/provision/setup-tails-builder18
3 files changed, 45 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index 204b5e3..ba15ffd 100644
--- a/Rakefile
+++ b/Rakefile
@@ -27,10 +27,24 @@ VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
# Environment variables that will be exported to the build script
EXPORTED_VARIABLES = ['http_proxy', 'MKSQUASHFS_OPTIONS']
+# Let's save the http_proxy set before playing with it
+EXTERNAL_HTTP_PROXY = ENV['http_proxy']
+
+# Hostname of the virtual machine (must be in /etc/hosts)
+VIRTUAL_MACHINE_HOSTNAME = 'squeeze.vagrantup.com'
+
task :parse_build_options do
options = ENV['TAILS_BUILD_OPTIONS'] || ''
options.split(' ').each do |opt|
case opt
+ # HTTP proxy settings
+ when 'extproxy'
+ abort "No HTTP proxy set, but one is required by TAILS_BUILD_OPTIONS. Aborting." unless EXTERNAL_HTTP_PROXY
+ ENV['http_proxy'] = EXTERNAL_HTTP_PROXY
+ when 'vmproxy'
+ ENV['http_proxy'] = "http://#{VIRTUAL_MACHINE_HOSTNAME}:3142"
+ when 'noproxy'
+ ENV['http_proxy'] = nil
# SquashFS compression settings
when 'gzipcomp'
ENV['MKSQUASHFS_OPTIONS'] = '-comp gzip'
@@ -75,7 +89,7 @@ end
namespace :vm do
desc 'Start the build virtual machine'
- task :up => '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 env.primary_vm.state
when :not_created
@@ -113,7 +127,7 @@ namespace :vm do
end
desc 'Re-run virtual machine setup'
- task :provision => 'validate_http_proxy' do
+ task :provision => ['parse_build_options', 'validate_http_proxy'] do
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
result = env.cli('provision')
abort "'vagrant provision' failed" unless result
diff --git a/vagrant/provision/assets/acng.conf b/vagrant/provision/assets/acng.conf
new file mode 100644
index 0000000..f627bd4
--- /dev/null
+++ b/vagrant/provision/assets/acng.conf
@@ -0,0 +1,12 @@
+CacheDir: /var/cache/apt-cacher-ng
+LogDir: /var/log/apt-cacher-ng
+Port:3142
+Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
+Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
+Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol
+Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin # incomplete, please create this file
+ReportPage: acng-report.html
+ExTreshold: 4
+VfilePattern = (^|.*?/)(Index|Packages(\.gz|\.bz2|\.lzma|\.xz)?|InRelease|Release|Release\.gpg|Sources(\.gz|\.bz2|\.lzma|\.xz)?|release|index\.db-.*\.gz|Contents-[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|((setup|setup-legacy)(\.ini|\.bz2|\.hint)(\.sig)?)|mirrors\.lst|repo(index|md)\.xml(\.asc|\.key)?|directory\.yast|products|content(\.asc|\.key)?|media|filelists\.xml\.gz|filelists\.sqlite\.bz2|repomd\.xml|packages\.[a-zA-Z][a-zA-Z]\.gz|info\.txt|license\.tar\.gz|license\.zip|.*\.db(\.tar\.gz)?|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|metalink\?repo|.*prestodelta\.xml\.gz)$|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*
+PfilePattern = .*(\.d?deb|\.rpm|\.dsc|\.tar(\.gz|\.bz2|\.lzma|\.xz)(\.gpg)?|\.diff(\.gz|\.bz2|\.lzma|\.xz)|\.o|\.jigdo|\.template|changelog|copyright|\.udeb|\.debdelta|\.diff/.*\.gz|(Devel)?ReleaseAnnouncement(\?.*)?|[a-f0-9]+-(susedata|updateinfo|primary|deltainfo).xml.gz|fonts/(final/)?[a-z]+32.exe(\?download.*)?|/dists/.*/installer-[^/]+/[0-9][^/]+/images/.*)$
+WfilePattern = (^|.*?/)(Release|InRelease|Release\.gpg|(Packages|Sources)(\.gz|\.bz2|\.lzma|\.xz)?|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|.*\.xml|.*\.db\.tar\.gz|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|[a-z]+32.exe)$|/dists/.*/installer-.*/images/.*
diff --git a/vagrant/provision/setup-tails-builder b/vagrant/provision/setup-tails-builder
index bbc7f93..1799c22 100755
--- a/vagrant/provision/setup-tails-builder
+++ b/vagrant/provision/setup-tails-builder
@@ -2,8 +2,24 @@
set -e
-# Refresh packages lists
+# Do not use virtual machine proxy before apt-cacher-ng is installed
+if [ "$http_proxy" = "http://$(hostname -f):3142" ] &&
+ ! [ -f /etc/apt-cacher-ng/acng.conf ]; then
+ LOCAL_HTTP_PROXY="$http_proxy"
+ http_proxy=''
+fi
+
apt-get update
+apt-get -y install apt-cacher-ng
+
+# Install custom configuration for apt-cacher-ng and restart
+sudo cp /vagrant/provision/assets/acng.conf /etc/apt-cacher-ng/acng.conf
+service apt-cacher-ng restart
+
+# Restore local HTTP proxy if needed
+if [ "$LOCAL_HTTP_PROXY" ]; then
+ http_proxy="$LOCAL_HTTP_PROXY"
+fi
# Upgrade if needed
apt-get -y dist-upgrade