step/step_check_blacklist.cc
step/step_check_old_certificate.cc
step/step_check_signature.cc
+ step/step_clear_data.cc
step/step_configure.cc
step/step_copy.cc
step/step_copy_tep.cc
return RequestType::Uninstall;
case PKGMGR_REQ_REINSTALL:
return RequestType::Reinstall;
+ case PKGMGR_REQ_CLEAR:
+ return RequestType::Clear;
case PKGMGR_REQ_RECOVER:
return RequestType::Recovery;
case PKGMGR_REQ_MANIFEST_DIRECT_INSTALL:
{ci::RequestType::Install, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::Recovery, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::Reinstall, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
+ {ci::RequestType::Clear, PKGMGR_INSTALLER_CLEAR_EVENT_STR},
{ci::RequestType::Uninstall, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
{ci::RequestType::Update, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
{ci::RequestType::Delta, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
Update,
Uninstall,
Reinstall,
+ Clear,
Delta,
Recovery,
ManifestDirectInstall,
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/step/step_clear_data.h"
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/system/error_code.hpp>
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+namespace {
+
+const char kDataDirectory[] = "data";
+
+} // namespace
+
+namespace common_installer {
+namespace filesystem {
+
+Step::Status StepClearData::precheck() {
+ if (context_->pkgid.get().empty()) {
+ LOG(ERROR) << "Pkgid is not set";
+ return Status::INVALID_VALUE;
+ }
+ return Status::OK;
+}
+
+Step::Status StepClearData::process() {
+ Status status = Status::OK;
+ context_->pkg_path.set(
+ context_->root_application_path.get() / context_->pkgid.get());
+ bf::path data_directory = context_->pkg_path.get() / kDataDirectory;
+ for (auto iter = bf::directory_iterator(data_directory);
+ iter != bf::directory_iterator(); ++iter) {
+ bs::error_code error;
+ bf::remove_all(iter->path(), error);
+ if (error) {
+ LOG(ERROR) << "Failed to remove: " << iter->path();
+ status = Status::APP_DIR_ERROR;
+ }
+ }
+ LOG(DEBUG) << "Removing files from " << data_directory << " finished";
+ return status;
+}
+
+} // namespace filesystem
+} // namespace common_installer
+
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_STEP_CLEAR_DATA_H_
+#define COMMON_STEP_STEP_CLEAR_DATA_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include <string>
+
+#include "common/installer_context.h"
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace filesystem {
+
+/**
+ * \brief Step responsible removing data/ directory in pkgmgr clear request
+ * Used by WGT and TPK backend
+ */
+class StepClearData : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status undo() override { return Status::OK; }
+ Status clean() override { return Status::OK; }
+ Status precheck() override;
+
+ SCOPE_LOG_TAG(ClearData)
+};
+
+} // namespace filesystem
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_CLEAR_DATA_H_
context_->pkgid.set(kStrEmpty);
context_->file_path.set(kStrEmpty);
break;
+ case RequestType::Clear:
+ context_->pkgid.set(pkgmgr_->GetRequestInfo());
+ break;
case RequestType::Delta:
context_->unpacked_dir_path.set(kStrEmpty);
context_->pkgid.set(kStrEmpty);