@@ -23,7 +23,13 @@ def mkzipdir(zf, path):
2323
2424def build_xpi (template_root_dir , manifest , xpi_path ,
2525 harness_options , limit_to = None , extra_harness_options = {},
26- bundle_sdk = True ):
26+ bundle_sdk = True , pkgdir = "" ):
27+ IGNORED_FILES = [".hgignore" , ".DS_Store" , "install.rdf" ,
28+ "application.ini" , xpi_path ]
29+
30+ files_to_copy = {} # maps zipfile path to local-disk abspath
31+ dirs_to_create = set () # zipfile paths, no trailing slash
32+
2733 zf = zipfile .ZipFile (xpi_path , "w" , zipfile .ZIP_DEFLATED )
2834
2935 open ('.install.rdf' , 'w' ).write (str (manifest ))
@@ -39,6 +45,31 @@ def build_xpi(template_root_dir, manifest, xpi_path,
3945 zf .write (str (harness_options ['icon64' ]), 'icon64.png' )
4046 del harness_options ['icon64' ]
4147
48+ # chrome.manifest
49+ if os .path .isfile (os .path .join (pkgdir , 'chrome.manifest' )):
50+ files_to_copy ['chrome.manifest' ] = os .path .join (pkgdir , 'chrome.manifest' )
51+
52+ # chrome folder (would contain content, skin, and locale folders typically)
53+ folder = 'chrome'
54+ if os .path .exists (os .path .join (pkgdir , folder )):
55+ dirs_to_create .add ('chrome' )
56+ # cp -r folder
57+ abs_dirname = os .path .join (pkgdir , folder )
58+ for dirpath , dirnames , filenames in os .walk (abs_dirname ):
59+ goodfiles = list (filter_filenames (filenames , IGNORED_FILES ))
60+ dirnames [:] = filter_dirnames (dirnames )
61+ for dirname in dirnames :
62+ arcpath = make_zipfile_path (template_root_dir ,
63+ os .path .join (dirpath , dirname ))
64+ dirs_to_create .add (arcpath )
65+ for filename in goodfiles :
66+ abspath = os .path .join (dirpath , filename )
67+ arcpath = ZIPSEP .join (
68+ [folder ,
69+ make_zipfile_path (abs_dirname , os .path .join (dirpath , filename )),
70+ ])
71+ files_to_copy [str (arcpath )] = str (abspath )
72+
4273 # Handle simple-prefs
4374 if 'preferences' in harness_options :
4475 from options_xul import parse_options , validate_prefs
@@ -63,12 +94,6 @@ def build_xpi(template_root_dir, manifest, xpi_path,
6394 os .remove ('.prefs.js' )
6495
6596
66- IGNORED_FILES = [".hgignore" , ".DS_Store" , "install.rdf" ,
67- "application.ini" , xpi_path ]
68-
69- files_to_copy = {} # maps zipfile path to local-disk abspath
70- dirs_to_create = set () # zipfile paths, no trailing slash
71-
7297 for dirpath , dirnames , filenames in os .walk (template_root_dir ):
7398 filenames = list (filter_filenames (filenames , IGNORED_FILES ))
7499 dirnames [:] = filter_dirnames (dirnames )
0 commit comments