我正在学习 http://www.borngeek.com/firefox/automatic-firefox-extension-updates/ 上的教程使我的 FF 扩展可以自动更新给用户,但我停留在最后一部分“托管更新 list ”,因为我正在使用 Tomcat 服务,我不知道如何设置 .htaccess(.htaccess 文件是否类似在配置服务器方面使用 WEB-INF 目录?)
到目前为止我做了什么,
创建 key 对:公钥和私钥
计算sha256: b3290c69a1...
创建update.rdf
<?xml version="1.0"?> <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:extension:myextension@mozilla.myextension.org"> <updates> <r:Seq> <r:li> <r:Description> <version>1.0.1</version> <targetApplication> <r:Description> <id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id> <minVersion>3.5</minVersion> <maxVersion>5.0.*</maxVersion> <updateLink>http://localhost:8080/myextension/pluginupdate/myextension.xpi</updateLink> <updateHash> sha256:b3290c69a1... </updateHash> </r:Description> </targetApplication> </r:Description> </r:li> </r:Seq> </updates> </r:Description> </r:RDF>
使用Key对update.rdf进行签名
将singed update.rdf和myextension.xpi放在pluginupdate目录下,pluginupdate与WEB-INF同级
我的安装.rdf
<?xml version="1.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>myextension@mozilla.myextension.org</em:id> <em:name>My Test extension</em:name> <em:version>1.0</em:version> <em:description>Test Mozilla Extension.</em:description> <em:creator>TEST Group</em:creator> <!-- optional items --> <em:contributor>Me</em:contributor> <em:homepageURL>http://?????????/</em:homepageURL> <em:updateKey> MIGfMA0G..... </em:updateKey> <em:updateURL>http://localhost:8080/myextension/pluginupdate/update.rdf</em:updateURL> <!-- Firefox --> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>3.5</em:minVersion> <em:maxVersion>5.0.*</em:maxVersion> </Description> </em:targetApplication> </Description> </RDF>
当我重新启动 FF 浏览器时,没有任何反应。 当我使用带有选项 -console 的命令行启动 FF 浏览器时
*** LOG addons.xpi: startup *** LOG addons.xpi: checkForChanges *** LOG addons.xpi: No changes found *** LOG addons.xpi: Opening database
那么,我如何托管和配置 Tomcat 来托管更新 list ?谢谢
更新
嗨,弗拉基米尔,
在 web.xml 中定义 MIME 类型后,-console 选项提供了更多信息。
我删除了扩展并重新安装了它,日志是
*** LOG addons.xpi: startup *** LOG addons.xpi: checkForChanges *** LOG addons.xpi: No changes found *** LOG addons.xpi: Opening database *** LOG addons.repository: Requesting https://services.addons.mozilla.org/en-GB/firefox/api/1.5/search/guid:myextension%40mozilla.myextension.org?src=firefox&appOS=Linux&appVersion=5.0&tMain=23&tFirstPaint=1641&tSessionRestored=1042 *** LOG addons.xpi: Starting install of file:///home/me/browserplugindev/firefox/test/myextension.xpi *** LOG addons.xpi: Addon myextension@mozilla.myextension.org will be installed as a packed xpi *** LOG addons.xpi: Install of file:///home/me/browserplugindev/firefox/test/myextension.xpi completed. NOTE: child process received `Goodbye', closing down *** LOG addons.xpi: shutdown *** LOG addons.xpi: startup *** LOG addons.xpi: checkForChanges *** LOG addons.xpi: Found updated manifest for myextension@mozilla.myextension.org in app-profile *** LOG addons.xpi: Processing install of myextension@mozilla.myextension.org in app-profile *** LOG addons.xpi: Opening database *** LOG addons.xpi: New add-on myextension@mozilla.myextension.org installed in app-profile *** LOG addons.xpi: Updating database with changes to installed add-ons *** LOG addons.xpi: Updating add-on states *** LOG addons.xpi: Writing add-ons list
弗洛姆线
LOG addons.repository: Requesting https://services.addons.mozilla.org/en-GB/firefox/api/1.5/search/guid:myextension%40mozilla.myextension.org?src=firefox&appOS=Linux&appVersion=5.0&tMain=23&tFirstPaint=1641&tSessionRestored=1042
我们可以看到更新管理器(?)正在向存储库发出请求,网址为 https://services.addons.mozilla.org/en-GB/firefox/api/1.5/search/guid:myextension%40mozilla.myextension。 org?src=firefox&appOS=Linux&appVersion=5.0&tMain=23&tFirstPaint=1641&tSessionRestored=1042
还有,启动后
*** LOG addons.xpi: Found updated manifest for myextension@mozilla.myextension.org in app-profile *** LOG addons.xpi: Processing install of myextension@mozilla.myextension.org in app-profile
那么是不是说明找到更新了。但是我没有在浏览器上看到类似“有新版本的 myextension,更新?”之类的通知。
我错过了什么吗?
最佳答案
.htaccess 文件的要点只是确保服务器知道 MIME 类型。看来您可以通过更改 conf/web.xml 文件为 Tomcat 做到这一点:
<mime-mapping>
<extension>xpi</extension>
<mime-type>application/x-xpinstall</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rdf</extension>
<mime-type>application/rdf+xml</mime-type>
</mime-mapping>
我查看了您的 update.rdf 和 install.rdf 文件,没有发现任何明显的问题 - 它应该可以工作。您可能想转到 about:config
并打开 extensions.logging.enabled
首选项,但是,这将确保将附加信息发送到错误控制台(按 Ctrl -Shift-J 在命令行上打开或使用 -jsconsole
。
关于Firefox 扩展自动更新功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6466084/