Big honking checkin for Install Builder

git-svn-id: svn://10.0.0.236/trunk@52641 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
selmer%netscape.com 1999-11-03 01:51:54 +00:00
parent 424a4cc34c
commit 00b336668e
9 changed files with 375 additions and 48 deletions

View File

@ -91,9 +91,9 @@ BOOL CInterpret::NewConfig(WIDGET *curWidget, CString globalsName, CString Dialo
if (d == INVALID_HANDLE_VALUE)
{
if (!DialogTitle.IsEmpty())
CopyDir(FooCopy,newDir,"NULL");
CopyDir(FooCopy,newDir,NULL, FALSE);
else
CopyDir(Template,newDir,"NULL");
CopyDir(Template,newDir,NULL, FALSE);
}
else
{
@ -236,26 +236,6 @@ BOOL CInterpret::Progress()
return TRUE;
}
void CInterpret::ExecuteCommand(char *command, int showflag, DWORD wait)
{
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
memset(&startupInfo, 0, sizeof(startupInfo));
memset(&processInfo, 0, sizeof(processInfo));
startupInfo.cb = sizeof(STARTUPINFO);
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
//startupInfo.wShowWindow = SW_SHOW;
startupInfo.wShowWindow = showflag;
BOOL executionSuccessful = CreateProcess(NULL, command, NULL, NULL, TRUE,
NORMAL_PRIORITY_CLASS, NULL, NULL,
&startupInfo, &processInfo);
DWORD error = GetLastError();
WaitForSingleObject(processInfo.hProcess, wait);
}
BOOL CInterpret::IterateListBox(char *parms)
{
char *target = strtok(parms, ",");
@ -707,7 +687,7 @@ BOOL CInterpret::interpret(CString cmds, WIDGET *curWidget)
CString todir = replaceVars(parms, NULL);
CString ext = p2;
BrowseDir(curWidget);
CopyDir(returnDir,todir,ext);
CopyDir(returnDir,todir,ext,FALSE);
}
else if (strcmp(pcmd, "DisplayImage") == 0)
{
@ -821,7 +801,7 @@ BOOL CInterpret::interpret(CString cmds, WIDGET *curWidget)
*p2++ = '\0';
CString from = replaceVars(parms, NULL);
CString to = replaceVars(p2, NULL);
CopyDir(from, to,"NULL");
CopyDir(from, to, NULL, TRUE);
}
}
else if (strcmp(pcmd, "SetGlobal") == 0)

View File

@ -41,7 +41,6 @@ public:
BOOL BrowseFile(WIDGET *curWidget);
BOOL BrowseDir(WIDGET *curWidget);
BOOL Progress(); // Not actually used right now
void ExecuteCommand(char *command, int showflag,DWORD wait);
BOOL IterateListBox(char *parms);
CString replaceVars(CString str, char *listval);
CString replaceVars(char *str, char *listval);

View File

@ -53,7 +53,7 @@ char *GetGlobal(CString theName)
}
extern "C" __declspec(dllexport)
void CopyDir(CString from, CString to, CString extension)
void CopyDir(CString from, CString to, LPCTSTR extension, int overwrite)
{
WIN32_FIND_DATA data;
HANDLE d;
@ -80,15 +80,15 @@ void CopyDir(CString from, CString to, CString extension)
tchild = to + "\\" + data.cFileName;
tmp = data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
if (tmp == FILE_ATTRIBUTE_DIRECTORY)
CopyDir(fchild, tchild,"NULL");
CopyDir(fchild, tchild, NULL, overwrite);
else
{
CString spot=fchild;
int loc = fchild.Find('.');
if (loc)
spot.Delete(0,loc+1);
if ((spot.CompareNoCase(extension)==0) || (extension.Compare("NULL") ==0))
CopyFile((const char *) fchild, (const char *) tchild, FALSE);
if (!extension || (spot.CompareNoCase((CString)extension)==0))
CopyFile((const char *) fchild, (const char *) tchild, !overwrite);
}
}
@ -98,3 +98,24 @@ void CopyDir(CString from, CString to, CString extension)
FindClose(d);
}
extern "C" __declspec(dllexport)
void ExecuteCommand(char *command, int showflag, DWORD wait)
{
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
memset(&startupInfo, 0, sizeof(startupInfo));
memset(&processInfo, 0, sizeof(processInfo));
startupInfo.cb = sizeof(STARTUPINFO);
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
//startupInfo.wShowWindow = SW_SHOW;
startupInfo.wShowWindow = showflag;
BOOL executionSuccessful = CreateProcess(NULL, command, NULL, NULL, TRUE,
NORMAL_PRIORITY_CLASS, NULL, NULL,
&startupInfo, &processInfo);
DWORD error = GetLastError();
WaitForSingleObject(processInfo.hProcess, wait);
}

View File

@ -7,4 +7,5 @@ extern __declspec(dllimport) int GlobalArrayIndex;
extern "C" __declspec(dllimport) char * GetGlobal(CString theName);
extern "C" __declspec(dllimport) WIDGET* SetGlobal(CString theName, CString theValue);
extern "C" __declspec(dllimport) WIDGET* findWidget(CString theName);
extern "C" __declspec(dllimport) void CopyDir(CString from, CString to, CString extension);
extern "C" __declspec(dllimport) void CopyDir(CString from, CString to, LPCTSTR extension, int overwrite);
extern "C" __declspec(dllexport) void ExecuteCommand(char *command, int showflag, DWORD wait);

View File

@ -41,6 +41,7 @@ MAKE_OBJ_TYPE = DLL
DLLNAME = globals
DLL=.\$(OBJDIR)\$(DLLNAME).dll
# -LDd creates debug version of library
CFLAGS = \
-W3 \
-GX \
@ -49,6 +50,10 @@ CFLAGS = \
-D_AFXDLL \
-D_MBCS \
-FD \
-LDd \
-MDd \
-Yd \
-Zi \
-c \
$(CFLAGS)
@ -66,11 +71,11 @@ include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\cck\InitDist.win>
export:: $(DLLNAME).h
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(CCKDIST)\CCKTool
$(MAKE_INSTALL) $(DLLNAME).h ..\include
libs:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib ..\lib
$(MAKE_INSTALL) $(DLLNAME).h ..\include
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(CCKDIST)\CCKTool
#clobber::
# rm -f $(DIST)\bin\$(DLLNAME).dll

View File

@ -1,29 +1,331 @@
#include "stdafx.h"
#include <Winbase.h>
#include <direct.h>
#include "globals.h"
#include "ifuncns.h"
#include "ib.h"
#define MAX_SIZE 1024
extern "C" __declspec(dllexport)
int StartIB(CString parms)
int interpret(char *cmd);
CString rootPath;
CString configName;
CString configPath;
CString workspacePath;
CString cdPath;
CString tempPath;
CString iniPath;
CString scriptPath;
CString nscpxpiPath;
char buffer[50000];
XPI xpiList[100];
int xpiLen = -1;
int findXPI(CString xpiname, CString filename)
{
CString root = GetGlobal("Root");
CString config = GetGlobal("CustomizationList");
int found = FALSE;
CString fromPath = root + "\\Installer";
CString destPath = root + "\\Configs\\" + config + "\\Output";
for (int i=0; !found && i<=xpiLen; i++)
if (xpiList[i].xpiname == xpiname &&
xpiList[i].filename == filename)
found = TRUE;
// Copy default installer files into config
CopyDir(fromPath, destPath,"NULL");
if (!found)
{
xpiLen++;
xpiList[xpiLen].xpiname = xpiname;
xpiList[xpiLen].filename = filename;
}
// Update config.ini with new content
CString inst_text1 = GetGlobal("InstallerScreenText1");
CString programPath = CString("C:\\Program Files\\Netscape\\Communicator");
CString configINI = CString(destPath + "\\config.ini");
return found;
}
WritePrivateProfileString( "General", "Product Name", inst_text1, configINI);
WritePrivateProfileString( "General", "Path", programPath, configINI);
WritePrivateProfileString( "General", "Program Folder Name", config, configINI);
int ExtractXPIFile(CString xpiname, CString xpifile)
{
CString command;
if (findXPI(xpiname, xpifile))
return TRUE;
// Can use -d instead of change CWD???
CString xpiArchive = nscpxpiPath + "\\" + xpiname;
command = rootPath + "unzip.exe -o" + " " + xpiArchive + " " + xpifile;
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
return TRUE;
}
int ReplaceXPIFiles()
{
CString command;
CString xpiArchive;
CString xpiArcDest;
// Go through the whole list putting them into the archives
for (int i=0; i<=xpiLen; i++)
{
// This copy preserves the existing archive if it exists - do we
// need to delete it the first time through?
xpiArchive = nscpxpiPath + "\\" + xpiList[i].xpiname;
xpiArcDest = cdPath + "\\" + xpiList[i].xpiname;
if (!CopyFile(xpiArchive, xpiArcDest, TRUE))
DWORD e = GetLastError();
command = rootPath + "zip.exe -m " + xpiArcDest + " " + xpiList[i].filename;
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
}
return TRUE;
}
int ReplaceINIFile()
{
CString command;
CString exeName("Seamonkey32e.exe");
char olddir[1024];
GetCurrentDirectory(sizeof(olddir), olddir);
if(SetCurrentDirectory((char *)(LPCTSTR) cdPath) == FALSE)
return FALSE;
CString Src = nscpxpiPath + exeName;
CString Dst = cdPath + exeName;
if (!CopyFile(Src, Dst, TRUE))
DWORD e = GetLastError();
command = rootPath + "nszip.exe " + exeName + " config.ini";
ExecuteCommand((char *)(LPCTSTR) command, SW_SHOW, INFINITE);
SetCurrentDirectory(olddir);
return TRUE;
}
void ModifyEntity(char *buffer, CString entity, CString newvalue)
{
CString buf(buffer);
entity = entity + " "; // Ensure we don't get false matches
int i = buf.Find(entity);
if (i == -1) return;
i = buf.Find('"', i+1);
if (i == -1) return;
i++;
int j = buf.Find('"', i);
if (j == -1) return;
j--;
buf.Delete(i, j-i+1);
buf.Insert(i, newvalue);
strcpy(buffer, (char *)(LPCTSTR) buf);
}
int ModifyDTD(CString xpifile, CString entity, CString newvalue)
{
CString newfile = xpifile + ".new";
int rv = TRUE;
char *fgetsrv;
// Read in DTD file and make substitutions
FILE *srcf = fopen(xpifile, "r");
FILE *dstf = fopen(newfile, "w");
if (!srcf)
rv = FALSE;
else
{
int done = FALSE;
while (!done)
{
fgetsrv = fgets(buffer, sizeof(buffer), srcf);
done = feof(srcf);
if (!done)
{
if (!fgetsrv || ferror(srcf))
{
rv = FALSE;
break;
}
ModifyEntity(buffer, entity, newvalue);
fputs(buffer, dstf);
}
}
fclose(srcf);
fclose(dstf);
}
remove(xpifile);
rename(newfile, xpifile);
return TRUE;
}
int interpret(char *cmd)
{
char *cmdname = strtok(cmd, "(");
if (strcmp(cmdname, "configure") == 0)
{
char temp[1024];
char *section = strtok(NULL, ",)");
char *key = strtok(NULL, ",)");
char *value = strtok(NULL, ",)");
char *newvalue = value;
if (value[0] == '%')
{
value++;
char *t = strchr(value, '%');
if (!t)
return FALSE;
*t = '\0';
newvalue = (char *)(LPCTSTR) GetGlobal(value);
}
if (!section || !key || !newvalue)
return FALSE;
CString iniSrc = nscpxpiPath + "\\config.ini";
if (!CopyFile(iniSrc, iniPath, TRUE))
DWORD e = GetLastError();
if (strcmp(key, "Program Folder Name") == 0)
{
strcpy(temp, "Netscape by ");
strcat(temp, newvalue);
newvalue = temp;
}
WritePrivateProfileString(section, key, newvalue, iniPath);
}
else if (strcmp(cmdname, "replaceXPI") == 0)
{
char *xpiname = strtok(NULL, ",)");
char *xpifile = strtok(NULL, ",)");
char *value = strtok(NULL, ",)");
char *newvalue = value;
if (value[0] == '%')
{
value++;
char *t = strchr(value, '%');
if (!t)
return FALSE;
*t = '\0';
newvalue = (char *)(LPCTSTR) GetGlobal(value);
}
if (!xpiname || !xpifile || !newvalue)
return FALSE;
ExtractXPIFile(xpiname, xpifile);
if (!CopyFile(newvalue, xpifile, FALSE))
{
DWORD e = GetLastError();
return FALSE;
}
}
else if (strcmp(cmdname, "modifyDTD") == 0)
{
char *xpiname = strtok(NULL, ",)");
char *xpifile = strtok(NULL, ",)");
char *entity = strtok(NULL, ",)");
char *value = strtok(NULL, ",)");
char *newvalue = value;
if (value[0] == '%')
{
value++;
char *t = strchr(value, '%');
if (!t)
return FALSE;
*t = '\0';
newvalue = (char *)(LPCTSTR) GetGlobal(value);
}
if (!xpiname || !xpifile || !entity || !newvalue)
return FALSE;
ExtractXPIFile(xpiname, xpifile);
ModifyDTD(xpifile, entity, newvalue);
}
else if (strcmp(cmdname, "wrapXPI") == 0)
{
}
else
return FALSE;
return TRUE;
}
extern "C" __declspec(dllexport)
int StartIB(CString parms)
{
char *fgetsrv;
int rv = TRUE;
char olddir[1024];
rootPath = GetGlobal("Root");
configName = GetGlobal("CustomizationList");
configPath = rootPath + "Configs\\" + configName;
cdPath = configPath + "\\CD";
tempPath = configPath + "\\Temp";
iniPath = cdPath + "\\config.ini";
scriptPath = rootPath + "\\script.ib";
workspacePath = configPath + "\\Workspace";
if (SearchPath(workspacePath, "NSCPXPI", NULL, 0, NULL, NULL))
nscpxpiPath = workspacePath + "\\NSCPXPI";
else
nscpxpiPath = rootPath + "NSCPXPI";
_mkdir((char *)(LPCTSTR) cdPath);
_mkdir((char *)(LPCTSTR) tempPath);
_mkdir((char *)(LPCTSTR) workspacePath);
GetCurrentDirectory(sizeof(olddir), olddir);
if(SetCurrentDirectory((char *)(LPCTSTR) tempPath) == FALSE)
return FALSE;
// Read in script file and interpret commands from it
FILE *f = fopen(scriptPath, "r");
if (!f)
rv = FALSE;
else
{
int done = FALSE;
while (!done)
{
fgetsrv = fgets(buffer, sizeof(buffer), f);
done = feof(f);
if (!done)
{
if (!fgetsrv || ferror(f))
{
rv = FALSE;
break;
}
buffer[strlen(buffer)] = '\0'; // Eliminate the trailing newline
if (!interpret(buffer))
{
rv = FALSE;
break;
}
}
}
fclose(f);
}
// Put all the extracted files back into their new XPI homes
ReplaceXPIFiles();
// Copy remaining default installer files into config
// preserving any existing files that we created already
// in previous steps
CopyDir(nscpxpiPath, cdPath, NULL, FALSE);
ReplaceINIFile();
SetCurrentDirectory(olddir);
return rv;
}

4
mozilla/cck/ib/ib.h Normal file
View File

@ -0,0 +1,4 @@
typedef struct s_xpi {
CString xpiname;
CString filename;
} XPI;

View File

@ -31,11 +31,13 @@ IS_COMPONENT = 1
OBJS= \
.\$(OBJDIR)\ib.obj \
.\$(OBJDIR)\ifuncns.obj \
$(NULL)
LINCS= $(LINCS) \
-I..\include \
-I$(PUBLIC)\zlib \
-I$(DIST)\$(OBJDIR)\include \
-I$(DEPTH)\xpinstall\wizard\windows\setup \
$(NULL)
MAKE_OBJ_TYPE = DLL
@ -60,6 +62,8 @@ LCFLAGS = $(LCFLAGS) \
# These are the libraries we need to link with to create the dll
LLIBS= $(LLIBS) \
../lib/globals.lib \
$(DIST)\lib\jar_s.lib \
$(DIST)\lib\zlib_s.lib \
$(NULL)
!ifdef MOZ_NO_DEBUG_RTL
@ -75,6 +79,9 @@ libs:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(CCKDIST)\CCKTool
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib ..\lib
export::
$(MAKE_INSTALL) script.ib $(CCKDIST)\CCKTool
#clobber::
# rm -f $(DIST)\bin\$(DLLNAME).dll
# rm -f $(DIST)\lib\$(DLLNAME).lib

8
mozilla/cck/ib/script.ib Normal file
View File

@ -0,0 +1,8 @@
configure(GENERAL,Product Name,%InstallerScreenText1%)
configure(GENERAL,Program Folder Name,%ProgramFolderName%)
replaceXPI(core.xpi,bin/chrome/global/skin/default/animthrob.gif,%SmallAnimPath%)
replaceXPI(core.xpi,bin/chrome/global/skin/default/animthrob_single.gif,%SmallStillPath%)
replaceXPI(core.xpi,bin/defaults/profile/bookmarks.html,%CustomBookmarkFile%)
modifyDTD(core.xpi,bin/chrome/navigator/locale/en-US/navigator.dtd,mainWindow.titlemodifier,%OrganizationName%)
modifyDTD(core.xpi,bin/chrome/navigator/locale/en-US/navigator.dtd,throbber.url,%AnimatedLogoURL%)
modifyDTD(core.xpi,bin/chrome/navigator/locale/en-US/navigator.dtd,defaultHomepage.url,%HomePageURL%)