Requires: ca-certificates-tizen
Requires: libtzplatform-config
+
%description
This is a meta package that installs the common application
installers of Tizen.
%description tests
Unit tests for al modules of app-installers
-
%prep
%setup -q
- RequestMode introduction
* Fri Aug 21 2015 Pawel Sikorski <p.sikorski@samsung.com> 1.6-1
-- Icons generation fix;
+- Icons generation fix;
- Privilege translation for backward compatilibity
* Fri Aug 21 2015 Pawel Sikorski <p.sikorski@samsung.com> 1.5-1
step/step_check_signature.cc
step/step_configure.cc
step/step_copy.cc
+ step/step_copy_tep.cc
step/step_copy_backup.cc
step/step_copy_storage_directories.cc
step/step_create_storage_directories.cc
step/step_unregister_app.cc
step/step_update_app.cc
step/step_update_security.cc
+ step/step_update_tep.cc
utils/file_util.cc
utils/string_util.cc
)
Property<boost::filesystem::path> file_path;
/**
+ * \brief tep file path used for TEP installation process
+ */
+ Property<boost::filesystem::path> tep_path;
+
+ /**
+ * \brief boolean property that indicates tep file should be moved or not
+ */
+ Property<bool> is_tep_move;
+
+ /**
* \brief path to temporary directory when package files are unpacked
* before coping them to final destination
*/
return pkgmgr_installer_get_request_info(pi_);
}
+boost::filesystem::path PkgMgrInterface::GetTepPath() const {
+ if (pkgmgr_installer_get_tep_path(pi_) == nullptr)
+ return boost::filesystem::path("");
+ else
+ return boost::filesystem::path(pkgmgr_installer_get_tep_path(pi_));
+}
+
+bool PkgMgrInterface::GetIsTepMove() {
+ return (pkgmgr_installer_get_tep_move_type(pi_) == 1)?true:false;
+}
+
} // namespace common_installer
#include "common/request.h"
#include "common/utils/macros.h"
#include "common/utils/logging.h"
+#include <boost/filesystem/path.hpp>
namespace common_installer {
AppQueryInterface* interface = nullptr);
/**
+ * Returns TEP path passed from pkgmgr_installer
+ *
+ * \return TEP path retrieved from pkgmgr_installer
+ */
+ boost::filesystem::path GetTepPath() const;
+
+ /**
+ * Returns True if TEP file should be moved. Otherwise, return false
+ *
+ * \return True if TEP file should be moved. Otherwise, return false
+ */
+ bool GetIsTepMove();
+
+ /**
* Get Raw pointer to pkgmgr_installer object
* NOTE: It should not be used (PkgMgrInterface can destroy it
*
namespace common_installer {
+bool RegisterAppInPkgmgrWithTep(const bf::path& tep_path,
+ const bf::path& xml_path,
+ const std::string & pkgid,
+ const CertificateInfo & cert_info,
+ uid_t uid,
+ RequestMode request_mode) {
+ int ret = request_mode != RequestMode::GLOBAL ?
+ pkgmgr_parser_parse_usr_manifest_for_installation_withtep(
+ xml_path.c_str(), tep_path.c_str(),
+ uid, const_cast<char* const*>(kAppinstTags)) :
+ pkgmgr_parser_parse_manifest_for_installation_withtep(
+ xml_path.c_str(), tep_path.c_str(),
+ const_cast<char* const*>(kAppinstTags));
+
+ if (ret) {
+ LOG(ERROR) << "Failed to register package: " << xml_path << ", "
+ "error code=" << ret;
+ return false;
+ }
+
+ if (!!cert_info.author_certificate.get()) {
+ if (!RegisterAuthorCertificate(cert_info, pkgid, uid)) {
+ LOG(ERROR) << "Failed to register author certificate";
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool RegisterAppInPkgmgr(const bf::path& xml_path,
const std::string& pkgid,
const CertificateInfo& cert_info,
return true;
}
+bool UpdateTepInfoInPkgmgr(const bf::path& tep_path, const std::string& pkgid,
+ uid_t uid, RequestMode request_mode) {
+ int ret = request_mode != RequestMode::GLOBAL ?
+ pkgmgr_parser_usr_update_tep(
+ pkgid.c_str(), tep_path.string().c_str(), uid) :
+ pkgmgr_parser_update_tep(
+ pkgid.c_str(), tep_path.string().c_str());
+
+ if (ret != 0) {
+ LOG(ERROR) << "Failed to upgrade tep info: " << pkgid;
+ return false;
+ }
+
+ return true;
+}
+
bool UpgradeAppInPkgmgr(const bf::path& xml_path, const std::string& pkgid,
const CertificateInfo& cert_info, uid_t uid,
RequestMode request_mode) {
uid_t uid,
RequestMode request_mode);
+bool RegisterAppInPkgmgrWithTep(const boost::filesystem::path& tep_path,
+ const boost::filesystem::path& xml_path,
+ const std::string& pkgid,
+ const CertificateInfo& cert_info,
+ uid_t uid,
+ RequestMode request_mode);
+
/**
* \brief Adapter interface for external PkgMgr module used for upgrading
* package within pkgmgr
RequestMode request_mode);
/**
+ * \brief Adapter interface for external PkgMgr module used for updating
+ * tep info about package within pkgmgr
+ *
+ * \param tep_path path of tep file
+ * \param pkgid package pkgid
+ * \param uid user id
+ * \param request_mode current request mode
+ *
+ * \return true if success
+ */
+bool UpdateTepInfoInPkgmgr(const boost::filesystem::path& tep_path,
+ const std::string& pkgid,
+ uid_t uid,
+ RequestMode request_mode);
+
+/**
* \brief Adapter interface for external PkgMgr module used for deregistering
* package into pkgmgr
*
case RequestType::Install:
context_->file_path.set(pkgmgr_->GetRequestInfo());
context_->pkgid.set(kStrEmpty);
+ if (!pkgmgr_->GetTepPath().empty()) {
+ context_->tep_path.set(pkgmgr_->GetTepPath());
+ context_->is_tep_move.set(pkgmgr_->GetIsTepMove());
+ }
break;
case RequestType::Update:
context_->file_path.set(pkgmgr_->GetRequestInfo());
context_->pkgid.set(kStrEmpty);
+ if (!pkgmgr_->GetTepPath().empty()) {
+ context_->tep_path.set(pkgmgr_->GetTepPath());
+ context_->is_tep_move.set(pkgmgr_->GetIsTepMove());
+ }
break;
case RequestType::Uninstall:
context_->pkgid.set(pkgmgr_->GetRequestInfo());
LOG(ERROR) << "Cannot move widget directory to install path";
return Status::ERROR;
}
-
LOG(INFO) << "Successfully move: " << context_->unpacked_dir_path.get()
<< " to: " << install_path << " directory";
return Status::OK;
--- /dev/null
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+// Copyright (c) 2015 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 "common/step/step_copy_tep.h"
+
+#include <cassert>
+#include <cstring>
+#include <string>
+
+#include "common/utils/file_util.h"
+
+namespace common_installer {
+namespace filesystem {
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+Step::Status StepCopyTep::precheck() {
+ if (context_->root_application_path.get().empty()) {
+ LOG(ERROR) << "root_application_path attribute is empty";
+ return Step::Status::INVALID_VALUE;
+ }
+
+ if (!boost::filesystem::exists(context_->root_application_path.get())) {
+ LOG(ERROR) << "root_application_path ("
+ << context_->root_application_path.get()
+ << ") path does not exist";
+ return Step::Status::INVALID_VALUE;
+ }
+
+ if (context_->pkgid.get().empty()) {
+ LOG(ERROR) << "pkgid attribute is empty";
+ return Step::Status::INVALID_VALUE;
+ }
+
+ return Step::Status::OK;
+}
+
+Step::Status StepCopyTep::process() {
+
+ if (context_->tep_path.get().empty())
+ return Step::Status::OK;
+
+ context_->pkg_path.set(
+ context_->root_application_path.get() / context_->pkgid.get());
+
+ bf::path tep_path = context_->pkg_path.get() / "res" / context_->tep_path.get().filename();
+ bs::error_code error;
+
+ if (context_->is_tep_move.get()) {
+ if (!MoveFile(context_->tep_path.get(), tep_path)) {
+ LOG(ERROR) << "Cannnot move TEP file into install path";
+ return Step::Status::ERROR;
+ }
+ } else {
+ if (!CopyFile(context_->tep_path.get(), tep_path)) {
+ LOG(ERROR) << "Cannot copy TEP file [" << context_->tep_path.get() <<
+ "] into install path [" << tep_path << "]";
+ return Step::Status::ERROR;
+ }
+ }
+ context_->tep_path.set(tep_path);
+
+ return Step::Status::OK;
+}
+
+Step::Status StepCopyTep::undo() {
+ if (bf::exists(context_->tep_path.get()))
+ bf::remove_all(context_->tep_path.get());
+ return Status::OK;
+}
+
+} // namespace filesystem
+} // namespace common_installer
--- /dev/null
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+// Copyright (c) 2015 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 COMMON_STEP_STEP_COPY_TEP_H_
+#define COMMON_STEP_STEP_COPY_TEP_H_
+
+#include "common/installer_context.h"
+
+#include "common/step/step.h"
+#include "common/utils/logging.h"
+
+namespace common_installer {
+namespace filesystem {
+
+/**
+ * \brief step responsible for moving/copying TEP files from designated path to
+ * final installed package destination during INSTALLATION/UPDATE.
+ * Used by WGT and TPK
+ */
+class StepCopyTep : public Step {
+ public:
+ using Step::Step;
+
+ /**
+ * \brief main logic of moving/copying files
+ *
+ * \return Status::OK if success, Status::ERROR otherwise
+ */
+ Status process() override;
+
+ /**
+ * \brief empty method
+ *
+ * \return Status::OK
+ */
+ Status clean() override { return Status::OK; }
+
+ /**
+ * \brief removes files from final package destination
+ *
+ * \return Status::OK if success, Status::ERROR otherwise
+ */
+ Status undo() override;
+
+ /**
+ * \brief checks if necessary paths/data are provided
+ *
+ * \return Status::OK if success, Status::ERROR otherwise
+ */
+ Status precheck() override;
+
+ SCOPE_LOG_TAG(CopyTEP)
+
+};
+
+} // namespace filesystem
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_TEPCOPY_H_
}
Step::Status StepRegisterApplication::process() {
- if (!RegisterAppInPkgmgr(context_->xml_path.get(),
- context_->pkgid.get(),
- context_->certificate_info.get(),
- context_->uid.get(),
- context_->request_mode.get())) {
+ if (!RegisterAppInPkgmgrWithTep(context_->tep_path.get(),
+ context_->xml_path.get(),
+ context_->pkgid.get(),
+ context_->certificate_info.get(),
+ context_->uid.get(),
+ context_->request_mode.get())) {
LOG(ERROR) << "Failed to register the app";
return Step::Status::ERROR;
}
--- /dev/null
+// Copyright (c) 2015 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 "common/step/step_update_tep.h"
+
+#include <pkgmgr-info.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <boost/filesystem.hpp>
+#include <vcore/Certificate.h>
+
+#include <cassert>
+#include <cstdio>
+#include <cstring>
+#include <string>
+
+#include "common/pkgmgr_registration.h"
+#include "common/utils/file_util.h"
+
+namespace bf = boost::filesystem;
+
+namespace common_installer {
+namespace pkgmgr {
+
+Step::Status StepUpdateTep::process() {
+ if (context_->tep_path.get().empty())
+ return Status::OK;
+
+ if (!UpdateTepInfoInPkgmgr(context_->tep_path.get(),
+ context_->pkgid.get(),
+ context_->uid.get(),
+ context_->request_mode.get())) {
+ LOG(ERROR) << "Cannot update tep info for application";
+ return Status::ERROR;
+ }
+
+ LOG(INFO) << "Successfully update the tep info for application";
+ return Status::OK;
+}
+
+Step::Status StepUpdateTep::undo() {
+ return Status::OK;
+}
+
+} // namespace pkgmgr
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 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 COMMON_STEP_STEP_UPDATE_TEP_H_
+#define COMMON_STEP_STEP_UPDATE_TEP_H_
+
+#include "common/installer_context.h"
+#include "common/step/step.h"
+#include "common/utils/logging.h"
+
+namespace common_installer {
+namespace pkgmgr {
+
+class StepUpdateTep : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override;
+ Status precheck() override { return Status::OK; };
+
+ SCOPE_LOG_TAG(UpdateTep)
+};
+
+} // namespace pkgmgr
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_UPDATE_TEP_H_
return true;
}
+bool CopyFile(const bf::path& src, const bf::path& dst) {
+ bs::error_code error;
+
+ bf::copy_file(src, dst, bf::copy_option::overwrite_if_exists, error);
+ if (error) {
+ LOG(WARNING) << "copy file " << src << " due to error [" << error << "]";
+ return false;
+ }
+ return true;
+}
+
bool MoveDir(const bf::path& src, const bf::path& dst) {
if (bf::exists(dst))
return false;
bs::error_code error;
bf::rename(src, dst, error);
if (error) {
- LOG(WARNING) << "Cannot move file: " << src << ". Will copy/remove...";
+ LOG(WARNING) << "Cannot move file: " << src <<
+ ". Will copy/remove... with error [" << error << "]";
bf::copy_file(src, dst, bf::copy_option::overwrite_if_exists, error);
if (error) {
+ LOG(WARNING) << "Cannot copy file " << src <<
+ " due to error [" << error << "]";
return false;
}
bf::remove_all(src, error);
if (error) {
- LOG(ERROR) << "Cannot remove old file when coping: " << src;
+ LOG(ERROR) << "Cannot remove old file when coping: " << src <<
+ "with error [" << error << "]";
}
}
return true;
bool CopyDir(const boost::filesystem::path& src,
const boost::filesystem::path& dst);
+bool CopyFile(const boost::filesystem::path& src,
+ const boost::filesystem::path& dst);
+
bool MoveDir(const boost::filesystem::path& src,
const boost::filesystem::path& dst);
manifest_x* manifest =
static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
+
if (!FillManifestX(const_cast<manifest_x*>(manifest))) {
LOG(ERROR) << "[Parse] Storing manifest_x failed. "
<< parser_->GetErrorMessage();
return common_installer::Step::Status::ERROR;
}
+ if (!context_->tep_path.get().empty())
+ manifest->tep_name = context_->tep_path.get().c_str();
+
// Copy data from ManifestData to InstallerContext
std::shared_ptr<const PackageInfo> info =
std::static_pointer_cast<const PackageInfo>(
#include "common/step/step_create_icons.h"
#include "common/step/step_create_storage_directories.h"
#include "common/step/step_copy.h"
+#include "common/step/step_copy_tep.h"
#include "common/step/step_copy_backup.h"
#include "common/step/step_check_old_certificate.h"
#include "common/step/step_fail.h"
#include "common/step/step_unzip.h"
#include "common/step/step_update_app.h"
#include "common/step/step_update_security.h"
+#include "common/step/step_update_tep.h"
#include "common/utils/logging.h"
#include "tpk/step/step_create_symbolic_link.h"
#include "tpk/step/step_parse.h"
AddStep<ci::security::StepPrivilegeCompatibility>();
AddStep<ci::security::StepRollbackInstallationSecurity>();
AddStep<ci::filesystem::StepCopy>();
+ AddStep<ci::filesystem::StepCopyTep>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<ci::backup::StepBackupManifest>();
AddStep<ci::backup::StepBackupIcons>();
AddStep<ci::backup::StepCopyBackup>();
+ AddStep<ci::filesystem::StepCopyTep>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
// TODO(t.iwanek): handle coping storage directories
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<ci::security::StepUpdateSecurity>();
AddStep<ci::pkgmgr::StepGenerateXml>();
AddStep<ci::pkgmgr::StepUpdateApplication>();
+ /* TODO(jungh.yeon): this temporary step will be removed
+ * when secondary parsing procedure has removed*/
+ AddStep<ci::pkgmgr::StepUpdateTep>();
}
void TpkInstaller::UninstallSteps() {