Implement basic FillAllowedPackageInfo function
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 11 May 2021 02:19:42 +0000 (11:19 +0900)
committer연정현/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <jungh.yeon@samsung.com>
Wed, 12 May 2021 07:12:49 +0000 (16:12 +0900)
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/rpk/step/configuration/step_parse_rpk_manifest.cc
src/rpk/step/configuration/step_parse_rpk_manifest.h

index ec6a875..35d6be3 100644 (file)
@@ -7,6 +7,7 @@
 #include <pkgmgr-info.h>
 
 #include <rpk_manifest_handlers/package_handler.h>
+#include <rpk_manifest_handlers/allowed_package_handler.h>
 
 #include <common/installer_context.h>
 #include <common/step/step.h>
@@ -19,6 +20,11 @@ namespace {
 
 const char kManifestFileName[] = "tizen-manifest.xml";
 
+const char kManifestKey[] = "manifest";
+
+const char kAllowedPackageKey[] = "manifest.allowed-package";
+
+
 }  // namespace
 
 
@@ -65,7 +71,7 @@ common_installer::Step::Status StepParseRpkManifest::process() {
   // Copy data from ManifestData to InstallerContext
   std::shared_ptr<const rpk::parse::PackageInfo> info =
       std::static_pointer_cast<const rpk::parse::PackageInfo>(
-          parser_->GetManifestData(kManifestFileName));
+          parser_->GetManifestData(kManifestKey));
 
   context_->pkgid.set(info->package());
 
@@ -178,13 +184,22 @@ bool StepParseRpkManifest::LocateConfigFile() {
 bool StepParseRpkManifest::FillManifestX(manifest_x* manifest) {
   if (!FillPackageInfo(manifest))
     return false;
+
+  if (!FillAllowedPackageInfo(manifest))
+    return false;
+
+  // author
+
+  // description
+
+  // dependencies
   return true;
 }
 
 bool StepParseRpkManifest::FillPackageInfo(manifest_x* manifest) {
   std::shared_ptr<const rpk::parse::PackageInfo> pkg_info =
       std::static_pointer_cast<const rpk::parse::PackageInfo>(
-          parser_->GetManifestData(kManifestFileName));
+          parser_->GetManifestData(kManifestKey));
   if (!pkg_info) {
     LOG(ERROR) << "Package info manifest data has not been found.";
     return false;
@@ -203,5 +218,30 @@ bool StepParseRpkManifest::FillPackageInfo(manifest_x* manifest) {
   return true;
 }
 
+bool StepParseRpkManifest::FillAllowedPackageInfo(manifest_x* manifest) {
+  // add allowed-package info
+  std::shared_ptr<const rpk::parse::AllowedPackageInfoList> allowed_pkg_info_list =
+      std::static_pointer_cast<const rpk::parse::AllowedPackageInfoList>(
+          parser_->GetManifestData(kAllowedPackageKey));
+  if (!allowed_pkg_info_list) {
+    LOG(ERROR) << "Package info manifest data has not been found.";
+    return false;
+  }
+
+  auto& allowed_pkg_list = allowed_pkg_info_list->allowed_packages();
+  if (allowed_pkg_list.size() == 0)
+    return true;
+/*
+  // TODO: this should be activated after manifest has variables for these
+  for (auto& allowed_pkg : allowed_pkg_list) {
+    // add allowed-package info
+    std::string pkgid = allowed_pkg->get_pkgid();
+    auto& required_privileges = allowed_pkg->get_privileges();
+  }
+*/
+
+  return true;
+}
+
 }  // namespace configuration
 }  // namespace rpk
index c75935b..00c3bfb 100644 (file)
@@ -49,6 +49,7 @@ class StepParseRpkManifest : public common_installer::Step {
  private:
   bool FillManifestX(manifest_x* manifest);
   bool FillPackageInfo(manifest_x* manifest);
+  bool FillAllowedPackageInfo(manifest_x* manifest);
 
   std::unique_ptr<rpk::parse::RPKConfigParser> parser_;
   ManifestLocation manifest_location_;