#include "step/configuration/step_parse_rpk_manifest.h"
+#include <pkgmgr-info.h>
+
#include <common/installer_context.h>
#include <common/step/step.h>
+#include "common/utils/paths.h"
+#include "common/utils/pkgmgr_query.h"
+
+namespace bf = boost::filesystem;
+
+namespace {
+
+const char kManifestFileName[] = "tizen-manifest.xml";
+
+} // namespace
+
namespace rpk {
namespace configuration {
return common_installer::Step::Status::OK;
}
+bool StepParseRpkManifest::LocateConfigFile() {
+ boost::filesystem::path manifest;
+ switch (manifest_location_) {
+ case ManifestLocation::RECOVERY: {
+ bf::path backup_path = common_installer::GetBackupPathForPackagePath(
+ context_->GetPkgPath()) / kManifestFileName;
+ bf::path in_package_path = context_->GetPkgPath() / kManifestFileName;
+ bf::path install_path =
+ bf::path(getUserManifestPath(context_->uid.get(),
+ context_->is_readonly_package.get()))
+ / bf::path(context_->pkgid.get());
+ install_path += ".xml";
+ bf::path backup_install_path =
+ common_installer::GetBackupPathForManifestFile(install_path);
+ if (bf::exists(backup_install_path))
+ manifest = backup_install_path;
+ else if (bf::exists(backup_path))
+ manifest = backup_path;
+ else if (bf::exists(install_path))
+ manifest = install_path;
+ else if (bf::exists(in_package_path))
+ manifest = in_package_path;
+ break;
+ }
+ case ManifestLocation::INSTALLED: {
+ uid_t uid;
+ bool is_readonly = context_->is_readonly_package.get();
+ common_installer::PkgQueryInterface pkg_query(
+ context_->pkgid.get(), context_->uid.get());
+ if (pkg_query.IsGlobalPackage())
+ uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+ else
+ uid = context_->uid.get();
+ bf::path xml_path =
+ bf::path(getUserManifestPath(uid, is_readonly))
+ / bf::path(context_->pkgid.get());
+ xml_path += ".xml";
+ context_->xml_path.set(xml_path);
+ manifest = context_->xml_path.get();
+ if (!boost::filesystem::exists(manifest)) {
+ /* This routine has added for platform update */
+ manifest = context_->unpacked_dir_path.get();
+ manifest /= kManifestFileName;
+ }
+ break;
+ }
+ case ManifestLocation::PACKAGE: {
+ manifest = context_->unpacked_dir_path.get();
+ manifest /= kManifestFileName;
+ break;
+ }
+ default: {
+ LOG(ERROR) << "Unknown manifest location value";
+ return false;
+ }
+ }
+
+ LOG(DEBUG) << "manifest path: " << manifest;
+
+ if (!boost::filesystem::exists(manifest))
+ return false;
+
+ path_ = manifest;
+ return true;
+}
+
} // namespace configuration
} // namespace rpk