2013-01-23 14:23:14 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
'''
|
|
|
|
Replace localized parts of a packaged directory with data from a langpack
|
|
|
|
directory.
|
|
|
|
'''
|
|
|
|
|
2013-03-06 10:26:32 +04:00
|
|
|
from mozpack.packager import l10n
|
2013-01-25 03:38:47 +04:00
|
|
|
from argparse import ArgumentParser
|
2013-01-25 03:40:13 +04:00
|
|
|
import buildconfig
|
2013-01-23 14:23:14 +04:00
|
|
|
|
|
|
|
# Set of files or directories not listed in a chrome.manifest but that are
|
|
|
|
# localized.
|
|
|
|
NON_CHROME = set([
|
2013-01-25 03:38:19 +04:00
|
|
|
'**/crashreporter*.ini',
|
2013-01-23 14:23:14 +04:00
|
|
|
'dictionaries',
|
|
|
|
'defaults/profile',
|
|
|
|
'defaults/pref*/*-l10n.js',
|
2020-07-01 21:40:29 +03:00
|
|
|
'locale.ini',
|
2013-01-23 14:23:14 +04:00
|
|
|
'update.locale',
|
2013-08-13 19:15:42 +04:00
|
|
|
'updater.ini',
|
2013-01-23 14:23:14 +04:00
|
|
|
'extensions/langpack-*@*',
|
|
|
|
'distribution/extensions/langpack-*@*',
|
2018-02-14 10:42:14 +03:00
|
|
|
'**/multilocale.txt'
|
2013-01-23 14:23:14 +04:00
|
|
|
])
|
|
|
|
|
|
|
|
|
2015-03-26 08:31:15 +03:00
|
|
|
def valid_extra_l10n(arg):
|
|
|
|
if '=' not in arg:
|
|
|
|
raise ValueError('Invalid value')
|
|
|
|
return tuple(arg.split('=', 1))
|
|
|
|
|
|
|
|
|
2013-01-23 14:23:14 +04:00
|
|
|
def main():
|
2013-01-25 03:38:47 +04:00
|
|
|
parser = ArgumentParser()
|
|
|
|
parser.add_argument('build',
|
|
|
|
help='Directory containing the build to repack')
|
|
|
|
parser.add_argument('l10n',
|
|
|
|
help='Directory containing the staged langpack')
|
2015-03-26 08:31:15 +03:00
|
|
|
parser.add_argument('extra_l10n', nargs='*', metavar='BASE=PATH',
|
|
|
|
type=valid_extra_l10n,
|
|
|
|
help='Extra directories with staged localized files '
|
|
|
|
'to be considered under the given base in the '
|
|
|
|
'repacked build')
|
2013-01-25 03:38:47 +04:00
|
|
|
parser.add_argument('--non-resource', nargs='+', metavar='PATTERN',
|
|
|
|
default=[],
|
|
|
|
help='Extra files not to be considered as resources')
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2013-01-25 03:40:13 +04:00
|
|
|
buildconfig.substs['USE_ELF_HACK'] = False
|
|
|
|
buildconfig.substs['PKG_SKIP_STRIP'] = True
|
2015-03-26 08:31:15 +03:00
|
|
|
l10n.repack(args.build, args.l10n, extra_l10n=dict(args.extra_l10n),
|
|
|
|
non_resources=args.non_resource, non_chrome=NON_CHROME)
|
2013-03-06 10:26:32 +04:00
|
|
|
|
2013-01-23 14:23:14 +04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|