1 [[!meta title="Writing code for Tails"]]
3 Hi, prospective Tails contributor! This document is intended to
4 quickly (in 20 minutes!) get you up to speed on how to write code for
5 Tails by giving a brief overview the Tails source tree and Git branch
6 organization without referring to more detailed (and hence longer)
7 resources. As such it might not be enough for some specific things,
8 but it should cover 95% of use cases for aspiring code
9 contributors. Also, this document risks getting out of date, so don't
10 trust every single detail as the written word of `$DEITY`.
12 Note that this document will not teach you how to *contribute* code to
13 Tails; it will only introduce you how to *write* code for Tails. Once
14 you have something to contribute, please read our
15 [[extensive instructions for contributors|contribute/how/code]].
19 # Git branch organization
21 * `master`: as soon as something is pushed to this branch in Tails
22 main git repository, the live Tails' website is rebuilt. This branch
23 is *only* used for the website. Don't waste time trying to build it,
24 or basing new branches on it if you intend to build them!
26 * `devel`: This is the development branch, where new features end
27 up. In general you should base new branches on this one.
29 * `stable`: When a new major Tails release is out, we merge `devel`
30 into `stable` and use it to build minor releases (e.g. when there's
31 a new Tor Browser (= Firefox ESR) release) and emergency releases
32 from. We only merge security fixes and bugfixes into this branch, so
33 new such branches should be based on `stable`.
35 * `testing`: After a freeze for a new major release (e.g. when we
36 prepare release candidates), this is the branch were the continued
37 work for this release happens. At that point `devel` is used for the
38 *next* major release. Bugfixes on new features introduced in the
39 this upcoming Tails release should be based on this branch (as
40 should new translations).
42 * `feature/DEBIAN_NEXT`: The development branch for Tails based on the
43 next Debian major release.
45 * `feature/XXXX-*`, `bugfix/XXXX-*`, `test/XXXX-*`: We use this naming
46 scheme for the branches if new features, bugfixes and automated
47 tests, where `XXXX` refers to the Redmine ticket they fix.
49 We will sometimes talk about "base branches", which are `stable`,
50 `testing`, `devel` and `feature/DEBIAN_NEXT`. When developing a new
51 branch, this should be the branch you based it on. It will be used
52 during the build to determine which packages from Tails APT repo to
53 install (see some details about this below).
55 For detailed information see our
56 [[documentation about Git|contribute/git]].
58 # Important files and directories
60 Some of the more important files during build, and for running Tails
61 sessions, are listed below. In general, just look at the existing
62 files or content to understand the format -- we won't explain them
63 fully here most of the time.
66 ## config/chroot_sources/
68 The files in here determine which APT repositories to use during
69 build, and in the resulting Tails image.
71 Note that while it is possible to add non-Debian repositories, and
72 that it is fine to do so for testing/development purposes, limitations
73 inherent in Tails' APT snapshot system (see below) prevents us from
74 using them in releases. In fact, in releases we can only use:
76 * Debian's APT repository
77 * `deb.torproject.org`
78 * `deb.tails.boum.org`
80 So, if you need a package from some other repository, feel free to add
81 through this mechanism it when developing your branch. When it's time
82 to merge we will figure out the best way to get the packages available
83 to us, usually by importing them to `deb.tails.boum.org`. The
84 preferred solution is always to have the packages available in
88 ## config/chroot_apt/preferences
90 The `/etc/apt/preferences` file that will be used during the build
91 process, and later copied in to the resulting Tails filesystem. We use
92 it *heavily*. If you want to install a package (or another version of
93 a package) that is not in the stable Debian release, you will have to
94 add a pinning rule in this file in order to make it install.
97 ## config/chroot_local-packageslists/tails-common.list
99 The primary list of packages to install in Tails. Sometimes extra
100 magic has to be done when installing a package, and then we install it
101 with a build-time hook (see `config/chroot_local-hooks/` below). If
102 the package is to be installed from another source than Debian Stable,
103 make sure to add a pinning rule (see `config/chroot_apt/preferences`
107 ## config/chroot_local-packages/
109 If you put a `.deb` here, it will be installed with high priority
110 (disregarding the rules in `config/chroot_apt/preferences`). This is
111 useful for testing purposes only!
114 ## config/base_branch
116 This encodes which base branch (see above) the current branch is based
117 on (the base branches themselves are "based" on themselves). In
118 practice this determines which APT suite from `deb.tails.boum.org` to
119 use (so if `config/base_branch` contains `devel`, then the `devel` APT
120 suite will be used). These APT suites are the place where we upload
121 all our custom Debian packages.
124 ## config/APT_overlays.d/
126 Each file here corresponds to an APT suite on `deb.tails.boum.org` to
127 be used. E.g. if we have `config/APT_overlays.d/feature-1234-example`
128 then the `feature-1234-example` APT suite will be used. Each branch
129 that is pushed to Tails' main Git repo will automatically have such a
130 suite created (but with illegal charactes changed to `-`, so
131 `feature/1234-example` becomes `feature-1234-example`).
133 This is useful for importing specific package versions in between
134 Tails releases, and gives us very exact control of which branches gets
138 ## config/APT_snapshots.d/
140 The APT repositories used to install packages during the build process
141 are snapshotted several times per day. The files in here simply encode
142 which snapshot to use for each APT repository. In general, the `devel`
143 branch always uses the latest snapshots, while all other branches more
144 or less use the snapshot from the last feature freeze (when we prepare
145 the release candidate for the last Tails major release). This way only
146 `devel` is a bit crazy, and the build result depends on what happens
147 e.g. in Debian's APT repository from day to day. Other branches remain
148 pretty much the same until these snapshots are bumped, or something
149 changes in `deb.tails.boum.org` (but then you should just merge your
150 base branch, and all should be good again).
152 For detailed information see our
153 [[documentation about APT repositories|contribute/APT_repository]].
157 These files are about what will happen outside of Tails filesystem, on
158 the ISO9660 filesystem of the resulting `.iso` image.
161 ## config/chroot_local-includes/
163 These files and directories will be copied into the Tails file system,
164 overwriting existing file. This is the main way to include e.g. static
165 configurations, custom scripts, and similar things not handled by
169 ## config/chroot_local-patches/
171 These patches will be applied on `/` of the Tails filesystem right
172 after `config/chroot_local-includes/` is copied in. Here we patch
173 various configuration files and similar installed by Debian packages,
174 but where we still want to keep any changes made upstream. Remember,
175 if we use `config/chroot_local-includes/` files are *overwritten*, so
176 any such upstream changes are lost. With a patch we'll get them as
177 well as our desired change (and we get build failures as a
178 "notification" when the upstream has changed in a conflicting way,
182 ## config/chroot_local-hooks/
184 These scripts will run right after the patches in
185 `config/chroot_local-patches/` are applied. Here we can pretty much do
186 anything we want. We use it to reconfigure various things, install
187 packages that require extra magic, programatically generating various
188 files (images, configurations, even some scripts), cleaning up
192 ## config/chroot_local-includes/lib/live/config/
194 These scripts will be run early during Tails' boot process, in lexical
195 order. Quite a few of them are installed by the `live-config` package,
196 but we have some custom ones in there as well. Note that
197 `0030-user-setup` is when the Live user (`amnesia`) is created, so
198 prior to that any reference to it won't work (e.g. in the build-hooks
199 in `config/chroot_local-hooks/`).
202 ## config/chroot_local-includes/etc/skel/
204 This is the seed for the Live user's (`amnesia` for now) home
205 directory. Put static application configuration files ("dot files" and
209 ## config/chroot_local-includes/usr/share/tails/
211 A directory where we dump Tails-specific files with no obvious place
212 to live. Generally these are files needed during build (and then we
213 clean them up with a build hook) or during Tails operation (e.g. by
217 ## config/chroot_local-includes/usr/local/
219 This is where we put most of the custom scripts shipped in Tails. Some
220 honorable mentions are:
222 * `config/chroot_local-includes/usr/local/sbin/` for scripts used by
224 * `config/chroot_local-includes/usr/local/bin/` for scripts used by
225 non-root users (and root too).
226 * `config/chroot_local-includes/usr/local/lib/` for scripts that we
227 don't want to expose to the user at all times (it's not in the
229 * `config/chroot_local-includes/usr/local/lib/tails-shell-library/`
230 for "libraries" often included in the above scripts.
233 # Overview of the build process
235 The order of how things are applied matters greatly. In terms of the
236 files and directories you have learned about above, this is how Tails
239 1. A minimal Debian system is `debootstrap`:ed.
240 2. APT is set up according to `config/chroot_sources/` and
241 `config/chroot_apt/preferences` (and `config/APT_overlays.d/` and
242 `config/APT_snapshots.d/`).
243 3. Packages listed in
244 `config/chroot_local-packageslists/tails-common.list` are
246 4. Packages stored in `config/chroot_local-packages/` are installed.
247 5. Everyting in `config/chroot_local-includes/` is copied to `/`,
248 overwriting existing files.
249 6. All patches in `config/chroot_local-patches/` are applied on `/`.
250 7. All build-time hooks in `config/chroot_local-hooks/` are run.
251 8. Now the Tails filesystem is done!
252 9. The ISO9660 filesystem used in the resulting `.iso` image is
253 created according to `config/binary_*`.
257 Just follow the "Using Vagrant" section in our
258 [[contribute/build#vagrant]] instruction. Copy-pasting the shell
259 commands should be enough. Then it's as simple as:
263 although you may want to look through the build options you can supply
264 via the `TAILS_BUILD_OPTIONS` environment variable.