From 6f677b86d046fe69d4c6626d65b221dddb13959c Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Thu, 14 Aug 2008 17:08:03 +0100 Subject: [PATCH] Bug 436719: Read updater.ini from app dir, not gre. r=bsmedberg, r=robstrong --- browser/installer/removed-files.in | 1 + browser/locales/Makefile.in | 4 -- .../update/src/updater/progressui_osx.mm | 6 +- toolkit/xre/nsUpdateDriver.cpp | 71 ++++++++++--------- 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/browser/installer/removed-files.in b/browser/installer/removed-files.in index fbc3f5cbee45..4bf016300f30 100644 --- a/browser/installer/removed-files.in +++ b/browser/installer/removed-files.in @@ -601,6 +601,7 @@ components/websrvcs.xpt components/widget_mac.xpt components/xml-rpc.xpt components/xpcom_obsolete.xpt +updater.app/Contents/MacOS/updater.ini init.d/README redo-prebinding.sh res/viewer.properties diff --git a/browser/locales/Makefile.in b/browser/locales/Makefile.in index 4bf421b446e7..b18d3c7e7a24 100644 --- a/browser/locales/Makefile.in +++ b/browser/locales/Makefile.in @@ -308,14 +308,10 @@ libs:: $(addprefix $(LOCALE_SRCDIR)/,updater/updater.ini) ifeq ($(OS_ARCH),WINNT) cat $< $(srcdir)/../installer/windows/nsis/updater_append.ini | \ iconv -f UTF-8 -t $(WIN_INSTALLER_CHARSET) > $(FINAL_TARGET)/updater.ini -else -ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) - $(SYSINSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/updater.app/Contents/MacOS else $(SYSINSTALL) $(IFLAGS1) $^ $(FINAL_TARGET) endif endif -endif ifdef MOZ_CRASHREPORTER libs:: $(addprefix $(LOCALE_SRCDIR)/,crashreporter/crashreporter-override.ini) diff --git a/toolkit/mozapps/update/src/updater/progressui_osx.mm b/toolkit/mozapps/update/src/updater/progressui_osx.mm index c3da818600a0..2ce2afc50df2 100644 --- a/toolkit/mozapps/update/src/updater/progressui_osx.mm +++ b/toolkit/mozapps/update/src/updater/progressui_osx.mm @@ -49,7 +49,7 @@ static float sProgressVal; // between 0 and 100 static BOOL sQuit = FALSE; static StringTable sLabels; -static const char *sProgramPath; +static const char *sUpdatePath; @interface UpdaterUI : NSObject { @@ -112,7 +112,7 @@ static const char *sProgramPath; int InitProgressUI(int *pargc, char ***pargv) { - sProgramPath = (*pargv)[0]; + sUpdatePath = (*pargv)[1]; return 0; } @@ -129,7 +129,7 @@ ShowProgressUI() return 0; char path[PATH_MAX]; - snprintf(path, sizeof(path), "%s.ini", sProgramPath); + snprintf(path, sizeof(path), "%s/updater.ini", sUpdatePath); if (ReadStrings(path, &sLabels) != OK) return -1; diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index 4e2dfb3855bb..b5b45a06342c 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -274,50 +274,51 @@ SetStatus(nsILocalFile *statusFile, const char *status) return PR_TRUE; } +static PRBool +CopyFileIntoUpdateDir(nsIFile *parentDir, const char *leafName, nsIFile *updateDir) +{ + nsDependentCString leaf(leafName); + nsCOMPtr file; + + // Make sure there is not an existing file in the target location. + nsresult rv = updateDir->Clone(getter_AddRefs(file)); + if (NS_FAILED(rv)) + return PR_FALSE; + rv = file->AppendNative(leaf); + if (NS_FAILED(rv)) + return PR_FALSE; + file->Remove(PR_FALSE); + + // Now, copy into the target location. + rv = parentDir->Clone(getter_AddRefs(file)); + if (NS_FAILED(rv)) + return PR_FALSE; + rv = file->AppendNative(leaf); + if (NS_FAILED(rv)) + return PR_FALSE; + rv = file->CopyToNative(updateDir, EmptyCString()); + if (NS_FAILED(rv)) + return PR_FALSE; + + return PR_TRUE; +} + static PRBool CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir, nsCOMPtr &updater) { - // We have to move the updater binary and its resource file. - const char *filesToMove[] = { + // Copy the updater application from the GRE and the updater ini from the app #if defined(XP_MACOSX) - kUpdaterApp, + if (!CopyFileIntoUpdateDir(greDir, kUpdaterApp, updateDir)) + return PR_FALSE; #else - kUpdaterINI, - kUpdaterBin, + if (!CopyFileIntoUpdateDir(greDir, kUpdaterBin, updateDir)) + return PR_FALSE; #endif - nsnull - }; + CopyFileIntoUpdateDir(appDir, kUpdaterINI, updateDir); - nsresult rv; - - for (const char **leafName = filesToMove; *leafName; ++leafName) { - nsDependentCString leaf(*leafName); - nsCOMPtr file; - - // Make sure there is not an existing file in the target location. - rv = updateDir->Clone(getter_AddRefs(file)); - if (NS_FAILED(rv)) - return PR_FALSE; - rv = file->AppendNative(leaf); - if (NS_FAILED(rv)) - return PR_FALSE; - file->Remove(PR_FALSE); - - // Now, copy into the target location. - rv = greDir->Clone(getter_AddRefs(file)); - if (NS_FAILED(rv)) - return PR_FALSE; - rv = file->AppendNative(leaf); - if (NS_FAILED(rv)) - return PR_FALSE; - rv = file->CopyToNative(updateDir, EmptyCString()); - if (*leafName != kUpdaterINI && NS_FAILED(rv)) - return PR_FALSE; - } - // Finally, return the location of the updater binary. - rv = updateDir->Clone(getter_AddRefs(updater)); + nsresult rv = updateDir->Clone(getter_AddRefs(updater)); if (NS_FAILED(rv)) return PR_FALSE; #if defined(XP_MACOSX)