- Improve readability.
- Reduce indentation depth.
- Extract codes to make lighter functions.
- Remove incorrect comments.
Change-Id: I05447a4dcf975e6069f5e1b11277d6509edd9557
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
return false;
}
- // search current locale first
for (auto& label : pkg_info->labels()) {
if (label.first.empty())
continue;
- // There is label info in PackageInfo using below format:
- // using LangTextPair = pair<lang, text>;
- // Maybe this can be refactored.
+
if (!strcmp(label.first.c_str(), locale)) {
label_ = label.second;
return true;
}
}
- // search again if cannot find label with current locale
+
for (auto& label : pkg_info->labels()) {
if (label.first.empty()) {
label_ = label.second;
if (GetAppLabel<tpk::parse::UIApplicationInfoList>(parser,
tpk::application_keys::kUIApplicationKey, locale))
return true;
+
if (GetAppLabel<tpk::parse::ServiceApplicationInfoList>(parser,
tpk::application_keys::kServiceApplicationKey, locale))
return true;
+
if (GetAppLabel<tpk::parse::WidgetApplicationInfoList>(parser,
tpk::application_keys::kWidgetApplicationKey, locale))
return true;
+
if (GetAppLabel<tpk::parse::WatchApplicationInfoList>(parser,
tpk::application_keys::kWatchApplicationKey, locale))
return true;
if (!desc_info)
return false;
- // search current locale first
if (locale) {
for (auto& desc : desc_info->descriptions) {
if (desc.xml_lang().empty())
continue;
+
if (!strcmp(desc.xml_lang().c_str(), locale)) {
description_ = desc.description();
return true;
}
}
}
- // search again if cannot find desc with current locale
+
for (auto& desc : desc_info->descriptions) {
if (desc.xml_lang().empty()) {
description_ = desc.description();
bool TpkArchiveInfo::GetIconInfo(const tpk::parse::TPKConfigParser& parser,
const char* locale) {
- // get icon from ui application
if (GetAppIcon<tpk::parse::UIApplicationInfoList>(parser,
tpk::application_keys::kUIApplicationKey, locale))
return true;
+
if (GetAppIcon<tpk::parse::ServiceApplicationInfoList>(parser,
tpk::application_keys::kServiceApplicationKey, locale))
return true;
+
if (GetAppIcon<tpk::parse::WidgetApplicationInfoList>(parser,
tpk::application_keys::kWidgetApplicationKey, locale))
return true;
+
if (GetAppIcon<tpk::parse::WatchApplicationInfoList>(parser,
tpk::application_keys::kWatchApplicationKey, locale))
return true;
bool TpkArchiveInfo::LoadArchiveInfo() {
bf::path tmp_dir = ci::GenerateTmpDir("/tmp");
+
if (!ci::CreateDir(tmp_dir))
return false;
+
LOG(DEBUG) << "Unpack at temporary dir: " << tmp_dir;
if (!ExtractPackageArchive(path_, kManifestFileName, tmp_dir.string()))
return false;
if (!GetAuthorInfo(parser))
LOG(WARNING) << "Failed to get author info";
+
if (!GetPrivilegesInfo(parser))
LOG(WARNING) << "Failed to get privilege info";
+
if (!GetDependencyInfo(parser))
LOG(WARNING) << "Failed to get dependency info";
if (!GetLabelInfo(parser, locale))
LOG(WARNING) << "Failed to get label info";
+
if (!GetDescriptionInfo(parser, locale))
LOG(WARNING) << "Failed to get description info";
+
if (!GetIconInfo(parser, locale))
LOG(WARNING) << "Failed to get icon path";
+
free(locale);
if (!icon_.empty()) {
bf::path icon_path = bf::path(kSharedResDir) / icon_;
RemoveTmpDir(tmp_dir.string());
return false;
}
+
if (!ReadIcon(icon_path, tmp_dir)) {
LOG(WARNING) << "Failed to get icon info";
RemoveTmpDir(tmp_dir.string());
break;
}
case ci::RequestMode::USER: {
- // if package is globally installed, leave directories
- ci::PkgQueryInterface pkg_query(pkgid, GLOBAL_USER);
- if (pkg_query.IsPackageInstalled(ci::RequestMode::GLOBAL))
- return true;
-
LOG(DEBUG) << "Removing external directories for user: " << uid;
ci::PerformExternalDirectoryDeletionForUser(uid, pkgid);
break;
ci::Step::Status StepAdjustInstallLocation::process() {
ci::PrivilegeLevel level = context_->privilege_level.get();
- // Unfortunately we don't know privilege level when parsing manifest,
- // because checking signature is done after parsing.
- if (level == ci::PrivilegeLevel::PUBLIC) {
- manifest_x* manifest = context_->manifest_data.get();
- // This may be allocated by step parse
- free(const_cast<char*>(manifest->installlocation));
- manifest->installlocation = strdup(kAutoLocation);
- if (!manifest->installlocation) {
- LOG(ERROR) << "Out of memory";
- return Status::ERROR;
- }
+
+ if (level != ci::PrivilegeLevel::PUBLIC)
+ return Status::OK;
+
+ manifest_x* manifest = context_->manifest_data.get();
+ if (!manifest)
+ return Status::ERROR;
+
+ free(const_cast<char*>(manifest->installlocation));
+ manifest->installlocation = strdup(kAutoLocation);
+ if (!manifest->installlocation) {
+ LOG(ERROR) << "Out of memory";
+ return Status::ERROR;
}
+
return Status::OK;
}
#include <boost/filesystem/path.hpp>
#include <boost/system/error_code.hpp>
+#include <common/utils/file_util.h>
+
namespace bf = boost::filesystem;
namespace bs = boost::system;
common_installer::Step::Status StepCheckReinstallManifest::process() {
bf::path target = context_->unpacked_dir_path.get() / kManifest;
+
if (bf::exists(target))
return Status::OK;
LOG(ERROR) << "Cannot find old manifest file";
return Status::APP_DIR_ERROR;
}
- bs::error_code error;
- bf::copy_file(source, target, error);
- if (error) {
+
+ if (!common_installer::CopyFile(source, target)) {
LOG(ERROR) << "Failed to copy old manifest file";
return Status::APP_DIR_ERROR;
}
#include <boost/filesystem.hpp>
#include <string>
+#include <common/utils/file_util.h>
+
namespace tpk {
namespace filesystem {
if (bf::exists(context_->GetPkgPath()))
return Status::OK;
- LOG(INFO) << "Create pkg_path("
- << context_->GetPkgPath()
- << ") for package("
- << context_->pkgid.get() << ")";
- bs::error_code error;
- bf::create_directories(context_->GetPkgPath(), error);
- if (error) {
+ LOG(INFO) << "Create pkg_path(" << context_->GetPkgPath()
+ << ") for package(" << context_->pkgid.get() << ")";
+
+ if (!common_installer::CreateDir(context_->GetPkgPath())) {
LOG(ERROR) << "Cannot create directory: "
- << context_->GetPkgPath().string()
- << ", error: " << error.message();
+ << context_->GetPkgPath().string();
return Step::Status::APP_DIR_ERROR;
}
LOG(ERROR) << "Failed to create external appdata directories";
return Status::APP_DIR_ERROR;
}
+
return Status::OK;
}
LOG(ERROR) << "Manifest data not set";
return Status::INVALID_VALUE;
}
+
return Status::OK;
}
using common_installer::InstallerContext;
typedef common_installer::Step::Status Status;
+bool CreateUGClientSymlink(const bf::path& app_exec_path) {
+ bf::path ug_client_path(tzplatform_mkpath(TZ_SYS_BIN, "ug-client"));
+
+ LOG(INFO) << "Createing symlink " << app_exec_path << " pointing " <<
+ ug_client_path;
+ boost::system::error_code error;
+ bf::create_symlink(ug_client_path, app_exec_path, error);
+ if (error) {
+ LOG(ERROR) << "Symlink creation failure: " << app_exec_path
+ << ", error :" << error.message();
+ return false;
+ }
+
+ return true;
+}
+
bool CreateSymLink(application_x* app, InstallerContext* context) {
- bf::path bindir = context->GetPkgPath() /
- bf::path("bin");
+ bf::path bindir = context->GetPkgPath() / bf::path("bin");
+
LOG(DEBUG) << "Creating dir: " << bindir;
if (!bf::is_symlink(symlink_status(bindir)) &&
!common_installer::CreateDir(bindir)) {
if (bf::exists(app_exec_path))
return true;
- // Ug-client path
- // Make a symlink with the name of appid, pointing /usr/bin/ug-client
- bf::path ug_client_path(tzplatform_mkpath(TZ_SYS_BIN, "ug-client"));
- LOG(INFO) << "Createing symlink " << app_exec_path << " pointing " <<
- ug_client_path;
- boost::system::error_code error;
- bf::create_symlink(ug_client_path, app_exec_path, error);
- if (error) {
- LOG(ERROR) << "Symlink creation failure: " << app_exec_path
- << ", error :" << error.message();
+ if (!CreateUGClientSymlink(app_exec_path))
return false;
- }
return true;
}
Status StepCreateTpkSymbolicLink::precheck() {
- manifest_x *m = context_->manifest_data.get();
+ manifest_x* m = context_->manifest_data.get();
+
if (!m) {
LOG(ERROR) << "manifest_data attribute is empty";
return Step::Status::INVALID_VALUE;
}
+
if (!m->application) {
LOG(ERROR) << "No application exists";
return Step::Status::ERROR;
// filter out non-tpk apps as this step is run for hybrid backend too
if (strcmp("webapp", app->type) == 0)
continue;
+
if (!CreateSymLink(app, context_))
return Status::ERROR;
}
context_->request_mode.get(),
context_->uid.get()))
return Status::APP_DIR_ERROR;
+
return Status::OK;
}
const bf::path& common_icon_location, const bf::path& icon_text,
application_x* app, icon_x* icon) {
bf::path destination = common_icon_location / app->appid;
+
if (!icon_text.extension().empty())
destination += icon_text.extension();
else
free(const_cast<char*>(icon->text));
icon->text = strdup(destination.c_str());
- if (!icon->text)
+ if (!icon->text) {
+ LOG(ERROR) << "Out of memory";
return Status::ICON_ERROR;
+ }
return Status::OK;
}
context_->root_application_path.get(),
context_->uid.get(),
context_->is_readonly_package.get());
+
if (!source.empty()) {
LOG(DEBUG) << "Fix location of icon: " << source << " to: " << icon_text;
if (!common_installer::CopyFile(source, icon_text))
return Status::ICON_ERROR;
}
+
return Status::OK;
}
GListRange<application_x*>(context_->manifest_data.get()->application)) {
if (!IsTpkApp(app))
continue;
+
for (auto& icon : GListRange<icon_x*>(app->icon)) {
bf::path icon_text(icon->text);
if (icon_text.parent_path() != common_icon_location) {
const std::string& entry, const bf::path& backup_path) {
if (!bf::exists(context_->GetPkgPath() / entry))
return Status::OK;
+
if (!ci::MoveDir(context_->GetPkgPath() / entry, backup_path / entry,
ci::FSFlag::FS_MERGE_OVERWRITE |
ci::FSFlag::FS_COMMIT_COPY_FILE |
const std::string& entry, const bf::path& mount_point) {
bs::error_code error;
bf::path mount_point_entry = mount_point / entry;
- if (bf::exists(mount_point_entry)) {
- bf::path destination = context_->GetPkgPath() / entry;
- if (bf::exists(destination)) {
- if (!bf::is_symlink(symlink_status(destination))) {
- LOG(ERROR) << "Cannot proceed. "
- << "Location of link is used by another file";
- return Status::APP_DIR_ERROR;
- }
- bf::remove(destination, error);
- if (error) {
- LOG(ERROR) << "Failed to remove previous symlink";
- return Status::APP_DIR_ERROR;
- }
+
+ if (!bf::exists(mount_point_entry))
+ return Status::OK;
+
+ bf::path destination = context_->GetPkgPath() / entry;
+ if (bf::exists(destination)) {
+ if (!bf::is_symlink(symlink_status(destination))) {
+ LOG(ERROR) << "Cannot proceed. "
+ << "Location of link is used by another file";
+ return Status::APP_DIR_ERROR;
}
- bf::create_symlink(mount_point_entry, destination, error);
+
+ bf::remove(destination, error);
if (error) {
- LOG(ERROR) << "Failed to create symlink for entry: " << mount_point_entry;
+ LOG(ERROR) << "Failed to remove previous symlink";
return Status::APP_DIR_ERROR;
}
}
+
+ bf::create_symlink(mount_point_entry, destination, error);
+ if (error) {
+ LOG(ERROR) << "Failed to create symlink for entry: " << mount_point_entry;
+ return Status::APP_DIR_ERROR;
+ }
+
return Status::OK;
}
for (auto& entry : tpk::GetExtractEntries()) {
LOG(DEBUG) << "Extracting: " << entry;
- if (context_->request_type.get() == ci::RequestType::MountUpdate)
+ if (context_->request_type.get() == ci::RequestType::MountUpdate) {
if (BackupDirectory(entry, backup_path) != Status::OK)
return Status::APP_DIR_ERROR;
+ }
+
auto status = PrepareDirectory(entry);
if (status != Status::OK)
return status;
}
+
return Status::OK;
}
LOG(DEBUG) << "Creating symlinks to zip package...";
for (auto& link_entry : tpk::GetSymlinkEntries()) {
LOG(DEBUG) << "Symlink: " << link_entry;
+
auto status = PrepareLink(link_entry, mount_point);
if (status != Status::OK)
return status;
}
+
return Status::OK;
}
ci::Step::Status StepTpkPreparePackageDirectory::process() {
auto status = ExtractEntries();
+
if (status != Status::OK)
return status;
+
return PrepareLinks();
}
LOG(ERROR) << "Package installation path is not set";
return Status::INVALID_VALUE;
}
+
return Status::OK;
}
ci::RemoveAll(context_->GetPkgPath() / entry);
if (!bf::exists(backupPath_ / entry))
continue;
+
ci::MoveDir(backupPath_ / entry, context_->GetPkgPath() / entry,
ci::FSFlag::FS_MERGE_OVERWRITE |
ci::FSFlag::FS_COMMIT_COPY_FILE |
ci::FSFlag::FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS);
}
ci::RemoveAll(backupPath_);
+
return Status::OK;
}
bool ReplacePaths(const bf::path& source, const bf::path& destination) {
if (!bf::exists(destination.parent_path())) {
- bs::error_code error;
- bf::create_directories(destination.parent_path(), error);
- if (error) {
- LOG(ERROR) << "Failed to create destination directory for directory "
- << "backup";
+ if (!ci::CreateDir(destination.parent_path()))
return false;
- }
}
+
if (!ci::MoveDir(source, destination)) {
LOG(ERROR) << "Failed to move " << source << " to " << destination;
return false;
}
+
return true;
}
ci::Step::Status StepTpkUpdatePackageDirectory::BackupDirectory(
const std::string& entry, const boost::filesystem::path& backup_path) {
bf::path source = context_->GetPkgPath() / entry;
+
if (bf::exists(source)) {
bf::path destination = backup_path / entry;
if (!ReplacePaths(source, destination))
return Status::APP_DIR_ERROR;
}
+
return Status::OK;
}
ci::Step::Status StepTpkUpdatePackageDirectory::RestoreDirectory(
const std::string& entry, const boost::filesystem::path& backup_path) {
- // restore backup if directory exists
- if (bf::exists(backup_path / entry)) {
- bf::path source = backup_path / entry;
- bf::path destination = context_->GetPkgPath() / entry;
- if (bf::exists(destination)) {
- bs::error_code error;
- bf::remove_all(destination, error);
- if (error) {
- LOG(ERROR) << "Failed to remove restore destination path: "
- << destination;
- return Status::APP_DIR_ERROR;
- }
- }
- if (!ReplacePaths(source, destination))
+ if (!bf::exists(backup_path / entry))
+ return Status::OK;
+
+ bf::path source = backup_path / entry;
+ bf::path destination = context_->GetPkgPath() / entry;
+ if (bf::exists(destination)) {
+ if (!ci::RemoveAll(destination))
return Status::APP_DIR_ERROR;
}
+
+ if (!ReplacePaths(source, destination))
+ return Status::APP_DIR_ERROR;
+
return Status::OK;
}
const boost::filesystem::path& dir_path) {
if (!ci::RemoveAll(dir_path))
return Status::APP_DIR_ERROR;
+
return Status::OK;
}
ci::Step::Status StepTpkUpdatePackageDirectory::BackupEntries() {
bf::path backup_path =
ci::GetBackupPathForPackagePath(context_->GetPkgPath());
+
for (auto& entry : tpk::GetExtractEntries()) {
auto status = BackupDirectory(entry, backup_path);
if (status != Status::OK)
return status;
}
+
return Status::OK;
}
auto status = BackupEntries();
if (status != Status::OK)
return status;
+
status = ExtractEntries();
if (status != Status::OK)
return status;
+
return PrepareLinks();
}
bf::path backup_path =
ci::GetBackupPathForPackagePath(context_->GetPkgPath());
RemoveDirectory(backup_path);
+
return Status::OK;
}
LOG(ERROR) << "Manifest data not set";
return Status::INVALID_VALUE;
}
+
return Status::OK;
}
}
common_installer::Step::Status StepConvertXml::undo() {
- if (ci::Remove(new_path_)) {
- if (!backup_path_.empty()) {
- bs::error_code error;
- bf::rename(backup_path_, new_path_, error);
- if (error)
- LOG(WARNING) << "Failed to restore " << new_path_
- << " due to error " << error;
- }
- }
+ if (!ci::Remove(new_path_))
+ return Step::Status::OK;
+
+ if (backup_path_.empty())
+ return Step::Status::OK;
+
+ bs::error_code error;
+ bf::rename(backup_path_, new_path_, error);
+ if (error)
+ LOG(WARNING) << "Failed to restore " << new_path_
+ << " due to error " << error;
return Step::Status::OK;
}
const xmlChar kAutoRestartAttributeKey[] = "auto-restart";
const char kXmlXSvcAppExpr[] = "//*[local-name()='service-application']";
+bool SetProperty(xmlNodePtr node, const char* attribute, const char* value) {
+ auto attrib = xmlSetProp(node,
+ reinterpret_cast<libxml_char>(attribute),
+ reinterpret_cast<libxml_char>(value));
+
+ if (attrib == nullptr) {
+ LOG(ERROR) << "Failed to set attribute: " << attribute;
+ return false;
+ }
+
+ return true;
+}
+
+bool SetManifestElement(char** src, const char* value) {
+ free(*src);
+ *src = strdup(value);
+
+ if (*src == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return false;
+ }
+
+ return true;
+}
+
} // namespace
namespace tpk {
xmlNodePtr node = xmlDocGetRootElement(doc);
- std::string pkgtype_attrib = "type";
- auto attrib = xmlSetProp(node,
- reinterpret_cast<libxml_char>(pkgtype_attrib.c_str()),
- reinterpret_cast<libxml_char>(context_->manifest_data.get()->type));
-
- if (attrib == nullptr) {
- LOG(ERROR) << "Failed to set attribute pkgtype";
+ if (!SetProperty(node, "type", context_->manifest_data.get()->type)) {
xmlFreeDoc(doc);
return Step::Status::ERROR;
}
- std::string readonly_attrib = "readonly";
- attrib = xmlSetProp(node,
- reinterpret_cast<libxml_char>(readonly_attrib.c_str()),
- reinterpret_cast<libxml_char>(context_->manifest_data.get()->readonly));
-
- if (attrib == nullptr) {
- LOG(ERROR) << "Failed to set attribute readonly";
+ if (!SetProperty(node, "readonly",
+ context_->manifest_data.get()->readonly)) {
xmlFreeDoc(doc);
return Step::Status::ERROR;
}
- std::string preload_attrib = "preload";
- 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";
+ if (!SetProperty(node, "preload",
+ context_->manifest_data.get()->preload)) {
xmlFreeDoc(doc);
return Step::Status::ERROR;
}
- std::string removable_attrib = "removable";
- attrib = xmlSetProp(node,
- reinterpret_cast<libxml_char>(removable_attrib.c_str()),
- reinterpret_cast<libxml_char>(context_->manifest_data.get()->removable));
-
- if (attrib == nullptr) {
- LOG(ERROR) << "Failed to set attribute removable";
+ if (!SetProperty(node, "removable",
+ context_->manifest_data.get()->removable)) {
xmlFreeDoc(doc);
return Step::Status::ERROR;
}
- if ((context_->privilege_level.get() !=
- common_installer::PrivilegeLevel::PARTNER) &&
- (context_->privilege_level.get() !=
- common_installer::PrivilegeLevel::PLATFORM)) {
- utils::VersionNumber api_version =
- utils::VersionNumber(context_->manifest_data.get()->api_version);
- utils::VersionNumber platform_version =
- utils::VersionNumber((common_installer::GetTizenProfile() ==
- common_installer::TizenProfile::WEARABLE) ?
- "2.3.1" : "2.4");
-
- if (api_version >= platform_version) {
- xmlXPathContextPtr xpath_ctx = xmlXPathNewContext(doc);
- if (!xpath_ctx) {
- LOG(ERROR) << "Failed to create XPath context";
- xmlFreeDoc(doc);
- return Step::Status::ERROR;
- }
+ if (IsNonPrivilegedPackage() && IsAdjustmentNecessary()) {
+ xmlXPathContextPtr xpath_ctx = xmlXPathNewContext(doc);
+ if (!xpath_ctx) {
+ LOG(ERROR) << "Failed to create XPath context";
+ xmlFreeDoc(doc);
+ return Step::Status::ERROR;
+ }
- for (auto& app : GListRange<application_x*>(
- context_->manifest_data.get()->application)) {
- std::string expr = std::string(kXmlXSvcAppExpr);
- xmlXPathObjectPtr xpath_obj = xmlXPathEvalExpression(
- (const xmlChar*)expr.c_str(), xpath_ctx);
- if (!xpath_obj || xmlXPathNodeSetIsEmpty(xpath_obj->nodesetval)) {
- if (xpath_obj)
- xmlXPathFreeObject(xpath_obj);
- continue;
- }
-
- for (int i = 0; i < xpath_obj->nodesetval->nodeNr; i++) {
- xmlNodePtr node = xpath_obj->nodesetval->nodeTab[i];
- xmlSetProp(node, kOnBootAttributeKey, (const xmlChar*)"false");
- xmlSetProp(node, kAutoRestartAttributeKey, (const xmlChar*)"false");
- }
-
- if (app->autorestart)
- free(app->autorestart);
- app->autorestart = strdup("false");
- if (!app->autorestart) {
- LOG(ERROR) << "Out of memory";
- xmlXPathFreeObject(xpath_obj);
- xmlXPathFreeContext(xpath_ctx);
- xmlFreeDoc(doc);
- return Step::Status::ERROR;
- }
-
- if (app->onboot)
- free(app->onboot);
- app->onboot = strdup("false");
- if (!app->onboot) {
- LOG(ERROR) << "Out of memory";
+ for (auto& app : GListRange<application_x*>(
+ context_->manifest_data.get()->application)) {
+ std::string expr = std::string(kXmlXSvcAppExpr);
+ xmlXPathObjectPtr xpath_obj = xmlXPathEvalExpression(
+ (const xmlChar*)expr.c_str(), xpath_ctx);
+ if (!xpath_obj || xmlXPathNodeSetIsEmpty(xpath_obj->nodesetval)) {
+ if (xpath_obj)
xmlXPathFreeObject(xpath_obj);
- xmlXPathFreeContext(xpath_ctx);
- xmlFreeDoc(doc);
- return Step::Status::ERROR;
- }
+ continue;
+ }
+
+ for (int i = 0; i < xpath_obj->nodesetval->nodeNr; i++) {
+ xmlNodePtr node = xpath_obj->nodesetval->nodeTab[i];
+ xmlSetProp(node, kOnBootAttributeKey, (const xmlChar*)"false");
+ xmlSetProp(node, kAutoRestartAttributeKey, (const xmlChar*)"false");
+ }
+
+ if (!SetManifestElement(&(app->autorestart), "false") ||
+ !SetManifestElement(&(app->onboot), "false")) {
xmlXPathFreeObject(xpath_obj);
+ xmlXPathFreeContext(xpath_ctx);
+ xmlFreeDoc(doc);
+ return Step::Status::ERROR;
}
- xmlXPathFreeContext(xpath_ctx);
+
+ xmlXPathFreeObject(xpath_obj);
}
+ xmlXPathFreeContext(xpath_ctx);
}
if (xmlSaveFile(xml_path_.c_str(), doc) == -1) {
return Step::Status::OK;
}
+bool StepManifestAdjustment::IsNonPrivilegedPackage() {
+ if ((context_->privilege_level.get() !=
+ common_installer::PrivilegeLevel::PARTNER) &&
+ (context_->privilege_level.get() !=
+ common_installer::PrivilegeLevel::PLATFORM))
+ return true;
+
+ return false;
+}
+
+bool StepManifestAdjustment::IsAdjustmentNecessary() {
+ utils::VersionNumber api_version =
+ utils::VersionNumber(context_->manifest_data.get()->api_version);
+ utils::VersionNumber platform_version =
+ utils::VersionNumber((common_installer::GetTizenProfile() ==
+ common_installer::TizenProfile::WEARABLE) ?
+ "2.3.1" : "2.4");
+
+ if (api_version >= platform_version)
+ return true;
+
+ return false;
+}
+
} // namespace pkgmgr
} // namespace tpk
private:
boost::filesystem::path xml_path_;
+ bool IsNonPrivilegedPackage();
+ bool IsAdjustmentNecessary();
+
STEP_NAME(ManifestAdjustment)
};
bf::path tmp_path = ExtractManifest(path);
if (tmp_path.empty())
return {};
+
bf::path manifest_path = tmp_path / kManifestFileName;
if (!bf::exists(manifest_path)) {
ClearTemporaryFile(tmp_path);
ClearTemporaryFile(tmp_path);
return {};
}
+
auto package_info = std::static_pointer_cast<const tpk::parse::PackageInfo>(
parser.GetManifestData(tpk::application_keys::kManifestKey));
if (!package_info) {
ClearTemporaryFile(tmp_path);
return {};
}
+
std::string pkg_id = package_info->package();
ClearTemporaryFile(tmp_path);
return pkg_id;