5
5
def get_files_to_zip ():
6
6
#Exclude git stuff, build scripts etc.
7
7
exclude = [
8
- r'(\\|/)\.git(\\|/)' ,
9
- r'\.(py|sh)$' ,
10
- r'\.DS_Store$' ,
11
- r'\.gitignore$' ,
12
- r'\.jpmignore$' ,
13
- r'package\.json$' ,
14
- r'icon\.html' ,
15
- r'.*unittest.*' ,
16
- r'(\\|/)promo(\\|/)' ,
17
- r'(\\|/)build(\\|/)' ,
18
- r'debug\.sh'
8
+ r'\.(py|sh|pem)$' , #file endings
9
+ r'(\\|/)\.' , #hidden files
10
+ r'package\.json|icon\.html' , #file names
11
+ r'(\\|/)(promo|unittest|build)(\\|/)' #folders
19
12
]
20
13
21
14
zippable_files = []
22
15
for root , folders , files in os .walk ('.' ):
16
+ print root
23
17
for f in files :
24
18
file = os .path .join (root ,f )
25
19
if not any (re .search (p , file ) for p in exclude ):
26
20
zippable_files .append (file )
27
21
return zippable_files
28
22
29
23
def create_firefox_addon ():
24
+ print ''
25
+ print '**** Creating addon for Firefox ****'
30
26
os .system ('jpm xpi' )
31
27
import glob , shutil
32
28
name = glob .glob ('*.xpi' )[0 ]
@@ -38,15 +34,17 @@ def create_addon(files, browser):
38
34
if not os .path .isdir (output_folder ):
39
35
os .mkdir (output_folder )
40
36
41
- extension = 'zip'
42
- if browser == 'firefox' :
43
- extension = 'xpi'
44
-
45
- output_file = os .path .join (output_folder , 'redirector-%s.%s' % (browser , extension ))
37
+ output_file = os .path .join (output_folder , 'redirector-%s.zip' % browser )
46
38
zf = zipfile .ZipFile (output_file , 'w' , zipfile .ZIP_STORED )
47
-
39
+ cert = 'extension-certificate.pem'
40
+
48
41
print ''
49
42
print '**** Creating addon for %s ****' % browser
43
+
44
+ if browser == 'opera' and not os .path .exists (cert ):
45
+ print 'Extension certificate does not exist, cannot create .nex file for Opera'
46
+ return
47
+
50
48
for f in files :
51
49
print 'Adding' , f
52
50
if f .endswith ('manifest.json' ):
@@ -55,7 +53,7 @@ def create_addon(files, browser):
55
53
del manifest ['applications' ] #Firefox specific, and causes warnings in other browsers...
56
54
57
55
if browser == 'opera' :
58
- manifest ['options_ui' ]['page' ] = 'data/ redirector.html' #Opera opens options in new tab, where the popup would look really ugly
56
+ manifest ['options_ui' ]['page' ] = 'redirector.html' #Opera opens options in new tab, where the popup would look really ugly
59
57
manifest ['options_ui' ]['chrome_style' ] = False
60
58
61
59
zf .writestr (f [2 :], json .dumps (manifest , indent = 2 ))
@@ -64,6 +62,12 @@ def create_addon(files, browser):
64
62
65
63
zf .close ()
66
64
65
+ if browser == 'opera' :
66
+ #Create .nex
67
+ os .system ('./nex-build.sh %s %s %s' % (output_file , output_file .replace ('.zip' , '.nex' ), cert ))
68
+
69
+
70
+
67
71
if __name__ == '__main__' :
68
72
#Make sure we can run this from anywhere
69
73
folder = os .path .dirname (os .path .realpath (__file__ ))
0 commit comments