| OLD | NEW | 
|---|
| 1 # This Source Code Form is subject to the terms of the Mozilla Public | 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 | 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/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 
| 4 | 4 | 
| 5 import base64 | 5 import base64 | 
| 6 import hashlib | 6 import hashlib | 
| 7 import json | 7 import json | 
| 8 import mimetypes | 8 import mimetypes | 
| 9 import os | 9 import os | 
| 10 import zipfile | 10 import zipfile | 
| 11 | 11 | 
| 12 import packager | 12 import packager | 
| 13 import packagerChrome | 13 import packagerChrome | 
|  | 14 # These functions are unused here, but releaseAutomation.py expects them. | 
|  | 15 from packager import readMetadata, getDefaultFileName # flake8: noqa | 
| 14 | 16 | 
| 15 # Files and directories expected inside of the .APPX archive. | 17 # Files and directories expected inside of the .APPX archive. | 
| 16 MANIFEST = 'AppxManifest.xml' | 18 MANIFEST = 'AppxManifest.xml' | 
| 17 CONTENT_TYPES = '[Content_Types].xml' | 19 CONTENT_TYPES = '[Content_Types].xml' | 
| 18 BLOCKMAP = 'AppxBlockMap.xml' | 20 BLOCKMAP = 'AppxBlockMap.xml' | 
| 19 EXTENSION_DIR = 'Extension' | 21 EXTENSION_DIR = 'Extension' | 
| 20 ASSETS_DIR = 'Assets' | 22 ASSETS_DIR = 'Assets' | 
| 21 | 23 | 
| 22 # Size of uncompressed block in the APPX block map. | 24 # Size of uncompressed block in the APPX block map. | 
| 23 BLOCKSIZE = 64 * 1024 | 25 BLOCKSIZE = 64 * 1024 | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 86     params['version'] = pad_version(params['version']) | 88     params['version'] = pad_version(params['version']) | 
| 87 | 89 | 
| 88     translation = load_translation(files, defaultLocale) | 90     translation = load_translation(files, defaultLocale) | 
| 89     name_key = 'name' if release_build else 'name_devbuild' | 91     name_key = 'name' if release_build else 'name_devbuild' | 
| 90     params['display_name'] = translation[name_key]['message'] | 92     params['display_name'] = translation[name_key]['message'] | 
| 91     params['description'] = translation['description']['message'] | 93     params['description'] = translation['description']['message'] | 
| 92 | 94 | 
| 93     for size in ['44', '50', '150']: | 95     for size in ['44', '50', '150']: | 
| 94         path = '{}/logo_{}.png'.format(ASSETS_DIR, size) | 96         path = '{}/logo_{}.png'.format(ASSETS_DIR, size) | 
| 95         if path not in files: | 97         if path not in files: | 
| 96             raise KeyError(path + 'is not found in files') | 98             raise KeyError(path + ' is not found in files') | 
| 97         params['logo_' + size] = path.replace('/', '\\') | 99         params['logo_' + size] = path.replace('/', '\\') | 
| 98 | 100 | 
| 99     template = _get_template_for(MANIFEST) | 101     template = _get_template_for(MANIFEST) | 
| 100     return template.render(params).encode('utf-8') | 102     return template.render(params).encode('utf-8') | 
| 101 | 103 | 
| 102 | 104 | 
| 103 def move_files_to_extension(files): | 105 def move_files_to_extension(files): | 
| 104     """Move all files into `Extension` folder for APPX packaging.""" | 106     """Move all files into `Extension` folder for APPX packaging.""" | 
| 105     # We sort the files to ensure that 'Extension/xyz' is moved before 'xyz'. | 107     # We sort the files to ensure that 'Extension/xyz' is moved before 'xyz'. | 
| 106     # If 'xyz' is moved first, it would overwrite 'Extension/xyz' and its | 108     # If 'xyz' is moved first, it would overwrite 'Extension/xyz' and its | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 174     if metadata.has_section('appx_assets'): | 176     if metadata.has_section('appx_assets'): | 
| 175         for name, path in metadata.items('appx_assets'): | 177         for name, path in metadata.items('appx_assets'): | 
| 176             path = os.path.join(baseDir, path) | 178             path = os.path.join(baseDir, path) | 
| 177             files.read(path, '{}/{}'.format(ASSETS_DIR, name)) | 179             files.read(path, '{}/{}'.format(ASSETS_DIR, name)) | 
| 178 | 180 | 
| 179     files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) | 181     files[MANIFEST] = create_appx_manifest(params, files, releaseBuild) | 
| 180     files[BLOCKMAP] = create_appx_blockmap(files) | 182     files[BLOCKMAP] = create_appx_blockmap(files) | 
| 181     files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) | 183     files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP]) | 
| 182 | 184 | 
| 183     files.zip(outfile, compression=zipfile.ZIP_STORED) | 185     files.zip(outfile, compression=zipfile.ZIP_STORED) | 
| OLD | NEW | 
|---|