├── .gitignore ├── lib ├── prefs.json ├── l10n.js ├── notification.js ├── urlShortener.js ├── main.js └── server.js ├── chrome.manifest ├── dependencies ├── chrome ├── locale │ └── en-US │ │ ├── settings.dtd │ │ ├── meta.properties │ │ └── messages.properties └── content │ └── settings.xul ├── metadata.gecko ├── README.md ├── ensure_dependencies.py └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.xpi 2 | *.zip 3 | *.pyc 4 | *.sh 5 | -------------------------------------------------------------------------------- /lib/prefs.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaults": { 3 | "serverPort": 8888, 4 | "allowedIPs": "127.0.0.1" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /chrome.manifest: -------------------------------------------------------------------------------- 1 | content autoinstaller chrome/content/ 2 | locale autoinstaller {{LOCALE}} chrome/locale/{{LOCALE}}/ 3 | -------------------------------------------------------------------------------- /dependencies: -------------------------------------------------------------------------------- 1 | _root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/ 2 | _self = buildtools/ensure_dependencies.py 3 | buildtools = buildtools hg:822863fb5df6 git:a0cd489 4 | -------------------------------------------------------------------------------- /chrome/locale/en-US/settings.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /chrome/locale/en-US/meta.properties: -------------------------------------------------------------------------------- 1 | # Translator of this locale, separate by commas if multiple 2 | translator=Wladimir Palant 3 | # Extension title, usually it shouldn't be translated 4 | name=Extension Auto-Installer 5 | # Extension description, to be displayed in the add-on manager 6 | description=Listens to new connections on a port and automatically installs extension packages received on this port. 7 | -------------------------------------------------------------------------------- /metadata.gecko: -------------------------------------------------------------------------------- 1 | [general] 2 | id=autoinstaller@adblockplus.org 3 | basename=autoinstaller 4 | version=1.3 5 | author=Wladimir Palant 6 | options=chrome://autoinstaller/content/settings.xul 7 | optionsType=2 8 | 9 | [homepage] 10 | default=https://github.com/palant/autoinstaller 11 | 12 | [compat] 13 | toolkit=45.0/57.0 14 | firefox=45.0/57.0 15 | fennec2=45.0/57.0 16 | thunderbird=45.0/57.0 17 | seamonkey=2.42/2.54 18 | -------------------------------------------------------------------------------- /chrome/content/settings.xul: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | &serverPort.description; 11 | &allowedIPs.description; 12 | 13 | -------------------------------------------------------------------------------- /chrome/locale/en-US/messages.properties: -------------------------------------------------------------------------------- 1 | title=Extension Auto-Installer 2 | 3 | iprejected_error=Add-on installation attempt from {0} rejected, not in the list of allowed IP addresses. 4 | read_error=Failed reading data from incoming connection (error code {0}). 5 | missingheader_error=Data received from incoming connection doesn't seem to be an HTTP request. 6 | missingbody_error=No POST data received from incoming connection. 7 | 8 | unsigned_error=Installation failed due to signing requirements. Install as a temporary unsigned add-on? 9 | unsigned_action=Install as temporary add-on 10 | download_error=Add-on download failed (error code {0}). 11 | installation_error=Add-on installation failed (error code {0}). 12 | tempinstall_error=Instalation of temporary add-on failed: {0} 13 | -------------------------------------------------------------------------------- /lib/l10n.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code is subject to the terms of the Mozilla Public License 3 | * version 2.0 (the "License"). You can obtain a copy of the License at 4 | * http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); 8 | Services.strings.flushBundles(); 9 | let bundle = Services.strings.createBundle("chrome://autoinstaller/locale/messages.properties"); 10 | 11 | function getMessage(name, ...params) 12 | { 13 | if (name instanceof Array) 14 | return getMessage(...name); 15 | 16 | let string = bundle.GetStringFromName(name); 17 | if (params.length) 18 | string = string.replace(/\{(\d+)\}/g, match => params[match[1]]); 19 | return string; 20 | } 21 | 22 | exports.getMessage = getMessage; 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Extension Auto-Installer (DEPRECATED!) 2 | ====================================== 3 | 4 | **IMPORTANT**: This extension is deprecated, it will not work in Firefox 57 and above. Providing comparable functionality in newer Firefox versions isn't possible. 5 | 6 | Extension Auto-Installer is a helper for Firefox/SeaMonkey/Thunderbird extension developers: it allows automatically adding or updating browser extensions, e.g. via command line tools. This makes testing your changes easier. [Detailed description](https://palant.de/2012/01/13/extension-auto-installer) 7 | 8 | Prerequisites 9 | ------------- 10 | * [Python 2.7](https://www.python.org/downloads/) 11 | * [Jinja2 module for Python](http://jinja.pocoo.org/docs/intro/#installation) 12 | 13 | How to build 14 | ------------ 15 | 16 | Run the following command: 17 | 18 | python build.py build 19 | 20 | This will create a development build with the file name like `autoinstaller-1.2.3.nnnn.xpi`. In order to create a release build use the following command: 21 | 22 | python build.py build --release 23 | 24 | How to test 25 | ----------- 26 | 27 | Testing your changes is easiest if you already have Extension Auto-Installer installed, e.g. the [stable version](https://addons.mozilla.org/addon/autoinstaller/). Then you can push the current repository state to your browser using the following command: 28 | 29 | python build.py autoinstall 8888 30 | 31 | Extension Auto-Installer will be updated automatically, without any prompts or browser restarts. 32 | -------------------------------------------------------------------------------- /lib/notification.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code is subject to the terms of the Mozilla Public License 3 | * version 2.0 (the "License"). You can obtain a copy of the License at 4 | * http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); 8 | 9 | function display(text, action) 10 | { 11 | let l10n = require("l10n"); 12 | text = l10n.getMessage(text); 13 | if (action) 14 | action = l10n.getMessage(action); 15 | 16 | return new Promise((resolve, reject) => 17 | { 18 | let window = Services.wm.getMostRecentWindow("navigator:browser"); 19 | if (window && window.PopupNotifications && window.PopupNotifications.show && 20 | window.gBrowser && window.gBrowser.selectedBrowser) 21 | { 22 | let browser = window.gBrowser.selectedBrowser; 23 | let button = null; 24 | if (action) 25 | { 26 | button = { 27 | label: action, 28 | accessKey: action[0], 29 | callback: () => resolve(true) 30 | }; 31 | } 32 | window.PopupNotifications.show(browser, "autoinstaller-notification", text, null, button, null, { 33 | persistence: 1000, 34 | removeOnDismissal: true, 35 | displayURI: {hostPort: l10n.getMessage("title")}, 36 | eventCallback: state => state == "removed" && resolve(false) 37 | }); 38 | } 39 | else 40 | { 41 | try 42 | { 43 | let alertsService = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService); 44 | alertsService.showAlertNotification(null, l10n.getMessage("title"), text, true, null, { 45 | observe: (subject, topic, data) => 46 | { 47 | if (topic == "alertclickcallback") 48 | resolve(true); 49 | else if (topic == "alertfinished") 50 | resolve(false); 51 | } 52 | }, "autoinstaller-notification"); 53 | } 54 | catch (e) 55 | { 56 | Cu.reportError(e); 57 | Cu.reportError("Extension Auto-Installer failed to display notification: " + text); 58 | resolve(false); 59 | } 60 | } 61 | }); 62 | } 63 | 64 | exports.display = display; 65 | -------------------------------------------------------------------------------- /lib/urlShortener.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code is subject to the terms of the Mozilla Public License 3 | * version 2.0 (the "License"). You can obtain a copy of the License at 4 | * http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | Cu.import("resource://gre/modules/Services.jsm"); 8 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 9 | 10 | let handler = 11 | { 12 | classDescription: "install-shortener: protocol handler", 13 | get contractID() 14 | { 15 | return "@mozilla.org/network/protocol;1?name=" + this.scheme 16 | }, 17 | classID: Components.ID("{6886f820-98f9-11e1-a8b0-0800200c9a66}"), 18 | 19 | init: function() 20 | { 21 | let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 22 | registrar.registerFactory(this.classID, this.classDescription, this.contractID, this); 23 | onShutdown.add((function() 24 | { 25 | registrar.unregisterFactory(this.classID, this); 26 | }).bind(this)); 27 | }, 28 | 29 | getShortURL: function(url) 30 | { 31 | return this.scheme + ":" + (this.urls.push(url) - 1); 32 | }, 33 | 34 | createInstance: function(outer, iid) 35 | { 36 | if (outer) 37 | throw Cr.NS_ERROR_NO_AGGREGATION; 38 | return this.QueryInterface(iid); 39 | }, 40 | 41 | urls: [], 42 | scheme: "install-shortener", 43 | defaultPort: -1, 44 | protocolFlags: 45 | Ci.nsIProtocolHandler.URI_NORELATIVE | 46 | Ci.nsIProtocolHandler.URI_NOAUTH | 47 | Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD | 48 | Ci.nsIProtocolHandler.URI_NON_PERSISTABLE | 49 | Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE, 50 | 51 | newURI: function(spec, originCharset, baseURI) 52 | { 53 | let uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI); 54 | uri.spec = spec; 55 | return uri; 56 | }, 57 | 58 | newChannel: function(uri) 59 | { 60 | return this.newChannel2(uri, null); 61 | }, 62 | 63 | newChannel2: function(uri, loadInfo) 64 | { 65 | if (!/^\d+$/.test(uri.path)) 66 | throw Cr.NS_ERROR_FAILURE; 67 | 68 | let index = parseInt(uri.path, 10); 69 | let result = this.urls[index]; 70 | if (typeof result == "undefined") 71 | throw Cr.NS_ERROR_FAILURE; 72 | 73 | delete this.urls[index]; 74 | result = Services.io.newURI(result, null, null); 75 | 76 | let channel; 77 | if (loadInfo) 78 | channel = Services.io.newChannelFromURIWithLoadInfo(result, loadInfo); 79 | else 80 | channel = Services.io.newChannelFromURI(result); 81 | channel.originalURI = uri; 82 | return channel; 83 | }, 84 | 85 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler, Ci.nsIFactory]) 86 | }; 87 | 88 | handler.init(); 89 | 90 | exports.getShortURL = handler.getShortURL.bind(handler); 91 | -------------------------------------------------------------------------------- /lib/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code is subject to the terms of the Mozilla Public License 3 | * version 2.0 (the "License"). You can obtain a copy of the License at 4 | * http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | let {Prefs} = require("prefs"); 8 | let {Server} = require("server"); 9 | let notification = require("notification"); 10 | 11 | // Init server and make sure to react to pref changes. 12 | let server = new Server(Prefs.serverPort, Prefs.allowedIPs, installAddon); 13 | 14 | Prefs.addListener(function(name) 15 | { 16 | if (name == "serverPort") 17 | server.setPort(Prefs.serverPort); 18 | else if (name == "allowedIPs") 19 | server.setAllowedIPs(Prefs.allowedIPs); 20 | }); 21 | onShutdown.add(() => server.setPort(0)); 22 | 23 | function installAddon(data) 24 | { 25 | let {AddonManager} = Cu.import("resource://gre/modules/AddonManager.jsm", {}); 26 | 27 | // Addon manager stores the source URL in the database. Use custom protocol 28 | // to "shorten" these URLs, otherwise the database will get big and slow. 29 | let url = require("urlShortener").getShortURL("data:application/x-xpinstall," + escape(data)); 30 | AddonManager.getInstallForURL(url, function(install) 31 | { 32 | install.addListener({ 33 | onInstallEnded: function(install, addon) 34 | { 35 | install.removeListener(this); 36 | 37 | if (addon.pendingOperations) 38 | { 39 | // Need to restart browser 40 | Cc["@mozilla.org/toolkit/app-startup;1"] 41 | .getService(Ci.nsIAppStartup) 42 | .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); 43 | } 44 | }, 45 | onDownloadFailed: function(install) 46 | { 47 | install.removeListener(this); 48 | if (install.error == AddonManager.ERROR_SIGNEDSTATE_REQUIRED) 49 | { 50 | notification.display("unsigned_error", "unsigned_action").then(installAsTemporary => 51 | { 52 | if (installAsTemporary) 53 | installTemporaryAddon(data); 54 | }); 55 | } 56 | else 57 | notification.display(["download_error", install.error]); 58 | }, 59 | onInstallFailed: function(install) 60 | { 61 | install.removeListener(this); 62 | notification.display(["installation_error", install.error]); 63 | } 64 | }); 65 | install.install(); 66 | }, "application/x-xpinstall"); 67 | } 68 | 69 | function installTemporaryAddon(data) 70 | { 71 | let {AddonManager} = Cu.import("resource://gre/modules/AddonManager.jsm", {}); 72 | let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {}); 73 | let {OS} = Cu.import("resource://gre/modules/osfile.jsm", {}); 74 | let {AsyncShutdown} = Cu.import("resource://gre/modules/AsyncShutdown.jsm", {}); 75 | 76 | let temppath = null; 77 | OS.File.openUnique(OS.Path.join(OS.Constants.Path.tmpDir, "ai-temp.xpi")).then(({file, path}) => 78 | { 79 | temppath = path; 80 | let buffer = new Uint8Array(data.length); 81 | for (let i = 0; i < data.length; i++) 82 | buffer[i] = data.charCodeAt(i); 83 | return file.write(buffer).then(bytes => file); 84 | }).then(file => 85 | { 86 | return file.close(); 87 | }).then(() => 88 | { 89 | return AddonManager.installTemporaryAddon(new FileUtils.File(temppath)); 90 | }).then(() => 91 | { 92 | // We are leaking this cleanup handler on purpose, it needs to stay around 93 | // even if Auto-Installer is updated. 94 | AsyncShutdown.profileChangeTeardown.addBlocker( 95 | "Extension Auto-Installer: remove temporary file " + Math.random() + Date.now(), 96 | () => OS.File.remove(temppath).catch(e => {}) 97 | ); 98 | }).catch(e => 99 | { 100 | Cu.reportError(e); 101 | notification.display(["tempinstall_error", e]); 102 | return temppath ? OS.File.remove(temppath).catch(e => {}) : undefined; 103 | }); 104 | } 105 | -------------------------------------------------------------------------------- /lib/server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This Source Code is subject to the terms of the Mozilla Public License 3 | * version 2.0 (the "License"). You can obtain a copy of the License at 4 | * http://mozilla.org/MPL/2.0/. 5 | */ 6 | 7 | let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); 8 | let {NetUtil} = Cu.import("resource://gre/modules/NetUtil.jsm", {}); 9 | 10 | let notification = require("notification"); 11 | 12 | function Server(port, allowedIPs, callback) 13 | { 14 | this.port = port; 15 | this._setAllowedIPs(allowedIPs); 16 | this.callback = callback; 17 | this._reinitSocket(); 18 | } 19 | 20 | Server.prototype = 21 | { 22 | socket: null, 23 | port: 0, 24 | loopbackOnly: false, 25 | allowedIPs: null, 26 | callback: null, 27 | timer: null, 28 | 29 | _reinitSocket: function() 30 | { 31 | if (this.socket) 32 | { 33 | try 34 | { 35 | this.socket.close(); 36 | } 37 | catch (e) 38 | { 39 | Cu.reportError(e); 40 | } 41 | this.socket = null; 42 | } 43 | 44 | if (this.port) 45 | { 46 | try 47 | { 48 | this.socket = Cc["@mozilla.org/network/server-socket;1"].createInstance(Ci.nsIServerSocket); 49 | this.socket.init(this.port, this.loopbackOnly, -1); 50 | this.socket.asyncListen(this); 51 | } 52 | catch (e) 53 | { 54 | this.socket = null; 55 | Cu.reportError(e); 56 | } 57 | } 58 | }, 59 | 60 | setPort: function(port) 61 | { 62 | if (this.port == port) 63 | return; 64 | 65 | this.port = port; 66 | this._reinitSocket(); 67 | }, 68 | 69 | _setAllowedIPs: function(string) 70 | { 71 | this.allowedIPs = {}; 72 | this.loopbackOnly = true; 73 | let ips = string.split(/[\s,]+/); 74 | for (let i = 0; i < ips.length; i++) 75 | { 76 | if (ips[i]) 77 | { 78 | this.allowedIPs[ips[i]] = true; 79 | if (!/^127\./.test(ips[i]) && ips[i] != "::1") 80 | this.loopbackOnly = false 81 | } 82 | } 83 | }, 84 | 85 | setAllowedIPs: function(string) 86 | { 87 | let oldLoopbackOnly = this.loopbackOnly; 88 | this._setAllowedIPs(string); 89 | if (oldLoopbackOnly != this.loopbackOnly) 90 | this._reinitSocket(); 91 | }, 92 | 93 | onSocketAccepted: function(server, transport) 94 | { 95 | if (!(transport.host in this.allowedIPs)) 96 | { 97 | notification.display(["iprejected_error", transport.host]); 98 | transport.close(Cr.NS_ERROR_FAILURE); 99 | return; 100 | } 101 | 102 | let response = "HTTP/1.1 399 No Content\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"; 103 | let responseStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); 104 | responseStream.setData(response, response.length); 105 | NetUtil.asyncCopy(responseStream, transport.openOutputStream(transport.OPEN_UNBUFFERED, 0, 0)); 106 | 107 | NetUtil.asyncFetch(transport.openInputStream(0, 0, 0), (inputStream, result) => { 108 | if (!Components.isSuccessCode(result)) 109 | { 110 | notification.display(["read_error", result.toString(16)]); 111 | return; 112 | } 113 | 114 | let binaryStream = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream); 115 | binaryStream.setInputStream(inputStream); 116 | 117 | let data = binaryStream.readBytes(binaryStream.available()); 118 | binaryStream.close(); 119 | 120 | if (!/\r?\n\r?\n/.test(data)) 121 | { 122 | notification.display("missingheader_error"); 123 | return; 124 | } 125 | 126 | data = data.replace(/[\x00-\xFF]*?\r?\n\r?\n/, ""); 127 | if (!data.length) 128 | { 129 | notification.display("missingbody_error"); 130 | return; 131 | } 132 | 133 | this.callback(data); 134 | }); 135 | }, 136 | 137 | onStopListening: function(server, status) 138 | { 139 | if (status != Components.results.NS_BINDING_ABORTED && !this.timer) 140 | { 141 | // Attempt to reconnect after 10 seconds 142 | this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); 143 | this.timer.initWithCallback(() => { 144 | this.timer = null; 145 | if (!this.socket || this.socket == server) 146 | this._reinitSocket(); 147 | }, 10000, Ci.nsITimer.TYPE_ONE_SHOT); 148 | } 149 | }, 150 | 151 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIServerSocketListener]) 152 | }; 153 | 154 | exports.Server = Server; 155 | -------------------------------------------------------------------------------- /ensure_dependencies.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This Source Code Form is subject to the terms of the Mozilla Public 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | import sys 8 | import os 9 | import posixpath 10 | import re 11 | import io 12 | import errno 13 | import logging 14 | import subprocess 15 | import urlparse 16 | import argparse 17 | 18 | from collections import OrderedDict 19 | from ConfigParser import RawConfigParser 20 | 21 | USAGE = ''' 22 | A dependencies file should look like this: 23 | 24 | # VCS-specific root URLs for the repositories 25 | _root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/ 26 | # File to update this script from (optional) 27 | _self = buildtools/ensure_dependencies.py 28 | # Clone elemhidehelper repository into extensions/elemhidehelper directory at 29 | # tag "1.2". 30 | extensions/elemhidehelper = elemhidehelper 1.2 31 | # Clone buildtools repository into buildtools directory at VCS-specific 32 | # revision IDs. 33 | buildtools = buildtools hg:016d16f7137b git:f3f8692f82e5 34 | # Clone the adblockplus repository into adblockplus directory, overwriting the 35 | # usual source URL for Git repository and specifying VCS specific revision IDs. 36 | adblockplus = adblockplus hg:893426c6a6ab git:git@github.com:user/adblockplus.git@b2ffd52b 37 | # Clone the adblockpluschrome repository into the adblockpluschrome directory, 38 | # from a specific Git repository, specifying the revision ID. 39 | adblockpluschrome = git:git@github.com:user/adblockpluschrome.git@1fad3a7 40 | ''' 41 | 42 | SKIP_DEPENDENCY_UPDATES = os.environ.get( 43 | 'SKIP_DEPENDENCY_UPDATES', '' 44 | ).lower() not in ('', '0', 'false') 45 | 46 | 47 | class Mercurial(): 48 | def istype(self, repodir): 49 | return os.path.exists(os.path.join(repodir, '.hg')) 50 | 51 | def clone(self, source, target): 52 | if not source.endswith('/'): 53 | source += '/' 54 | subprocess.check_call(['hg', 'clone', '--quiet', '--noupdate', source, target]) 55 | 56 | def get_revision_id(self, repo, rev=None): 57 | command = ['hg', 'id', '--repository', repo, '--id'] 58 | if rev: 59 | command.extend(['--rev', rev]) 60 | 61 | # Ignore stderr output and return code here: if revision lookup failed we 62 | # should simply return an empty string. 63 | result = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] 64 | return result.strip() 65 | 66 | def pull(self, repo): 67 | subprocess.check_call(['hg', 'pull', '--repository', repo, '--quiet']) 68 | 69 | def update(self, repo, rev, revname): 70 | subprocess.check_call(['hg', 'update', '--repository', repo, '--quiet', '--check', '--rev', rev]) 71 | 72 | def ignore(self, target, repo): 73 | 74 | if not self.istype(target): 75 | 76 | config_path = os.path.join(repo, '.hg', 'hgrc') 77 | ignore_path = os.path.abspath(os.path.join(repo, '.hg', 'dependencies')) 78 | 79 | config = RawConfigParser() 80 | config.read(config_path) 81 | 82 | if not config.has_section('ui'): 83 | config.add_section('ui') 84 | 85 | config.set('ui', 'ignore.dependencies', ignore_path) 86 | with open(config_path, 'w') as stream: 87 | config.write(stream) 88 | 89 | module = os.path.relpath(target, repo) 90 | _ensure_line_exists(ignore_path, module) 91 | 92 | def postprocess_url(self, url): 93 | return url 94 | 95 | 96 | class Git(): 97 | def istype(self, repodir): 98 | return os.path.exists(os.path.join(repodir, '.git')) 99 | 100 | def clone(self, source, target): 101 | source = source.rstrip('/') 102 | if not source.endswith('.git'): 103 | source += '.git' 104 | subprocess.check_call(['git', 'clone', '--quiet', source, target]) 105 | 106 | def get_revision_id(self, repo, rev='HEAD'): 107 | command = ['git', 'rev-parse', '--revs-only', rev + '^{commit}'] 108 | return subprocess.check_output(command, cwd=repo).strip() 109 | 110 | def pull(self, repo): 111 | # Fetch tracked branches, new tags and the list of available remote branches 112 | subprocess.check_call(['git', 'fetch', '--quiet', '--all', '--tags'], cwd=repo) 113 | # Next we need to ensure all remote branches are tracked 114 | newly_tracked = False 115 | remotes = subprocess.check_output(['git', 'branch', '--remotes'], cwd=repo) 116 | for match in re.finditer(r'^\s*(origin/(\S+))$', remotes, re.M): 117 | remote, local = match.groups() 118 | with open(os.devnull, 'wb') as devnull: 119 | if subprocess.call(['git', 'branch', '--track', local, remote], 120 | cwd=repo, stdout=devnull, stderr=devnull) == 0: 121 | newly_tracked = True 122 | # Finally fetch any newly tracked remote branches 123 | if newly_tracked: 124 | subprocess.check_call(['git', 'fetch', '--quiet', 'origin'], cwd=repo) 125 | 126 | def update(self, repo, rev, revname): 127 | subprocess.check_call(['git', 'checkout', '--quiet', revname], cwd=repo) 128 | 129 | def ignore(self, target, repo): 130 | module = os.path.sep + os.path.relpath(target, repo) 131 | exclude_file = os.path.join(repo, '.git', 'info', 'exclude') 132 | _ensure_line_exists(exclude_file, module) 133 | 134 | def postprocess_url(self, url): 135 | # Handle alternative syntax of SSH URLS 136 | if '@' in url and ':' in url and not urlparse.urlsplit(url).scheme: 137 | return 'ssh://' + url.replace(':', '/', 1) 138 | return url 139 | 140 | repo_types = OrderedDict(( 141 | ('hg', Mercurial()), 142 | ('git', Git()), 143 | )) 144 | 145 | # [vcs:]value 146 | item_regexp = re.compile( 147 | '^(?:(' + '|'.join(map(re.escape, repo_types.keys())) + '):)?' 148 | '(.+)$' 149 | ) 150 | 151 | # [url@]rev 152 | source_regexp = re.compile( 153 | '^(?:(.*)@)?' 154 | '(.+)$' 155 | ) 156 | 157 | 158 | def merge_seqs(seq1, seq2): 159 | """Return a list of any truthy values from the suplied sequences 160 | 161 | (None, 2), (1,) => [1, 2] 162 | None, (1, 2) => [1, 2] 163 | (1, 2), (3, 4) => [3, 4] 164 | """ 165 | return map(lambda item1, item2: item2 or item1, seq1 or (), seq2 or ()) 166 | 167 | 168 | def parse_spec(path, line): 169 | if '=' not in line: 170 | logging.warning('Invalid line in file %s: %s' % (path, line)) 171 | return None, None 172 | 173 | key, value = line.split('=', 1) 174 | key = key.strip() 175 | items = value.split() 176 | if not len(items): 177 | logging.warning('No value specified for key %s in file %s' % (key, path)) 178 | return key, None 179 | 180 | result = OrderedDict() 181 | is_dependency_field = not key.startswith('_') 182 | 183 | for i, item in enumerate(items): 184 | try: 185 | vcs, value = re.search(item_regexp, item).groups() 186 | vcs = vcs or '*' 187 | if is_dependency_field: 188 | if i == 0 and vcs == '*': 189 | # In order to be backwards compatible we have to assume that the first 190 | # source contains only a URL/path for the repo if it does not contain 191 | # the VCS part 192 | url_rev = (value, None) 193 | else: 194 | url_rev = re.search(source_regexp, value).groups() 195 | result[vcs] = merge_seqs(result.get(vcs), url_rev) 196 | else: 197 | if vcs in result: 198 | logging.warning('Ignoring duplicate value for type %r ' 199 | '(key %r in file %r)' % (vcs, key, path)) 200 | result[vcs] = value 201 | except AttributeError: 202 | logging.warning('Ignoring invalid item %r for type %r ' 203 | '(key %r in file %r)' % (item, vcs, key, path)) 204 | continue 205 | return key, result 206 | 207 | 208 | def read_deps(repodir): 209 | result = {} 210 | deps_path = os.path.join(repodir, 'dependencies') 211 | try: 212 | with io.open(deps_path, 'rt', encoding='utf-8') as handle: 213 | for line in handle: 214 | # Remove comments and whitespace 215 | line = re.sub(r'#.*', '', line).strip() 216 | if not line: 217 | continue 218 | 219 | key, spec = parse_spec(deps_path, line) 220 | if spec: 221 | result[key] = spec 222 | return result 223 | except IOError, e: 224 | if e.errno != errno.ENOENT: 225 | raise 226 | return None 227 | 228 | 229 | def safe_join(path, subpath): 230 | # This has been inspired by Flask's safe_join() function 231 | forbidden = {os.sep, os.altsep} - {posixpath.sep, None} 232 | if any(sep in subpath for sep in forbidden): 233 | raise Exception('Illegal directory separator in dependency path %s' % subpath) 234 | 235 | normpath = posixpath.normpath(subpath) 236 | if posixpath.isabs(normpath): 237 | raise Exception('Dependency path %s cannot be absolute' % subpath) 238 | if normpath == posixpath.pardir or normpath.startswith(posixpath.pardir + posixpath.sep): 239 | raise Exception('Dependency path %s has to be inside the repository' % subpath) 240 | return os.path.join(path, *normpath.split(posixpath.sep)) 241 | 242 | 243 | def get_repo_type(repo): 244 | for name, repotype in repo_types.iteritems(): 245 | if repotype.istype(repo): 246 | return name 247 | return 'hg' 248 | 249 | 250 | def ensure_repo(parentrepo, parenttype, target, type, root, sourcename): 251 | if os.path.exists(target): 252 | return 253 | 254 | if SKIP_DEPENDENCY_UPDATES: 255 | logging.warning('SKIP_DEPENDENCY_UPDATES environment variable set, ' 256 | '%s not cloned', target) 257 | return 258 | 259 | postprocess_url = repo_types[type].postprocess_url 260 | root = postprocess_url(root) 261 | sourcename = postprocess_url(sourcename) 262 | 263 | if os.path.exists(root): 264 | url = os.path.join(root, sourcename) 265 | else: 266 | url = urlparse.urljoin(root, sourcename) 267 | 268 | logging.info('Cloning repository %s into %s' % (url, target)) 269 | repo_types[type].clone(url, target) 270 | repo_types[parenttype].ignore(target, parentrepo) 271 | 272 | 273 | def update_repo(target, type, revision): 274 | resolved_revision = repo_types[type].get_revision_id(target, revision) 275 | current_revision = repo_types[type].get_revision_id(target) 276 | 277 | if resolved_revision != current_revision: 278 | if SKIP_DEPENDENCY_UPDATES: 279 | logging.warning('SKIP_DEPENDENCY_UPDATES environment variable set, ' 280 | '%s not checked out to %s', target, revision) 281 | return 282 | 283 | if not resolved_revision: 284 | logging.info('Revision %s is unknown, downloading remote changes' % revision) 285 | repo_types[type].pull(target) 286 | resolved_revision = repo_types[type].get_revision_id(target, revision) 287 | if not resolved_revision: 288 | raise Exception('Failed to resolve revision %s' % revision) 289 | 290 | logging.info('Updating repository %s to revision %s' % (target, resolved_revision)) 291 | repo_types[type].update(target, resolved_revision, revision) 292 | 293 | 294 | def resolve_deps(repodir, level=0, self_update=True, overrideroots=None, skipdependencies=set()): 295 | config = read_deps(repodir) 296 | if config is None: 297 | if level == 0: 298 | logging.warning('No dependencies file in directory %s, nothing to do...\n%s' % (repodir, USAGE)) 299 | return 300 | if level >= 10: 301 | logging.warning('Too much subrepository nesting, ignoring %s' % repo) 302 | return 303 | 304 | if overrideroots is not None: 305 | config['_root'] = overrideroots 306 | 307 | for dir, sources in config.iteritems(): 308 | if (dir.startswith('_') or 309 | skipdependencies.intersection([s[0] for s in sources if s[0]])): 310 | continue 311 | 312 | target = safe_join(repodir, dir) 313 | parenttype = get_repo_type(repodir) 314 | _root = config.get('_root', {}) 315 | 316 | for key in sources.keys() + _root.keys(): 317 | if key == parenttype or key is None and vcs != '*': 318 | vcs = key 319 | source, rev = merge_seqs(sources.get('*'), sources.get(vcs)) 320 | 321 | if not (vcs and source and rev): 322 | logging.warning('No valid source / revision found to create %s' % target) 323 | continue 324 | 325 | ensure_repo(repodir, parenttype, target, vcs, _root.get(vcs, ''), source) 326 | update_repo(target, vcs, rev) 327 | resolve_deps(target, level + 1, self_update=False, 328 | overrideroots=overrideroots, skipdependencies=skipdependencies) 329 | 330 | if self_update and '_self' in config and '*' in config['_self']: 331 | source = safe_join(repodir, config['_self']['*']) 332 | try: 333 | with io.open(source, 'rb') as handle: 334 | sourcedata = handle.read() 335 | except IOError, e: 336 | if e.errno != errno.ENOENT: 337 | raise 338 | logging.warning("File %s doesn't exist, skipping self-update" % source) 339 | return 340 | 341 | target = __file__ 342 | with io.open(target, 'rb') as handle: 343 | targetdata = handle.read() 344 | 345 | if sourcedata != targetdata: 346 | logging.info("Updating %s from %s, don't forget to commit" % (target, source)) 347 | with io.open(target, 'wb') as handle: 348 | handle.write(sourcedata) 349 | if __name__ == '__main__': 350 | logging.info('Restarting %s' % target) 351 | os.execv(sys.executable, [sys.executable, target] + sys.argv[1:]) 352 | else: 353 | logging.warning('Cannot restart %s automatically, please rerun' % target) 354 | 355 | 356 | def _ensure_line_exists(path, pattern): 357 | with open(path, 'a+') as f: 358 | file_content = [l.strip() for l in f.readlines()] 359 | if not pattern in file_content: 360 | file_content.append(pattern) 361 | f.seek(0, os.SEEK_SET) 362 | f.truncate() 363 | for l in file_content: 364 | print >>f, l 365 | 366 | if __name__ == '__main__': 367 | logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) 368 | 369 | parser = argparse.ArgumentParser(description='Verify dependencies for a set of repositories, by default the repository of this script.') 370 | parser.add_argument('repos', metavar='repository', type=str, nargs='*', help='Repository path') 371 | parser.add_argument('-q', '--quiet', action='store_true', help='Suppress informational output') 372 | args = parser.parse_args() 373 | 374 | if args.quiet: 375 | logging.disable(logging.INFO) 376 | 377 | repos = args.repos 378 | if not len(repos): 379 | repos = [os.path.dirname(__file__)] 380 | for repo in repos: 381 | resolve_deps(repo) 382 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | --------------------------------------------------------------------------------