Skeloton for update installation 27/38927/1
authorTomasz Iwanek <t.iwanek@samsung.com>
Wed, 25 Mar 2015 15:24:11 +0000 (16:24 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Thu, 30 Apr 2015 11:21:47 +0000 (13:21 +0200)
Tizen-JIRA: TC-2482

Change-Id: I8d0c0b18f8732360c32e99dbb03c0088436ff854

src/common/pkgmgr_interface.cc
src/common/pkgmgr_interface.h
src/common/step/step_configure.cc
src/tpk/task.cc
src/tpk/task.h
src/wgt/wgt_backend.cc

index c007542..9df7915 100644 (file)
@@ -51,6 +51,8 @@ PkgMgrInterface::Type PkgMgrInterface::GetRequestType() const {
   switch (pkgmgr_installer_get_request_type(pi_)) {
     case PKGMGR_REQ_INSTALL:
       return PkgMgrInterface::Type::Install;
+    case PKGMGR_REQ_UPGRADE:
+      return PkgMgrInterface::Type::Update;
     case PKGMGR_REQ_UNINSTALL:
       return PkgMgrInterface::Type::Uninstall;
     case PKGMGR_REQ_REINSTALL:
index 738f4dc..f7dc605 100644 (file)
@@ -27,10 +27,11 @@ class PkgMgrInterface {
   /** Request type received from pkgmgr_installer
    */
   enum class Type {
-       Unknown,
-       Install,
-       Uninstall,
-       Reinstall
+    Unknown,
+    Install,
+    Update,
+    Uninstall,
+    Reinstall
   };
 
   /** Returns Request type passed from pkgmgr_installer
index 3fe37f7..3ce8da2 100644 (file)
@@ -26,14 +26,18 @@ Step::Status StepConfigure::process() {
       context_->file_path.set(pkgmgr->GetRequestInfo());
       context_->pkgid.set(kStrEmpty);
       break;
+    case PkgMgrInterface::Type::Update:
+      context_->file_path.set(pkgmgr->GetRequestInfo());
+      context_->pkgid.set(kStrEmpty);
+      break;
     case PkgMgrInterface::Type::Uninstall:
       context_->pkgid.set(pkgmgr->GetRequestInfo());
       context_->file_path.set(kStrEmpty);
       break;
     default:
-      // currently, only installation and uninstallation handled
       // TODO(p.sikorski): should return unsupported, and display error
-      LOG(ERROR) << "Only installation and uninstallation is now supported";
+      LOG(ERROR) <<
+          "Only installation, update and uninstallation is now supported";
       return Status::ERROR;
       break;
   }
index 15c907d..0853519 100644 (file)
@@ -6,8 +6,12 @@
 #include "common/pkgmgr_interface.h"
 #include "common/app_installer.h"
 #include "common/step/step_configure.h"
+#include "common/step/step_backup_icons.h"
+#include "common/step/step_backup_manifest.h"
 #include "common/step/step_copy.h"
+#include "common/step/step_copy_backup.h"
 #include "common/step/step_generate_xml.h"
+#include "common/step/step_old_manifest.h"
 #include "common/step/step_parse.h"
 #include "common/step/step_register_app.h"
 #include "common/step/step_remove_files.h"
@@ -16,6 +20,8 @@
 #include "common/step/step_check_signature.h"
 #include "common/step/step_unregister_app.h"
 #include "common/step/step_unzip.h"
+#include "common/step/step_update_app.h"
+#include "common/step/step_update_security.h"
 #include "tpk/step/step_parse.h"
 #include "tpk/step/step_create_symbolic_link.h"
 #include "utils/logging.h"
@@ -62,6 +68,9 @@ bool Task::Run() {
     case ci::PkgMgrInterface::Type::Install:
       ret = Install();
       break;
+    case ci::PkgMgrInterface::Type::Update:
+      ret = Update();
+      break;
     case ci::PkgMgrInterface::Type::Uninstall:
       ret = Uninstall();
       break;
@@ -94,6 +103,25 @@ int Task::Install() {
   return ai.Run();
 }
 
+int Task::Update() {
+  ci::AppInstaller ai(kPkgType);
+
+  ai.AddStep<ci::configure::StepConfigure>();
+  ai.AddStep<ci::unzip::StepUnzip>();
+  ai.AddStep<ci::signature::StepCheckSignature>();
+  ai.AddStep<tpk::step::StepParse>();
+  ai.AddStep<ci::old_manifest::StepOldManifest>();
+  ai.AddStep<ci::backup_manifest::StepBackupManifest>();
+  ai.AddStep<ci::backup_icons::StepBackupIcons>();
+  ai.AddStep<ci::copy_backup::StepCopyBackup>();
+  ai.AddStep<tpk::step::StepCreateSymbolicLink>();
+  ai.AddStep<ci::update_security::StepUpdateSecurity>();
+  ai.AddStep<ci::generate_xml::StepGenerateXml>();
+  ai.AddStep<ci::update_app::StepUpdateApplication>();
+
+  return ai.Run();
+}
+
 int Task::Uninstall() {
   ci::AppInstaller ai(kPkgType);
 
index 36db06c..bab2ed2 100644 (file)
@@ -17,6 +17,7 @@ class Task {
 
  private:
   int Install();
+  int Update();
   int Uninstall();
   int Reinstall();
 };  //  class Task
index 39ff124..34c1f39 100644 (file)
@@ -8,16 +8,22 @@
 #include "common/app_installer.h"
 #include "common/pkgmgr_interface.h"
 #include "common/step/step_configure.h"
+#include "common/step/step_backup_manifest.h"
+#include "common/step/step_backup_icons.h"
 #include "common/step/step_copy.h"
+#include "common/step/step_copy_backup.h"
 #include "common/step/step_generate_xml.h"
 #include "common/step/step_parse.h"
 #include "common/step/step_register_app.h"
 #include "common/step/step_remove_files.h"
 #include "common/step/step_revoke_security.h"
 #include "common/step/step_register_security.h"
+#include "common/step/step_old_manifest.h"
 #include "common/step/step_check_signature.h"
 #include "common/step/step_unregister_app.h"
 #include "common/step/step_unzip.h"
+#include "common/step/step_update_app.h"
+#include "common/step/step_update_security.h"
 #include "wgt/step/step_parse.h"
 #include "wgt/step/step_create_symbolic_link.h"
 
@@ -30,7 +36,6 @@ int main(int argc, char** argv) {
     LOG(ERROR) << "Cannot connect to PkgMgrInstaller";
     return -result;
   }
-
   ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Instance();
 
   ci::AppInstaller installer("wgt");
@@ -48,6 +53,21 @@ int main(int argc, char** argv) {
       installer.AddStep<ci::security::StepRegisterSecurity>();
       break;
     }
+    case ci::PkgMgrInterface::Type::Update: {
+      installer.AddStep<ci::configure::StepConfigure>();
+      installer.AddStep<ci::unzip::StepUnzip>();
+      installer.AddStep<ci::signature::StepCheckSignature>();
+      installer.AddStep<wgt::parse::StepParse>();
+      installer.AddStep<ci::old_manifest::StepOldManifest>();
+      installer.AddStep<ci::backup_manifest::StepBackupManifest>();
+      installer.AddStep<ci::backup_icons::StepBackupIcons>();
+      installer.AddStep<ci::copy_backup::StepCopyBackup>();
+      installer.AddStep<wgt::symbolic_link::StepCreateSymbolicLink>();
+      installer.AddStep<ci::update_security::StepUpdateSecurity>();
+      installer.AddStep<ci::generate_xml::StepGenerateXml>();
+      installer.AddStep<ci::update_app::StepUpdateApplication>();
+      break;
+    }
     case ci::PkgMgrInterface::Type::Uninstall: {
       installer.AddStep<ci::configure::StepConfigure>();
       installer.AddStep<ci::parse::StepParse>();