secureswitools/swisistools/source/interpretsislib/installer.cpp
branchRCL_3
changeset 73 79647526f98c
parent 66 8b7f4e561641
child 81 42552535c1ac
equal deleted inserted replaced
70:e8965914fac7 73:79647526f98c
   136 				if ((currStr->find(L".SIS",0) != std::wstring::npos)
   136 				if ((currStr->find(L".SIS",0) != std::wstring::npos)
   137 					|| (currStr->find(L".sis",0) != std::wstring::npos))
   137 					|| (currStr->find(L".sis",0) != std::wstring::npos))
   138 				{
   138 				{
   139 					InstallSISFile sisFileName(shortName + KDirectorySeparator + *currStr, 
   139 					InstallSISFile sisFileName(shortName + KDirectorySeparator + *currStr, 
   140 												curr->iTargetDrive, curr->iGenerateStub, 
   140 												curr->iTargetDrive, curr->iGenerateStub, 
   141 												curr->iNonRemovable, curr->iReadOnly, curr->iNotRegister, curr->iSUFlag);
   141 												curr->iNonRemovable, curr->iReadOnly, curr->iNotRegister, 
       
   142 												curr->iSUFlag, curr->iGenerateRomStub);
   142 
   143 
   143 					sisFiles.push_back(sisFileName);
   144 					sisFiles.push_back(sisFileName);
   144 				}
   145 				}
   145 			}
   146 			}
   146 
   147 
   151 		}
   152 		}
   152 		else if ((shortName.find(L".SIS",0) != std::wstring::npos)
   153 		else if ((shortName.find(L".SIS",0) != std::wstring::npos)
   153 				|| (shortName.find(L".sis",0) != std::wstring::npos))
   154 				|| (shortName.find(L".sis",0) != std::wstring::npos))
   154 		{
   155 		{
   155 			InstallSISFile sisFileName(shortName, curr->iTargetDrive, curr->iGenerateStub, 
   156 			InstallSISFile sisFileName(shortName, curr->iTargetDrive, curr->iGenerateStub, 
   156 										curr->iNonRemovable, curr->iReadOnly, curr->iNotRegister, curr->iSUFlag);
   157 										curr->iNonRemovable, curr->iReadOnly, curr->iNotRegister, 
       
   158 										curr->iSUFlag, curr->iGenerateRomStub);
   157 
   159 
   158 			sisFiles.push_back(sisFileName);
   160 			sisFiles.push_back(sisFileName);
   159 		}
   161 		}
   160 		else
   162 		else
   161 		{
   163 		{
   336 	if (!DependenciesOk(file))
   338 	if (!DependenciesOk(file))
   337 	{
   339 	{
   338 		return MISSING_DEPENDENCY;
   340 		return MISSING_DEPENDENCY;
   339 	}
   341 	}
   340 
   342 
   341 	if (!IsValidUpgrade(file, aInstallSISFile.iSUFlag, aInstallSISFile.iNonRemovable))
   343 	if (!IsValidUpgrade(file, aInstallSISFile.iSUFlag, aInstallSISFile.iNonRemovable, aInstallSISFile.iGenerateRomStub))
   342 	{
   344 	{
   343 		return INVALID_UPGRADE;
   345 		return INVALID_UPGRADE;
   344 	}
   346 	}
   345 
   347 
   346 	InstallableFiles installable;
   348 	InstallableFiles installable;
   347 	GetInstallableFiles(file, installable, *iExpressionEvaluator, aInstallSISFile.iTargetDrive);
   349 	GetInstallableFiles(file, installable, *iExpressionEvaluator, aInstallSISFile.iTargetDrive, 
       
   350 									iParamList.SystemDriveLetter(), aInstallSISFile.iGenerateRomStub);
   348 
   351 
   349 	// Uninstall the same package (if found) prior to any installation
   352 	// Uninstall the same package (if found) prior to any installation
   350 	UninstallPkg(file);
   353 	UninstallPkg(file, aInstallSISFile.iGenerateRomStub);
   351 
   354 
   352 	CheckDestinations(file, installable, aInstallSISFile);
   355 	CheckDestinations(file, installable, aInstallSISFile);
   353 
   356 
   354 	InstallFiles(installable, iParamList.SystemDriveLetter());
   357 	InstallFiles(installable, iParamList.SystemDriveLetter(), aInstallSISFile.iGenerateRomStub);
   355 
   358 
   356 	UpdateRegistry(file, installable, aInstallSISFile, aInstallSISFile.iSUFlag);
   359 	UpdateRegistry(file, installable, aInstallSISFile, aInstallSISFile.iSUFlag);
   357 	
   360 	
   358 	if (aInstallSISFile.iGenerateStub)
   361 	if (aInstallSISFile.iGenerateStub)
   359 	{
   362 	{
   360 		CreateStubSisFile(aInstallSISFile, file);
   363 		CreateStubSisFile(aInstallSISFile, file);
       
   364 	}
       
   365 
       
   366 	if (aInstallSISFile.iGenerateRomStub)
       
   367 	{
       
   368 		CreateRomStubSisFile(aInstallSISFile, file);
   361 	}
   369 	}
   362 
   370 
   363 	FreeInstallableFiles(installable);
   371 	FreeInstallableFiles(installable);
   364 
   372 
   365 	return SUCCESS;
   373 	return SUCCESS;
   456 
   464 
   457 	// case c)
   465 	// case c)
   458 	return (stubExistsInRom && (romUpgradableSA || puInstall || spInstall));    	
   466 	return (stubExistsInRom && (romUpgradableSA || puInstall || spInstall));    	
   459 }
   467 }
   460 
   468 
   461 void Installer::UninstallPkg(const SisFile& aSis)
   469 void Installer::UninstallPkg(const SisFile& aSis, const bool aGenerateRomStub)
   462 {
   470 {
   463 	TUint32 uid = aSis.GetPackageUid();
   471 	TUint32 uid = aSis.GetPackageUid();
   464 	TUint32 installType = aSis.GetInstallType();
   472 	TUint32 installType = aSis.GetInstallType();
   465 
   473 
   466 	// Check to see the SA is installed, otherwise, RemovePkg() will throw an exception
   474 	// Check to see the SA is installed, otherwise, RemovePkg() will throw an exception
   467 	if (iRegistry.IsInstalled(uid) && (installType == CSISInfo::EInstInstallation))
   475 	if (iRegistry.IsInstalled(uid) && (installType == CSISInfo::EInstInstallation))
   468 	{
   476 	{
   469 		LINFO(L"Removing package \"" << aSis.GetPackageName() << L"\" prior to re-installation");
   477 		LINFO(L"Removing package \"" << aSis.GetPackageName().c_str() << L"\" prior to re-installation");
   470 
   478 
   471 		// Remove all installed files for this Uid's packages and all the SisRegistry Entries
   479 		// Remove all installed files for this Uid's packages and all the SisRegistry Entries
   472 		iRegistry.RemovePkg(uid, true);
   480 		iRegistry.RemovePkg(uid, true);
   473 	}
   481 	}
   474 
   482 
   476 	{
   484 	{
   477 		// Clean up the installed files from the specified SP package and the SisRegistry Entry
   485 		// Clean up the installed files from the specified SP package and the SisRegistry Entry
   478 		iRegistry.RemoveEntry(uid, aSis.GetPackageName().c_str(), aSis.GetVendorName().c_str());
   486 		iRegistry.RemoveEntry(uid, aSis.GetPackageName().c_str(), aSis.GetVendorName().c_str());
   479 	}
   487 	}
   480 
   488 
   481 	// Regenerate the ROM stub registry entries for eclipsing check later.
   489 	if(!aGenerateRomStub)
   482 	iRegistry.GenerateStubRegistry();
   490 	{
       
   491 		// Regenerate the ROM stub registry entries for eclipsing check later.
       
   492 		iRegistry.GenerateStubRegistry();
       
   493 	}
       
   494 	else
       
   495 	{
       
   496 		std::list<std::wstring> stubFileEntries;
       
   497 
       
   498 		iRegistry.GetStubFileEntries(uid, stubFileEntries);
       
   499 		if((!stubFileEntries.empty()))
       
   500 	    {
       
   501 			LINFO(L"Rom Stub Upgrade, removing \"" << iRegistry.GetRomStubFile() << L"\" prior to re-installation");
       
   502 			RemoveFile(iRegistry.GetRomStubFile());
       
   503 		
       
   504 			std::list<std::wstring>::const_iterator end = stubFileEntries.end();
       
   505 			for (std::list<std::wstring>::const_iterator curr = stubFileEntries.begin() ;
       
   506 			 curr != end; ++curr)
       
   507 			{
       
   508 				std::wstring file = *curr;
       
   509 				file[0]='z';
       
   510 				ConvertToLocalPath(file, iParamList.RomDrivePath());
       
   511 				RemoveFile(file);
       
   512 			}
       
   513 	 	}
       
   514 	}
   483 }
   515 }
   484 
   516 
   485 
   517 
   486 struct CheckDependencyMet
   518 struct CheckDependencyMet
   487 {
   519 {
   543 
   575 
   544 	return iMissing[aFile.GetPackageName()].size() == 0;
   576 	return iMissing[aFile.GetPackageName()].size() == 0;
   545 	}
   577 	}
   546 
   578 
   547 
   579 
   548 bool Installer::IsValidUpgrade(const SisFile& aFile, bool aSUFlag, bool aNonRemovable)
   580 bool Installer::IsValidUpgrade(const SisFile& aFile, bool aSUFlag, bool aNonRemovable, bool aGenerateRomStub)
   549 {
   581 {
   550 	TUint32 pkg = aFile.GetPackageUid();
   582 	TUint32 pkg = aFile.GetPackageUid();
   551 	TUint32 installFlags = aFile.GetInstallFlags();
   583 	TUint32 installFlags = aFile.GetInstallFlags();
   552 
   584 
   553 	if(aNonRemovable)
   585 	if(aNonRemovable)
   580 
   612 
   581 	TUint32 installType = aFile.GetInstallType();
   613 	TUint32 installType = aFile.GetInstallType();
   582 
   614 
   583 	if (iRegistry.IsInstalled(pkg))
   615 	if (iRegistry.IsInstalled(pkg))
   584 		{
   616 		{
   585 		ValidateRegistry(aFile,pkg,installFlags,RUFlag,aNonRemovable);	
   617 		if (aGenerateRomStub && (installType == CSISInfo::EInstAugmentation || installType == CSISInfo::EInstPartialUpgrade))
       
   618 			{
       
   619 			// Installing SP and PU to Rom (z) drive not allowed
       
   620 			std::stringstream err;
       
   621 			err << "Could not perform SP or PU upgrade for Rom (z) drive installation";
       
   622 			
       
   623 			throw InterpretSisError(err.str(), ATTEMPT_TO_UPGRADE_ROM_PKG);
       
   624 			}
       
   625 		else
       
   626 			{
       
   627 			ValidateRegistry(aFile,pkg,installFlags,RUFlag,aNonRemovable,aGenerateRomStub);	
       
   628 			}
   586 		}
   629 		}
   587 	else if (installType == CSISInfo::EInstAugmentation || installType == CSISInfo::EInstPartialUpgrade)
   630 	else if (installType == CSISInfo::EInstAugmentation || installType == CSISInfo::EInstPartialUpgrade)
   588 		{
   631 		{
   589 		// Installing SP and PU without the base package
   632 		if(iParamList.IsFlagSet(CParameterList::EFlagsRomInstallSet))
   590 		std::stringstream err;
   633 			{
   591 		err << "Could not perform upgrade - the base package 0x" << std::hex 
   634 			// Installing SP and PU to Rom Drive is not supported.
   592 			<< pkg << " is missing";
   635 			std::stringstream err;
   593 
   636 			err << "Installing SP and PU to Rom (z) Drive is not supported.";
   594 		throw InterpretSisError(err.str(), MISSING_BASE_PACKAGE);
   637 			throw InterpretSisError(err.str(), ATTEMPT_TO_UPGRADE_ROM_PKG);
       
   638 			}
       
   639 		else
       
   640 			{
       
   641 			// Installing SP and PU without the base package
       
   642 			std::stringstream err;
       
   643 			err << "Could not perform upgrade - the base package 0x" << std::hex 
       
   644 				<< pkg << " is missing";
       
   645 
       
   646 			throw InterpretSisError(err.str(), MISSING_BASE_PACKAGE);
       
   647 			}
   595 		}
   648 		}
   596 
   649 
   597 	return true;
   650 	return true;
   598 	}
   651 	}
   599 
   652 
   600 void Installer::ValidateRegistry(const SisFile& aFile, TUint32 aPckgUid, TUint32 aInstallFlags, bool aRUFlag, bool aNonRemovable)
   653 void Installer::ValidateRegistry(const SisFile& aFile, TUint32 aPckgUid, TUint32 aInstallFlags, 
       
   654 										bool aRUFlag, bool aNonRemovable, bool aGenerateRomStub)
   601 	{
   655 	{
   602 	bool isSisNonRemovable = aInstallFlags & CSISInfo::EInstFlagNonRemovable;
   656 	bool isSisNonRemovable = aInstallFlags & CSISInfo::EInstFlagNonRemovable;
   603 	bool isBaseRemovable = false;
   657 	bool isBaseRemovable = false;
   604 	bool inRom = false;
   658 	bool inRom = false;
   605 	bool isPreInstalled = false;
   659 	bool isPreInstalled = false;
   611 	// Check is this package has been installed before
   665 	// Check is this package has been installed before
   612 	TUint32 installType = aFile.GetInstallType();
   666 	TUint32 installType = aFile.GetInstallType();
   613 
   667 
   614 	if (installType == CSISInfo::EInstInstallation)
   668 	if (installType == CSISInfo::EInstInstallation)
   615 		{
   669 		{
   616 		if (inRom && !aRUFlag)
   670 		if (inRom && !aRUFlag && !aGenerateRomStub)
   617 			{
   671 			{
   618 			std::stringstream err;
   672 			std::stringstream err;
   619 			err << "Illegal SA upgrade to ROM package 0x" << std::hex << aPckgUid;
   673 			err << "Illegal SA upgrade to ROM package 0x" << std::hex << aPckgUid;
   620 			throw InterpretSisError(err.str(), ATTEMPT_TO_UPGRADE_ROM_PKG);
   674 			throw InterpretSisError(err.str(), ATTEMPT_TO_UPGRADE_ROM_PKG);
   621 			}
   675 			}
   622 		// This is not a ROM base package, check is there a SIS stub base package present
   676 		// This is not a ROM base package, check is there a SIS stub base package present
   623 		else if (iRegistry.IsRomStubPackage(aPckgUid) && !aRUFlag)
   677 		else if (iRegistry.IsRomStubPackage(aPckgUid) && !aRUFlag && !aGenerateRomStub)
   624 			{			
   678 			{			
   625 			std::stringstream err;
   679 			std::stringstream err;
   626 			err << "Indirect SA upgrade to ROM package 0x" << std::hex << aPckgUid
   680 			err << "Indirect SA upgrade to ROM package 0x" << std::hex << aPckgUid
   627 				<< " missing RU flag";
   681 				<< " missing RU flag";
   628 			throw InterpretSisError(err.str(), ATTEMPT_TO_UPGRADE_ROM_PKG);
   682 			throw InterpretSisError(err.str(), ATTEMPT_TO_UPGRADE_ROM_PKG);
   709 		}
   763 		}
   710 	#endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   764 	#endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   711 	}
   765 	}
   712 
   766 
   713 bool Installer::GetInstallableFiles(const SisFile& aFile, InstallableFiles& aList, ExpressionEvaluator& aEvaluator, 
   767 bool Installer::GetInstallableFiles(const SisFile& aFile, InstallableFiles& aList, ExpressionEvaluator& aEvaluator, 
   714 									int aInstallingDrive)
   768 									int aInstallingDrive, const int aSystemDrive, const bool aGenerateRomStub)
   715 {
   769 {
   716 	return aFile.GetInstallableFiles(aList, aEvaluator, 
   770 	return aFile.GetInstallableFiles(aList, aEvaluator, 
   717 		iConfigManager.GetLocalDrivePath(aInstallingDrive), aInstallingDrive);
   771 		iConfigManager.GetLocalDrivePath(aInstallingDrive), aInstallingDrive, aSystemDrive, aGenerateRomStub);
   718 }
   772 }
   719 
   773 
   720 
   774 
   721 struct InstallFile
   775 struct InstallFile
   722 {
   776 {
   723 	InstallFile(const std::wstring& aCDrive, const int aSystemDrive)
   777 	InstallFile(const std::wstring& aCDrive, const int aSystemDrive, const bool aGenerateRomStub)
   724 		: iSystemDrivePath(aCDrive), iSystemDrive(aSystemDrive) {}
   778 		: iSystemDrivePath(aCDrive), iSystemDrive(aSystemDrive), iGenerateRomStub(aGenerateRomStub) {}
   725 
   779 
   726 	const std::wstring& iSystemDrivePath;
   780 	const std::wstring& iSystemDrivePath;
   727 	const int iSystemDrive;
   781 	const int iSystemDrive;
       
   782 	const bool iGenerateRomStub;
   728 
   783 
   729 	void operator()(const InstallableFile* aFile)
   784 	void operator()(const InstallableFile* aFile)
   730 	{
   785 	{
   731 		std::fstream output;
   786 		std::fstream output;
   732 		std::wstring target(aFile->GetTarget());
   787 		std::wstring target(aFile->GetTarget());
   740             }
   795             }
   741         else
   796         else
   742             {
   797             {
   743 			// Unicode characters can not be displayed on DOS prompt
   798 			// Unicode characters can not be displayed on DOS prompt
   744  			std::string temporary = wstring2string(target);
   799  			std::string temporary = wstring2string(target);
       
   800 			if(temporary[0]=='$')
       
   801 			{
       
   802 				temporary[0] = iSystemDrive;
       
   803 			}
   745 			std::wstring targetDisplay = string2wstring( temporary );
   804 			std::wstring targetDisplay = string2wstring( temporary );
   746 		    LINFO(L"Installing file: " << targetDisplay);
   805 		    LINFO(L"Installing file: " << targetDisplay);
       
   806 
       
   807 			if(target[0]==L'$')
       
   808 			{
       
   809 				localTarget = target;
       
   810 				ConvertToLocalPath( localTarget, iSystemDrivePath );
       
   811 				target[0] = iSystemDrive;
       
   812 				aFile->SetTarget(target);
       
   813 			}
   747 
   814 
   748             std::wstring targetDirectory = localTarget.substr( 0, localTarget.rfind( KDirectorySeparator ) );    		
   815             std::wstring targetDirectory = localTarget.substr( 0, localTarget.rfind( KDirectorySeparator ) );    		
   749 			const unsigned char* buffer = NULL;
   816 			const unsigned char* buffer = NULL;
   750 			TUint32 len;
   817 			TUint32 len;
   751 
   818 
   760 			else // SA 
   827 			else // SA 
   761 			{
   828 			{
   762 				// if the FN option specified, leave the file creation
   829 				// if the FN option specified, leave the file creation
   763 				if (fileNullOption)
   830 				if (fileNullOption)
   764 				{
   831 				{
   765 					LINFO(L"File " << target << L" contains \"Delete-File-On-Uninstall\" option." );
   832 					LINFO(L"File " << target.c_str() << L" contains \"Delete-File-On-Uninstall\" option." );
   766 				}
   833 				}
   767 				else 
   834 				else 
   768 				{
   835 				{
   769 					if ( !MakeDir( targetDirectory ) )
   836 					if ( !MakeDir( targetDirectory ) )
   770 					{
   837 					{
   787 					}
   854 					}
   788 					CloseHandle(hFile);
   855 					CloseHandle(hFile);
   789 				}
   856 				}
   790 			}
   857 			}
   791 
   858 
   792 			if (aFile->IsExecutable() && !fileNullOption)
   859 			if (aFile->IsExecutable() && !fileNullOption && !iGenerateRomStub)
   793 			{
   860 			{
   794 				// register the hash
   861 				// register the hash
   795 				std::wstring basename = localTarget.substr( localTarget.rfind( KDirectorySeparator ) + 1 );
   862 				std::wstring basename = localTarget.substr( localTarget.rfind( KDirectorySeparator ) + 1 );
   796 				#ifndef __TOOLS2_LINUX__
   863 				#ifndef __TOOLS2_LINUX__
   797 				// Remove the null character at the end and.
   864 				// Remove the null character at the end and.
   833         }
   900         }
   834 	}
   901 	}
   835 };
   902 };
   836 
   903 
   837 
   904 
   838 void Installer::InstallFiles(const InstallableFiles& aList, const int aInstallDrive)
   905 void Installer::InstallFiles(const InstallableFiles& aList, int aInstallDrive, const bool aGenerateRomStub)
   839 {
   906 {
       
   907 	if(aGenerateRomStub)
       
   908 		{
       
   909 		aInstallDrive = 'z'; //Rom Drive
       
   910 		}
       
   911 
   840 	std::wstring localTargetPath = iConfigManager.GetLocalDrivePath(aInstallDrive);
   912 	std::wstring localTargetPath = iConfigManager.GetLocalDrivePath(aInstallDrive);
   841 
   913 
   842 	std::for_each(aList.begin(), aList.end(), InstallFile(localTargetPath, aInstallDrive));
   914 	std::for_each(aList.begin(), aList.end(), InstallFile(localTargetPath, aInstallDrive, aGenerateRomStub));
   843 }
   915 }
   844 
   916 
   845 
   917 
   846 void Installer::UpdateRegistry(const SisFile& aFile, const InstallableFiles& aList, 
   918 void Installer::UpdateRegistry(const SisFile& aFile, const InstallableFiles& aList, 
   847 												   const InstallSISFile& aInstallSISFile, const bool aSUFlag)
   919 												   const InstallSISFile& aInstallSISFile, const bool aSUFlag)
  1152 	}
  1224 	}
  1153 
  1225 
  1154 	return isEclipsable;
  1226 	return isEclipsable;
  1155 }
  1227 }
  1156 
  1228 
       
  1229 /** This function handles file overwriting scenarios from Stub SIS files only and not from SISregistry.
       
  1230       (i.e: we are trying to install z:\somedir\somename.ext however it already exists)
       
  1231  @param aFile the SIS file to be installed
       
  1232  @param aTarget The fully qualified filename (full path and name)
       
  1233 */
       
  1234 void Installer::HandleRomFileOverwriting(const SisFile& aFile, const std::wstring& aTarget)
       
  1235 {
       
  1236 	// find out which Rom Stub this file belongs to
       
  1237 	TUint32 owningUid = 0;
       
  1238 	CSISController* sisController = iRegistry.GetStubControllerUid(aTarget);
       
  1239 
       
  1240 	if(sisController)
       
  1241 	{
       
  1242 		owningUid=sisController->UID1();
       
  1243 	}
       
  1244 
       
  1245 	// no package owns this file. Always allow orphaned file overwriting!
       
  1246 	if (owningUid == 0)
       
  1247 	{
       
  1248 		LWARN(aTarget << L" overwrites orphaned file");
       
  1249 	}
       
  1250 	else if (aFile.GetPackageUid() != owningUid)
       
  1251 	{
       
  1252 		std::wostringstream os;
       
  1253 		os << aTarget.c_str() << L" overwrites file from package 0x" << std::hex << owningUid << L" \"" << sisController->SISInfo().PackageName(0) << L"\"" << std::endl;
       
  1254 		iProblemFiles.append(os.str());
       
  1255 		iError = ECLIPSING_VIOLATION;
       
  1256 	}
       
  1257 	
       
  1258 	if(sisController)
       
  1259 	{
       
  1260 		delete sisController;	
       
  1261 	}
       
  1262 }
       
  1263 
  1157 /** This function handles overwriting scenarios (i.e: we are trying to install c:\somedir\somename.ext however it already exists)
  1264 /** This function handles overwriting scenarios (i.e: we are trying to install c:\somedir\somename.ext however it already exists)
  1158  In this case we have 2 possibilities:
  1265  In this case we have 2 possibilities:
  1159  1) We are correctly overwriting the already present file (a PU)
  1266  1) We are correctly overwriting the already present file (a PU)
  1160  2) We are incorrectly overwriting the file present
  1267  2) We are incorrectly overwriting the file present
  1161  @param aFile the SIS file to be installed
  1268  @param aFile the SIS file to be installed
  1281 	const std::wstring exeType = L".exe";
  1388 	const std::wstring exeType = L".exe";
  1282 
  1389 
  1283     int num_of_files = aFiles.size();
  1390     int num_of_files = aFiles.size();
  1284 	TUint32 pkgUid = aFile.GetPackageUid();
  1391 	TUint32 pkgUid = aFile.GetPackageUid();
  1285 	TUint32 installType = aFile.GetInstallType();
  1392 	TUint32 installType = aFile.GetInstallType();
  1286 	std::list<std::wstring> stubFileEntries;
       
  1287 
       
  1288 	iRegistry.GetStubFileEntries(pkgUid, stubFileEntries);
       
  1289 
  1393 
  1290 	// if a base package exists, check to see if it chains back to a ROM stub. If so, populate
  1394 	// if a base package exists, check to see if it chains back to a ROM stub. If so, populate
  1291 	// iEclipsableRomFiles with the files owned by the ROM stub. Only ROM files can be eclipsed.
  1395 	// iEclipsableRomFiles with the files owned by the ROM stub. Only ROM files can be eclipsed.
  1292 	//
  1396 	//
  1293 	// if the package has been signed by a SU cert, then there is no need to generate the eclipsable
  1397 	// if the package has been signed by a SU cert, then there is no need to generate the eclipsable
  1337 					std::wostringstream os;
  1441 					std::wostringstream os;
  1338 					os << target.c_str() << L" eclipses file from ROM" << std::endl;
  1442 					os << target.c_str() << L" eclipses file from ROM" << std::endl;
  1339 					iProblemFiles.append(os.str());
  1443 					iProblemFiles.append(os.str());
  1340 					iError = ECLIPSING_VIOLATION;
  1444 					iError = ECLIPSING_VIOLATION;
  1341 					continue;
  1445 					continue;
       
  1446 				}
       
  1447 			}
       
  1448 
       
  1449 			if(aInstallSISFile.iGenerateRomStub)
       
  1450 			{
       
  1451 				bool isOverwrite = FileExists(file->GetLocalTarget());
       
  1452 				// To check if We are incorrectly overwriting the file present.
       
  1453 				if (isOverwrite)
       
  1454 				{
       
  1455 					HandleRomFileOverwriting(aFile, target);
  1342 				}
  1456 				}
  1343 			}
  1457 			}
  1344 			
  1458 			
  1345 			// additional platsec checks
  1459 			// additional platsec checks
  1346 			if (target.find(privatePath) != std::wstring::npos)
  1460 			if (target.find(privatePath) != std::wstring::npos)
  1572 		 }
  1686 		 }
  1573 	}
  1687 	}
  1574 }
  1688 }
  1575 
  1689 
  1576 
  1690 
       
  1691 void Installer::CreateRomStubSisFile(const InstallSISFile& aInstallSISFile, SisFile& aSis)
       
  1692 {
       
  1693 
       
  1694 	int targetDrive = aInstallSISFile.iTargetDrive;
       
  1695 	std::wstring drivePath = iConfigManager.GetLocalDrivePath(targetDrive);
       
  1696 
       
  1697 	#ifndef __TOOLS2_LINUX__
       
  1698 	drivePath.append(L"\\system\\install\\");
       
  1699 	#else
       
  1700 	drivePath.append(L"/system/install/");
       
  1701 	#endif
       
  1702 
       
  1703 	// build Rom Stub Pathname
       
  1704 	if ( !MakeDir( drivePath ) )
       
  1705 	{
       
  1706 		throw InterpretSisError(L"Directory Creation Error - "+drivePath, DIRECTORY_CREATION_ERROR);
       
  1707 	}
       
  1708 
       
  1709 	size_t found;
       
  1710   	found=aInstallSISFile.iFileName.find_last_of(L"/\\");
       
  1711 	std::wstring sisFile = aInstallSISFile.iFileName.substr(found+1);
       
  1712 	std::wstring sisFilename = sisFile.substr(0,sisFile.length()-4);
       
  1713 	drivePath.append(sisFilename);
       
  1714 	drivePath.append(L"_");
       
  1715 	std::wstringstream sUid;
       
  1716 	sUid << std::hex << aSis.GetPackageUid();
       
  1717 	drivePath.append(sUid.str());
       
  1718 	drivePath.append(L".sis");
       
  1719 
       
  1720 	// Display the target SIS file. Format the stub SIS file string so it displays correctly.
       
  1721 	std::wstring ctrlDrive(L"z:");
       
  1722 	std::wstring ctrlTarget = drivePath.substr(iConfigManager.GetLocalDrivePath(targetDrive).length(),drivePath.length());
       
  1723 	ctrlDrive.append(ctrlTarget);
       
  1724 
       
  1725 	LINFO(L"\tCreating ROM stub: " << ctrlDrive);
       
  1726 	aSis.MakeSISRomStub(drivePath);
       
  1727 	// If the NR flag is set, change the file attribute to RO
       
  1728 }
       
  1729 
  1577 void Installer::CreateStubSisFile(const InstallSISFile& aInstallSISFile, SisFile& aSis)
  1730 void Installer::CreateStubSisFile(const InstallSISFile& aInstallSISFile, SisFile& aSis)
  1578 {
  1731 {
  1579 	int targetDrive = aInstallSISFile.iTargetDrive;
  1732 	int targetDrive = aInstallSISFile.iTargetDrive;
  1580 	std::wstring drivePath = iConfigManager.GetLocalDrivePath(targetDrive);
  1733 	std::wstring drivePath = iConfigManager.GetLocalDrivePath(targetDrive);
  1581 	#ifndef __TOOLS2_LINUX__
  1734 	#ifndef __TOOLS2_LINUX__