cp %{SOURCE1001} .
%build
-%cmake . -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
+%cmake . -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+ -DTIZEN_FULL_VERSION=%{tizen_full_version}
make %{?_smp_mflags}
%install
step/backup/step_backup_manifest.cc
step/backup/step_copy_backup.cc
step/configuration/step_block_cross_update.cc
+ step/configuration/step_check_tizen_version.cc
step/configuration/step_configure.cc
step/configuration/step_fail.cc
step/configuration/step_parse_manifest.cc
SET(PLUGINS_LIST_INSTALL_FILE_PATH ${PLUGINS_LIST_INSTALL_PATH}/${PLUGINS_LIST_FILE_NAME})
ADD_DEFINITIONS("-DPLUGINS_LIST_INSTALL_FILE_PATH=\"${PLUGINS_LIST_INSTALL_FILE_PATH}\"")
+IF(NOT DEFINED TIZEN_FULL_VERSION)
+ MESSAGE(FATAL_ERROR "TIZEN_FULL_VERSION MUST BE defined")
+ELSE(NOT DEFINED TIZEN_FULL_VERSION)
+ ADD_DEFINITIONS("-DTIZEN_FULL_VERSION=\"${TIZEN_FULL_VERSION}\"")
+ENDIF(NOT DEFINED TIZEN_FULL_VERSION)
CONFIGURE_FILE(${PLUGINS_LIST_FILE_PATH}.in ${PLUGINS_LIST_FILE_PATH} @ONLY)
INSTALL(FILES ${PLUGINS_LIST_FILE_PATH} DESTINATION ${PLUGINS_LIST_INSTALL_PATH}/)
--- /dev/null
+// 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.
+
+#include "common/step/configuration/step_check_tizen_version.h"
+
+#include <manifest_parser/utils/version_number.h>
+
+#include "common/installer_context.h"
+
+namespace {
+
+const char kPlatformVersion[] = TIZEN_FULL_VERSION;
+
+int CompareVersion(const std::string& a, const std::string& b) {
+ utils::VersionNumber a_ver(a);
+ utils::VersionNumber b_ver(b);
+
+ return a_ver.Trim(3).Compare(b_ver.Trim(3));
+}
+
+} // namespace
+
+namespace common_installer {
+namespace configuration {
+
+Step::Status StepCheckTizenVersion::process() {
+ const char* version = context_->manifest_data.get()->api_version;
+ if (CompareVersion(std::string(kPlatformVersion), std::string(version)) < 0) {
+ LOG(ERROR) << "Package's api version(" << version << ") is higher than "
+ << "platform version(" << kPlatformVersion << ")";
+ return Status::OPERATION_NOT_ALLOWED;
+ }
+ return Status::OK;
+}
+
+Step::Status StepCheckTizenVersion::precheck() {
+ const char* version = context_->manifest_data.get()->api_version;
+ if (version == nullptr) {
+ LOG(ERROR) << "Api version not found";
+ return Status::INVALID_VALUE;
+ }
+ return Status::OK;
+}
+
+} // namespace configuration
+} // namespace common_installer
--- /dev/null
+// 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 COMMON_STEP_CONFIGURATION_STEP_CHECK_TIZEN_VERSION_H_
+#define COMMON_STEP_CONFIGURATION_STEP_CHECK_TIZEN_VERSION_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace configuration {
+
+class StepCheckTizenVersion : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override;
+
+ SCOPE_LOG_TAG(CheckTizenVersion)
+};
+
+} // namespace configuration
+} // namespace common_installer
+
+#endif // COMMON_STEP_CONFIGURATION_STEP_CHECK_TIZEN_VERSION_H_