setup-tails-builder 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/bin/sh
  2. set -e
  3. export DEBIAN_FRONTEND=noninteractive
  4. # Do not use virtual machine proxy before apt-cacher-ng is installed
  5. if [ "$http_proxy" = "http://$(hostname -f):3142" ] &&
  6. ! [ -f /etc/apt-cacher-ng/acng.conf ]; then
  7. LOCAL_HTTP_PROXY="$http_proxy"
  8. http_proxy=''
  9. fi
  10. rm -f /etc/apt/preferences.d/* /etc/apt/sources.list.d/*
  11. # Add our builder-jessie repository for live-build, and pin it low
  12. echo 'deb http://deb.tails.boum.org/ builder-jessie main' > /etc/apt/sources.list.d/tails.list
  13. sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/tails <<EOF
  14. Package: *
  15. Pin: origin deb.tails.boum.org
  16. Pin-Priority: 99
  17. EOF
  18. sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/discount <<EOF
  19. Package: discount libmarkdown2 libmarkdown2-dev
  20. Pin: origin deb.tails.boum.org
  21. Pin-Priority: 500
  22. EOF
  23. sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/ikiwiki <<EOF
  24. Package: ikiwiki
  25. Pin: origin deb.tails.boum.org
  26. Pin-Priority: 500
  27. EOF
  28. sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/live-build <<EOF
  29. Package: live-build
  30. Pin: origin deb.tails.boum.org
  31. Pin-Priority: 500
  32. EOF
  33. sed -e 's/^[[:blank:]]*//' > /etc/apt/preferences.d/syslinux-utils <<EOF
  34. Package: syslinux-utils
  35. Pin: origin deb.tails.boum.org
  36. Pin-Priority: 500
  37. EOF
  38. # We don't want to use apt-cacher-ng for gpg
  39. http_proxy="" gpg --keyserver hkps.pool.sks-keyservers.net --recv-key C7988EA7A358D82E
  40. gpg --export C7988EA7A358D82E | sudo apt-key add -
  41. # We need a newer version of debootstrap for saving the list of
  42. # packages used when building Tails (#6297).
  43. echo 'deb http://ftp.us.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list
  44. apt-get update
  45. apt-get -o Dpkg::Options::="--force-confold" -y install apt-cacher-ng
  46. # Install custom configuration for apt-cacher-ng and restart
  47. install -o root -g root -m 644 /vagrant/provision/assets/acng.conf /etc/apt-cacher-ng/acng.conf
  48. service apt-cacher-ng restart
  49. # Restore local HTTP proxy if needed
  50. if [ "$LOCAL_HTTP_PROXY" ]; then
  51. http_proxy="$LOCAL_HTTP_PROXY"
  52. fi
  53. # Upgrade if needed
  54. apt-get -y dist-upgrade
  55. # Those are needed to build Tails
  56. apt-get -y install \
  57. debootstrap/jessie-backports \
  58. dpkg-dev \
  59. eatmydata \
  60. gettext \
  61. git \
  62. ikiwiki \
  63. intltool \
  64. libfile-slurp-perl \
  65. liblist-moreutils-perl \
  66. live-build \
  67. rsync \
  68. syslinux-utils \
  69. time \
  70. whois
  71. # Be sure to get all the modules we need for our Ikiwiki
  72. apt-get -y --no-install-recommends install \
  73. libfile-chdir-perl \
  74. libhtml-scrubber-perl \
  75. libhtml-template-perl \
  76. libtext-multimarkdown-perl \
  77. libtimedate-perl \
  78. liburi-perl libhtml-parser-perl \
  79. libxml-simple-perl \
  80. libyaml-libyaml-perl po4a \
  81. libyaml-perl \
  82. libyaml-syck-perl \
  83. perlmagick \
  84. wdg-html-validator
  85. # Add build script
  86. install -o root -g root -m 755 /vagrant/provision/assets/build-tails /usr/local/bin
  87. disable_live_build_conf()
  88. {
  89. local var="$1"
  90. [ -e /etc/live/build.conf ] || return 0
  91. sed -e "/^[[:space:]]*$var=/d" -i /etc/live/build.conf
  92. }
  93. # Force live-build to use the mirrors configured in auto/config
  94. for prefix in MIRROR PARENT_MIRROR ; do
  95. for target in BOOTSTRAP BINARY CHROOT ; do
  96. for archive in '' BACKPORTS SECURITY UPDATES VOLATILE ; do
  97. if [ -z "$archive" ] ; then
  98. archive_suffix=''
  99. else
  100. archive_suffix="_${archive}"
  101. fi
  102. var="LB_${prefix}_${target}${archive_suffix}"
  103. disable_live_build_conf "$var"
  104. done
  105. done
  106. done
  107. # Clean up
  108. apt-get -y autoremove
  109. apt-get -y clean
  110. perl /usr/lib/apt-cacher-ng/expire-caller.pl || echo "The clean-up of apt-cacher-ng's cache failed: this is not fatal and most likely just means that some disk space could not be reclaimed -- in order to fix that situation you need to manually investigate /var/log/apt-cacher-ng/main_*.html " >&2
  111. # XXX: Remove this once we generate a basebox > 20160226
  112. if grep -q "^AcceptEnv" /etc/ssh/sshd_config; then
  113. sed -i 's/^AcceptEnv/#AcceptEnv/' /etc/ssh/sshd_config
  114. systemctl reload ssh.service
  115. fi