#include "hybrid/step/configuration/step_merge_tpk_privileges.h"
#include "hybrid/step/configuration/step_stash_tpk_config.h"
#include "hybrid/step/encryption/step_encrypt_resources.h"
-#include "hybrid/step/pkgmgr/step_generate_xml.h"
+#include "hybrid/step/pkgmgr/step_merge_xml.h"
#include "wgt/step/configuration/step_parse.h"
#include "wgt/step/configuration/step_set_old_signature_files_location.h"
#include "wgt/step/encryption/step_remove_encryption_data.h"
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::CONCAT);
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::filesystem::StepCopyStorageDirectories>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::CONCAT);
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::filesystem::StepCopyStorageDirectories>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::CONCAT);
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::CONCAT);
AddStep<wgt::filesystem::StepCopyPreviewIcons>();
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::CONCAT);
AddStep<tpk::filesystem::StepTpkPatchIcons>();
AddStep<wgt::filesystem::StepWgtPatchIcons>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::OVERWRITE);
AddStep<tpk::filesystem::StepTpkPatchIcons>();
AddStep<wgt::filesystem::StepWgtPatchIcons>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::OVERWRITE);
AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
AddStep<wgt::pkgmgr::StepGenerateXml>();
- AddStep<hybrid::pkgmgr::StepGenerateXml>();
+ AddStep<hybrid::pkgmgr::StepMergeXml>();
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<hybrid::configuration::StepMergeTpkConfig>(
hybrid::configuration::StepMergeTpkConfig::MergeType::CONCAT);
+++ /dev/null
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#include "hybrid/step/pkgmgr/step_generate_xml.h"
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
-#include <pkgmgr_parser.h>
-
-#include <common/utils/file_util.h>
-#include <common/utils/glist_range.h>
-
-#include <utility>
-#include <string>
-#include <vector>
-
-#include "hybrid/hybrid_backend_data.h"
-
-namespace ci = common_installer;
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-
-namespace {
-
-const std::vector<std::string> kBlackListNodes = {
- {"author"},
- {"description"},
- {"profile"},
- {"privileges"},
- {"provides-appdefined-privileges"},
- {"trust-anchor"},
-};
-const std::vector<std::string> kNeedMergeNodes = {
- {"manifest"},
-};
-const std::vector<std::pair<std::string, std::string>> kApplicationNodeNames = {
- {"ui-application", "uiapp"},
- {"service-application", "svcapp"},
- {"widget-application", "widgetapp"},
- {"watch-application", "watchapp"},
-};
-
-} // namespace
-
-namespace hybrid {
-namespace pkgmgr {
-
-bool StepGenerateXml::LoadXmlDocument(const bf::path& wgt_xml_path,
- const bf::path& tpk_xml_path) {
- // trim blanks
- int keep_blanks = xmlKeepBlanksDefault(0);
- wgt_doc_ = xmlParseFile(wgt_xml_path.string().c_str());
- if (!wgt_doc_) {
- LOG(ERROR) << "Failed to parse file: " << wgt_xml_path;
- xmlKeepBlanksDefault(keep_blanks);
- return false;
- }
- tpk_doc_ = xmlParseFile(tpk_xml_path.string().c_str());
- if (!tpk_doc_) {
- LOG(ERROR) << "Failed to parse file: " << tpk_xml_path;
- xmlKeepBlanksDefault(keep_blanks);
- return false;
- }
- xmlKeepBlanksDefault(keep_blanks);
- return true;
-}
-
-xmlNodePtr StepGenerateXml::GetXmlNode(const xmlDocPtr doc,
- const std::string& name, const std::string& attr,
- const std::string& attr_val) {
- xmlXPathContextPtr ctxt = xmlXPathNewContext(doc);
- if (!ctxt) {
- LOG(ERROR) << "Failed to create XPath context";
- return nullptr;
- }
-
- std::string expr = "//*[local-name()='" + name + "']";
- if (!attr.empty() && !attr_val.empty())
- expr.append("[@" + attr + "='" + attr_val + "']");
-
- xmlXPathObjectPtr obj =
- xmlXPathEvalExpression((const xmlChar*)expr.c_str(), ctxt);
- if (!obj || !obj->nodesetval || !obj->nodesetval->nodeNr) {
- xmlXPathFreeContext(ctxt);
- return nullptr;
- }
-
- xmlNodePtr node = obj->nodesetval->nodeTab[0];
- xmlXPathFreeObject(obj);
- xmlXPathFreeContext(ctxt);
-
- return node;
-}
-
-void StepGenerateXml::MergeXmlNode(xmlNodePtr node1, xmlNodePtr node2) {
- xmlNodePtr last = xmlGetLastChild(node1);
- xmlNodePtr next;
- // merge node2's child into node1
- for (xmlNodePtr cur = node2->children; cur; cur = next) {
- next = cur->next;
- if (std::find(kBlackListNodes.begin(), kBlackListNodes.end(),
- reinterpret_cast<const char*>(cur->name)) != kBlackListNodes.end())
- continue;
- // to avoid duplicate
- if (std::find(kNeedMergeNodes.begin(), kNeedMergeNodes.end(),
- reinterpret_cast<const char*>(cur->name)) != kNeedMergeNodes.end())
- continue;
- if (xmlAddNextSibling(last, cur) != nullptr)
- last = last->next;
- }
-}
-
-void StepGenerateXml::SetXmlNodeAttribute(xmlNodePtr node,
- const std::string& attr, const std::string& attr_val) {
- xmlSetProp(node, reinterpret_cast<const xmlChar*>(attr.c_str()),
- reinterpret_cast<const xmlChar*>(attr_val.c_str()));
-}
-
-ci::Step::Status StepGenerateXml::process() {
- bf::path wgt_xml_path = context_->xml_path.get();
- bf::path tpk_xml_path = context_->GetPkgPath() / "tizen-manifest.xml";
-
- if (!LoadXmlDocument(wgt_xml_path, tpk_xml_path))
- return Step::Status::MANIFEST_ERROR;
-
- for (auto& entry : kNeedMergeNodes) {
- xmlNodePtr tpk_node = GetXmlNode(tpk_doc_, entry);
- if (tpk_node == nullptr)
- continue;
- // TODO(s89.jang): If cannot find node from wgt doc, merge tpk node itself
- // instead of merging its child nodes.
- xmlNodePtr wgt_node = GetXmlNode(wgt_doc_, entry);
- MergeXmlNode(wgt_node, tpk_node);
- }
-
- // set app's executable path
- HybridBackendData* data =
- static_cast<HybridBackendData*>(context_->backend_data.get());
- manifest_x* tpk_data = data->tpk_manifest_data.get();
- for (application_x* app :
- GListRange<application_x*>(tpk_data->application)) {
- auto r = std::find_if(kApplicationNodeNames.begin(),
- kApplicationNodeNames.end(),
- [app](const std::pair<std::string, std::string>& e) {
- return strcmp(e.second.c_str(), app->component_type) == 0;
- });
- if (r == kApplicationNodeNames.end()) {
- LOG(WARNING) << "Cannot find component type!";
- continue;
- }
- xmlNodePtr node = GetXmlNode(wgt_doc_, (*r).first, "appid", app->appid);
- SetXmlNodeAttribute(node, "exec", app->exec);
- }
-
- if (xmlSaveFormatFile(wgt_xml_path.string().c_str(), wgt_doc_, 1) == -1) {
- LOG(ERROR) << "Cannot write xml file";
- return Step::Status::MANIFEST_ERROR;
- }
-
- if (pkgmgr_parser_check_manifest_validation(
- wgt_xml_path.string().c_str()) != 0) {
- LOG(ERROR) << "Merged manifest is not valid";
- return Step::Status::MANIFEST_ERROR;
- }
-
- return Status::OK;
-}
-
-ci::Step::Status StepGenerateXml::precheck() {
- bf::path wgt_xml_path = context_->xml_path.get();
- if (!bf::exists(wgt_xml_path)) {
- LOG(ERROR) << "Converted config file not found: " << wgt_xml_path;
- return Step::Status::MANIFEST_ERROR;
- }
-
- bf::path tpk_xml_path = context_->GetPkgPath() / "tizen-manifest.xml";
- if (!bf::exists(tpk_xml_path)) {
- LOG(ERROR) << "Native manifest file not found: " << tpk_xml_path;
- return Step::Status::MANIFEST_ERROR;
- }
-
- return Status::OK;
-}
-
-} // namespace pkgmgr
-} // namespace hybrid
+++ /dev/null
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef HYBRID_STEP_PKGMGR_STEP_GENERATE_XML_H_
-#define HYBRID_STEP_PKGMGR_STEP_GENERATE_XML_H_
-
-#include <boost/filesystem.hpp>
-
-#include <common/step/step.h>
-#include <manifest_parser/utils/logging.h>
-#include <libxml/tree.h>
-
-#include <string>
-
-namespace hybrid {
-namespace pkgmgr {
-
-class StepGenerateXml : public common_installer::Step {
- public:
- using Step::Step;
- explicit StepGenerateXml(common_installer::InstallerContext* context)
- : Step(context), wgt_doc_(nullptr), tpk_doc_(nullptr) {}
- Status process() override;
- Status clean() override { return Status::OK; }
- Status undo() override { return Status::OK; }
- Status precheck() override;
-
- private:
- bool LoadXmlDocument(const boost::filesystem::path& wgt_xml_path,
- const boost::filesystem::path& tpk_xml_path);
- xmlNodePtr GetXmlNode(const xmlDocPtr doc, const std::string& name,
- const std::string& attr = {}, const std::string& attr_val = {});
- void MergeXmlNode(xmlNodePtr node1, xmlNodePtr node2);
- void SetXmlNodeAttribute(xmlNodePtr node, const std::string& attr,
- const std::string& attr_val);
-
- xmlDocPtr wgt_doc_;
- xmlDocPtr tpk_doc_;
-
- STEP_NAME(GenerateXml2);
-};
-
-} // namespace pkgmgr
-} // namespace hybrid
-
-#endif // HYBRID_STEP_PKGMGR_STEP_GENERATE_XML_H_
--- /dev/null
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "hybrid/step/pkgmgr/step_merge_xml.h"
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/system/error_code.hpp>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+#include <pkgmgr_parser.h>
+
+#include <common/utils/file_util.h>
+#include <common/utils/glist_range.h>
+
+#include <utility>
+#include <string>
+#include <vector>
+
+#include "hybrid/hybrid_backend_data.h"
+
+namespace ci = common_installer;
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+namespace {
+
+const std::vector<std::string> kBlackListNodes = {
+ {"author"},
+ {"description"},
+ {"profile"},
+ {"privileges"},
+ {"provides-appdefined-privileges"},
+ {"trust-anchor"},
+};
+const std::vector<std::string> kNeedMergeNodes = {
+ {"manifest"},
+};
+const std::vector<std::pair<std::string, std::string>> kApplicationNodeNames = {
+ {"ui-application", "uiapp"},
+ {"service-application", "svcapp"},
+ {"widget-application", "widgetapp"},
+ {"watch-application", "watchapp"},
+};
+
+} // namespace
+
+namespace hybrid {
+namespace pkgmgr {
+
+bool StepMergeXml::LoadXmlDocument(const bf::path& wgt_xml_path,
+ const bf::path& tpk_xml_path) {
+ // trim blanks
+ int keep_blanks = xmlKeepBlanksDefault(0);
+ wgt_doc_ = xmlParseFile(wgt_xml_path.string().c_str());
+ if (!wgt_doc_) {
+ LOG(ERROR) << "Failed to parse file: " << wgt_xml_path;
+ xmlKeepBlanksDefault(keep_blanks);
+ return false;
+ }
+ tpk_doc_ = xmlParseFile(tpk_xml_path.string().c_str());
+ if (!tpk_doc_) {
+ LOG(ERROR) << "Failed to parse file: " << tpk_xml_path;
+ xmlKeepBlanksDefault(keep_blanks);
+ return false;
+ }
+ xmlKeepBlanksDefault(keep_blanks);
+ return true;
+}
+
+xmlNodePtr StepMergeXml::GetXmlNode(const xmlDocPtr doc,
+ const std::string& name, const std::string& attr,
+ const std::string& attr_val) {
+ xmlXPathContextPtr ctxt = xmlXPathNewContext(doc);
+ if (!ctxt) {
+ LOG(ERROR) << "Failed to create XPath context";
+ return nullptr;
+ }
+
+ std::string expr = "//*[local-name()='" + name + "']";
+ if (!attr.empty() && !attr_val.empty())
+ expr.append("[@" + attr + "='" + attr_val + "']");
+
+ xmlXPathObjectPtr obj =
+ xmlXPathEvalExpression((const xmlChar*)expr.c_str(), ctxt);
+ if (!obj || !obj->nodesetval || !obj->nodesetval->nodeNr) {
+ xmlXPathFreeContext(ctxt);
+ return nullptr;
+ }
+
+ xmlNodePtr node = obj->nodesetval->nodeTab[0];
+ xmlXPathFreeObject(obj);
+ xmlXPathFreeContext(ctxt);
+
+ return node;
+}
+
+void StepMergeXml::MergeXmlNode(xmlNodePtr node1, xmlNodePtr node2) {
+ xmlNodePtr last = xmlGetLastChild(node1);
+ xmlNodePtr next;
+ // merge node2's child into node1
+ for (xmlNodePtr cur = node2->children; cur; cur = next) {
+ next = cur->next;
+ if (std::find(kBlackListNodes.begin(), kBlackListNodes.end(),
+ reinterpret_cast<const char*>(cur->name)) != kBlackListNodes.end())
+ continue;
+ // to avoid duplicate
+ if (std::find(kNeedMergeNodes.begin(), kNeedMergeNodes.end(),
+ reinterpret_cast<const char*>(cur->name)) != kNeedMergeNodes.end())
+ continue;
+ if (xmlAddNextSibling(last, cur) != nullptr)
+ last = last->next;
+ }
+}
+
+void StepMergeXml::SetXmlNodeAttribute(xmlNodePtr node,
+ const std::string& attr, const std::string& attr_val) {
+ xmlSetProp(node, reinterpret_cast<const xmlChar*>(attr.c_str()),
+ reinterpret_cast<const xmlChar*>(attr_val.c_str()));
+}
+
+ci::Step::Status StepMergeXml::process() {
+ bf::path wgt_xml_path = context_->xml_path.get();
+ bf::path tpk_xml_path = context_->GetPkgPath() / "tizen-manifest.xml";
+
+ if (!LoadXmlDocument(wgt_xml_path, tpk_xml_path))
+ return Step::Status::MANIFEST_ERROR;
+
+ for (auto& entry : kNeedMergeNodes) {
+ xmlNodePtr tpk_node = GetXmlNode(tpk_doc_, entry);
+ if (tpk_node == nullptr)
+ continue;
+ // TODO(s89.jang): If cannot find node from wgt doc, merge tpk node itself
+ // instead of merging its child nodes.
+ xmlNodePtr wgt_node = GetXmlNode(wgt_doc_, entry);
+ MergeXmlNode(wgt_node, tpk_node);
+ }
+
+ // set app's executable path
+ HybridBackendData* data =
+ static_cast<HybridBackendData*>(context_->backend_data.get());
+ manifest_x* tpk_data = data->tpk_manifest_data.get();
+ for (application_x* app :
+ GListRange<application_x*>(tpk_data->application)) {
+ auto r = std::find_if(kApplicationNodeNames.begin(),
+ kApplicationNodeNames.end(),
+ [app](const std::pair<std::string, std::string>& e) {
+ return strcmp(e.second.c_str(), app->component_type) == 0;
+ });
+ if (r == kApplicationNodeNames.end()) {
+ LOG(WARNING) << "Cannot find component type!";
+ continue;
+ }
+ xmlNodePtr node = GetXmlNode(wgt_doc_, (*r).first, "appid", app->appid);
+ SetXmlNodeAttribute(node, "exec", app->exec);
+ }
+
+ if (xmlSaveFormatFile(wgt_xml_path.string().c_str(), wgt_doc_, 1) == -1) {
+ LOG(ERROR) << "Cannot write xml file";
+ return Step::Status::MANIFEST_ERROR;
+ }
+
+ if (pkgmgr_parser_check_manifest_validation(
+ wgt_xml_path.string().c_str()) != 0) {
+ LOG(ERROR) << "Merged manifest is not valid";
+ return Step::Status::MANIFEST_ERROR;
+ }
+
+ return Status::OK;
+}
+
+ci::Step::Status StepMergeXml::precheck() {
+ bf::path wgt_xml_path = context_->xml_path.get();
+ if (!bf::exists(wgt_xml_path)) {
+ LOG(ERROR) << "Converted config file not found: " << wgt_xml_path;
+ return Step::Status::MANIFEST_ERROR;
+ }
+
+ bf::path tpk_xml_path = context_->GetPkgPath() / "tizen-manifest.xml";
+ if (!bf::exists(tpk_xml_path)) {
+ LOG(ERROR) << "Native manifest file not found: " << tpk_xml_path;
+ return Step::Status::MANIFEST_ERROR;
+ }
+
+ return Status::OK;
+}
+
+} // namespace pkgmgr
+} // namespace hybrid
--- /dev/null
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef HYBRID_STEP_PKGMGR_STEP_MERGE_XML_H_
+#define HYBRID_STEP_PKGMGR_STEP_MERGE_XML_H_
+
+#include <boost/filesystem.hpp>
+
+#include <common/step/step.h>
+#include <manifest_parser/utils/logging.h>
+#include <libxml/tree.h>
+
+#include <string>
+
+namespace hybrid {
+namespace pkgmgr {
+
+class StepMergeXml : public common_installer::Step {
+ public:
+ using Step::Step;
+ explicit StepMergeXml(common_installer::InstallerContext* context)
+ : Step(context), wgt_doc_(nullptr), tpk_doc_(nullptr) {}
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override;
+
+ private:
+ bool LoadXmlDocument(const boost::filesystem::path& wgt_xml_path,
+ const boost::filesystem::path& tpk_xml_path);
+ xmlNodePtr GetXmlNode(const xmlDocPtr doc, const std::string& name,
+ const std::string& attr = {}, const std::string& attr_val = {});
+ void MergeXmlNode(xmlNodePtr node1, xmlNodePtr node2);
+ void SetXmlNodeAttribute(xmlNodePtr node, const std::string& attr,
+ const std::string& attr_val);
+
+ xmlDocPtr wgt_doc_;
+ xmlDocPtr tpk_doc_;
+
+ STEP_NAME(MergeXml);
+};
+
+} // namespace pkgmgr
+} // namespace hybrid
+
+#endif // HYBRID_STEP_PKGMGR_STEP_MERGE_XML_H_
private:
bool CreateSymlinksForApps();
- STEP_NAME(SymbolicLink)
+ STEP_NAME(CreateSymbolicLink)
};
} // namespace filesystem
bool ShareDirFor3x();
bool CreatePrivateTmpDir();
- STEP_NAME(PatchWgtStorageDirectories)
+ STEP_NAME(WgtPatchStorageDirectories)
};
} // namespace filesystem
*/
Status precheck() override { return Status::OK; }
- STEP_NAME(CreateWgtResourceDirectory)
+ STEP_NAME(WgtResourceDirectory)
};
} // namespace filesystem
bool UndoShareDirFor3x();
boost::filesystem::path backup_dir_;
- STEP_NAME(UndoPatchWgtStorageDirectories)
+ STEP_NAME(WgtUndoPatchStorageDirectories)
};
} // namespace filesystem
private:
boost::filesystem::path GetSignatureRoot() const override;
- STEP_NAME(StepDirectManifestSignature)
+ STEP_NAME(DirectManifestSignature)
};
} // namespace security