summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlho Kim <ilho159.kim@samsung.com>2024-10-10 17:41:42 +0900
committerIlho Kim <ilho159.kim@samsung.com>2024-10-11 15:10:55 +0900
commit5e01cd814550d4514ea0a07e544b32dcd7b3b827 (patch)
treea85c5bf9dd9126057faaff0907284320814019e6
parent4108405e631ae8861b09764d69b560d5e87fd1a0 (diff)
downloadapp-installers-5e01cd814550d4514ea0a07e544b32dcd7b3b827.tar.gz
app-installers-5e01cd814550d4514ea0a07e544b32dcd7b3b827.tar.bz2
app-installers-5e01cd814550d4514ea0a07e544b32dcd7b3b827.zip
Add StepClearInstallLocation
If the installation is executed with the file exist in the package installation path, the file remains even after installation is completed This step removes files that exist in the installation path Change-Id: I92a17f2a13d443374fe69badd00a7dd5411c3ad9 Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
-rw-r--r--src/common/installer/app_installer.cc3
-rw-r--r--src/common/step/filesystem/step_clear_install_location.cc40
-rw-r--r--src/common/step/filesystem/step_clear_install_location.h30
3 files changed, 73 insertions, 0 deletions
diff --git a/src/common/installer/app_installer.cc b/src/common/installer/app_installer.cc
index 054dc357..97245f9d 100644
--- a/src/common/installer/app_installer.cc
+++ b/src/common/installer/app_installer.cc
@@ -33,6 +33,7 @@
#include "common/step/configuration/step_switch_readonly_mode.h"
#include "common/step/filesystem/step_acquire_external_storage.h"
#include "common/step/filesystem/step_change_ownership_and_permission.h"
+#include "common/step/filesystem/step_clear_install_location.h"
#include "common/step/filesystem/step_copy.h"
#include "common/step/filesystem/step_copy_storage_directories.h"
#include "common/step/filesystem/step_copy_tep.h"
@@ -331,6 +332,7 @@ void AppInstaller::InstallSteps() {
AddStep<ci::configuration::StepParsePreload>();
AddStep<ci::pkgmgr::StepCheckRestriction>();
AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::filesystem::StepClearInstallLocation>();
AddStep<ci::security::StepSignature>(true);
AddStep<ci::security::StepRollbackInstallationSecurity>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
@@ -737,6 +739,7 @@ void AppInstaller::ReadonlyUpdateInstallSteps() {
AddStep<ci::pkgmgr::StepCheckUpgradable>();
AddStep<ci::configuration::StepParsePreload>();
AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::filesystem::StepClearInstallLocation>();
AddStep<ci::security::StepSignature>(true);
AddStep<ci::configuration::StepSwitchReadonlyMode>();
AddStep<ci::security::StepCheckOldCertificate>();
diff --git a/src/common/step/filesystem/step_clear_install_location.cc b/src/common/step/filesystem/step_clear_install_location.cc
new file mode 100644
index 00000000..aaf33cec
--- /dev/null
+++ b/src/common/step/filesystem/step_clear_install_location.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2024 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/filesystem/step_clear_install_location.h"
+
+#include <filesystem>
+
+#include "common/installer_context.h"
+#include "common/utils/file_util.h"
+
+namespace fs = std::filesystem;
+
+namespace common_installer {
+namespace filesystem {
+
+Step::Status StepClearInstallLocation::process() {
+ fs::path install_path;
+ if (context_->storage.get() == Storage::EXTENDED) {
+ install_path = fs::path(GetExtendedRootAppPath(context_->uid.get())) /
+ context_->pkgid.get();
+ } else {
+ install_path = context_->GetPkgPath();
+ }
+
+ if (fs::exists(install_path)) {
+ LOG(WARNING) << "Install path [" << install_path
+ << "] is already exists, try to remove install path";
+ if (!RemoveAll(install_path)) {
+ LOG(ERROR) << "Failed to remove the already existing install path["
+ << install_path << "]";
+ return Step::Status::APP_DIR_ERROR;
+ }
+ }
+
+ return Step::Status::OK;
+}
+
+} // namespace filesystem
+} // namespace common_installer
diff --git a/src/common/step/filesystem/step_clear_install_location.h b/src/common/step/filesystem/step_clear_install_location.h
new file mode 100644
index 00000000..7cf7b856
--- /dev/null
+++ b/src/common/step/filesystem/step_clear_install_location.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2024 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_FILESYSTEM_STEP_CLEAR_INSTALL_LOCATION_H_
+#define COMMON_STEP_FILESYSTEM_STEP_CLEAR_INSTALL_LOCATION_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace filesystem {
+
+class StepClearInstallLocation : public common_installer::Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override { return Status::OK; }
+
+ STEP_NAME(ClearInstallLocation)
+};
+
+} // namespace filesystem
+} // namespace common_installer
+
+#endif // COMMON_STEP_FILESYSTEM_STEP_CLEAR_INSTALL_LOCATION_H_