308 { |
308 { |
309 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TOpaqueDataType componentData; |
309 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TOpaqueDataType componentData; |
310 |
310 |
311 componentData.iLocale = aLocale; |
311 componentData.iLocale = aLocale; |
312 componentData.iServiceUid = aServUid; |
312 componentData.iServiceUid = aServUid; |
313 componentData.iOpaqueData = aStrValue; |
313 |
314 |
314 /* |
315 aAppOpaqueData.iOpaqueDataType.push_back(componentData); |
315 * Under LINUX : The OpaqueData which is read from the resource file will be in UTF-16 format contained |
|
316 * in a std::wstring. So, we need to convert it back to UTF-32 format which is the format |
|
317 * of LINUX specific std::wstring. |
|
318 * |
|
319 * Under WINDOWS : Nothing needs to be done and this is taken care of by XercesStringToWString() |
|
320 * which is platform specific. |
|
321 */ |
|
322 componentData.iOpaqueData = XercesStringToWString(reinterpret_cast<const XMLCh*>(aStrValue.c_str())); |
|
323 aAppOpaqueData.iOpaqueDataType.push_back(componentData); |
316 } |
324 } |
317 |
325 |
318 /** |
326 /** |
319 * Get the path of Database "scr.db" |
327 * Get the path of Database "scr.db" |
320 */ |
328 */ |
324 if ( |
332 if ( |
325 (aParamList->RomLogFileNames().size() != 0 && aParamList->RomDrivePath().size() == 0 ) || |
333 (aParamList->RomLogFileNames().size() != 0 && aParamList->RomDrivePath().size() == 0 ) || |
326 aParamList->IsFlagSet(CParameterList::EFlagsDisableZDriveChecksSet) |
334 aParamList->IsFlagSet(CParameterList::EFlagsDisableZDriveChecksSet) |
327 ) |
335 ) |
328 { |
336 { |
|
337 #ifdef __LINUX__ |
|
338 return wstring2string(aParamList->SystemDrivePath()) + "/sys/install/scr/scr.db"; |
|
339 #else |
329 return wstring2string(aParamList->SystemDrivePath()) + "\\sys\\install\\scr\\scr.db"; |
340 return wstring2string(aParamList->SystemDrivePath()) + "\\sys\\install\\scr\\scr.db"; |
330 } |
341 #endif |
331 |
342 } |
|
343 |
|
344 #ifdef __LINUX__ |
|
345 return wstring2string(aParamList->RomDrivePath()) + "/sys/install/scr/provisioned/scr.db"; |
|
346 #else |
332 return wstring2string(aParamList->RomDrivePath()) + "\\sys\\install\\scr\\provisioned\\scr.db"; |
347 return wstring2string(aParamList->RomDrivePath()) + "\\sys\\install\\scr\\provisioned\\scr.db"; |
|
348 #endif |
333 } |
349 } |
334 |
350 |
335 /** |
351 /** |
336 * Update Installation Information in Database using SRCTOOL |
352 * Update Installation Information in Database using SRCTOOL |
337 */ |
353 */ |
338 |
354 |
339 void UpdateInstallationInformation_xml(const CParameterList* aParamList, |
355 void UpdateInstallationInformation_xml(const CParameterList* aParamList, |
340 XmlDetails::TScrPreProvisionDetail aScrPreProvisionDetail) |
356 XmlDetails::TScrPreProvisionDetail aScrPreProvisionDetail) |
341 { |
357 { |
342 CXmlGenerator xmlGenerator; |
358 CXmlGenerator xmlGenerator; |
343 char* tmpFileName = tmpnam(NULL); |
359 |
|
360 #ifndef __TOOLS2_LINUX__ |
|
361 char* tmpFileName = tmpnam(NULL); |
|
362 #else |
|
363 char tmpFileName[] = "/tmp/interpretsis_preprovision_XXXXXX"; |
|
364 int temp_fd; |
|
365 temp_fd=mkstemp(tmpFileName); |
|
366 fclose(fdopen(temp_fd,"w")); |
|
367 #endif |
|
368 |
344 std::wstring filename(string2wstring(tmpFileName)); |
369 std::wstring filename(string2wstring(tmpFileName)); |
345 |
370 |
346 int isRomApplication = 1; |
371 int isRomApplication = 1; |
347 xmlGenerator.WritePreProvisionDetails(filename , aScrPreProvisionDetail, isRomApplication); |
372 xmlGenerator.WritePreProvisionDetails(filename , aScrPreProvisionDetail, isRomApplication); |
348 |
373 |
|
374 #ifdef __LINUX__ |
|
375 std::string executable = "scrtool"; |
|
376 #else |
349 std::string executable = "scrtool.exe"; |
377 std::string executable = "scrtool.exe"; |
|
378 #endif |
|
379 |
350 std::string command; |
380 std::string command; |
351 |
381 |
352 command = executable + " -d " + GetDbPath(aParamList) + " -p " + tmpFileName; |
382 command = executable + " -d " + GetDbPath(aParamList) + " -p " + tmpFileName; |
353 |
383 |
354 cout << "Updating DB : " << command << endl; |
384 cout << "Updating DB : " << command << endl; |
623 { |
665 { |
624 if (curr->find(AppResourceFileExtension,0) != std::wstring::npos) |
666 if (curr->find(AppResourceFileExtension,0) != std::wstring::npos) |
625 { |
667 { |
626 iCount++; |
668 iCount++; |
627 std::string fName; |
669 std::string fName; |
628 fName = Ucs2ToUtf8( *curr ); |
670 fName = wstring2string( *curr ); |
629 std::string FilePath = wstring2string(aFilePath); |
671 std::string FilePath = wstring2string(aFilePath); |
|
672 #ifdef __LINUX__ |
|
673 FilePath.append("/"); |
|
674 #else |
630 FilePath.append("\\"); |
675 FilePath.append("\\"); |
|
676 #endif |
|
677 |
631 FilePath.append(fName); |
678 FilePath.append(fName); |
632 std::cout<<"Parsing - "<<fName<<" "; |
679 std::cout<<"Parsing - "<<fName<<" "; |
633 ReadApplicationInformationFromResourceFilesL(scrPreProvisionDetail,FilePath,aParamList,aInterpretSis,iNewFileFlag); |
680 ReadApplicationInformationFromResourceFilesL(scrPreProvisionDetail,FilePath,aParamList,aInterpretSis,iNewFileFlag); |
634 std::cout<<" "<<std::endl; |
681 std::cout<<" "<<std::endl; |
635 } |
682 } |
643 |
690 |
644 if(iNewFileFlag) |
691 if(iNewFileFlag) |
645 UpdateInstallationInformation_xml(aParamList,scrPreProvisionDetail); |
692 UpdateInstallationInformation_xml(aParamList,scrPreProvisionDetail); |
646 |
693 |
647 if(!iCount) |
694 if(!iCount) |
648 LERROR(L"Failed : No Resource File in the Directory Specified - "); |
695 LINFO(L"No Resource File in the Directory Specified - "); |
649 } |
696 } |
650 |
697 |
651 /** |
698 /** |
652 * Backup hash files for re-installation (SA over SA or PU over PU) |
699 * Backup hash files for re-installation (SA over SA or PU over PU) |
653 */ |
700 */ |
654 void BackupHashForFile(const std::wstring& aFile, const int aDriveLetter, const std::wstring& aPath) |
701 void BackupHashForFile(const std::wstring& aFile, const int aDriveLetter, const std::wstring& aPath) |
655 { |
702 { |
|
703 #ifdef __LINUX__ |
|
704 std::wstring hashdir = L"$:/sys/hash/"; |
|
705 #else |
656 std::wstring hashdir = L"$:\\sys\\hash\\"; |
706 std::wstring hashdir = L"$:\\sys\\hash\\"; |
|
707 #endif |
|
708 |
657 std::wstring basename = aFile.substr( aFile.rfind( KDirectorySeparator ) + 1) ; |
709 std::wstring basename = aFile.substr( aFile.rfind( KDirectorySeparator ) + 1) ; |
658 if (basename.size() == 0) |
710 if (basename.size() == 0) |
659 { |
711 { |
|
712 #ifdef __LINUX__ |
|
713 basename = aFile.substr(aFile.rfind(L"/")); |
|
714 #else |
660 basename = aFile.substr(aFile.rfind(L"\\")); |
715 basename = aFile.substr(aFile.rfind(L"\\")); |
|
716 #endif |
661 } |
717 } |
662 |
718 |
663 hashdir[0] = aDriveLetter; |
719 hashdir[0] = aDriveLetter; |
|
720 #ifdef __LINUX__ |
|
721 std::wstring hashFile = aPath + L"/sys/hash/" + basename; |
|
722 #else |
664 std::wstring hashFile = aPath + L"\\sys\\hash\\" + basename; |
723 std::wstring hashFile = aPath + L"\\sys\\hash\\" + basename; |
|
724 #endif |
665 |
725 |
666 if (FileExists(hashFile)) |
726 if (FileExists(hashFile)) |
667 { |
727 { |
668 std::string iLocalFile = wstring2string(hashFile); |
728 std::string iLocalFile = wstring2string(hashFile); |
669 std::string iBackupFile = wstring2string(hashFile); |
729 std::string iBackupFile = wstring2string(hashFile); |
670 iBackupFile.append("_backup"); |
730 iBackupFile.append("_backup"); |
671 |
731 |
672 int err=FileCopyA(iLocalFile.c_str(),iBackupFile.c_str(),0); |
732 int err=FileCopyA(iLocalFile.c_str(),iBackupFile.c_str(),0); |
673 if (err == 0) |
733 if (err != 0) |
674 LERROR(L"Failed to Backup hash file "); |
734 LERROR(L"Failed to Backup hash file "); |
675 } |
735 } |
676 } |
736 } |
677 |
737 |
678 /** |
738 /** |
679 * Restore hash files for re-installation (SA over SA or PU over PU) |
739 * Restore hash files for re-installation (SA over SA or PU over PU) |
680 */ |
740 */ |
681 void RestoreHashForFile(const std::wstring& aFile, const int aDriveLetter, const std::wstring& aPath) |
741 void RestoreHashForFile(const std::wstring& aFile, const int aDriveLetter, const std::wstring& aPath) |
682 { |
742 { |
|
743 #ifdef __LINUX__ |
|
744 std::wstring hashdir = L"$:/sys/hash/"; |
|
745 #else |
683 std::wstring hashdir = L"$:\\sys\\hash\\"; |
746 std::wstring hashdir = L"$:\\sys\\hash\\"; |
|
747 #endif |
684 std::wstring basename = aFile.substr( aFile.rfind( KDirectorySeparator ) + 1) ; |
748 std::wstring basename = aFile.substr( aFile.rfind( KDirectorySeparator ) + 1) ; |
685 if (basename.size() == 0) |
749 if (basename.size() == 0) |
686 { |
750 { |
|
751 #ifdef __LINUX__ |
|
752 basename = aFile.substr(aFile.rfind(L"/")); |
|
753 #else |
687 basename = aFile.substr(aFile.rfind(L"\\")); |
754 basename = aFile.substr(aFile.rfind(L"\\")); |
|
755 #endif |
688 } |
756 } |
689 |
757 |
690 hashdir[0] = aDriveLetter; |
758 hashdir[0] = aDriveLetter; |
|
759 #ifdef __LINUX__ |
|
760 std::wstring hashFile = aPath + L"/sys/hash/" + basename; |
|
761 #else |
691 std::wstring hashFile = aPath + L"\\sys\\hash\\" + basename; |
762 std::wstring hashFile = aPath + L"\\sys\\hash\\" + basename; |
|
763 #endif |
692 std::wstring LocalFile(hashFile); |
764 std::wstring LocalFile(hashFile); |
693 hashFile.append(L"_backup"); |
765 hashFile.append(L"_backup"); |
694 |
766 |
695 if (FileExists(hashFile)) |
767 if (FileExists(hashFile)) |
696 { |
768 { |
697 std::string iLocalFile = wstring2string(LocalFile); |
769 std::string iLocalFile = wstring2string(LocalFile); |
698 std::string iBackupFile = wstring2string(hashFile); |
770 std::string iBackupFile = wstring2string(hashFile); |
699 |
771 |
700 int err = FileMoveA(iBackupFile.c_str(),iLocalFile.c_str()); |
772 int err = FileMoveA(iBackupFile.c_str(),iLocalFile.c_str()); |
701 |
773 if (err != 0) |
702 if (err == 0) |
774 LERROR(L"Failed to Restore hash file "); |
703 LERROR(L"Failed to Restore hash file "); |
|
704 } |
775 } |
705 } |
776 } |
706 |
777 |
707 /** |
778 /** |
708 * Returns the size of the first occurance of an invalid directory separator. |
779 * Returns the size of the first occurance of an invalid directory separator. |
713 * e.g. /sys/bin/ should be replaced with \sys\bin\ |
784 * e.g. /sys/bin/ should be replaced with \sys\bin\ |
714 * and //sys//bin// should be replaced with \sys\bin\ |
785 * and //sys//bin// should be replaced with \sys\bin\ |
715 */ |
786 */ |
716 |
787 |
717 // Constants |
788 // Constants |
|
789 #ifdef __LINUX__ |
|
790 const std::wstring KSisDirectorySeparatortap( L"/" ); |
|
791 #else |
718 const std::wstring KSisDirectorySeparatortap( L"\\" ); |
792 const std::wstring KSisDirectorySeparatortap( L"\\" ); |
|
793 #endif |
|
794 |
719 |
795 |
720 int FirstInvalidDirSeparatorSizetap(std::wstring& aPath, std::wstring::size_type& aIndex) |
796 int FirstInvalidDirSeparatorSizetap(std::wstring& aPath, std::wstring::size_type& aIndex) |
721 { |
797 { |
722 // If path semantics is correct (as needed by sisx library) |
798 // If path semantics is correct (as needed by sisx library) |
723 // then the function will return 0 |
799 // then the function will return 0 |
724 int ret = 0; |
800 int ret = 0; |
725 int pos = 0; |
801 int pos = 0; |
|
802 #ifdef __LINUX__ |
|
803 if((pos = aPath.find(L"\\\\", aIndex)) != std::wstring::npos) |
|
804 #else |
726 if((pos = aPath.find(L"//", aIndex)) != std::wstring::npos) |
805 if((pos = aPath.find(L"//", aIndex)) != std::wstring::npos) |
|
806 #endif |
727 { |
807 { |
728 ret = 2; |
808 ret = 2; |
729 } |
809 } |
|
810 #ifdef __LINUX__ |
|
811 else if((pos = aPath.find(L"\\", aIndex)) != std::wstring::npos) |
|
812 #else |
730 else if((pos = aPath.find(L"/", aIndex)) != std::wstring::npos) |
813 else if((pos = aPath.find(L"/", aIndex)) != std::wstring::npos) |
|
814 #endif |
731 { |
815 { |
732 ret = 1; |
816 ret = 1; |
733 } |
817 } |
734 aIndex = pos; |
818 aIndex = pos; |
735 return ret; |
819 return ret; |