diff options
-rw-r--r-- | Rakefile | 18 | ||||
-rw-r--r-- | vagrant/provision/assets/acng.conf | 12 | ||||
-rwxr-xr-x | vagrant/provision/setup-tails-builder | 18 |
3 files changed, 45 insertions, 3 deletions
@@ -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 |