Implement delta mode for wgt 39/50539/7
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 29 Oct 2015 12:18:35 +0000 (13:18 +0100)
committerPawel Sikorski <p.sikorski@samsung.com>
Thu, 5 Nov 2015 15:46:27 +0000 (07:46 -0800)
Change-Id: Iec9dd993cdc552ef1bb96e6c70f18ad452b593cc

src/common/step/step_delta_patch.cc
src/common/step/step_delta_patch.h
src/wgt/wgt_installer.cc

index 3600c3d..0da315b 100644 (file)
@@ -178,6 +178,12 @@ bool ApplyPatch(const delta::DeltaInfo& info, const bf::path& app_dir,
 namespace common_installer {
 namespace filesystem {
 
+StepDeltaPatch::StepDeltaPatch(InstallerContext* context,
+                               const std::string& delta_root)
+    : Step(context),
+      delta_root_(delta_root) {
+}
+
 Step::Status StepDeltaPatch::precheck() {
   if (context_->unpacked_dir_path.get().empty()) {
     LOG(ERROR) << "Unpacked dir is not set";
@@ -223,14 +229,20 @@ Step::Status StepDeltaPatch::process() {
     return Status::ERROR;
   }
 
-  if (!CopyDir(context_->root_application_path.get() / context_->pkgid.get(),
-               context_->unpacked_dir_path.get())) {
+  if (!CopyDir(context_->root_application_path.get() / context_->pkgid.get()
+               / delta_root_, context_->unpacked_dir_path.get())) {
     LOG(ERROR) << "Failed to copy package files";
     return Status::ERROR;
   }
 
-  RemoveBinarySymlinks(context_->unpacked_dir_path.get());
-  RemoveStorageDirectories(context_->unpacked_dir_path.get());
+  // if there is no root set, that means we need to handle files added by
+  // installer itself (during installation) and files added during runtime
+  // they will be restored in process so just remove extra copy here, so that
+  // it doesn't interfere with installation process
+  if (delta_root_.empty()) {
+    RemoveBinarySymlinks(context_->unpacked_dir_path.get());
+    RemoveStorageDirectories(context_->unpacked_dir_path.get());
+  }
 
   // apply changes mentioned in delta
   if (!ApplyPatch(*delta_info, context_->unpacked_dir_path.get(), patch_dir_))
index 6722c88..cc9cf78 100644 (file)
@@ -5,8 +5,9 @@
 #ifndef COMMON_STEP_STEP_DELTA_PATCH_H_
 #define COMMON_STEP_STEP_DELTA_PATCH_H_
 
-#include "common/installer_context.h"
+#include <string>
 
+#include "common/installer_context.h"
 #include "common/step/step.h"
 #include "common/utils/logging.h"
 
@@ -34,7 +35,8 @@ namespace filesystem {
  */
 class StepDeltaPatch : public Step {
  public:
-  using Step::Step;
+  explicit StepDeltaPatch(InstallerContext* context,
+                          const std::string& delta_root = "");
 
   Status process() override;
   Status clean() override { return Status::OK; }
@@ -43,6 +45,7 @@ class StepDeltaPatch : public Step {
 
  private:
   boost::filesystem::path patch_dir_;
+  std::string delta_root_;
 
   SCOPE_LOG_TAG(DeltaPatch)
 };
index 43a0f8c..b3e53e1 100644 (file)
@@ -13,6 +13,7 @@
 #include "common/step/step_copy.h"
 #include "common/step/step_copy_backup.h"
 #include "common/step/step_copy_storage_directories.h"
+#include "common/step/step_delta_patch.h"
 #include "common/step/step_fail.h"
 #include "common/step/step_kill_apps.h"
 #include "common/step/step_generate_xml.h"
@@ -130,8 +131,30 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       break;
     }
     case ci::RequestType::Delta: {
-      // TODO(t.iwanek): add proper steps for this mode...
-      AddStep<ci::configuration::StepFail>();
+      AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+      AddStep<ci::filesystem::StepUnzip>();
+      // TODO(t.iwanek): manifest is parsed twice...
+      AddStep<wgt::parse::StepParse>(false);  // start file may not have changed
+      AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
+      AddStep<wgt::parse::StepParse>(true);
+      AddStep<ci::security::StepCheckSignature>();
+      AddStep<wgt::security::StepAddDefaultPrivileges>();
+      AddStep<ci::security::StepPrivilegeCompatibility>();
+      AddStep<wgt::security::StepCheckSettingsLevel>();
+      AddStep<ci::security::StepCheckOldCertificate>();
+      AddStep<wgt::filesystem::StepWgtResourceDirectory>();
+      AddStep<ci::backup::StepOldManifest>();
+      AddStep<ci::pkgmgr::StepKillApps>();
+      AddStep<ci::backup::StepBackupManifest>();
+      AddStep<ci::backup::StepBackupIcons>();
+      AddStep<ci::backup::StepCopyBackup>();
+      AddStep<wgt::filesystem::StepWgtCopyStorageDirectories>();
+      AddStep<wgt::filesystem::StepCreateSymbolicLink>();
+      AddStep<wgt::filesystem::StepWgtCreateIcons>();
+      AddStep<ci::security::StepUpdateSecurity>();
+      AddStep<ci::pkgmgr::StepGenerateXml>();
+      AddStep<ci::pkgmgr::StepUpdateApplication>();
+      break;
     }
     case ci::RequestType::Recovery: {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);