Fix for bug 104107: Avoid manually changing persmission of files in

customized linux tar file (r=mitchf)
This commit is contained in:
shrutiv%netscape.com 2002-07-01 23:54:05 +00:00
parent e1522de4fb
commit 08ff17ae57
2 changed files with 71 additions and 45 deletions

View File

@ -7,12 +7,15 @@
__declspec(dllexport) WIDGET GlobalWidgetArray[1000];
__declspec(dllexport) int GlobalArrayIndex=0;
__declspec(dllexport) BOOL IsSameCache = TRUE;
CString strNscpInstaller = "./netscape-installer/";
CString strXpi = strNscpInstaller + "xpi/*.xpi";
CString strConfigini = strNscpInstaller + "config.ini";
void ExtractContents(CString rootPath, CString instblobPath,
CString instFilename, CString platformInfo,
CString platformPath, CString extractPath);
void PopulateNscpxpi(CString rootpath, CString platformInfo,
CString nscpxpiPath, CString extractPath);
void PopulateNscpxpi(CString rootpath, CString platformInfo, CString instFilename, CString instblobPath,
CString tarfile, CString nscpxpiPath, CString extractPath);
extern "C" __declspec(dllexport)
int GetAttrib(CString theValue, char* attribArray[MAX_SIZE])
@ -236,7 +239,7 @@ void CreateDirectories(CString instblobPath)
{
CString rootPath, curVersion, instDirname, instFilename, fileExtension,
platformInfo, platformPath, extractPath, languageInfo,
languagePath, nscpxpiPath;
languagePath, nscpxpiPath, tarfile;
int blobPathlen, findfilePos, finddirPos;
char oldDir[MAX_SIZE];
@ -248,6 +251,8 @@ void CreateDirectories(CString instblobPath)
instFilename = instblobPath.Right(blobPathlen - finddirPos - 1);
findfilePos = instFilename.Find('.');
fileExtension = instFilename.Right(instFilename.GetLength()- findfilePos - 1);
findfilePos = instFilename.ReverseFind('.');
tarfile = instFilename.Left(findfilePos);
if (fileExtension == "tar.gz")
platformInfo = "Linux";
@ -277,8 +282,12 @@ void CreateDirectories(CString instblobPath)
platformInfo + "\\" + languageInfo;
nscpxpiPath = languagePath + "\\Nscpxpi";
_mkdir(languagePath);
_mkdir(nscpxpiPath);
PopulateNscpxpi(rootPath, platformInfo, nscpxpiPath, extractPath);
if (GetFileAttributes(nscpxpiPath) != -1)
// directory exists
EraseDirectory(nscpxpiPath);
else
_mkdir(nscpxpiPath);
PopulateNscpxpi(rootPath, platformInfo, instFilename, instblobPath, tarfile, nscpxpiPath, extractPath);
}
EraseDirectory(extractPath);
RemoveDirectory(extractPath);
@ -295,11 +304,13 @@ void ExtractContents(CString rootPath, CString instblobPath,
if (platformInfo == "Linux")
{
// change path to linux format
extractPath.Replace("\\","/");
extractPath.Replace(":","");
extractPath.Insert(0,"/cygdrive/");
command = "tar -zxvf " + instFilename + " -C " + quotes +
extractPath + quotes;
// Extract config.ini and .xpi files from tar.gz file
command = "tar -zxvf " + instFilename + " -C " + quotes + extractPath +
quotes + spaces + strXpi + spaces + strConfigini;
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
}
else if (platformInfo == "Windows")
@ -322,23 +333,36 @@ void ExtractContents(CString rootPath, CString instblobPath,
}
void PopulateNscpxpi(CString rootPath, CString platformInfo,
CString nscpxpiPath, CString extractPath)
void PopulateNscpxpi(CString rootPath, CString platformInfo, CString instFilename, CString instblobPath,
CString tarfile, CString nscpxpiPath, CString extractPath)
// Populate Nscpxpi directory with appropriate installer files
{
CString command,
quotes = "\"",
spaces = " ",
nscpzipFile = nscpxpiPath + "\\NSSetup.zip";
if (platformInfo == "Linux")
{
CString strNscpInstaller = "\\netscape-installer";
_mkdir(nscpxpiPath+strNscpInstaller);
CString tempnscpxpiPath = nscpxpiPath;
CopyDirectory(extractPath+strNscpInstaller+"\\xpi", nscpxpiPath, TRUE);
CopyDirectory(extractPath+strNscpInstaller, nscpxpiPath+strNscpInstaller,
FALSE);
CopyFile(nscpxpiPath+strNscpInstaller+"\\Config.ini",
nscpxpiPath+"\\Config.ini", FALSE);
CopyFile(extractPath+strNscpInstaller+"\\Config.ini", nscpxpiPath+"\\Config.ini", FALSE);
CopyFile(instblobPath, nscpxpiPath+"\\"+instFilename, FALSE);
// change path to linux format
tempnscpxpiPath.Replace("\\","/");
tempnscpxpiPath.Replace(":","");
tempnscpxpiPath.Insert(0,"/cygdrive/");
// Decompress tar.gz file
CString command = "gzip -d " + quotes + tempnscpxpiPath + "/" + instFilename + quotes;
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
// Delete .xpi and config.ini files in tar.gz
command = "tar --delete -f " + quotes + tempnscpxpiPath + "/" +
tarfile + quotes + spaces + strXpi + spaces + strConfigini;
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
}
else if (platformInfo == "Windows")
{

View File

@ -47,11 +47,11 @@ CString remoteAdminFile;
CString curPlatform;
CString platformPath;
CString templinuxPath;
CString nsinstPath;
CString nsinstallerDir;
CString templinuxDirPath;
CString xpiDir;
CString templinuxDir;
CString tarfile;
CString targzfile;
CString strNscpInstaller = "./netscape-installer";
// For use with PrefsTree
CString gstrCFGPrefFile;
@ -2118,12 +2118,17 @@ void CreateLinuxInstaller()
{
char currentdir[_MAX_PATH];
_getcwd(currentdir,_MAX_PATH);
if (FileExists(xpiDstPath+"\\"+tarfile))
DeleteFile(xpiDstPath+"\\"+tarfile);
// delete tar.gz file of output dir if it already exists
if (FileExists(xpiDstPath+"\\"+targzfile))
DeleteFile(xpiDstPath+"\\"+targzfile);
// Copy customized files to templinux directory
CopyDirectory(xpiDstPath, templinuxPath + xpiDir, TRUE);
CopyFile(xpiDstPath+"\\Config.ini", templinuxPath+"\\Config.ini",FALSE);
DeleteFile(templinuxPath + xpiDir + "\\Config.ini");
// Remove extra carriage returns in config.ini file
FILE *fout = fopen(templinuxPath+"\\config.tmp", "wb");
if (!fout)
{
@ -2173,14 +2178,23 @@ void CreateLinuxInstaller()
fputs("[END]\n", fout);
fclose(fout);
DeleteFile(templinuxPath+"\\Config.ini");
rename(templinuxPath+"\\config.tmp",templinuxPath+"\\config.ini");
rename(templinuxPath+"\\config.tmp", templinuxPath+"\\config.ini");
_chdir(outputPath);
templinuxPath = tempPath;
templinuxPath.Replace("\\", "/");
templinuxPath.Replace(":","");
templinuxPath.Insert(0,"/cygdrive/");
CString command = "tar -zcvf " + tarfile + " -C " +quotes+ templinuxPath + "/" + templinuxDir +quotes+ spaces + nsinstallerDir;
int pos = targzfile.ReverseFind('.');
CString tarfile = targzfile.Left(pos);
CopyFile(nscpxpiPath+"\\"+tarfile, xpiDstPath+"\\"+tarfile, FALSE);
templinuxDirPath.Replace("\\", "/");
templinuxDirPath.Replace(":","");
templinuxDirPath.Insert(0,"/cygdrive/");
// Add customized xpi files to linux tar file
CString command = "tar -rvf " + tarfile + " -C " + quotes +
templinuxDirPath + quotes + spaces + strNscpInstaller;
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
// Compress tar file to create customized tar.gz file
command = "gzip " + tarfile;
ExecuteCommand((char *)(LPCTSTR) command, SW_HIDE, INFINITE);
_chdir(currentdir);
}
@ -2414,12 +2428,11 @@ int StartIB(/*CString parms, WIDGET *curWidget*/)
SetGlobal("%REGION%", strREGION);
// initializing variables for CCK linux build
templinuxPath = tempPath + "\\templinux\\netscape-installer";
nsinstPath = "\\netscape-installer\\xpi";
nsinstallerDir = "netscape-installer";
xpiDir = "\\xpi";
templinuxDir = "tempLinux";
tarfile = "netscape-i686-pc-linux-gnu-sea.tar.gz";
templinuxPath = tempPath + "\\templinux\\netscape-installer";
xpiDir = "\\xpi";
templinuxDir = "tempLinux";
targzfile = "netscape-i686-pc-linux-gnu-sea.tar.gz";
templinuxDirPath = tempPath + "\\" + templinuxDir;
// AfxMessageBox("set breakpoint",MB_OK);
@ -2433,23 +2446,12 @@ int StartIB(/*CString parms, WIDGET *curWidget*/)
if (curPlatform == "Linux")
{
// Create directories for temporarily storing customized files
_mkdir(tempPath);
_chdir(tempPath);
_mkdir(templinuxDir);
_chdir(templinuxDir);
_mkdir(nsinstallerDir);
CopyDirectory(nscpxpiPath+"\\"+nsinstallerDir, templinuxPath, TRUE);
// get rid of this ugly code when bugzilla bug 105351 is fixed
CopyFile(nscpxpiPath+"\\full.start",
templinuxPath+"\\xpi\\full.start", FALSE);
CopyFile(nscpxpiPath+"\\full.end",
templinuxPath+"\\xpi\\full.end", FALSE);
CopyFile(nscpxpiPath+"\\recommended.start",
templinuxPath+"\\xpi\\recommended.start", FALSE);
CopyFile(nscpxpiPath+"\\recommended.end",
templinuxPath+"\\xpi\\recommended.end", FALSE);
_mkdir(templinuxPath);
_mkdir(templinuxPath + xpiDir);
}
iniSrcPath = nscpxpiPath + "\\config.ini";