From 016886906903c4b8feef5610c4bcd9705ef6beda Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 8 Jul 2022 20:20:42 +0900 Subject: [PATCH] Implement StepRestoreWgtSymbolicLink If the uninstallation fails with the bin path removed recover the wgt symbolic link Change-Id: If1a4fd95be319fded67bd778f21e9abd2fae512a Signed-off-by: Ilho Kim --- src/hybrid/hybrid_installer.cc | 3 ++ .../filesystem/step_restore_wgt_symbolic_link.cc | 34 ++++++++++++++++++++++ .../filesystem/step_restore_wgt_symbolic_link.h | 34 ++++++++++++++++++++++ src/wgt/wgt_installer.cc | 3 ++ 4 files changed, 74 insertions(+) create mode 100644 src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc create mode 100644 src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 9bc672d..363412e 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -96,6 +96,7 @@ #include "wgt/step/encryption/step_remove_encryption_data.h" #include "wgt/step/filesystem/step_copy_preview_icons.h" #include "wgt/step/filesystem/step_create_symbolic_link.h" +#include "wgt/step/filesystem/step_restore_wgt_symbolic_link.h" #include "wgt/step/filesystem/step_wgt_patch_icons.h" #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h" #include "wgt/step/filesystem/step_wgt_undo_patch_storage_directories.h" @@ -242,6 +243,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep( wgt::filesystem::HybridAdditionalSharedDirs); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -611,6 +613,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep( wgt::filesystem::HybridAdditionalSharedDirs); + AddStep(); AddStep(); AddStep(); AddStep(); diff --git a/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc new file mode 100644 index 0000000..8624ad3 --- /dev/null +++ b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2022 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/filesystem/step_restore_wgt_symbolic_link.h" + +#include "wgt/step/filesystem/step_create_symbolic_link.h" + +namespace bf = boost::filesystem; +namespace bs = boost::system; + +namespace wgt { +namespace filesystem { + +common_installer::Step::Status StepRestoreWgtSymbolicLink::undo() { + StepCreateSymbolicLink step(context_); + + Status result = step.precheck(); + if (result != Status::OK) { + LOG(ERROR) << "Fail to execute precheck of CreateWgtSymbolicLink"; + return result; + } + + result = step.process(); + if (result != Status::OK) { + LOG(ERROR) << "Fail to execute process of CreateWgtSymbolicLink"; + return result; + } + + return result; +} + +} // namespace filesystem +} // namespace wgt diff --git a/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h new file mode 100644 index 0000000..f0f141e --- /dev/null +++ b/src/wgt/step/filesystem/step_restore_wgt_symbolic_link.h @@ -0,0 +1,34 @@ +// Copyright (c) 2022 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_FILESYSTEM_STEP_RESTORE_WGT_SYMBOLIC_LINK_H_ +#define WGT_STEP_FILESYSTEM_STEP_RESTORE_WGT_SYMBOLIC_LINK_H_ + +#include + +#include +#include + +namespace wgt { +namespace filesystem { + +/** + * \brief Step that create symbolic link to application + */ +class StepRestoreWgtSymbolicLink : public common_installer::Step { + public: + using Step::Step; + + Status precheck() override { return Status::OK; } + Status process() override { return Status::OK; } + Status clean() override { return Status::OK; } + Status undo() override; + + STEP_NAME(RestoreWgtSymbolicLink) +}; + +} // namespace filesystem +} // namespace wgt + +#endif // WGT_STEP_FILESYSTEM_STEP_RESTORE_WGT_SYMBOLIC_LINK_H_ diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 40a63f7..9bbdd93 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -98,6 +98,7 @@ #include "wgt/step/encryption/step_remove_encryption_data.h" #include "wgt/step/filesystem/step_copy_preview_icons.h" #include "wgt/step/filesystem/step_create_symbolic_link.h" +#include "wgt/step/filesystem/step_restore_wgt_symbolic_link.h" #include "wgt/step/filesystem/step_wgt_patch_icons.h" #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h" #include "wgt/step/filesystem/step_wgt_prepare_package_directory.h" @@ -321,6 +322,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) ci::Plugin::ActionType::Uninstall); AddStep( wgt::filesystem::WgtAdditionalSharedDirs); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -753,6 +755,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) ci::Plugin::ActionType::Uninstall); AddStep( wgt::filesystem::WgtAdditionalSharedDirs); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4