Fill installed_storage value in StepParseRpkManifest 62/293962/2
authorilho kim <ilho159.kim@samsung.com>
Fri, 9 Jun 2023 05:59:09 +0000 (14:59 +0900)
committerilho kim <ilho159.kim@samsung.com>
Mon, 12 Jun 2023 07:55:22 +0000 (16:55 +0900)
installed_storage valid is filled in StepCheckInstallLocation
but some install mode has not StepCheckInstallLocation(ex. ManifestDirectUpdateSteps)
So It is necessary to set the value in StepParseRpkManifest

Change-Id: I8be98cbab55ee169cd42cf0696b82e35055e951d
Signed-off-by: ilho kim <ilho159.kim@samsung.com>
src/rpk/step/configuration/step_parse_rpk_manifest.cc

index 65f6d1ec342ea5754f577ac2fa7e4706b06dbfd2..e987ba2a97a39576f68dc85369032022fe71205e 100644 (file)
@@ -41,6 +41,8 @@ const char kInternalOnly[] = "internal-only";
 
 const char kRpk[] = "rpk";
 
+const char kInstalledInternally[] = "installed_internal";
+
 }  // namespace
 
 
@@ -282,6 +284,26 @@ bool StepParseRpkManifest::FillPackageInfo(manifest_x* manifest) {
     manifest->metadata = g_list_append(manifest->metadata, md);
   }
 
+  // set installed_storage if package is installed
+  // this is internal field in package manager but after reading configuration
+  // we must know it
+  common_installer::PkgQueryInterface pkg_query(
+      manifest->package, context_->uid.get());
+  if (!manifest->installed_storage) {
+    if (manifest_location_ == ManifestLocation::INSTALLED ||
+        manifest_location_ == ManifestLocation::RECOVERY) {
+      std::string storage = pkg_query.StorageForPkgId();
+      if (storage.empty()) {
+        // Failed to query installation storage, assign internal
+        manifest->installed_storage = strdup(kInstalledInternally);
+      } else {
+        manifest->installed_storage = strdup(storage.c_str());
+      }
+    } else {
+      manifest->installed_storage = strdup(kInstalledInternally);
+    }
+  }
+
   return true;
 }