summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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_