Implement recovery of ReadonlyUpdateUninstall 59/281159/4
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 13 Sep 2022 12:51:59 +0000 (21:51 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 14 Sep 2022 02:41:20 +0000 (11:41 +0900)
Change-Id: Ibf742a8003f5d0148d98845360b15e84c0fcd1f7
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/installer/app_installer.cc
src/common/recovery_file.cc
src/common/step/pkgmgr/step_recover_parser_plugins.cc
src/common/step/recovery/step_open_recovery_file.cc
src/common/step/recovery/step_recovery.cc
src/common/step/recovery/step_recovery.h

index bdef968..dd6e3a8 100644 (file)
@@ -743,6 +743,7 @@ void AppInstaller::ReadonlyUpdateInstallSteps() {
 
 void AppInstaller::ReadonlyUpdateUninstallSteps() {
   AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+  AddStep<ci::recovery::StepCreateRecoveryFile>();
   AddStep<ci::configuration::StepParseManifest>(
       ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
       ci::configuration::StepParseManifest::StoreLocation::BACKUP);
index 815c433..cd1b632 100644 (file)
@@ -35,6 +35,7 @@ const char kRecoveryDeltaString[] = "DELTA";
 const char kRecoveryMountInstallString[] = "MOUNTINSTALL";
 const char kRecoveryMountUpdateString[] = "MOUNTUPDATE";
 const char kRecoveryReadonlyUpdateInstallString[] = "READONLYUPDATEINSTALL";
+const char kRecoveryReadonlyUpdateUninstallString[] = "READONLYUPDATEUNINSTALL";
 const char kRecoveryUnknownString[] = "UNKNOWN";
 
 const std::map<std::string, ci::RequestType> kStringToRequestMap = {
@@ -47,6 +48,8 @@ const std::map<std::string, ci::RequestType> kStringToRequestMap = {
   {kRecoveryMountUpdateString, ci::RequestType::MountUpdate},
   {kRecoveryReadonlyUpdateInstallString,
       ci::RequestType::ReadonlyUpdateInstall},
+  {kRecoveryReadonlyUpdateUninstallString,
+      ci::RequestType::ReadonlyUpdateUninstall},
 };
 
 std::string TruncateNewLine(const char* data) {
@@ -256,6 +259,9 @@ bool RecoveryFile::WriteAndCommitFileContent() {
   case RequestType::ReadonlyUpdateInstall:
     ofs << kRecoveryReadonlyUpdateInstallString << std::endl;
     break;
+  case RequestType::ReadonlyUpdateUninstall:
+    ofs << kRecoveryReadonlyUpdateUninstallString << std::endl;
+    break;
   default:
     ofs << kRecoveryUnknownString << std::endl;
     break;
index 8fb4e71..4d221cc 100644 (file)
@@ -27,6 +27,7 @@ ci::Plugin::ActionType GetActionType(ci::InstallerContext* context) {
     case ci::RequestType::Delta:
     case ci::RequestType::MountUpdate:
     case ci::RequestType::ReadonlyUpdateInstall:
+    case ci::RequestType::ReadonlyUpdateUninstall:
       return ci::Plugin::ActionType::RecoverUpgrade;
     default:
       LOG(ERROR) << "Invalid request type : " << static_cast<int>(type);
index c6d7111..2f976e8 100644 (file)
@@ -55,6 +55,13 @@ Step::Status StepOpenRecoveryFile::process() {
       context_->root_application_path.set(
           GetRootAppPath(true, context_->uid.get()));
       break;
+    case RequestType::ReadonlyUpdateUninstall:
+      LOG(INFO) << "Running recovery for readonly update uninstallation";
+      context_->request_type.set(RequestType::RecoveryUpdate);
+      context_->is_readonly_package.set(true);
+      context_->root_application_path.set(
+          GetRootAppPath(true, context_->uid.get()));
+      break;
     default:
       LOG(ERROR) << context_->file_path.get() << " is unknown recovery type ("
                  << static_cast<int>(recovery_file->type()) << ")";
index 1e4dc39..2c541d1 100644 (file)
@@ -33,6 +33,8 @@ Step::Status StepRecovery::process() {
     return RecoveryMountUpdate();
   case RequestType::ReadonlyUpdateInstall:
     return RecoveryReadonlyUpdateInstall();
+  case RequestType::ReadonlyUpdateUninstall:
+    return RecoveryReadonlyUpdateUninstall();
   default:
     LOG(ERROR) << "Recovery is not supported for given type of installation";
     return Status::RECOVERY_ERROR;
@@ -59,6 +61,10 @@ Step::Status StepRecovery::RecoveryReadonlyUpdateInstall() {
   return RecoveryUpdate();
 }
 
+Step::Status StepRecovery::RecoveryReadonlyUpdateUninstall() {
+  return RecoveryReadonlyUpdateInstall();
+}
+
 Step::Status StepRecovery::Cleanup() {
   return Status::OK;
 }
index bdd881e..16c7808 100644 (file)
@@ -39,6 +39,7 @@ class StepRecovery : public Step {
   virtual Status RecoveryMountNew();
   virtual Status RecoveryMountUpdate();
   virtual Status RecoveryReadonlyUpdateInstall();
+  virtual Status RecoveryReadonlyUpdateUninstall();
   virtual Status Cleanup();
 };