Bug 436719: Read updater.ini from app dir, not gre. r=bsmedberg, r=robstrong

This commit is contained in:
Dave Townsend 2008-08-14 17:08:03 +01:00
Родитель 0653ac9735
Коммит 1bc0aea457
4 изменённых файлов: 40 добавлений и 42 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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)

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsIFile> 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<nsIFile> &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<nsIFile> 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)