Source code

Revision control

Other Tools

1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5
# Generate updater.ini by doing some light substitution on the localized updater.ini input,
6
# and appending the contents of updater_ini_append on Windows.
7
8
from __future__ import absolute_import, unicode_literals, print_function
9
10
import buildconfig
11
import codecs
12
import re
13
import shutil
14
15
16
def main(output, updater_ini, updater_ini_append, locale=None):
17
assert(locale is not None)
18
fixup_re = re.compile('^(Info|Title)Text=')
19
# updater.ini is always utf-8.
20
with codecs.open(updater_ini, 'rb', 'utf_8') as f:
21
for line in f:
22
line = fixup_re.sub(r'\1=', line)
23
line = line.replace('%MOZ_APP_DISPLAYNAME%',
24
buildconfig.substs['MOZ_APP_DISPLAYNAME'])
25
output.write(line)
26
if buildconfig.substs['OS_TARGET'] == 'WINNT':
27
# Also append the contents of `updater_ini_append`.
28
with codecs.open(updater_ini_append, 'rb', 'utf_8') as f:
29
shutil.copyfileobj(f, output)