- Add StepRecoverParserPlugin to provide recovery interface.
- Add clean / undo interface.
- Change StepRemoveManifest to remove manifest file at cleanup time.
- StepUnregisterApp will not remove modified manifest file.
Change-Id: I296bf6acfd5dbd2281e9eefb093e89688b2d9b15
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
*/
class Plugin {
public:
- enum class ActionType { Install, Upgrade, Uninstall };
+ enum class ActionType {
+ Unknown,
+ Install,
+ Upgrade,
+ Clean,
+ Undo,
+ Uninstall,
+ RecoverInstall,
+ RecoverUpgrade,
+ RecoverUninstall
+ };
enum class ProcessType { Pre, Main, Post };
virtual ~Plugin();
{ActionType::Install, "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL"},
{ActionType::Upgrade, "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE"},
{ActionType::Uninstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL"},
+ {ActionType::RecoverInstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERINSTALL"}, // NOLINT
+ {ActionType::RecoverUpgrade, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERUPGRADE"}, // NOLINT
+ {ActionType::RecoverUninstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERUNINSTALL"}, // NOLINT
+ {ActionType::Clean, "PKGMGR_CATEGORY_PARSER_PLUGIN_CLEAN"},
+ {ActionType::Undo, "PKGMGR_CATEGORY_PARSER_PLUGIN_UNDO"},
};
auto pos = names.find(action);
{ActionType::Install, "PKGMGR_MDPARSER_PLUGIN_INSTALL"},
{ActionType::Upgrade, "PKGMGR_MDPARSER_PLUGIN_UPGRADE"},
{ActionType::Uninstall, "PKGMGR_MDPARSER_PLUGIN_UNINSTALL"},
+ {ActionType::RecoverInstall, "PKGMGR_MDPARSER_PLUGIN_RECOVERINSTALL"},
+ {ActionType::RecoverUpgrade, "PKGMGR_MDPARSER_PLUGIN_RECOVERUPGRADE"},
+ {ActionType::RecoverUninstall, "PKGMGR_MDPARSER_PLUGIN_RECOVERUNINSTALL"},
+ {ActionType::Clean, "PKGMGR_MDPARSER_PLUGIN_CLEAN"},
+ {ActionType::Undo, "PKGMGR_MDPARSER_PLUGIN_UNDO"},
};
auto pos = names.find(action);
{{ActionType::Install, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_INSTALL"}, // NOLINT
{{ActionType::Upgrade, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE"}, // NOLINT
{{ActionType::Uninstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL"}, // NOLINT
+ {{ActionType::RecoverInstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERINSTALL"}, // NOLINT
+ {{ActionType::RecoverUpgrade, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERUPGRADE"}, // NOLINT
+ {{ActionType::RecoverUninstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERUNINSTALL"}, // NOLINT
{{ActionType::Install, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_INSTALL"}, // NOLINT
{{ActionType::Upgrade, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UPGRADE"}, // NOLINT
{{ActionType::Uninstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UNINSTALL"}, // NOLINT
+ {{ActionType::RecoverInstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERINSTALL"}, // NOLINT
+ {{ActionType::RecoverUpgrade, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERUPGRADE"}, // NOLINT
+ {{ActionType::RecoverUninstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERUNINSTALL"}, // NOLINT
+ {{ActionType::Clean, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_CLEAN"}, // NOLINT
+ {{ActionType::Undo, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UNDO"}, // NOLINT
{{ActionType::Install, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_INSTALL"}, // NOLINT
{{ActionType::Upgrade, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UPGRADE"}, // NOLINT
- {{ActionType::Uninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL"} // NOLINT
+ {{ActionType::Uninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL"}, // NOLINT
+ {{ActionType::RecoverInstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERINSTALL"}, // NOLINT
+ {{ActionType::RecoverUpgrade, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERUPGRADE"}, // NOLINT
+ {{ActionType::RecoverUninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERUNINSTALL"}, // NOLINT
};
auto pos = names.find(std::make_pair(action, process));
--- /dev/null
+// Copyright (c) 2018 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 "common/step/pkgmgr/step_recover_parser_plugins.h"
+
+#include <pkgmgr-info.h>
+
+#include <boost/filesystem/path.hpp>
+
+#include "common/plugins/plugin.h"
+#include "common/step/pkgmgr/step_run_parser_plugins.h"
+
+namespace bf = boost::filesystem;
+namespace ci = common_installer;
+
+namespace {
+
+ci::Plugin::ActionType GetActionType(ci::InstallerContext* context) {
+ ci::RequestType type = context->recovery_info.get().recovery_file->type();
+ switch (type) {
+ case ci::RequestType::Install:
+ case ci::RequestType::MountInstall:
+ return ci::Plugin::ActionType::RecoverInstall;
+ case ci::RequestType::Update:
+ case ci::RequestType::Delta:
+ case ci::RequestType::MountUpdate:
+ case ci::RequestType::ReadonlyUpdateInstall:
+ return ci::Plugin::ActionType::RecoverUpgrade;
+ default:
+ LOG(ERROR) << "Invalid request type : " << static_cast<int>(type);
+ return ci::Plugin::ActionType::Unknown;
+ }
+}
+
+} // namespace
+
+namespace common_installer {
+namespace pkgmgr {
+
+Step::Status StepRecoverParserPlugin::RecoveryNew() {
+ return RecoverPlugin();
+}
+
+Step::Status StepRecoverParserPlugin::RecoveryUpdate() {
+ return RecoverPlugin();
+}
+
+Step::Status StepRecoverParserPlugin::RecoverPlugin() {
+ if (!SetXmlPath()) {
+ LOG(ERROR) << "Failed to set xml path for plugin, but continue";
+ return Status::OK;
+ }
+ StepRunParserPlugin plugin(context_, GetActionType(context_));
+ if (plugin.process() != Step::Status::OK) {
+ LOG(ERROR) << "Failed to execute plugin properly, but conitnue";
+ return Status::OK;
+ }
+ return Status::OK;
+}
+
+bool StepRecoverParserPlugin::SetXmlPath() {
+ if (context_->pkgid.get().empty())
+ return false;
+ bf::path xml_path =
+ bf::path(getUserManifestPath(context_->uid.get(),
+ context_->is_readonly_package.get()))
+ / context_->pkgid.get();
+ xml_path += ".xml";
+ context_->xml_path.set(xml_path);
+ return true;
+}
+
+} // namespace pkgmgr
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2018 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 COMMON_STEP_PKGMGR_STEP_RECOVER_PARSER_PLUGINS_H_
+#define COMMON_STEP_PKGMGR_STEP_RECOVER_PARSER_PLUGINS_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/installer_context.h"
+#include "common/step/recovery/step_recovery.h"
+
+namespace common_installer {
+namespace pkgmgr {
+
+class StepRecoverParserPlugin : public recovery::StepRecovery {
+ public:
+ using StepRecovery::StepRecovery;
+
+ Status RecoveryNew() override;
+ Status RecoveryUpdate() override;
+
+ private:
+ Status RecoverPlugin();
+ bool SetXmlPath();
+
+ STEP_NAME(RecoverParserPlugin)
+};
+
+} // namespace pkgmgr
+} // namespace common_installer
+
+#endif // COMMON_STEP_PKGMGR_STEP_RECOVER_PARSER_PLUGINS_H_
namespace pkgmgr {
-common_installer::Step::Status StepRemoveManifest::process() {
+common_installer::Step::Status StepRemoveManifest::clean() {
bf::path manifest_path;
if (context_->request_type.get() == RequestType::ReadonlyUpdateUninstall) {
manifest_path = bf::path(tzplatform_getenv(TZ_SYS_RW_PACKAGES)) /
*
* \return Status::OK if success, Status::ERROR otherwise
*/
- Status process() override;
-
- Status clean() override { return Status::OK; }
+ Status process() override { return Status::OK; }
+ Status clean() override;
Status undo() override { return Status::OK; }
Status precheck() override { return Status::OK; }
Step::Status StepRunParserPlugin::undo() {
// For update, we need to reread configuration of old version of widget
// so running whole process from beginning
- if (action_type_ == Plugin::ActionType::Install) {
+ if (action_type_ == Plugin::ActionType::Install)
ProcessPlugins(context_->xml_path.get(), context_->manifest_data.get(),
- Plugin::ActionType::Uninstall);
- } else if (action_type_ == Plugin::ActionType::Upgrade) {
+ Plugin::ActionType::Undo);
+ else if (action_type_ == Plugin::ActionType::Upgrade)
ProcessPlugins(context_->backup_xml_path.get(),
context_->old_manifest_data.get(),
- Plugin::ActionType::Upgrade);
- }
+ Plugin::ActionType::Undo);
return Status::OK;
}
+Step::Status StepRunParserPlugin::clean() {
+ return ProcessPlugins(context_->xml_path.get(),
+ context_->manifest_data.get(),
+ Plugin::ActionType::Clean);
+}
+
} // namespace pkgmgr
} // namespace common_installer
Plugin::ActionType action_type);
Step::Status process() override;
- Step::Status clean() { return Status::OK; }
+ Step::Status clean() override;
Step::Status undo() override;
Step::Status precheck() { return Status::OK; }
LOG(ERROR) << "Failed to unregister package into database";
}
- if (!context_->partial_rw.get()) {
- // remove manifest file
- if (!Remove(context_->xml_path.get()))
- return Status::MANIFEST_ERROR;
- }
-
LOG(DEBUG) << "Successfully unregister the application";
return Status::OK;