diff --git a/mozilla/xpinstall/packager/unix/config.it b/mozilla/xpinstall/packager/unix/config.it index 150add5559e..69e9b932d1d 100644 --- a/mozilla/xpinstall/packager/unix/config.it +++ b/mozilla/xpinstall/packager/unix/config.it @@ -240,10 +240,17 @@ XPInstall Engine=xpcom.xpi ;------------------------------------------------------------------------- -[RunApp0] +[PostInstallRun0] ;------------------------------------------------------------------------- -Target=mozilla -Arguments=-installer +Target=run-mozilla.sh +Arguments=regxpcom + + +;------------------------------------------------------------------------- +[PostInstallRun1] +;------------------------------------------------------------------------- +Target=run-mozilla.sh +Arguments=regchrome ;------------------------------------------------------------------------- diff --git a/mozilla/xpinstall/wizard/unix/src2/XIDefines.h b/mozilla/xpinstall/wizard/unix/src2/XIDefines.h index 6c54a0dda93..44a5f2dcd5a 100644 --- a/mozilla/xpinstall/wizard/unix/src2/XIDefines.h +++ b/mozilla/xpinstall/wizard/unix/src2/XIDefines.h @@ -95,6 +95,7 @@ #define DOWNLOAD_ONLY_ATTR "DOWNLOAD_ONLY" #define RUNAPPd "RunApp%d" +#define POSTINSTALLRUNd "PostInstallRun%d" #define TARGET "Target" #define ARGS "Arguments" diff --git a/mozilla/xpinstall/wizard/unix/src2/installer.ini b/mozilla/xpinstall/wizard/unix/src2/installer.ini index 5a4b9e96637..90e09807730 100644 --- a/mozilla/xpinstall/wizard/unix/src2/installer.ini +++ b/mozilla/xpinstall/wizard/unix/src2/installer.ini @@ -29,6 +29,7 @@ DESCRIPTION=Description PREPARING=Preparing %s... EXTRACTING=Extracting %s... INSTALLING_XPI=Installing %s... +COMPLETING_INSTALL=Completing Installation... PROCESSING_FILE=Processing file %d of %d... NO_PERMS=Choose another directory because you do not have permission to install to: %s DL_SETTINGS=Download Settings diff --git a/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.cpp b/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.cpp index 1b5bbb4ed91..1ffcb3c13c0 100644 --- a/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.cpp +++ b/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.cpp @@ -28,6 +28,7 @@ #include "nsXInstaller.h" #include "nsXIEngine.h" #include +#include #include #include @@ -51,6 +52,7 @@ DLProgress; static char *sXPInstallEngine; static nsRunApp *sRunAppList = NULL; +static nsRunApp *sPostInstallRun = NULL; static DLProgress sDLProgress; static GtkWidget *sDLTable = NULL; @@ -228,6 +230,24 @@ nsInstallDlg::Parse(nsINIParser *aParser) if (bufsize == 0) XI_IF_FREE(mTitle); + for (i = 0; err == OK; i++) + { + /* construct PostInstallRunX section name */ + sprintf(secName, POSTINSTALLRUNd, i); + err = aParser->GetStringAlloc(secName, TARGET, &app, &bufsize); + if (err == OK && bufsize > 0) + { + /* "args" is optional: this may return E_NO_KEY which we ignore */ + aParser->GetStringAlloc(secName, ARGS, &args, &bufsize); + newRunApp = new nsRunApp(app, args); + if (!newRunApp) + return E_MEM; + err = AppendRunApp(&sPostInstallRun, newRunApp); + } + } + err = OK; /* reset error since PostInstallRunX sections are optional + and we could have gotten a parse error (E_NO_SEC) */ + for (i = 0; err == OK; i++) { /* construct RunAppX section name */ @@ -236,24 +256,22 @@ nsInstallDlg::Parse(nsINIParser *aParser) if (err == OK && bufsize > 0) { /* "args" is optional: this may return E_NO_KEY which we ignore */ - err = aParser->GetStringAlloc(secName, ARGS, &args, &bufsize); + aParser->GetStringAlloc(secName, ARGS, &args, &bufsize); newRunApp = new nsRunApp(app, args); if (!newRunApp) return E_MEM; - err = AppendRunApp(newRunApp); + err = AppendRunApp(&sRunAppList, newRunApp); } } err = OK; /* reset error since RunAppX sections are optional and we could have gotten a parse error (E_NO_SEC) */ - return err; - BAIL: return err; } int -nsInstallDlg::AppendRunApp(nsRunApp *aNewRunApp) +nsInstallDlg::AppendRunApp(nsRunApp **aRunAppList, nsRunApp *aNewRunApp) { int err = OK; nsRunApp *currRunApp = NULL, *nextRunApp = NULL; @@ -263,14 +281,14 @@ nsInstallDlg::AppendRunApp(nsRunApp *aNewRunApp) return E_PARAM; /* special case: list is empty */ - if (!sRunAppList) + if (!*aRunAppList) { - sRunAppList = aNewRunApp; + *aRunAppList = aNewRunApp; return OK; } /* list has at least one element */ - currRunApp = sRunAppList; + currRunApp = *aRunAppList; while (currRunApp) { if (!(nextRunApp = currRunApp->GetNext())) @@ -284,11 +302,10 @@ nsInstallDlg::AppendRunApp(nsRunApp *aNewRunApp) } void -nsInstallDlg::FreeRunAppList() +nsInstallDlg::FreeRunAppList(nsRunApp *aRunAppList) { - nsRunApp *currRunApp = NULL, *nextRunApp = NULL; + nsRunApp *currRunApp = aRunAppList, *nextRunApp = NULL; - currRunApp = sRunAppList; while (currRunApp) { nextRunApp = currRunApp->GetNext(); @@ -298,13 +315,12 @@ nsInstallDlg::FreeRunAppList() } void -nsInstallDlg::RunApps() +nsInstallDlg::RunApps(nsRunApp *aRunAppList, int aSequential) { - nsRunApp *currRunApp = sRunAppList; + nsRunApp *currRunApp = aRunAppList; char *argv[3], *dest; char apppath[MAXPATHLEN]; extern char **environ; /* globally available to all processes */ - int pid; dest = gCtx->opt->mDestination; if (chdir(dest) < 0) @@ -313,27 +329,32 @@ nsInstallDlg::RunApps() while (currRunApp) { /* run application with supplied args */ - if ((pid = fork()) == 0) + sprintf(apppath, "%s/%s", dest, currRunApp->GetApp()); + + argv[0] = apppath; + argv[1] = currRunApp->GetArgs(); + argv[2] = NULL; /* null-terminate arg vector */ + + if (!fork()) { /* child */ - if (*(dest + strlen(dest)) == '/') /* trailing slash */ - sprintf(apppath, "%s%s", dest, currRunApp->GetApp()); - else /* no trailing slash */ - sprintf(apppath, "%s/%s", dest, currRunApp->GetApp()); - - argv[0] = apppath; - argv[1] = currRunApp->GetArgs(); - argv[2] = NULL; /* null-terminate arg vector */ execve(apppath, argv, environ); /* shouldn't reach this but in case execve fails we will */ - exit(0); + _exit(0); } /* parent continues running to finish installation */ + if (aSequential) + { + wait(NULL); + } + currRunApp = currRunApp->GetNext(); } + + } int @@ -597,14 +618,27 @@ nsInstallDlg::PerformInstall() engine->DeleteXPIs(bCus, comps); } + // destroy installer engine thread object + XI_IF_DELETE(engine); + + // run post-install applications to complete installation + if (sPostInstallRun) + { + MajorProgressCB("", 1, 1, ACT_COMPLETE); + RunApps(sPostInstallRun, 1); + FreeRunAppList(sPostInstallRun); + } + // run all specified applications after installation if (sRunAppList) { if (gCtx->opt->mShouldRunApps) - RunApps(); - FreeRunAppList(); + RunApps(sRunAppList, 0); + FreeRunAppList(sRunAppList); } + return OK; + BAIL: // destroy installer engine thread object XI_IF_DELETE(engine); @@ -705,6 +739,10 @@ nsInstallDlg::MajorProgressCB(char *aName, int aNum, int aTotal, int aActivity) sprintf(msg, gCtx->Res("INSTALLING_XPI"), aName); break; + case ACT_COMPLETE: + sprintf(msg, gCtx->Res("COMPLETING_INSTALL")); + break; + default: break; } @@ -731,6 +769,8 @@ nsInstallDlg::MajorProgressCB(char *aName, int aNum, int aTotal, int aActivity) gtk_widget_show(sMinorLabel); gtk_widget_show(sMinorProgBar); } + else if (aActivity == ACT_COMPLETE) + gtk_label_set_text(GTK_LABEL(sMinorLabel), ""); XI_GTK_UPDATE_UI(); } diff --git a/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.h b/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.h index 8cf9dbdffcb..4cf7ec95c2d 100644 --- a/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.h +++ b/mozilla/xpinstall/wizard/unix/src2/nsInstallDlg.h @@ -67,7 +67,8 @@ public: { ACT_DOWNLOAD, ACT_EXTRACT, - ACT_INSTALL + ACT_INSTALL, + ACT_COMPLETE }; enum @@ -89,9 +90,9 @@ private: static void ShowProxySettings(GtkWidget *aWidget, gpointer aData); static void PSDlgOK (GtkWidget *aWidget, gpointer aData); static void PSDlgCancel(GtkWidget *aWidget, gpointer aData); - static void RunApps(); - static void FreeRunAppList(); - int AppendRunApp(nsRunApp *aNewRunApp); + static void RunApps(nsRunApp *aRunAppList, int aSequential); + static void FreeRunAppList(nsRunApp *aRunAppList); + int AppendRunApp(nsRunApp **aRunAppList, nsRunApp *aNewRunApp); static void DLPause(GtkWidget *aWidget, gpointer aData); static void DLResume(GtkWidget *aWidget, gpointer aData); static void DLCancel(GtkWidget *aWidget, gpointer aData); diff --git a/mozilla/xpinstall/wizard/unix/src2/nsXIContext.cpp b/mozilla/xpinstall/wizard/unix/src2/nsXIContext.cpp index 8c382348530..81be8b55a73 100644 --- a/mozilla/xpinstall/wizard/unix/src2/nsXIContext.cpp +++ b/mozilla/xpinstall/wizard/unix/src2/nsXIContext.cpp @@ -167,6 +167,7 @@ nsXIContext::LoadResources() "PREPARING", "EXTRACTING", "INSTALLING_XPI", + "COMPLETING_INSTALL", "PROCESSING_FILE", "NO_PERMS", "DL_SETTINGS", diff --git a/mozilla/xpinstall/wizard/unix/src2/nsXInstaller.cpp b/mozilla/xpinstall/wizard/unix/src2/nsXInstaller.cpp index c1b31406d98..a1817e3b8be 100644 --- a/mozilla/xpinstall/wizard/unix/src2/nsXInstaller.cpp +++ b/mozilla/xpinstall/wizard/unix/src2/nsXInstaller.cpp @@ -399,7 +399,7 @@ main(int argc, char **argv) XI_IF_DELETE(installer); - _exit(err); + exit(err); } /*------------------------------------------------------------------*