From 60341ef37cf9046d0f99b5d3eb4dc1a2ad90acf9 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Mon, 5 Oct 2015 10:58:39 +0000 Subject: Build that works for Opera --- build.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'build.py') diff --git a/build.py b/build.py index 291004e..9c4f4ab 100755 --- a/build.py +++ b/build.py @@ -5,21 +5,15 @@ import os, os.path, re, zipfile, json def get_files_to_zip(): #Exclude git stuff, build scripts etc. exclude = [ - r'(\\|/)\.git(\\|/)', - r'\.(py|sh)$', - r'\.DS_Store$', - r'\.gitignore$', - r'\.jpmignore$', - r'package\.json$', - r'icon\.html', - r'.*unittest.*', - r'(\\|/)promo(\\|/)', - r'(\\|/)build(\\|/)', - r'debug\.sh' + r'\.(py|sh|pem)$', #file endings + r'(\\|/)\.', #hidden files + r'package\.json|icon\.html', #file names + r'(\\|/)(promo|unittest|build)(\\|/)' #folders ] zippable_files = [] for root, folders, files in os.walk('.'): + print root for f in files: file = os.path.join(root,f) if not any(re.search(p, file) for p in exclude): @@ -27,6 +21,8 @@ def get_files_to_zip(): return zippable_files def create_firefox_addon(): + print '' + print '**** Creating addon for Firefox ****' os.system('jpm xpi') import glob, shutil name = glob.glob('*.xpi')[0] @@ -38,15 +34,17 @@ def create_addon(files, browser): if not os.path.isdir(output_folder): os.mkdir(output_folder) - extension = 'zip' - if browser == 'firefox': - extension = 'xpi' - - output_file = os.path.join(output_folder, 'redirector-%s.%s' % (browser, extension)) + output_file = os.path.join(output_folder, 'redirector-%s.zip' % browser) zf = zipfile.ZipFile(output_file, 'w', zipfile.ZIP_STORED) - + cert = 'extension-certificate.pem' + print '' print '**** Creating addon for %s ****' % browser + + if browser == 'opera' and not os.path.exists(cert): + print 'Extension certificate does not exist, cannot create .nex file for Opera' + return + for f in files: print 'Adding', f if f.endswith('manifest.json'): @@ -55,7 +53,7 @@ def create_addon(files, browser): del manifest['applications'] #Firefox specific, and causes warnings in other browsers... if browser == 'opera': - manifest['options_ui']['page'] = 'data/redirector.html' #Opera opens options in new tab, where the popup would look really ugly + manifest['options_ui']['page'] = 'redirector.html' #Opera opens options in new tab, where the popup would look really ugly manifest['options_ui']['chrome_style'] = False zf.writestr(f[2:], json.dumps(manifest, indent=2)) @@ -64,6 +62,12 @@ def create_addon(files, browser): zf.close() + if browser == 'opera': + #Create .nex + os.system('./nex-build.sh %s %s %s' % (output_file, output_file.replace('.zip', '.nex'), cert)) + + + if __name__ == '__main__': #Make sure we can run this from anywhere folder = os.path.dirname(os.path.realpath(__file__)) -- cgit v1.2.3