1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02:00

Firefox: update manifest files when building

This commit is contained in:
Deathamns 2014-12-16 17:02:26 +01:00
parent ec69a50101
commit 45137c2be9
5 changed files with 84 additions and 81 deletions

View File

@ -1,32 +1 @@
content ublock ./
locale ublock en ./locale/en/
locale ublock ar ./locale/ar/
locale ublock cs ./locale/cs/
locale ublock da ./locale/da/
locale ublock de ./locale/de/
locale ublock el ./locale/el/
locale ublock es ./locale/es/
locale ublock et ./locale/et/
locale ublock fi ./locale/fi/
locale ublock fil ./locale/fil/
locale ublock fr ./locale/fr/
locale ublock he ./locale/he/
locale ublock hi ./locale/hi/
locale ublock hr ./locale/hr/
locale ublock hu ./locale/hu/
locale ublock id ./locale/id/
locale ublock it ./locale/it/
locale ublock ja ./locale/ja/
locale ublock mr ./locale/mr/
locale ublock nb ./locale/nb/
locale ublock nl ./locale/nl/
locale ublock pl ./locale/pl/
locale ublock pt-BR ./locale/pt-BR/
locale ublock pt-PT ./locale/pt-PT/
locale ublock ro ./locale/ro/
locale ublock ru ./locale/ru/
locale ublock sv ./locale/sv/
locale ublock tr ./locale/tr/
locale ublock uk ./locale/uk/
locale ublock vi ./locale/vi/
locale ublock zh-CN ./locale/zh-CN/
content ublock ./

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<r:RDF xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.mozilla.org/2004/em-rdf#">
<r:Description about="urn:mozilla:install-manifest">
<id>{2b10c1c8-a11f-4bad-fe9c-1c11e82cac42}</id>
<version>0.7.2.0</version>
<name>µBlock</name>
<description>Finally, an efficient blocker. Easy on CPU and memory.</description>
<id>{{2b10c1c8-a11f-4bad-fe9c-1c11e82cac42}}</id>
<version>{version}</version>
<name>{name}</name>
<description>{description}</description>
<homepageURL>https://github.com/gorhill/uBlock</homepageURL>
<creator>Raymond Hill</creator>
<creator>{author}</creator>
<type>2</type>
<bootstrap>true</bootstrap>
<multiprocessCompatible>true</multiprocessCompatible>
@ -16,7 +16,7 @@
<!-- Firefox -->
<targetApplication>
<r:Description>
<id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id>
<id>{{ec8030f7-c20a-464f-9b0e-13a3a9e97384}}</id>
<minVersion>29.0</minVersion>
<maxVersion>37.0</maxVersion>
</r:Description>
@ -25,7 +25,7 @@
<!-- SeaMonkey -->
<targetApplication>
<r:Description>
<id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</id>
<id>{{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}}</id>
<minVersion>2.26</minVersion>
<maxVersion>2.34</maxVersion>
</r:Description>

View File

@ -0,0 +1,75 @@
#!/usr/bin/env python3
import os
import json
import sys
from shutil import rmtree
from collections import OrderedDict
if not sys.argv[1]:
raise SystemExit('Build dir missing.')
def mkdirs(path):
try:
os.makedirs(path)
finally:
return os.path.exists(path)
pj = os.path.join
build_dir = os.path.abspath(sys.argv[1])
source_locale_dir = pj(build_dir, '_locales')
target_locale_dir = pj(build_dir, 'locale')
language_codes = []
description = ''
for alpha2 in os.listdir(source_locale_dir):
locale_path = pj(source_locale_dir, alpha2, 'messages.json')
with open(locale_path, encoding='utf-8') as f:
string_data = json.load(f, object_pairs_hook=OrderedDict)
if alpha2 == 'en':
description = string_data['extShortDesc']['message']
alpha2 = alpha2.replace('_', '-')
language_codes.append(alpha2)
mkdirs(pj(target_locale_dir, alpha2))
locale_path = pj(target_locale_dir, alpha2, 'messages.properties')
with open(locale_path, 'wt', encoding='utf-8', newline='\n') as f:
for string_name in string_data:
f.write(string_name)
f.write('=')
f.write(string_data[string_name]['message'].replace('\n', r'\n'))
f.write('\n')
# generate chrome.manifest file
chrome_manifest = pj(build_dir, 'chrome.manifest')
with open(chrome_manifest, 'at', encoding='utf-8', newline='\n') as f:
f.write('\n')
for alpha2 in language_codes:
f.write('locale ublock ' + alpha2 + ' ./locale/' + alpha2 + '/\n')
rmtree(source_locale_dir)
# update install.rdf
proj_dir = pj(os.path.split(os.path.abspath(__file__))[0], '..')
chromium_manifest = pj(proj_dir, 'platform', 'chromium', 'manifest.json')
with open(chromium_manifest, encoding='utf-8') as m:
manifest = json.load(m)
manifest['description'] = description
install_rdf = pj(build_dir, 'install.rdf')
with open(install_rdf, 'r+t', encoding='utf-8', newline='\n') as f:
install_rdf = f.read()
f.seek(0)
f.write(install_rdf.format(**manifest))

View File

@ -24,6 +24,6 @@ cp platform/firefox/chrome.manifest $DES/
cp platform/firefox/install.rdf $DES/
echo "*** uBlock_xpi: Generating locales"
python tools/make-locale-firefox.py $DES/
python tools/make-firefox-meta.py $DES/
echo "*** uBlock_xpi: Package done."

View File

@ -1,41 +0,0 @@
#!/usr/bin/env python3
import os
import json
import sys
from shutil import rmtree
from collections import OrderedDict
if not sys.argv[1]:
raise SystemExit('Build dir missing.')
def mkdirs(path):
try:
os.makedirs(path)
finally:
return os.path.exists(path)
build_dir = os.path.abspath(sys.argv[1])
source_locale_dir = os.path.join(build_dir, '_locales')
target_locale_dir = os.path.join(build_dir, 'locale')
for alpha2 in os.listdir(source_locale_dir):
locale_path = os.path.join(source_locale_dir, alpha2, 'messages.json')
with open(locale_path, encoding='utf-8') as f:
string_data = json.load(f, object_pairs_hook=OrderedDict)
alpha2 = alpha2.replace('_', '-')
mkdirs(os.path.join(target_locale_dir, alpha2))
locale_path = os.path.join(target_locale_dir, alpha2, 'messages.properties')
with open(locale_path, 'wt', encoding='utf-8', newline='\n') as f:
for string_name in string_data:
f.write(string_name)
f.write('=')
f.write(string_data[string_name]['message'].replace('\n', r'\n'))
f.write('\n')
rmtree(source_locale_dir)