mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
326930 XULRunner Software Update should apply patches to the correct application directory. Patch by Ben Turner <bent.mozilla@gmail.com>. r=bsmedberg
This commit is contained in:
parent
81402b75f5
commit
2b17634426
@ -24,6 +24,7 @@
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
* Ben Goodger <ben@mozilla.org>
|
||||
* Fredrik Holmqvist <thesuckiestemail@yahoo.se>
|
||||
* Ben Turner <mozilla@songbirdnest.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -2104,8 +2105,11 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_UPDATER)
|
||||
// Check for and process any available updates
|
||||
ProcessUpdates(dirProvider.GetAppDir(), gRestartArgc, gRestartArgv);
|
||||
// Check for and process any available updates
|
||||
ProcessUpdates(dirProvider.GetGREDir(),
|
||||
dirProvider.GetAppDir(),
|
||||
gRestartArgc,
|
||||
gRestartArgv);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIProfileLock> profileLock;
|
||||
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
* Ben Turner <mozilla@songbirdnest.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -277,16 +278,16 @@ CopyUpdaterIntoUpdateDir(nsIFile *appDir, nsIFile *updateDir,
|
||||
}
|
||||
|
||||
static void
|
||||
ApplyUpdate(nsIFile *appDir, nsIFile *updateDir, nsILocalFile *statusFile,
|
||||
int appArgc, char **appArgv)
|
||||
ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsILocalFile *statusFile,
|
||||
nsIFile *appDir, int appArgc, char **appArgv)
|
||||
{
|
||||
// Steps:
|
||||
// - mark update as 'applying'
|
||||
// - copy updater into update dir
|
||||
// - run updater w/ app dir as the current working dir
|
||||
// - run updater w/ appDir as the current working dir
|
||||
|
||||
nsCOMPtr<nsIFile> updater;
|
||||
if (!CopyUpdaterIntoUpdateDir(appDir, updateDir, updater)) {
|
||||
if (!CopyUpdaterIntoUpdateDir(greDir, updateDir, updater)) {
|
||||
LOG(("failed copying updater\n"));
|
||||
return;
|
||||
}
|
||||
@ -307,10 +308,11 @@ ApplyUpdate(nsIFile *appDir, nsIFile *updateDir, nsILocalFile *statusFile,
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCAutoString appDirPath;
|
||||
// Get the directory to which the update will be applied. On Mac OSX we need
|
||||
// to apply the update to the Foo.app directory which is the parent of the
|
||||
// parent of the appDir. On other platforms we will just apply to the appDir.
|
||||
nsCAutoString applyToDir;
|
||||
#if defined(XP_MACOSX)
|
||||
// On Mac OSX, we need to apply the update to the Contents directory
|
||||
// which is the parent of the parent of the appDir.
|
||||
{
|
||||
nsCOMPtr<nsIFile> parentDir1, parentDir2;
|
||||
rv = appDir->GetParent(getter_AddRefs(parentDir1));
|
||||
@ -319,10 +321,10 @@ ApplyUpdate(nsIFile *appDir, nsIFile *updateDir, nsILocalFile *statusFile,
|
||||
rv = parentDir1->GetParent(getter_AddRefs(parentDir2));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
rv = parentDir2->GetNativePath(appDirPath);
|
||||
rv = parentDir2->GetNativePath(applyToDir);
|
||||
}
|
||||
#else
|
||||
rv = appDir->GetNativePath(appDirPath);
|
||||
rv = appDir->GetNativePath(applyToDir);
|
||||
#endif
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
@ -371,10 +373,10 @@ ApplyUpdate(nsIFile *appDir, nsIFile *updateDir, nsILocalFile *statusFile,
|
||||
LOG(("spawning updater process [%s]\n", updaterPath.get()));
|
||||
|
||||
#if defined(USE_EXECV)
|
||||
chdir(appDirPath.get());
|
||||
chdir(applyToDir.get());
|
||||
execv(updaterPath.get(), argv);
|
||||
#elif defined(XP_WIN)
|
||||
_chdir(appDirPath.get());
|
||||
_chdir(applyToDir.get());
|
||||
|
||||
if (!WinLaunchChild(updaterPath.get(), appArgc + 4, argv))
|
||||
return;
|
||||
@ -387,7 +389,7 @@ ApplyUpdate(nsIFile *appDir, nsIFile *updateDir, nsILocalFile *statusFile,
|
||||
if (!attr)
|
||||
goto end;
|
||||
|
||||
status = PR_ProcessAttrSetCurrentDirectory(attr, appDirPath.get());
|
||||
status = PR_ProcessAttrSetCurrentDirectory(attr, applyToDir.get());
|
||||
if (status != PR_SUCCESS)
|
||||
goto end;
|
||||
|
||||
@ -401,12 +403,12 @@ end:
|
||||
}
|
||||
|
||||
nsresult
|
||||
ProcessUpdates(nsIFile *appDir, int argc, char **argv)
|
||||
ProcessUpdates(nsIFile *greDir, nsIFile *appDir, int argc, char **argv)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFile> updatesDir;
|
||||
rv = appDir->Clone(getter_AddRefs(updatesDir));
|
||||
rv = greDir->Clone(getter_AddRefs(updatesDir));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("updates"));
|
||||
@ -429,7 +431,7 @@ ProcessUpdates(nsIFile *appDir, int argc, char **argv)
|
||||
for (int i = 0; i < dirEntries.Count(); ++i) {
|
||||
nsCOMPtr<nsILocalFile> statusFile;
|
||||
if (GetStatusFile(dirEntries[i], statusFile) && IsPending(statusFile)) {
|
||||
ApplyUpdate(appDir, dirEntries[i], statusFile, argc, argv);
|
||||
ApplyUpdate(greDir, dirEntries[i], statusFile, appDir, argc, argv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
* Ben Turner <mozilla@songbirdnest.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -47,11 +48,16 @@ class nsIFile;
|
||||
* This function processes any available updates. As part of that process, it
|
||||
* may exit the current process and relaunch it at a later time.
|
||||
*
|
||||
* Two directories are passed to this function: greDir (where the actual
|
||||
* binary resides) and appDir (which contains application.ini for XULRunner
|
||||
* apps). If this is not a XULRunner app then appDir is identical to greDir.
|
||||
*
|
||||
* The argc and argv passed to this function should be what is needed to
|
||||
* relaunch the current process.
|
||||
*
|
||||
* This function does not modify appDir.
|
||||
*/
|
||||
NS_HIDDEN_(nsresult) ProcessUpdates(nsIFile *appDir, int argc, char **argv);
|
||||
NS_HIDDEN_(nsresult) ProcessUpdates(nsIFile *greDir, nsIFile *appDir,
|
||||
int argc, char **argv);
|
||||
|
||||
#endif // nsUpdateDriver_h__
|
||||
|
Loading…
Reference in New Issue
Block a user