step/step_parse_preload.cc
step/step_convert_xml.cc
step/step_tpk_patch_icons.cc
+ step/step_manifest_adjustment.cc
tpk_app_query_interface.cc
tpk_installer.cc
)
--- /dev/null
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "tpk/step/step_manifest_adjustment.h"
+
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+namespace bs = boost::system;
+namespace bf = boost::filesystem;
+
+using libxml_char = const unsigned char *;
+
+namespace tpk {
+namespace pkgmgr {
+
+common_installer::Step::Status StepManifestAdjustment::precheck() {
+ bf::path xml_path = context_->xml_path.get();
+
+ if (!bf::exists(xml_path)) {
+ LOG(ERROR) << "Cannot find manifest file at " << xml_path;
+ return Step::Status::ERROR;
+ }
+
+ xml_path_ = xml_path;
+
+ return Step::Status::OK;
+}
+
+common_installer::Step::Status StepManifestAdjustment::process() {
+ xmlDocPtr doc = xmlParseFile(xml_path_.c_str());
+
+ if (doc == nullptr) {
+ LOG(ERROR) << "Could not parse file";
+ return Step::Status::ERROR;
+ }
+
+ xmlNodePtr node = xmlDocGetRootElement(doc);
+
+ std::string preload_attrib = "preload";
+ auto attrib = xmlSetProp(node,
+ reinterpret_cast<libxml_char>(preload_attrib.c_str()),
+ reinterpret_cast<libxml_char>(context_->manifest_data.get()->preload));
+
+ if (attrib == nullptr) {
+ LOG(ERROR) << "Failed to set attribute preload";
+ return Step::Status::ERROR;
+ }
+
+ if (xmlSaveFile(xml_path_.c_str(), doc) == -1) {
+ LOG(ERROR) << "Failed to modify xml file";
+ return Step::Status::ERROR;
+ }
+
+ xmlFreeDoc(doc);
+
+ return Step::Status::OK;
+}
+
+common_installer::Step::Status StepManifestAdjustment::clean() {
+ return Step::Status::OK;
+}
+
+common_installer::Step::Status StepManifestAdjustment::undo() {
+ return Step::Status::OK;
+}
+
+} // namespace pkgmgr
+} // namespace tpk
--- /dev/null
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef TPK_STEP_STEP_MANIFEST_ADJUSTMENT_H_
+#define TPK_STEP_STEP_MANIFEST_ADJUSTMENT_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include <boost/filesystem/path.hpp>
+
+#include <common/step/step.h>
+
+namespace tpk {
+namespace pkgmgr {
+
+class StepManifestAdjustment : public common_installer::Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override;
+ Status undo() override;
+ Status precheck() override;
+
+ private:
+ boost::filesystem::path xml_path_;
+
+ SCOPE_LOG_TAG(StepManifestAdjustment)
+};
+
+} // namespace pkgmgr
+} // namespace tpk
+
+#endif // TPK_STEP_STEP_MANIFEST_ADJUSTMENT_H_
#include <common/step/step_update_tep.h>
#include "tpk/step/step_check_tpk_background_category.h"
#include "tpk/step/step_create_symbolic_link.h"
+#include "tpk/step/step_manifest_adjustment.h"
#include "tpk/step/step_parse_preload.h"
#include "tpk/step/step_convert_xml.h"
#include "tpk/step/step_tpk_patch_icons.h"
ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
ci::parse::StepParseManifest::StoreLocation::NORMAL);
AddStep<ci::tpk::StepParsePreload>();
+ AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<ci::security::StepPrivilegeCompatibility>();
AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
ci::parse::StepParseManifest::StoreLocation::NORMAL);
AddStep<ci::tpk::StepParsePreload>();
+ AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<ci::security::StepPrivilegeCompatibility>();
AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();