This article is from: https://developer.mozilla.org/zh-CN/Add-ons/Updates
Provided by my own translation.
Firefox supports automatic upgrades of extensions using a JSON upgrade manifest description file. Extensions deployed on AMO can be automatically updated to the latest version, other extensions must specify the location of their upgrade description files.
A typical upgrade description file is as follows:
{
"addons": {
"[email protected]": {
"updates": [
{ "version": "0.1",
"update_link": "https://example.com/addon-0.1.xpi" },
{ "version": "0.2",
"update_link": "http://example.com/addon-0.2.xpi",
"update_hash": "sha256:fe93c2156f05f20621df1723b0f39c8ab28cdbeec342efa95535d3abff932096" },
{ "version": "0.3",
"update_link": "https://example.com/addon-0.3.xpi",
"applications": {
"gecko": { "strict_min_version": "44" } } }
]
}
}
}
Extension upgrade
If your add-on is not deployed on AMO , you must explicitly state the location of your add-on's upgrade manifest file. For WebExtensions , add the following to your manifest file:
"applications": {
"gecko": {
"update_url": "https://example.com/updates.json"
}
}
For XUL extensions, add the following to the install.rdf
file's <Description about="urn:mozilla:install-manifest">
element:
<em:updateURL>https://example.com/updates.json</em:updateURL>
Manifest structure
manifest is a JSON file that uses top-level objects. This object contains the following possible properties:
Property Type Descriptionaddons |
object |
An object containing an entity for the add-on to upgrade. The key of each entity must be the ID of the adder, and its value must be an addon object and its updates. |
Addon objects
addons[*]
The properties of each addons object must contain a collection of description objects for the upgrade add-on. This object has the following properties:
Property Type Descriptionupdates |
Array optional |
A data contains update description objects for 0 or more appenders . |
Update objects
addons[*].updates[*]
Upgrade description objects must be collections of objects, which can have the following properties:
Property Type Descriptionversion |
string |
The version number of the add-on. This version number must exist if an upgrade address is specified. If any compatibility information is specified, it will overwrite the version number in the special information with this version number. |
update_link |
string optional |
A link address to the appender XPI file, it must be an HTTPS address, otherwise the update_hash must be included in order to verify it. |
update_hash |
string optional |
A update_link指向的文件的Hash编码。 must contain this value if update_link is not an HTTPS address. If present, it must be a hash encoded with sha256: or sha512:开头的字符串 followed by the hexadecimal value of the corresponding type. |
update_info_url |
string optional |
The address of an HTML file containing upgrade instructions. |
multiprocess_compatible |
bool optional(default: true ) |
If false, this add-on must be required to run in a multi-process Firefox environment. |
applications |
object optional |
An object containing application-specific compatibility information. Each attribute must contain an application object , which is described below. Including Firefox and other applications built on the same runtime environment, If this property is omitted, Gecko is supported. Also, if this attribute is defined, it must contain a gecko attribute, otherwise the upgrade entity will be ignored. |
Application objects
addons[*].updates[*].applications.gecko
The Application object specifies the appropriate description information for a particular application. They must be a collection of objects, which can contain the following properties:
Property Type Descriptionstrict_min_version |
string optional(default: 42.0a1 ) |
The minimum version number that the appender can run. |
strict_max_version |
string optional(default: * ) |
The maximum version number that the appender can run. |
advisory_max_version |
string optional(default: * ) |
The maximum version number at which the appender runs optimally. This property is mostly ignored. |