From 2f6be9c679cc17879107760a463b917a9349e33a Mon Sep 17 00:00:00 2001 From: "shrutiv%netscape.com" Date: Fri, 18 Jan 2002 19:30:05 +0000 Subject: [PATCH] Fix for bug 11279: Change CCK directory structure to support different plaltforms and languages (r=smeredith) git-svn-id: svn://10.0.0.236/trunk@112444 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/cck/cckwiz/iniFiles/Linux_page.ini | 119 ---------------- mozilla/cck/cckwiz/iniFiles/cck.ini | 12 +- mozilla/cck/globals/comp.cpp | 58 +------- mozilla/cck/globals/globals.cpp | 151 +++++++++++++++++++++ mozilla/cck/globals/globals.h | 3 + 5 files changed, 166 insertions(+), 177 deletions(-) delete mode 100644 mozilla/cck/cckwiz/iniFiles/Linux_page.ini diff --git a/mozilla/cck/cckwiz/iniFiles/Linux_page.ini b/mozilla/cck/cckwiz/iniFiles/Linux_page.ini deleted file mode 100644 index bfd9e27a68d..00000000000 --- a/mozilla/cck/cckwiz/iniFiles/Linux_page.ini +++ /dev/null @@ -1,119 +0,0 @@ -; Mode: INI; tab-width: 8; indent-tabs-mode: nil -*- -; -; The contents of this file are subject to the Netscape Public -; License Version 1.1 (the "License"); you may not use this file -; except in compliance with the License. You may obtain a copy of -; the License at http://www.mozilla.org/NPL/ -; -; Software distributed under the License is distributed on an "AS -; IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -; implied. See the License for the specific language governing -; rights and limitations under the License. -; -; The Original Code is the Client Customization Kit. -; -; The Initial Developer of the Original Code is Netscape -; Communications Corporation. Portions created by Netscape are -; Copyright (C) 1998 Netscape Communications Corporation. All Rights -; Reserved. -; - -[Local Variables] -Name=Linux_page -Title=<%CustomizationList%> - Specify platform information -Caption=2nd level node -Help=Online;%Root%CCKHelp\platform.html - - -[Navigation Controls] -onNext= -Help=platform_Help.ini - -[Image 1888] -Type=Image -Name=platform.bmp -Value= -Start_x=0 -Start_y=0 -Width=425 -Height=56 - -[Widget 2888] -Type=BoldGroup -Name=GroupBox2888 -Value=Platform -Start_x=0 -Start_y=32 -Width=407 -Height=90 - -[Widget 3888] -Type=Text -Name=Text3888 -Value=Choose platform for installer: -Start_x=11 -Start_y=55 -Width=100 -Height=15 - -[Widget 4888] -Type=DropBox -Name=lPlatform -Value= -Start_x=130 -Start_y=54 -Width=65 -height=75 -subsection=Options for DropBox4888 -onCommand=ChangePlatform(lPlatform) -[Options for DropBox4888] -opt1=Windows -opt2=Linux - -[Widget 5888] -Type=Text -Name=Text5888 -Value=Customizing for Macintosh: First create a customized Windows installer, then transfer the customized Windows files to a standard Macintosh installation package. For details, click Help below. -Start_x=11 -Start_y=87 -Width=380 -Height=30 - -[Widget 6888] -Type=BoldGroup -Name=GroupBox6888 -Value=Linux tar file -Start_x=0 -Start_y=135 -Width=407 -Height=60 - -[Widget 7888] -Type=Text -Name=Text7888 -Value=Enter the path for a Netscape 6 Linux tar file. If necessary, download it first from http://home.netscape.com. -Start_x=11 -Start_y=150 -Width=380 -Height=15 - -[Widget 8888] -Type=EditBox -Name=LinuxPath -Value= -Start_x=11 -Start_y=170 -Width=310 -Height=15 - -[Widget 9888] -Type=Button -Name=Button9888 -Value=Choose File... -Start_x=340 -Start_y=170 -Width=50 -Height=14 -onCommand=BrowseFile() -Target=LinuxPath - diff --git a/mozilla/cck/cckwiz/iniFiles/cck.ini b/mozilla/cck/cckwiz/iniFiles/cck.ini index 670057c8f53..cca577d87ac 100644 --- a/mozilla/cck/cckwiz/iniFiles/cck.ini +++ b/mozilla/cck/cckwiz/iniFiles/cck.ini @@ -35,16 +35,16 @@ onNext= Help=cck.txt [Sub Pages] -CheckList=show -Linux_page=show +CheckList=show +Platform_page=show Info=show Branding_page1=show Customize_page3=show ;Branding_page5=show -Customize_page1=show -Mail_page=show -News_page=show -Proxy=show +Customize_page1=show +Mail_page=show +News_page=show +Proxy=show Branding_page2=show ;Branding_page4=show Build_page1=show diff --git a/mozilla/cck/globals/comp.cpp b/mozilla/cck/globals/comp.cpp index 6eaa487f287..de5c9fe8b41 100644 --- a/mozilla/cck/globals/comp.cpp +++ b/mozilla/cck/globals/comp.cpp @@ -16,14 +16,6 @@ CString iniDstPath; CString scriptPath; CString nscpxpiPath; -CString linuxOption; -CString linuxblobPath; -CString linuxDir; -CString nsinstPath; -CString xpiDir; -CString tarfile; -CString quotes; - COMPONENT Components[100]; int numComponents; @@ -111,54 +103,16 @@ int GenerateComponentList(CString parms, WIDGET *curWidget) configPath = rootPath + "Configs\\" + configName; workspacePath = configPath + "\\Workspace"; nscpxpiPath; + CString curVersion = GetGlobal("Version"); + CString curPlatform = GetGlobal("lPlatform"); + CString curLanguage = GetGlobal("Language"); + CString localePath = rootPath+"Version\\"+curVersion+"\\"+curPlatform+"\\"+curLanguage; - linuxOption = GetGlobal("lPlatform"); - if (linuxOption == "Linux") - { - linuxblobPath = GetGlobal("LinuxPath"); - linuxDir = "nscpxpiLinux"; - nsinstPath = "\\netscape-installer\\xpi"; - xpiDir = "\\xpi"; - CString tnscpxpilinuxPath = rootPath + linuxDir; - CString nscpxpilinuxPath = tnscpxpilinuxPath; - int pathlen = linuxblobPath.GetLength(); - int pos = linuxblobPath.ReverseFind('\\'); - pos += 1; - CString linuxinstDirPath = linuxblobPath.Left(pos); - tarfile = linuxblobPath.Right(pathlen-pos); - - int direxist = GetFileAttributes(nscpxpilinuxPath); - if ((direxist == -1) && (linuxblobPath != "")) - // nscpxpiLinux directory does not exist - { - quotes = "\""; - char currentdir[_MAX_PATH]; - _getcwd(currentdir, _MAX_PATH); - _chdir(rootPath); - _mkdir(linuxDir); - _chdir(linuxinstDirPath); - tnscpxpilinuxPath.Replace("\\","/"); - tnscpxpilinuxPath.Replace(":",""); - tnscpxpilinuxPath.Insert(0,"/cygdrive/"); - CString command = "tar -zxvf " + tarfile + " -C " + quotes + tnscpxpilinuxPath + quotes; - ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE); - - nscpxpiPath = nscpxpilinuxPath + nsinstPath; - CString tempxpiPath = nscpxpiPath; - tempxpiPath.Replace(xpiDir,""); - CopyFile(tempxpiPath+"\\Config.ini", nscpxpiPath+"\\Config.ini", - FALSE); - _chdir(currentdir); - } - nscpxpiPath = nscpxpilinuxPath + nsinstPath; - } - else - { if (SearchPath(workspacePath, "NSCPXPI", NULL, 0, NULL, NULL)) nscpxpiPath = workspacePath + "\\NSCPXPI"; else - nscpxpiPath = rootPath + "NSCPXPI"; - } + nscpxpiPath = localePath + "\\Nscpxpi"; + iniSrcPath = nscpxpiPath + "\\config.ini"; BuildComponentList(Components, &numComponents, iniSrcPath, 1); diff --git a/mozilla/cck/globals/globals.cpp b/mozilla/cck/globals/globals.cpp index 961d73d2684..9dea18ad979 100644 --- a/mozilla/cck/globals/globals.cpp +++ b/mozilla/cck/globals/globals.cpp @@ -137,6 +137,38 @@ void ExecuteCommand(char *command, int showflag, DWORD wait) WaitForSingleObject(processInfo.hProcess, wait); } +extern "C" __declspec(dllexport) +void CopyDirectory(CString source, CString dest, BOOL subdir) +// Copy files in subdirectories if the subdir flag is set (equal to 1). +{ + CFileFind finder; + CString sFileToFind = source + "\\*.*"; + BOOL bWorking = finder.FindFile(sFileToFind); + while (bWorking) + { + bWorking = finder.FindNextFile(); + CString newPath=dest + "\\"; + + if (finder.IsDots()) continue; + if (finder.IsDirectory()) + { + CString dirPath = finder.GetFilePath(); + newPath += finder.GetFileName(); + _mkdir(newPath); + if (subdir == TRUE) + CopyDirectory(dirPath, newPath, TRUE); + if (!CopyFile(dirPath,newPath,0)) + DWORD e = GetLastError(); + continue; + } + + newPath += finder.GetFileName(); + CString source = finder.GetFilePath(); + if (!CopyFile(source,newPath,0)) + DWORD e = GetLastError(); + } +} + extern "C" __declspec(dllexport) void EraseDirectory(CString sPath) { @@ -159,6 +191,125 @@ void EraseDirectory(CString sPath) } } +__declspec(dllexport) +CString SearchDirectory(CString dirPath, BOOL subDir, CString serachStr) +// This function searches all the files in the directory dirPath, +// for the file whose name contains the search string serachStr, +// searching recursively if subDir is TRUE +{ + CFileFind finder; + CString filePath; + CString fileName; + CString retval; + CString sFileToFind = dirPath + "\\*.*"; + BOOL found = finder.FindFile(sFileToFind); + while (found) + { + found = finder.FindNextFile(); + + if (finder.IsDots()) continue; + + filePath = finder.GetFilePath(); + fileName = finder.GetFileName(); + if (fileName.Find(serachStr) != -1) + return fileName; + + if (finder.IsDirectory()) + { + if (subDir == TRUE) + retval = SearchDirectory(filePath, TRUE, serachStr); + return retval; + } + } + return fileName; +} + +extern "C" __declspec(dllexport) +void CreateDirectories(CString instblobPath) +// Create appropriate platform and language directories +{ + CString quotes = "\""; + CString rootPath = GetGlobal("Root"); + CString curVersion = GetGlobal("Version"); + int instblobPathlen = instblobPath.GetLength(); + int findfilePos = instblobPath.Find('.'); + int finddirPos = instblobPath.ReverseFind('\\'); + CString instDirname = instblobPath.Left(finddirPos); + CString instFilename = instblobPath.Right(instblobPathlen - finddirPos -1); + CString fileExtension = instblobPath.Right(instblobPathlen - findfilePos -1); + SetGlobal("InstallerFilename",instFilename); + + // Is the blob path a Linux blob installer + if (fileExtension == "tar.gz") + { + char oldDir[MAX_SIZE]; + CString platformInfo = "Linux"; + CString platformPath = rootPath + "Version\\" + curVersion + "\\" + platformInfo; + CString extractPath = platformPath + "\\" + "temp"; + CString tempPath = extractPath; + + if (GetFileAttributes(platformPath) == -1) + // platform directory does not exist + _mkdir(platformPath); + + // extract contents of Linux blob installer + _mkdir(extractPath); + GetCurrentDirectory(sizeof(oldDir), oldDir); + SetCurrentDirectory((char *)(LPCTSTR) instDirname); + tempPath.Replace("\\","/"); + tempPath.Replace(":",""); + tempPath.Insert(0,"/cygdrive/"); + CString command = "tar -zxvf " + instFilename + " -C " + quotes + tempPath + quotes; + ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE); + CString searchStr = "defl"; + searchStr = SearchDirectory(extractPath, TRUE, searchStr); + + if (searchStr != "") + { + CString languageInfo = searchStr.Mid(4,4); + CString languagePath = rootPath + "Version\\" + curVersion + "\\" + platformInfo + "\\" + languageInfo; + CString nscpxpiPath = languagePath + "\\Nscpxpi"; + + _mkdir(languagePath); + _mkdir(nscpxpiPath); + + // checking if nscpxpi directory is non-empty + // to avoid the steps of populating installer files + BOOL empty = TRUE; + CFileFind fn; + if (fn.FindFile(nscpxpiPath+"\\*.*") != 0) + { + while (TRUE) + { + int fileExist = fn.FindNextFile(); + if (!fn.IsDots()) + { + empty = FALSE; + break; + } + if (fileExist == 0) break; + } + } + if (empty) + { + CString nsinstallerStr = "\\netscape-installer"; + _mkdir(nscpxpiPath+nsinstallerStr); + CopyDirectory(extractPath+nsinstallerStr+"\\xpi", + nscpxpiPath, TRUE); + CopyDirectory(extractPath+nsinstallerStr, + nscpxpiPath+nsinstallerStr, FALSE); + CopyFile(nscpxpiPath+nsinstallerStr+"\\Config.ini", + nscpxpiPath+"\\Config.ini", FALSE); + CopyFile(rootPath+"script_linux.ib", + languagePath+"\\script.ib", FALSE); + } + } + EraseDirectory(extractPath); + RemoveDirectory(extractPath); + SetCurrentDirectory(oldDir); + } +} + __declspec(dllexport) CString GetModulePath() { diff --git a/mozilla/cck/globals/globals.h b/mozilla/cck/globals/globals.h index 0749d67e631..3fb9063c452 100644 --- a/mozilla/cck/globals/globals.h +++ b/mozilla/cck/globals/globals.h @@ -12,5 +12,8 @@ extern "C" __declspec(dllimport) WIDGET* findWidget(CString theName); 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); extern "C" __declspec(dllimport) int GetAttrib(CString theValue, char* attribArray[]); +extern "C" __declspec(dllimport) void CopyDirectory(CString source, CString dest, BOOL subdir); extern "C" __declspec(dllimport) void EraseDirectory(CString sPath); +__declspec(dllimport) CString SearchDirectory(CString dirPath, BOOL subDir, CString searchStr); +extern "C" __declspec(dllimport) void CreateDirectories(CString instblobPath); __declspec(dllimport) CString GetModulePath();