Revert "Change package version comparsion behavior" 54/271654/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 24 Feb 2022 06:33:02 +0000 (15:33 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 24 Feb 2022 06:34:02 +0000 (15:34 +0900)
This reverts commit ee680e185d6019ad0eaa702aa1766787048e92fd.

Revert this patch temporarily due to image creation failure.

Change-Id: I072e1309ced346ada1f5d4d3790811b059713b76

src/common/step/configuration/step_check_tizen_version.cc

index 8c01409..5abd419 100644 (file)
@@ -6,15 +6,19 @@
 
 #include <manifest_parser/utils/version_number.h>
 #include <pkgmgrinfo_basic.h>
+#include <vconf.h>
 
 #include <cstring>
 #include <string>
 
 #include "common/installer_context.h"
+#include "common/utils/glist_range.h"
 
 namespace {
 
 const char kPlatformVersion[] = TIZEN_FULL_VERSION;
+const char kDotnetAppType[] = "dotnet";
+const char kDotnetAPILevelVconfKey[] = "db/dotnet/tizen_api_version";
 
 int CompareVersion(const std::string& a, const std::string& b) {
   utils::VersionNumber a_ver(a);
@@ -30,9 +34,13 @@ namespace configuration {
 
 Step::Status StepCheckTizenVersion::process() {
   const char* version = context_->manifest_data.get()->api_version;
-  if (!ComparePlatformVersion(version))
-    return Status::OPERATION_NOT_ALLOWED;
-
+  if (IsDotnetAppExist()) {
+    if (!CompareDotnetVersion(version))
+      return Status::OPERATION_NOT_ALLOWED;
+  } else {
+    if (!ComparePlatformVersion(version))
+      return Status::OPERATION_NOT_ALLOWED;
+  }
   return Status::OK;
 }
 
@@ -46,7 +54,12 @@ Step::Status StepCheckTizenVersion::precheck() {
 }
 
 bool StepCheckTizenVersion::IsDotnetAppExist() {
-  // Does nothing. Don't delete this until someone overrides this delete it.
+  GList* applications = context_->manifest_data.get()->application;
+  for (const auto& app : GListRange<application_x*>(applications)) {
+    if (!strcmp(app->type, kDotnetAppType))
+      return true;
+  }
+
   return false;
 }
 
@@ -59,5 +72,26 @@ bool StepCheckTizenVersion::ComparePlatformVersion(const std::string& version) {
   return true;
 }
 
+bool StepCheckTizenVersion::CompareDotnetVersion(const std::string& version) {
+  int dotnet_api_level;
+  if (vconf_get_int(kDotnetAPILevelVconfKey, &dotnet_api_level)) {
+    if (!context_->is_readonly_package.get() &&
+        !context_->is_preload_rw_package.get()) {
+      LOG(ERROR) << "Failed to get platform dotnet API level";
+      return false;
+    } else {
+      // During platform image creation stage, vconf API does not work and
+      // version check fails. This is workaround for this case.
+      return true;
+    }
+  }
+  if (CompareVersion(std::to_string(dotnet_api_level), version) < 0) {
+    LOG(ERROR) << "Package's dotnet API level(" << version << ") is higher "
+               << "than platform dotnet API level(" << dotnet_api_level << ")";
+    return false;
+  }
+  return true;
+}
+
 }  // namespace configuration
 }  // namespace common_installer