#include <pkgmgr-info.h>
+#include <rpk_manifest_handlers/package_handler.h>
+
#include <common/installer_context.h>
#include <common/step/step.h>
#include "common/utils/paths.h"
return Step::Status::PARSE_ERROR;
}
+ // 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));
+
+ context_->pkgid.set(info->package());
+
+ manifest_x* manifest =
+ static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
+ if (!manifest) {
+ LOG(ERROR) << "Out of memory";
+ return Step::Status::ERROR;
+ }
+
+ std::unique_ptr<manifest_x, decltype(pkgmgr_parser_free_manifest_xml)*>
+ manifest_auto(manifest, pkgmgr_parser_free_manifest_xml);
+
+ if (!FillManifestX(const_cast<manifest_x*>(manifest))) {
+ LOG(ERROR) << "[Parse] Storing manifest_x failed. "
+ << parser_->GetErrorMessage();
+ return Step::Status::PARSE_ERROR;
+ }
+/*
+ // TODO: add this code when recovery logic has added
+ // write pkgid for recovery file
+ if (context_->recovery_info.get().recovery_file) {
+ context_->recovery_info.get().recovery_file->set_pkgid(manifest->package);
+ context_->recovery_info.get().recovery_file->WriteAndCommitFileContent();
+ }
+*/
+ LOG(INFO) << "Parsed package id: " << info->package();
+
+ switch (store_location_) {
+ case StoreLocation::NORMAL:
+ context_->manifest_data.set(manifest_auto.release());
+ break;
+ case StoreLocation::BACKUP:
+ context_->old_manifest_data.set(manifest_auto.release());
+ break;
+ default:
+ LOG(ERROR) << "Unknown store location for parsed data";
+ return Step::Status::ERROR;
+ }
+
return common_installer::Step::Status::OK;
}
return true;
}
+bool StepParseRpkManifest::FillManifestX(manifest_x* manifest) {
+ if (!FillPackageInfo(manifest))
+ return false;
+ 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));
+ if (!pkg_info) {
+ LOG(ERROR) << "Package info manifest data has not been found.";
+ return false;
+ }
+
+ manifest->ns = strdup(pkg_info->xmlns().c_str());
+ manifest->package = strdup(pkg_info->package().c_str());
+ manifest->version = strdup(pkg_info->version().c_str());
+
+/*
+ // TODO: add this code when manifest has variables for these
+ manifest->res_type = strdup(pkg_info->res_type().c_str());
+ manifest->res_version = strdup(pkg_info->res_version().c_str());
+*/
+
+ return true;
+}
+
} // namespace configuration
} // namespace rpk