Add StepAdjustInstallLocation 47/83447/2
authorSangyoon Jang <s89.jang@samsung.com>
Thu, 11 Aug 2016 03:19:17 +0000 (12:19 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Thu, 11 Aug 2016 03:32:14 +0000 (12:32 +0900)
This step adjusts install location for 3rd party(Public privilege level)
package. 3rd party packages cannot set install location by itself, so
installer set it as 'auto' by force.

Change-Id: I2608741c0714c336b72489bc453224c46aa70f90
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/tpk/CMakeLists.txt
src/tpk/step/configuration/step_adjust_install_location.cc [new file with mode: 0644]
src/tpk/step/configuration/step_adjust_install_location.h [new file with mode: 0644]
src/tpk/tpk_installer.cc

index 03d4e346edd0d012d5629b2825969b01fbaffc34..646a52f1221655ab0da8e18315aab0d47c065101 100644 (file)
@@ -1,5 +1,6 @@
 SET(SRCS
   external_dirs.cc
+  step/configuration/step_adjust_install_location.cc
   step/filesystem/step_check_pkg_directory_path.cc
   step/filesystem/step_create_external_storage_directories.cc
   step/filesystem/step_create_symbolic_link.cc
diff --git a/src/tpk/step/configuration/step_adjust_install_location.cc b/src/tpk/step/configuration/step_adjust_install_location.cc
new file mode 100644 (file)
index 0000000..5739dfd
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (c) 2016 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 "tpk/step/configuration/step_adjust_install_location.h"
+
+#include <cstdlib>
+#include <cstring>
+
+namespace ci = common_installer;
+
+namespace {
+
+const char kAutoLocation[] = "auto";
+
+}  // namespace
+
+namespace tpk {
+namespace configuration {
+
+ci::Step::Status StepAdjustInstallLocation::process() {
+  ci::PrivilegeLevel level = context_->privilege_level.get();
+  // Unfortunately we don't know privilege level when parsing manifest,
+  // because checking signature is done after parsing.
+  if (level == ci::PrivilegeLevel::PUBLIC) {
+    manifest_x* manifest = context_->manifest_data.get();
+    // This may be allocated by step parse
+    free(const_cast<char*>(manifest->installlocation));
+    manifest->installlocation = strdup(kAutoLocation);
+  }
+  return Status::OK;
+}
+
+}  // namespace configuration
+}  // namespace tpk
diff --git a/src/tpk/step/configuration/step_adjust_install_location.h b/src/tpk/step/configuration/step_adjust_install_location.h
new file mode 100644 (file)
index 0000000..7f3e897
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (c) 2016 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 TPK_STEP_CONFIGURATION_STEP_ADJUST_INSTALL_LOCATION_H_
+#define TPK_STEP_CONFIGURATION_STEP_ADJUST_INSTALL_LOCATION_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/installer_context.h"
+#include "common/step/step.h"
+
+namespace tpk {
+namespace configuration {
+
+class StepAdjustInstallLocation : 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(AdjustInstallLocation)
+};
+
+}  // namespace configuration
+}  // namespace tpk
+
+#endif  // TPK_STEP_CONFIGURATION_STEP_ADJUST_INSTALL_LOCATION_H_
index 5317688b0f74382d435f5d92fcc686b0f74ef7f7..4337dcad50f5bf5257cb638bead695e0ad3bf8ed 100644 (file)
@@ -63,6 +63,7 @@
 #include <common/step/security/step_rollback_installation_security.h>
 #include <common/step/security/step_update_security.h>
 
+#include "tpk/step/configuration/step_adjust_install_location.h"
 #include "tpk/step/filesystem/step_create_external_storage_directories.h"
 #include "tpk/step/filesystem/step_create_symbolic_link.h"
 #include "tpk/step/filesystem/step_check_pkg_directory_path.h"
@@ -155,6 +156,7 @@ void TpkInstaller::InstallSteps() {
   AddStep<ci::pkgmgr::StepCheckRestriction>();
   AddStep<ci::configuration::StepCheckTizenVersion>();
   AddStep<ci::security::StepCheckSignature>();
+  AddStep<tpk::configuration::StepAdjustInstallLocation>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<ci::filesystem::StepAcquireExternalStorage>(false);
@@ -186,6 +188,7 @@ void TpkInstaller::UpdateSteps() {
   AddStep<ci::configuration::StepParsePreload>();
   AddStep<ci::configuration::StepCheckTizenVersion>();
   AddStep<ci::security::StepCheckSignature>();
+  AddStep<tpk::configuration::StepAdjustInstallLocation>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<ci::security::StepCheckOldCertificate>();
@@ -286,6 +289,7 @@ void TpkInstaller::DeltaSteps() {
   AddStep<ci::filesystem::StepDeltaPatch>();
   AddStep<ci::filesystem::StepDisableExternalMount>();
   AddStep<ci::security::StepCheckSignature>();
+  AddStep<tpk::configuration::StepAdjustInstallLocation>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<ci::security::StepCheckOldCertificate>();
@@ -344,6 +348,7 @@ void TpkInstaller::MountInstallSteps() {
   AddStep<ci::pkgmgr::StepCheckRestriction>();
   AddStep<ci::configuration::StepCheckTizenVersion>();
   AddStep<ci::security::StepCheckSignature>();
+  AddStep<tpk::configuration::StepAdjustInstallLocation>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<ci::security::StepRollbackInstallationSecurity>();
@@ -375,6 +380,7 @@ void TpkInstaller::MountUpdateSteps() {
   AddStep<ci::configuration::StepParsePreload>();
   AddStep<ci::configuration::StepCheckTizenVersion>();
   AddStep<ci::security::StepCheckSignature>();
+  AddStep<tpk::configuration::StepAdjustInstallLocation>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<ci::security::StepCheckOldCertificate>();
@@ -410,6 +416,7 @@ void TpkInstaller::ManifestDirectInstallSteps() {
   AddStep<ci::configuration::StepCheckTizenVersion>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::security::StepCheckSignature>();
+  AddStep<tpk::configuration::StepAdjustInstallLocation>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<tpk::filesystem::StepCreateSymbolicLink>();
@@ -432,6 +439,7 @@ void TpkInstaller::ManifestDirectUpdateSteps() {
   AddStep<ci::configuration::StepCheckTizenVersion>();
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::security::StepCheckSignature>();
+  AddStep<tpk::configuration::StepAdjustInstallLocation>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<tpk::filesystem::StepCreateSymbolicLink>();