config 5.01 KB
Newer Older
amnesia's avatar
amnesia committed
1
#! /bin/sh
2
# automatically run by "lb config"
amnesia's avatar
amnesia committed
3

4 5
set -x

6 7
# we require building from git
if ! git rev-parse --is-inside-work-tree; then
Tails developers's avatar
Typos.  
Tails developers committed
8
    echo "${PWD} is not a Git tree. Exiting."
9 10 11
    exit 1
fi

12 13 14
. config/amnesia
if [ -e config/amnesia.local ] ; then
   . config/amnesia.local
amnesia's avatar
amnesia committed
15 16
fi

intrigeri's avatar
intrigeri committed
17 18
export LB_BOOTSTRAP_INCLUDE='eatmydata'

19 20
# sanity checks
if grep -qs -E '^Pin:\s+release\s+.*a=' config/chroot_apt/preferences ; then
anonym's avatar
anonym committed
21
    echo "Found unsupported a= syntax in config/chroot_apt/preferences,"
22 23 24
    echo "use n= instead. Exiting."
    exit 1
fi
25 26 27 28 29 30
if grep -qs -E '^Pin:\s+release\s+.*o=Debian Backports' \
	config/chroot_apt/preferences ; then
    echo "Found unsupported 'o=Debian Backports' syntax,"
    echo "in config/chroot_apt/preferences. Use o=Debian instead. Exiting."
    exit 1
fi
31

32
# init variables
33
RUN_LB_CONFIG="lb config noauto"
amnesia's avatar
amnesia committed
34

35
# init config/ with defaults for the target distribution
36
$RUN_LB_CONFIG --distribution jessie ${@}
amnesia's avatar
amnesia committed
37

38
# set up everything for time-based snapshots:
39
apt-snapshots-serials prepare-build
40

41 42
DEBIAN_MIRROR="$(apt-mirror debian)"
DEBIAN_SECURITY_MIRROR="$(apt-mirror debian-security)"
43 44
TORPROJECT_MIRROR="$(apt-mirror torproject)"

45 46 47 48
[ -n "$DEBIAN_MIRROR" ]          || exit 1
[ -n "$DEBIAN_SECURITY_MIRROR" ] || exit 1
[ -n "$TORPROJECT_MIRROR" ]      || exit 1

49 50 51 52 53 54
perl -pi \
     -E \
       "s|^(deb(?:-src)?\s+)https?://ftp[.]us[.]debian[.]org/debian/?(\s+)|\$1$DEBIAN_MIRROR\$2| ; \
        s|^(deb(?:-src)?\s+)https?://deb[.]torproject[.]org/torproject[.]org/?(\s+)|\$1$TORPROJECT_MIRROR\$2|" \
    config/chroot_sources/*.chroot \
    || exit 1
55

amnesia's avatar
amnesia committed
56
# set Amnesia's general options
57
$RUN_LB_CONFIG \
58
   --verbose \
59
   --apt-recommends false \
Tails developers's avatar
Tails developers committed
60
   --backports false \
61
   --binary-images iso \
62
   --binary-indices false \
63
   --checksums none \
amnesia's avatar
amnesia committed
64
   --bootappend-live "${AMNESIA_APPEND}" \
Cyril Brulebois's avatar
Cyril Brulebois committed
65
   --bootstrap debootstrap \
66
   --bootstrap-config tails-build-jessie \
67
   --archive-areas "main contrib non-free" \
68
   --includes none \
69
   --iso-application="The Amnesic Incognito Live System" \
70
   --iso-publisher="https://tails.boum.org/" \
amnesia's avatar
amnesia committed
71
   --iso-volume="TAILS ${AMNESIA_FULL_VERSION}" \
amnesia's avatar
amnesia committed
72
   --memtest none \
73 74 75 76 77
   --mirror-binary              "$DEBIAN_MIRROR" \
   --mirror-bootstrap           "$DEBIAN_MIRROR" \
   --mirror-chroot              "$DEBIAN_MIRROR" \
   --mirror-binary-security     "$DEBIAN_SECURITY_MIRROR" \
   --mirror-chroot-security     "$DEBIAN_SECURITY_MIRROR" \
78
   --packages-lists="standard" \
79
   --tasks="standard" \
80
   --linux-packages="linux-image-3.16.0-4" \
81
   --syslinux-menu vesamenu \
T(A)ILS developers's avatar
T(A)ILS developers committed
82
   --syslinux-splash data/splash.png \
amnesia's avatar
amnesia committed
83
   --syslinux-timeout 4 \
84
   --initramfs=live-boot \
amnesia's avatar
amnesia committed
85 86
   ${@}

87
# build i386 images on amd64 as well, include a bunch of kernels
amnesia's avatar
amnesia committed
88 89
hw_arch="`dpkg --print-architecture`"
if [ "$hw_arch" = i386 -o "$hw_arch" = amd64 ]; then
90
   $RUN_LB_CONFIG \
amnesia's avatar
amnesia committed
91
      --architecture i386 \
92
      --linux-flavours "586 amd64" \
amnesia's avatar
amnesia committed
93
      ${@}
94 95
# build powerpc images on powerpc64 as well, include only powerpc kernel
elif [ "$hw_arch" = powerpc -o "$hw_arch" = powerpc64 ]; then
96
   $RUN_LB_CONFIG \
97 98 99
      --architecture powerpc \
      --linux-flavours powerpc \
      ${@}
amnesia's avatar
amnesia committed
100 101
fi

102 103 104 105 106 107 108 109
install -d config/chroot_local-includes/etc/amnesia/

# environment
TAILS_WIKI_SUPPORTED_LANGUAGES="$(ikiwiki-supported-languages ikiwiki.setup)"
[ -n "$TAILS_WIKI_SUPPORTED_LANGUAGES" ] || exit 16
echo "TAILS_WIKI_SUPPORTED_LANGUAGES='${TAILS_WIKI_SUPPORTED_LANGUAGES}'" \
   >> config/chroot_local-includes/etc/amnesia/environment

amnesia's avatar
amnesia committed
110
# version
111
echo "${AMNESIA_FULL_VERSION}" > config/chroot_local-includes/etc/amnesia/version
amnesia's avatar
amnesia committed
112
if git rev-list HEAD 2>&1 >/dev/null; then
113 114
   git rev-list HEAD | head -n 1 >> config/chroot_local-includes/etc/amnesia/version
fi
115 116
echo "live-build: `dpkg-query -W -f='${Version}\n' live-build`" \
   >> config/chroot_local-includes/etc/amnesia/version
117 118 119 120 121
# os-release
cat >> config/chroot_local-includes/etc/os-release <<EOF
TAILS_PRODUCT_NAME="Tails"
TAILS_VERSION_ID="$AMNESIA_VERSION"
EOF
122 123

# changelog
124
cp debian/changelog config/chroot_local-includes/usr/share/doc/amnesia/Changelog
125

126 127 128 129 130 131
# create readahead-list from squashfs.sort
if [ -e config/binary_rootfs/squashfs.sort ]; then
    mkdir -p config/chroot_local-includes/usr/share/amnesia
    sort -k2 -n -r config/binary_rootfs/squashfs.sort |
        cut -d' ' -f1 > config/chroot_local-includes/usr/share/amnesia/readahead-list
fi
132 133 134

# custom APT sources
tails-custom-apt-sources > config/chroot_sources/tails.chroot
Cyril Brulebois's avatar
Cyril Brulebois committed
135

136 137 138 139 140 141 142 143
# tails-transform-mirror-url and its dependencies
install -m 0755 \
   submodules/mirror-pool-dispatcher/bin/tails-transform-mirror-url \
   config/chroot_local-includes/usr/local/bin/
install -m 0755 -d config/chroot_local-includes/usr/local/lib/nodejs
install -m 0755 \
   submodules/mirror-pool-dispatcher/lib/js/mirror-dispatcher.js \
   config/chroot_local-includes/usr/local/lib/nodejs/
144

Cyril Brulebois's avatar
Cyril Brulebois committed
145
# custom debootstrap script, setting some APT magic to log downloads:
146 147 148 149 150 151
patch \
    --follow-symlinks \
    --output=/usr/share/debootstrap/scripts/tails-build-jessie \
    /usr/share/debootstrap/scripts/jessie \
    data/debootstrap/scripts/jessie.patch
sed -i "s,%%topdir%%,$(pwd)," /usr/share/debootstrap/scripts/tails-build-jessie