I'm getting some trouble and a little confused about auto update
process on a standalone xulrunner application.
First of all, here's my app structure folder (deployed xulrunner),
under path_to_app:
path_to_app/chrome
path_to_app/chrome/app_folders
path_to_app/chrome.manifest (binding to others manifest files,
according to gecko 2)
path_to_app/application.ini
path_to_app/xulrunner-stub (renamed to my app name)
Here' my code to generate complete update mar (using
make_full_update.sh [1], common.sh [2] and mar generation tools [3],
all from wiki [4])
make_full_update.sh aUpdate.mar path_to_app;
And, with aUpdate.mar file ready, I get some crypto and size stuff,
using sha512sum [5], and ls tools [6].
I had made the inverse process, through "mar -x aUpdate.mar" to check
integrity of all mar compress process. It seems ok to me. To complete
update, all my folder structure are preserved after extracting mar
file.
With all that information, I'm now ready to get my updates.xml file:
<?xml version="1.0"?>
<updates>
<update type="major" version="2.0" extensionVersion="2.0"
buildID="20100829101458" detailsURL="http://
somereleasenotes/">
<patch type="complete"
URL="http://<AUS_SERVER_LOC>/aUpdate.mar"
hashFunction="SHA512"
hashValue="<SHA512SUM_CMD_OUTPUT_HASH>"
size="<LS_CMD_OUTPUT_SIZE>" />
</update>
</updates>
Now, with updates.xml ready on my AUS server, I can set user update
settings to parse update information:
pref("app.update.enabled", true);
pref("app.update.auto", true);
pref("app.update.mode", 1);
pref("app.update.silent", false);
pref("app.update.url", "http://<AUS_SERVER_LOC>/updates.xml");
pref("app.update.url.manual", "http://someloc");
pref("app.update.url.details", "http://someloc");
pref("app.update.interval", 86400);
pref("app.update.nagTimer.download", 86400);
pref("app.update.nagTimer.restart", 1800);
pref("app.update.timer", 600000);
pref("app.update.showInstalledUI", false);
pref("app.update.incompatible.mode", 0);
After define auto-update settings, my app execute the following code
(and directly, without wait for app request updates.xml)
function checkUpdates()
{
var updateListener = {
onProgress: function(request, position, totalSize)
{
alert('update check progress');
},
onCheckComplete: function(request, updates,
updateCount)
{
// after retrieve sucessfully updates.xml
infos, app will execute this code
alert('update check complete - ' + updateCount
+ ' available');
if(updateCount > 0)
{
// don't ask user for applying
updates. do it at all.
var updater =
Components.classes["@mozilla.org/updates/update-service;1"]
.createInstance(Components.interfaces.nsIApplicationUpdateService);
// select the most important update
(major, complete)
var update =
updater.selectUpdate(updates, updateCount);
var download =
updater.downloadUpdate(update, false);
// if downloadUpdate is async, why
return a simple useless state string?
alert(download);
}
},
onError: function(request, update)
{
alert('update check error');
},
QueryInterface: function(aIID)
{
if (!
aIID.equals(Components.interfaces.nsIUpdateCheckListener) && !
aIID.equals(Components.interfaces.nsISupports))
throw
Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
};
var checker = Components.classes["@mozilla.org/updates/update-
checker;1"].
createInstance(Components.interfaces.nsIUpdateChecker);
checker.checkForUpdates(updateListener, true);
};
// init update checking
checkUpdates();
Well, here, almost everything works fine for me. Xulrunner download
updates.xml, verify the most important update and retrieve all
patches. After calling updater.downloadUpdate(update, false); the
'aUpdate.mar' file is actually downloaded on app folder, and some
update UI appears asking to restart my app.
After restart my app, I get the following message, on an UI:
The Update could not be installed (patch apply failed).
And, under my app folder structure I get a new folder called
"updates", with an subfolder "0", with the following content:
update.version contains "3.6"
update.status contain "pending"
update.mar is my AUS update patch, at all.
So, there's no any other debug information that I can post here. It's
very frustrating.
Any help about that error (patch apply failed) ?
References
[1] http://hg.mozilla.org/mozilla-central/file/default/tools/update-packaging/make_full_update.sh
[2] http://hg.mozilla.org/mozilla-central/file/86f3dd6d5d52/tools/update-packaging/common.sh
[3] http://ftp.mozilla.org/pub/mozilla.org/xulrunner/mar-generation-tools/mar-generation-tools-linux.zip
[4] https://wiki.mozilla.org/UpdateGeneration
[5] "sha512sum aUpdate.mar" gives SHA512 hashCode.
[6] "ls aUpdate.mar" gives file size.