344 } |
345 } |
345 |
346 |
346 InstallableFiles installable; |
347 InstallableFiles installable; |
347 GetInstallableFiles(file, installable, *iExpressionEvaluator, aInstallSISFile.iTargetDrive); |
348 GetInstallableFiles(file, installable, *iExpressionEvaluator, aInstallSISFile.iTargetDrive); |
348 |
349 |
|
350 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
351 TBool iBackupFlag = false; |
|
352 Backup(file, installable, iBackupFlag); |
|
353 #endif |
|
354 |
349 // Uninstall the same package (if found) prior to any installation |
355 // Uninstall the same package (if found) prior to any installation |
350 UninstallPkg(file); |
356 UninstallPkg(file); |
351 |
357 |
352 CheckDestinations(file, installable, aInstallSISFile); |
358 CheckDestinations(file, installable, aInstallSISFile); |
353 |
359 |
354 InstallFiles(installable, iParamList.SystemDriveLetter()); |
360 InstallFiles(installable, iParamList.SystemDriveLetter()); |
355 |
361 |
|
362 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
356 UpdateRegistry(file, installable, aInstallSISFile, aInstallSISFile.iSUFlag); |
363 UpdateRegistry(file, installable, aInstallSISFile, aInstallSISFile.iSUFlag); |
|
364 #else |
|
365 try { |
|
366 |
|
367 UpdateRegistry(file, installable, aInstallSISFile, aInstallSISFile.iSUFlag); |
|
368 } |
|
369 catch (InterpretSisError& e) |
|
370 { |
|
371 RestoreAll(file, installable, iBackupFlag); |
|
372 |
|
373 LERROR(L"\t" << string2wstring(e.what())); |
|
374 int result = e.GetErrorCode(); |
|
375 return result; |
357 |
376 |
|
377 } |
|
378 catch (...) |
|
379 {//Update Registry Failed. UnInstall the files. |
|
380 |
|
381 RestoreAll(file, installable, iBackupFlag); |
|
382 return RSC_PARSING_ERROR; |
|
383 } |
|
384 |
|
385 if(iBackupFlag) |
|
386 RemoveBackup(file, installable); |
|
387 #endif |
|
388 |
358 if (aInstallSISFile.iGenerateStub) |
389 if (aInstallSISFile.iGenerateStub) |
359 { |
390 { |
360 CreateStubSisFile(aInstallSISFile, file); |
391 CreateStubSisFile(aInstallSISFile, file); |
361 } |
392 } |
362 |
393 |
480 |
511 |
481 // Regenerate the ROM stub registry entries for eclipsing check later. |
512 // Regenerate the ROM stub registry entries for eclipsing check later. |
482 iRegistry.GenerateStubRegistry(); |
513 iRegistry.GenerateStubRegistry(); |
483 } |
514 } |
484 |
515 |
|
516 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
517 // Backup all installed files for this Uid's packages and all the SisRegistry Entries |
|
518 void Installer::Backup(const SisFile& aFile, InstallableFiles& aInstallable, TBool& aBackupFlag) |
|
519 { |
|
520 TUint32 uid = aFile.GetPackageUid(); |
|
521 TUint32 installType = aFile.GetInstallType(); |
|
522 |
|
523 // Check to see the SA is installed, else backup is not required. |
|
524 if (iRegistry.IsInstalled(uid) && ((installType == CSISInfo::EInstInstallation) || (installType == CSISInfo::EInstPartialUpgrade))) |
|
525 { |
|
526 aBackupFlag = true; |
|
527 int err = 0; |
|
528 LINFO(L"Backup package \"" << aFile.GetPackageName() << L"\" prior to re-installation"); |
|
529 |
|
530 // Backup all installed files for this Uid's packages and all the SisRegistry Entries |
|
531 iRegistry.BackupCtl(uid); |
|
532 |
|
533 //Backup SCR DB |
|
534 std::string DbPath = iRegistry.GetDbPath(); |
|
535 if (FileExists(string2wstring(DbPath))) |
|
536 { |
|
537 std::string BackupDb(DbPath); |
|
538 BackupDb.append("_backup"); |
|
539 |
|
540 err=FileCopyA(DbPath.c_str(),BackupDb.c_str(),0); |
|
541 if (err != 0) |
|
542 LERROR(L"Failed to Backup Database scr.db "); |
|
543 } |
|
544 |
|
545 // Backup all installed files for this Uid's packages and all the SisRegistry Entries |
|
546 InstallableFiles::const_iterator filedesIter; |
|
547 //Backup files |
|
548 for(filedesIter = aInstallable.begin() ; filedesIter != aInstallable.end(); ++filedesIter) |
|
549 { |
|
550 std::wstring itargetLocalFile = (*filedesIter)->GetLocalTarget(); |
|
551 if (FileExists(itargetLocalFile)) |
|
552 { |
|
553 std::wstring itargetBackupFile = (*filedesIter)->GetLocalTarget(); |
|
554 std::wstring temp = itargetBackupFile.c_str(); |
|
555 temp.append(L"_backup"); |
|
556 itargetBackupFile = temp; |
|
557 |
|
558 |
|
559 int pos =0; |
|
560 #ifdef __LINUX__ |
|
561 std::wstring sysBin = L"/sys/bin/"; |
|
562 #else |
|
563 std::wstring sysBin = L"\\sys\\bin\\"; |
|
564 #endif |
|
565 |
|
566 if((pos = itargetBackupFile.find(sysBin, 0)) != std::wstring::npos) |
|
567 { |
|
568 BackupHashForFile(itargetLocalFile, iParamList.SystemDriveLetter(), iParamList.SystemDrivePath()); |
|
569 } |
|
570 |
|
571 std::string iLocalFile = wstring2string(itargetLocalFile); |
|
572 std::string iBackupFile = wstring2string(itargetBackupFile); |
|
573 |
|
574 err=FileCopyA(iLocalFile.c_str(),iBackupFile.c_str(),0); |
|
575 if (err != 0) |
|
576 LERROR(L"Failed to Backup installable file "); |
|
577 } |
|
578 } |
|
579 } |
|
580 } |
|
581 |
|
582 // Remove Backup of all installed files for this Uid's packages and all the SisRegistry Entries |
|
583 void Installer::RemoveBackup(const SisFile& aFile, InstallableFiles& aInstallable) |
|
584 { |
|
585 TUint32 uid = aFile.GetPackageUid(); |
|
586 TUint32 installType = aFile.GetInstallType(); |
|
587 |
|
588 // Check to see the SA is installed, else backup is not required. |
|
589 if (iRegistry.IsInstalled(uid) && ((installType == CSISInfo::EInstInstallation) || (installType == CSISInfo::EInstPartialUpgrade))) |
|
590 { |
|
591 LINFO(L"Remove Backup of package \"" << aFile.GetPackageName() << L"\" after re-installation success"); |
|
592 // Remove all installed files for this Uid's packages and all the SisRegistry Entries |
|
593 iRegistry.RemoveCtlBackup(uid); |
|
594 |
|
595 //Remove Backup SCR DB |
|
596 std::string DbPath = iRegistry.GetDbPath(); |
|
597 std::string BackupDb(DbPath); |
|
598 BackupDb.append("_backup"); |
|
599 std::wstring DbBackup = string2wstring(BackupDb); |
|
600 |
|
601 if (FileExists(DbBackup)) |
|
602 RemoveFile(DbBackup); |
|
603 |
|
604 // Remove all installed files for this Uid's packages and all the SisRegistry Entries |
|
605 InstallableFiles::const_iterator filedesIter; |
|
606 std::wstring itargetLocalFile; |
|
607 std::wstring itargetBackupFile; |
|
608 |
|
609 for(filedesIter = aInstallable.begin() ; filedesIter != aInstallable.end(); ++filedesIter) |
|
610 { |
|
611 itargetLocalFile = (*filedesIter)->GetLocalTarget(); |
|
612 itargetBackupFile = (*filedesIter)->GetLocalTarget(); |
|
613 std::wstring temp = itargetBackupFile.c_str(); |
|
614 temp.append(L"_backup"); |
|
615 itargetBackupFile = temp; |
|
616 |
|
617 if (FileExists(itargetBackupFile)) |
|
618 { |
|
619 RemoveFile(itargetBackupFile); |
|
620 RemoveHashForFile(itargetBackupFile, iParamList.SystemDriveLetter(), iParamList.SystemDrivePath()); |
|
621 } |
|
622 } |
|
623 } |
|
624 } |
|
625 |
|
626 // Restore all installed files for this Uid's packages and all the SisRegistry Entries |
|
627 void Installer::Restore(const SisFile& aFile, InstallableFiles& aInstallable, TBool& aBackupFlag) |
|
628 { |
|
629 TUint32 uid = aFile.GetPackageUid(); |
|
630 TUint32 installType = aFile.GetInstallType(); |
|
631 |
|
632 // Check to see the SA is installed, else backup is not required. |
|
633 if((installType == CSISInfo::EInstInstallation) || (installType == CSISInfo::EInstPartialUpgrade)) |
|
634 { |
|
635 LINFO(L"Restoring Installed Package "); |
|
636 |
|
637 // Restore all .ctl file for this Uid's packages and all the SisRegistry Entries |
|
638 iRegistry.RestoreCtl(uid, aBackupFlag); |
|
639 |
|
640 // Restore all installed files for this Uid's packages and all the SisRegistry Entries |
|
641 InstallableFiles::const_iterator filedesIter; |
|
642 for(filedesIter = aInstallable.begin() ; filedesIter != aInstallable.end(); ++filedesIter) |
|
643 { |
|
644 std::wstring itargetLocalFile = (*filedesIter)->GetLocalTarget(); |
|
645 std::wstring itargetBackupFile = (*filedesIter)->GetLocalTarget(); |
|
646 itargetBackupFile.append(L"_backup"); |
|
647 if (FileExists(itargetBackupFile)) |
|
648 { |
|
649 int pos =0; |
|
650 #ifdef __LINUX__ |
|
651 std::wstring sysBin = L"/sys/bin/"; |
|
652 #else |
|
653 std::wstring sysBin = L"\\sys\\bin\\"; |
|
654 #endif |
|
655 |
|
656 if((pos = itargetBackupFile.find(sysBin, 0)) != std::wstring::npos) |
|
657 { |
|
658 RestoreHashForFile(itargetLocalFile, iParamList.SystemDriveLetter(), iParamList.SystemDrivePath()); |
|
659 } |
|
660 |
|
661 std::string iLocalFile = wstring2string(itargetLocalFile); |
|
662 std::string iBackupFile = wstring2string(itargetBackupFile); |
|
663 |
|
664 int err = FileMoveA(iBackupFile.c_str(),iLocalFile.c_str()); |
|
665 if (err != 0) |
|
666 LERROR(L"Failed to Restore file "); |
|
667 } |
|
668 } |
|
669 } |
|
670 } |
|
671 |
|
672 void Installer::RestoreAll(const SisFile& aFile, InstallableFiles& aInstallable, TBool& aBackupFlag) |
|
673 { |
|
674 InstallableFiles::const_iterator filedesIter; |
|
675 std::wstring itargetLocalFile; |
|
676 |
|
677 for(filedesIter = aInstallable.begin() ; filedesIter != aInstallable.end(); ++filedesIter) |
|
678 { |
|
679 itargetLocalFile = (*filedesIter)->GetLocalTarget(); |
|
680 |
|
681 if (FileExists(itargetLocalFile)) |
|
682 { |
|
683 RemoveFile(itargetLocalFile); |
|
684 RemoveHashForFile(itargetLocalFile, iParamList.SystemDriveLetter(), iParamList.SystemDrivePath()); |
|
685 } |
|
686 } |
|
687 Restore(aFile, aInstallable, aBackupFlag); |
|
688 FreeInstallableFiles(aInstallable); |
|
689 } |
|
690 |
|
691 #endif |
485 |
692 |
486 struct CheckDependencyMet |
693 struct CheckDependencyMet |
487 { |
694 { |
488 CheckDependencyMet( |
695 CheckDependencyMet( |
489 Installer& aInstaller, |
696 Installer& aInstaller, |