1Partner repacks
2===============
3.. _partner repacks:
4
5We create slightly-modified Firefox releases for some extra audiences
6
7* EME-free builds, which disable DRM plugins by default
8* Funnelcake builds, which are used for Mozilla experiments
9* partner builds, which customize Firefox for external partners
10
11We use the phrase "partner repacks" to refer to all these builds because they
12use the same process of repacking regular Firefox releases with additional files.
13The specific differences depend on the type of build.
14
15We produce partner repacks for some beta builds, and for release builds, as part of the release
16automation. We don't produce any files to update these builds as they are handled automatically
17(see updates_).
18
19We also produce :ref:`partner attribution` builds, which are Firefox Windows installers with a cohort identifier
20added.
21
22Parameters & Scheduling
23-----------------------
24
25Partner repacks have a number of parameters which control how they work:
26
27* ``release_enable_emefree``
28* ``release_enable_partner_repack``
29* ``release_partner_config``
30* ``release_partner_build_number``
31* ``release_partners``
32
33We split the repacks into two 'paths', EME-free and everything else, to retain some
34flexibility over enabling/disabling them separately. This costs us some duplication of the kinds
35in the repacking stack. The two enable parameters are booleans to turn these two paths
36on/off. We set them in shipit's `is_partner_enabled() <https://github.com/mozilla-releng/shipit/blob/main/api/src/shipit_api/admin/release.py#L93>`_ when starting a
37release. They're both true for Firefox betas >= b8 and releases, but otherwise disabled.
38
39``release_partner_config`` is a dictionary of configuration data which drives the task generation
40logic. It's usually looked up during the release promotion action task, using the Github
41GraphQL API in the `get_partner_config_by_url()
42<python/taskgraph.util.html#taskgraph.util.partners.get_partner_config_by_url>`_ function, with the
43url defined in `taskcluster/ci/config.yml <https://searchfox
44.org/mozilla-release/search?q=regexp%3A^partner+path%3Aconfig.yml&redirect=true>`_.
45
46``release_partner_build_number`` is an integer used to create unique upload paths in the firefox
47candidates directory, while ``release_partners`` is a list of partners that should be
48repacked (i.e. a subset of the whole config). Both are intended for use when respinning a few partners after
49the regular Firefox has shipped. More information on that can be found in the
50`RelEng Docs <https://moz-releng-docs.readthedocs.io/en/latest/procedures/misc-operations/off-cycle-partner-repacks-and-funnelcake.html>`_.
51
52Most of the machine time for generating partner repacks takes place in the `promote` phase of the
53automation, or `promote_rc` in the case of X.0 release candidates. The EME-free builds are copied into the
54Firefox releases directory in the `push` phase, along with the regular bits.
55
56
57Configuration
58-------------
59
60We need some configuration to know *what* to repack, and *how* to do that. The *what* is defined by
61default.xml manifests, as used with the `repo <https://gerrit.googlesource.com/git-repo>`_ tool
62for git. The `default.xml for EME-free <https://github
63.com/mozilla-partners/mozilla-EME-free-manifest/blob/master/default.xml>`_ illustrates this::
64
65    <?xml version="1.0" ?>
66    <manifest>
67      <remote fetch="git@github.com:mozilla-partners/" name="mozilla-partners"/>
68      <remote fetch="git@github.com:mozilla/" name="mozilla"/>
69
70      <project name="repack-scripts" path="scripts" remote="mozilla-partners" revision="master"/>
71      <project name="build-tools" path="scripts/tools" remote="mozilla" revision="master"/>
72      <project name="mozilla-EME-free" path="partners/mozilla-EME-free" remote="mozilla-partners" revision="master"/>
73    </manifest>
74
75The repack-scripts and build-tools repos are found in all manifests, and then there is a list of
76partner repositories which contain the *how* configuration. Some of these repos are not publicly
77visible.
78
79A partner repository may contain multiple configurations inside the ``desktop`` directory. Each
80subdirectory must contain a ``repack.cfg`` and a ``distribution`` directory, the latter
81containing the customizations needed. Here's `EME-free's repack.cfg <https://github.com/mozilla-partners/mozilla-EME-free/blob/master/desktop/mozilla-EME-free/repack.cfg>`_::
82
83    aus="mozilla-EMEfree"
84    dist_id="mozilla-EMEfree"
85    dist_version="1.0"
86    linux-i686=false
87    linux-x86_64=false
88    locales="ach af an ar"  # truncated for display here
89    mac=true
90    win32=true
91    win64=true
92    output_dir="%(platform)s-EME-free/%(locale)s"
93
94    # Upload params
95    upload_to_candidates=true
96
97Note the list of locales and boolean toggles for enabling platforms. The ``output_dir`` and
98``upload_to_candidates`` parameters are only present for repacks which are uploaded into the
99`candidates directory <https://archive.mozilla.org/pub/firefox/candidates/>`_.
100
101All customizations will be placed in the ``distribution`` directory at the root of the Firefox
102install directory, or in the case of OS X in ``Firefox.app/Contents/Resources/distribution/``. A
103``distribution.ini`` file is the minimal requirement, here's an example from `EME-free
104<https://github.com/mozilla-partners/mozilla-EME-free/blob/master/desktop/mozilla-EME-free/distribution
105/distribution.ini>`_::
106
107    # Partner Distribution Configuration File
108    # Author: Mozilla
109    # Date: 2015-03-27
110
111    [Global]
112    id=mozilla-EMEfree
113    version=1.0
114    about=Mozilla Firefox EME-free
115
116    [Preferences]
117    media.eme.enabled=false
118    app.partner.mozilla-EMEfree="mozilla-EMEfree"
119
120Extensions and other customizations might also be included in repacks.
121
122
123Repacking process
124-----------------
125
126The stack of tasks to create partner repacks is broadly similar to localised nightlies and
127regular releases. The basic form is
128
129* partner repack - insert the customisations into the the regular builds
130* signing - sign the internals which will become the installer (Mac only)
131* repackage - create the "installer" (Mac and Windows)
132* chunking dummy - a linux only bridge to ...
133* repackage signing - sign the "installers" (mainly Windows)
134* beetmover - move the files to a partner-specific destination
135* beetmover checksums - possibly beetmove the checksums from previous step
136
137Some key divergences are:
138
139* all intermediate artifacts are uploaded with a ``releng/partner`` prefix
140* we don't insert any binaries on Windows so no need for internal signing
141* there's no need to create any complete mar files at the repackage step
142* we support both public and private destinations in beetmover
143* we only need beetmover checksums for EME-free builds
144
145
146Partner repack
147^^^^^^^^^^^^^^
148
149* kinds: ``release-partner-repack`` ``release-eme-free-repack``
150* platforms: Typically all (but depends on what's enabled by partner configuration)
151* upstreams: ``build-signing`` ``l10n-signing``
152
153There is one task per platform in this step, calling out to `scripts/desktop_partner_repacks.py
154<https://hg.mozilla.org/mozilla-central/file/default/testing/mozharness/scripts
155/desktop_partner_repacks.py>`_ in mozharness to prepare an environment and then perform the repacks.
156The actual repacking is done by `python/mozrelease/mozrelease/partner_repack.py
157<https://hg.mozilla.org/mozilla-central/file/default/python/mozrelease/mozrelease/partner_repack.py>`_.
158
159It takes as input the build-signing and l10n-signing artifacts, which are all zip/tar.gz/tar.bz2
160archives, simplifying the repack process by avoiding dmg and exe. Windows produces ``target.zip``
161& ``setup.exe``, Mac is ``target.tar.gz``, Linux is the final product ``target.tar.bz2``
162(beetmover handles pretty naming as usual).
163
164Signing
165^^^^^^^
166
167* kinds: ``release-partner-repack-notarization-part-1`` ``release-partner-repack-notarization-poller`` ``release-partner-repack-signing``
168* platforms: Mac
169* upstreams: ``release-partner-repack`` ``release-eme-free-repack``
170
171We chunk the single partner repack task out to a signing task with 5 artifacts each. For
172example, EME-free will become 19 tasks. We collect the target.tar.gz from the
173upstream, and return a signed target.tar.gz. We use a ``target.dmg`` artifact for
174nightlies/regular releases, but this is converted to ``target.tar.gz`` by the signing
175scriptworker before sending it to the signing server, so partners are equivalent. The ``part-1`` task
176uploads the binaries to apple, while the ``poller`` task waits for their approval, then
177``release-partner-repack-signing`` staples on the notarization ticket.
178
179Repackage
180^^^^^^^^^
181
182* kinds: ``release-partner-repack-repackage`` ``release-eme-free-repack-repackage``
183* platforms: Mac & Windows
184* upstreams:
185
186    * Mac: ``release-partner-signing`` ``release-eme-free-signing``
187    * Windows: ``release-partner-repack`` ``release-eme-free-repack``
188
189Mac has a repackage job for each of the signing tasks. Windows repackages are chunked here to
190the same granularity as mac. Takes ``target.zip`` & ``setup.exe`` to produce ``target.exe`` on
191Windows, and ``target.tar.gz`` to produce ``target.dmg`` on Mac. There's no need to produce any
192complete.mar files here like regular release bits do because we can reuse those.
193
194Chunking dummy
195^^^^^^^^^^^^^^
196
197* kinds: ``release-partner-repack-chunking-dummy``
198* platforms: Linux
199* upstreams: ``release-partner-repack``
200
201We're need Linux chunked at the next step so this dummy takes care of that for the relatively simple path
202Linux follows. One task per sub config+locale combination, the same as Windows and Mac. This doesn't need to
203exist for EME-free because we don't need to create Linux builds there.
204
205Repackage Signing
206^^^^^^^^^^^^^^^^^
207
208* kinds: ``release-partner-repack-repackage-signing`` ``release-eme-free-repack-repackage-signing``
209* platforms: All
210* upstreams:
211
212   * Mac & Windows: ``release-partner-repackage`` ``release-eme-free-repackage``
213   * Linux: ``release-partner-repack-chunking-dummy``
214
215This step GPG signs all platforms, and authenticode signs the Windows installer.
216
217Beetmover
218^^^^^^^^^
219
220* kinds: ``release-partner-repack-beetmover`` ``release-eme-free-repack-beetmover``
221* platforms: All
222* upstreams: ``release-partner-repack-repackage-signing`` ``release-eme-free-repack-repackage-signing``
223
224Moves and renames the artifacts to their public location in the `candidates directory
225<https://archive.mozilla.org/pub/firefox/candidates/>`_, or a private S3 bucket. Each task will
226have the ``project:releng:beetmover:action:push-to-partner`` scope, with public uploads having
227``project:releng:beetmover:bucket:release`` and private uploads using
228``project:releng:beetmover:bucket:partner``. The ``upload_to_candidates`` key in the partner config
229controls the second scope. There's a separate partner code path in `beetmoverscript <https://github.com/mozilla-releng/scriptworker-scripts/tree/master/beetmoverscript>`_.
230
231Beetmover checksums
232^^^^^^^^^^^^^^^^^^^
233
234* kinds: ``release-eme-free-repack-beetmover-checksums``
235* platforms: Mac & Windows
236* upstreams: ``release-eme-free-repack-repackage-beetmover``
237
238The EME-free builds should be present in our SHA256SUMS file and friends (`e.g. <https://archive
239.mozilla.org/pub/firefox/releases/61.0/SHA256SUMS>`_) so we beetmove the target.checksums from
240the beetmover tasks into the candidates directory. They get picked up by the
241``release-generate-checksums`` kind.
242
243.. _updates:
244
245Updates
246-------
247
248It's very rare to need to update a partner repack differently from the original
249release build but we retain that capability. A partner build with distribution name ``foo``,
250based on a release Firefox build, will query for an update on the ``release-cck-foo`` channel. If
251the update server `Balrog <http://mozilla-balrog.readthedocs.io/en/latest/>`_ finds no rule for
252that channel it will fallback to the ``release`` channel. The update files for the regular releases do not
253modify the ``distribution/`` directory, so the customizations are not modified.
254
255`Bug 1430254 <https://bugzilla.mozilla.org/show_bug.cgi?id=1430254>`_ is an example of an exception to this
256logic.
257