diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /b2g/simulator | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'b2g/simulator')
-rw-r--r-- | b2g/simulator/bootstrap.js | 4 | ||||
-rw-r--r-- | b2g/simulator/build_xpi.py | 148 | ||||
-rw-r--r-- | b2g/simulator/custom-prefs.js | 8 | ||||
-rw-r--r-- | b2g/simulator/custom-settings.json | 6 | ||||
-rw-r--r-- | b2g/simulator/icon.png | bin | 0 -> 4762 bytes | |||
-rw-r--r-- | b2g/simulator/icon64.png | bin | 0 -> 7858 bytes | |||
-rw-r--r-- | b2g/simulator/install.rdf.in | 52 |
7 files changed, 218 insertions, 0 deletions
diff --git a/b2g/simulator/bootstrap.js b/b2g/simulator/bootstrap.js new file mode 100644 index 000000000..b728caa3d --- /dev/null +++ b/b2g/simulator/bootstrap.js @@ -0,0 +1,4 @@ +function startup(data, reason) {} +function shutdown(data, reason) {} +function install(data, reason) {} +function uninstall(data, reason) {} diff --git a/b2g/simulator/build_xpi.py b/b2g/simulator/build_xpi.py new file mode 100644 index 000000000..392be09b2 --- /dev/null +++ b/b2g/simulator/build_xpi.py @@ -0,0 +1,148 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Generate xpi for the simulator addon by: +# - building a special gaia profile for it, as we need: +# * more languages, and, +# * less apps +# than b2g desktop's one +# - retrieve usefull app version metadata from the build system +# - finally, use addon sdk's cfx tool to build the addon xpi +# that ships: +# * b2g desktop runtime +# * gaia profile + +import sys, os, re, subprocess +from mozbuild.preprocessor import Preprocessor +from mozbuild.base import MozbuildObject +from mozbuild.util import ensureParentDir +from mozpack.mozjar import JarWriter +from zipfile import ZipFile +from distutils.version import LooseVersion + +ftp_root_path = "/pub/mozilla.org/labs/fxos-simulator" +UPDATE_URL = "https://ftp.mozilla.org" + ftp_root_path + "/%(update_path)s/update.rdf" +XPI_NAME = "fxos-simulator-%(version)s-%(platform)s.xpi" + +class GaiaBuilder(object): + def __init__(self, build, gaia_path): + self.build = build + self.gaia_path = gaia_path + + def clean(self): + self.build._run_make(target="clean", directory=self.gaia_path) + + def profile(self, env): + self.build._run_make(target="profile", directory=self.gaia_path, num_jobs=1, silent=False, append_env=env) + + def override_prefs(self, srcfile): + # Note that each time we call `make profile` in gaia, a fresh new pref file is created + # cat srcfile >> profile/user.js + with open(os.path.join(self.gaia_path, "profile", "user.js"), "a") as userJs: + userJs.write(open(srcfile).read()) + +def preprocess_file(src, dst, version, app_buildid, update_url): + ensureParentDir(dst) + + defines = { + "ADDON_ID": "fxos_" + version.replace(".", "_") + "_simulator@mozilla.org", + # (reduce the app build id to only the build date + # as addon manager doesn't handle big ints in addon versions) + "ADDON_VERSION": ("%s.%s" % (version, app_buildid[:8])), + "ADDON_NAME": "Firefox OS " + version + " Simulator", + "ADDON_DESCRIPTION": "a Firefox OS " + version + " simulator", + "ADDON_UPDATE_URL": update_url + } + pp = Preprocessor(defines=defines) + pp.do_filter("substitution") + with open(dst, "w") as output: + with open(src, "r") as input: + pp.processFile(input=input, output=output) + +def add_dir_to_zip(jar, top, pathInZip, blacklist=()): + for dirpath, subdirs, files in os.walk(top): + dir_relpath = os.path.relpath(dirpath, top) + if dir_relpath.startswith(blacklist): + continue + for filename in files: + relpath = os.path.join(dir_relpath, filename) + if relpath in blacklist: + continue + path = os.path.normpath(os.path.join(pathInZip, relpath)) + file = open(os.path.join(dirpath, filename), "rb") + mode = os.stat(os.path.join(dirpath, filename)).st_mode + jar.add(path.encode("ascii"), file, mode=mode) + +def add_file_to_zip(jar, path, pathInZip): + file = open(path, "rb") + mode = os.stat(path).st_mode + jar.add(pathInZip.encode("ascii"), file, mode=mode) + +def main(platform): + build = MozbuildObject.from_environment() + topsrcdir = build.topsrcdir + distdir = build.distdir + + srcdir = os.path.join(topsrcdir, "b2g", "simulator") + + app_buildid = open(os.path.join(build.topobjdir, "config", "buildid")).read().strip() + + # The simulator uses a shorter version string, + # it only keeps the major version digits A.B + # whereas MOZ_B2G_VERSION is A.B.C.D + b2g_version = build.config_environment.defines["MOZ_B2G_VERSION"].replace('"', '') + version = ".".join(str(n) for n in LooseVersion(b2g_version).version[0:2]) + + # Build a gaia profile specific to the simulator in order to: + # - disable the FTU + # - set custom prefs to enable devtools debugger server + # - set custom settings to disable lockscreen and screen timeout + # - only ship production apps + gaia_path = build.config_environment.substs["GAIADIR"] + builder = GaiaBuilder(build, gaia_path) + builder.clean() + env = { + "NOFTU": "1", + "GAIA_APP_TARGET": "production", + "SETTINGS_PATH": os.path.join(srcdir, "custom-settings.json") + } + builder.profile(env) + builder.override_prefs(os.path.join(srcdir, "custom-prefs.js")) + + # Build the simulator addon xpi + xpi_name = XPI_NAME % {"version": version, "platform": platform} + xpi_path = os.path.join(distdir, xpi_name) + + update_path = "%s/%s" % (version, platform) + update_url = UPDATE_URL % {"update_path": update_path} + + # Preprocess some files... + manifest = os.path.join(build.topobjdir, "b2g", "simulator", "install.rdf") + preprocess_file(os.path.join(srcdir, "install.rdf.in"), + manifest, + version, + app_buildid, + update_url) + + with JarWriter(xpi_path, optimize=False) as zip: + # Ship addon files into the .xpi + add_file_to_zip(zip, manifest, "install.rdf") + add_file_to_zip(zip, os.path.join(srcdir, "bootstrap.js"), "bootstrap.js") + add_file_to_zip(zip, os.path.join(srcdir, "icon.png"), "icon.png") + add_file_to_zip(zip, os.path.join(srcdir, "icon64.png"), "icon64.png") + + # Ship b2g-desktop, but prevent its gaia profile to be shipped in the xpi + add_dir_to_zip(zip, os.path.join(distdir, "b2g"), "b2g", + ("gaia", "B2G.app/Contents/MacOS/gaia", + "B2G.app/Contents/Resources/gaia")) + # Then ship our own gaia profile + add_dir_to_zip(zip, os.path.join(gaia_path, "profile"), "profile") + +if __name__ == '__main__': + if 2 != len(sys.argv): + print("""Usage: + python {0} MOZ_PKG_PLATFORM +""".format(sys.argv[0])) + sys.exit(1) + main(*sys.argv[1:]) diff --git a/b2g/simulator/custom-prefs.js b/b2g/simulator/custom-prefs.js new file mode 100644 index 000000000..634a9cebe --- /dev/null +++ b/b2g/simulator/custom-prefs.js @@ -0,0 +1,8 @@ +user_pref("devtools.debugger.prompt-connection", false); +user_pref("devtools.debugger.forbid-certified-apps", false); +user_pref("devtools.apps.forbidden-permissions", ""); +user_pref("b2g.software-buttons", true); + +// Required for Mulet in order to run the debugger server from the command line +user_pref("devtools.debugger.remote-enabled", true); +user_pref("devtools.chrome.enabled", true); diff --git a/b2g/simulator/custom-settings.json b/b2g/simulator/custom-settings.json new file mode 100644 index 000000000..ea0264d9a --- /dev/null +++ b/b2g/simulator/custom-settings.json @@ -0,0 +1,6 @@ +{ + "debugger.remote-mode": "adb-devtools", + "screen.timeout": 0, + "lockscreen.enabled": false, + "lockscreen.locked": false +} diff --git a/b2g/simulator/icon.png b/b2g/simulator/icon.png Binary files differnew file mode 100644 index 000000000..c4307fc84 --- /dev/null +++ b/b2g/simulator/icon.png diff --git a/b2g/simulator/icon64.png b/b2g/simulator/icon64.png Binary files differnew file mode 100644 index 000000000..275cd04a5 --- /dev/null +++ b/b2g/simulator/icon64.png diff --git a/b2g/simulator/install.rdf.in b/b2g/simulator/install.rdf.in new file mode 100644 index 000000000..e9827d084 --- /dev/null +++ b/b2g/simulator/install.rdf.in @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- This Source Code Form is subject to the terms of the Mozilla Public + - License, v. 2.0. If a copy of the MPL was not distributed with this + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#"> + <Description about="urn:mozilla:install-manifest"> + <em:id>@ADDON_ID@</em:id> + <em:version>@ADDON_VERSION@</em:version> + <em:type>2</em:type> + <em:bootstrap>true</em:bootstrap> + <em:unpack>true</em:unpack> + + <!-- Firefox --> + <em:targetApplication> + <Description> + <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> + <em:minVersion>44.0a1</em:minVersion> + <em:maxVersion>45.0</em:maxVersion> + </Description> + </em:targetApplication> + + <!-- Front End MetaData --> + <em:name>@ADDON_NAME@</em:name> + <em:description>@ADDON_DESCRIPTION@</em:description> + <em:creator>Myk Melez (https://github.com/mykmelez)</em:creator> + + <em:optionsType>2</em:optionsType> + + <em:updateURL>@ADDON_UPDATE_URL@</em:updateURL> + + <em:contributor>Alexandre Poirot (https://github.com/ochameau)</em:contributor> + <em:contributor>Anant Narayanan (https://github.com/anantn)</em:contributor> + <em:contributor>Brandon Kase (https://github.com/bkase)</em:contributor> + <em:contributor>Breck Yunits (https://github.com/breck7)</em:contributor> + <em:contributor>César Carruitero (https://github.com/ccarruitero)</em:contributor> + <em:contributor>David Gomes (https://github.com/davidgomes)</em:contributor> + <em:contributor>Fabrice Desré (https://github.com/fabricedesre)</em:contributor> + <em:contributor>Fraser Tweedale (https://github.com/frasertweedale)</em:contributor> + <em:contributor>Harald Kirschner (https://github.com/digitarald)</em:contributor> + <em:contributor>Jérémie Patonnier (https://github.com/JeremiePat)</em:contributor> + <em:contributor>J. Ryan Stinnett (https://github.com/jryans)</em:contributor> + <em:contributor>Kan-Ru Chen (陳侃如) (https://github.com/kanru)</em:contributor> + <em:contributor>Louis Stowasser (https://github.com/louisstow)</em:contributor> + <em:contributor>Luca Greco (https://github.com/rpl)</em:contributor> + <em:contributor>Matthew Claypotch (https://github.com/potch)</em:contributor> + <em:contributor>Matthew Riley MacPherson (https://github.com/tofumatt)</em:contributor> + <em:contributor>Nick Desaulniers (https://github.com/nickdesaulniers)</em:contributor> + <em:contributor>Soumen Ganguly (https://github.com/SoumenG)</em:contributor> + <em:contributor>Sudheesh Singanamalla (https://github.com/sudheesh001)</em:contributor> + <em:contributor>Victor Bjelkholm (https://github.com/VictorBjelkholm)</em:contributor> + </Description> +</RDF> |