Modify Uninstall procedure to allow force-uninstall 22/58522/6
authorArkadiusz Szulakiewicz <a.szulakiewi@partner.samsung.com>
Mon, 1 Feb 2016 15:01:43 +0000 (16:01 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 3 Feb 2016 14:37:51 +0000 (06:37 -0800)
Change-Id: Ib8336c4ecf53d96d3508d13e37776bd06487538d

src/hybrid/hybrid_installer.cc
src/wgt/CMakeLists.txt
src/wgt/step/step_wgt_remove_manifest.cc [new file with mode: 0644]
src/wgt/step/step_wgt_remove_manifest.h [new file with mode: 0644]
src/wgt/wgt_installer.cc

index e7ea48a..0a88baf 100644 (file)
@@ -55,6 +55,7 @@
 #include "wgt/step/step_remove_encryption_data.h"
 #include "wgt/step/step_wgt_patch_icons.h"
 #include "wgt/step/step_wgt_patch_storage_directories.h"
+#include "wgt/step/step_wgt_remove_manifest.h"
 
 namespace ci = common_installer;
 
@@ -134,13 +135,13 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
           ci::parse::StepParseManifest::StoreLocation::NORMAL);
       AddStep<ci::pkgmgr::StepKillApps>();
-      AddStep<ci::backup::StepBackupManifest>();
       AddStep<ci::pkgmgr::StepUnregisterApplication>();
       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
       AddStep<ci::filesystem::StepRemoveFiles>();
       AddStep<ci::filesystem::StepRemoveIcons>();
       AddStep<wgt::encrypt::StepRemoveEncryptionData>();
       AddStep<ci::security::StepRevokeSecurity>();
+      AddStep<wgt::pkgmgr::StepRemoveManifest>();
       break;
     case ci::RequestType::Reinstall:
       // RDS is not supported for hybrid apps
index 6cb1e7a..405d9e4 100644 (file)
@@ -14,6 +14,7 @@ SET(SRCS
   step/step_wgt_patch_icons.cc
   step/step_wgt_patch_storage_directories.cc
   step/step_wgt_resource_directory.cc
+  step/step_wgt_remove_manifest.cc
   step/step_add_default_privileges.cc
   wgt_app_query_interface.cc
   wgt_installer.cc
diff --git a/src/wgt/step/step_wgt_remove_manifest.cc b/src/wgt/step/step_wgt_remove_manifest.cc
new file mode 100644 (file)
index 0000000..68a982e
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/step/step_wgt_remove_manifest.h"
+
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <boost/system/error_code.hpp>
+
+#include <pkgmgr-info.h>
+#include <pkgmgr_installer.h>
+
+#include <algorithm>
+#include <string>
+
+#include "common/utils/file_util.h"
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+namespace wgt {
+namespace pkgmgr {
+
+
+common_installer::Step::Status StepRemoveManifest::process() {
+  bs::error_code error;
+  bf::remove(context_->xml_path.get(), error);
+
+  if (error) {
+    LOG(ERROR) << "Failed to remove xml manifest file";
+    return Status::MANIFEST_ERROR;
+  }
+  LOG(DEBUG) << "Manifest file removed";
+  return Status::OK;
+}
+
+
+}  // namespace wgt
+}  // namespace pkgmgr
diff --git a/src/wgt/step/step_wgt_remove_manifest.h b/src/wgt/step/step_wgt_remove_manifest.h
new file mode 100644 (file)
index 0000000..459d633
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_STEP_STEP_WGT_REMOVE_MANIFEST_H_
+#define WGT_STEP_STEP_WGT_REMOVE_MANIFEST_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/installer_context.h"
+#include "common/step/step.h"
+
+namespace wgt {
+namespace pkgmgr {
+
+/**
+ * \brief Step responsbile for removing manifest file during uninstallation
+ */
+class StepRemoveManifest : public common_installer::Step {
+ public:
+  using common_installer::Step::Step;
+
+  /**
+   * \brief main logic of remove manifest
+   *
+   * \return Status::OK if success, Status::ERROR otherwise
+   */
+  Status process() override;
+
+  Status clean() override { return Status::OK; }
+  Status undo() override { return Status::OK; }
+  Status precheck() override { return Status::OK; }
+
+  SCOPE_LOG_TAG(RemoveManifest)
+};
+
+}  // namespace pkgmgr
+}  // namespace wgt
+
+#endif  // WGT_STEP_STEP_WGT_REMOVE_MANIFEST_H_
index 8cf97b0..2397ebd 100644 (file)
@@ -58,6 +58,7 @@
 #include "wgt/step/step_wgt_patch_icons.h"
 #include "wgt/step/step_wgt_patch_storage_directories.h"
 #include "wgt/step/step_wgt_resource_directory.h"
+#include "wgt/step/step_wgt_remove_manifest.h"
 
 namespace ci = common_installer;
 
@@ -126,13 +127,13 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
           ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
           ci::parse::StepParseManifest::StoreLocation::NORMAL);
       AddStep<ci::pkgmgr::StepKillApps>();
-      AddStep<ci::backup::StepBackupManifest>();
       AddStep<ci::pkgmgr::StepUnregisterApplication>();
       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
       AddStep<ci::filesystem::StepRemoveFiles>();
       AddStep<ci::filesystem::StepRemoveIcons>();
       AddStep<wgt::encrypt::StepRemoveEncryptionData>();
       AddStep<ci::security::StepRevokeSecurity>();
+      AddStep<wgt::pkgmgr::StepRemoveManifest>();
       break;
     }
     case ci::RequestType::Reinstall: {