For linking with testsuites.
Task was renamed to TpkInstaller class.
HOSTTEST was removed due to missing files for this configuration
in project files.
Change-Id: I97de47bb1b4a622cfea89c8f7a692253056a1535
# Targets
SET(TARGET_LIBNAME_COMMON "common-installer")
SET(TARGET_LIBNAME_WGT "wgt-installer")
+SET(TARGET_LIBNAME_TPK "tpk-installer")
SET(TARGET_WGT_BACKEND "wgt-backend")
SET(TARGET_TPK_BACKEND "tpk-backend")
-IF(NOT DEFINED TARGET_TPK_BACKEND)
- SET(TARGET_TPK_BACKEND "tpk-backend")
-ENDIF(NOT DEFINED TARGET_TPK_BACKEND)
-
-SET(TARGET_TPK ${TARGET_TPK_BACKEND})
-OPTION(HOSTTEST "Option for the test on the host PC" OFF)
SET(SRCS
- main.cc
- task.cc
step/step_parse.cc
step/step_create_symbolic_link.cc
step/step_copy_manifest_xml.cc
tpk_app_query_interface.cc
+ tpk_installer.cc
xml_parser/xml_parser.cc
)
-ADD_EXECUTABLE(${TARGET_TPK} ${SRCS})
-
-SET(TPK_LDFLAGS -rdynamic)
-IF(${HOSTTEST})
- MESSAGE("Host Test mode.")
-SET(TPK_CFLAGS ${TPK_CFLAGS} -DHOSTTEST)
- SET(MOCK_MODULES test/mock_pkgmgr_installer.c)
-SET(SRCS ${SRCS} ${MOCK_MODULES})
+ADD_LIBRARY(${TARGET_LIBNAME_TPK} STATIC ${SRCS})
+ADD_EXECUTABLE(${TARGET_TPK_BACKEND} "tpk_backend.cc")
-ELSE(${HOSTTEST})
- SET(TPK_CFLAGS ${TPK_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/../)
- ADD_DEFINITIONS(${TPK_CFLAGS})
-ENDIF(${HOSTTEST})
+TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_TPK} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
+TARGET_INCLUDE_DIRECTORIES(${TARGET_TPK_BACKEND} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
-APPLY_PKG_CONFIG(${TARGET_TPK}
+APPLY_PKG_CONFIG(${TARGET_LIBNAME_TPK}
PUBLIC PKGMGR_DEPS
Boost
)
-TARGET_LINK_LIBRARIES(${TARGET_TPK} PUBLIC ${TARGET_LIBNAME_COMMON})
+TARGET_LINK_LIBRARIES(${TARGET_LIBNAME_TPK} PUBLIC ${TARGET_LIBNAME_COMMON})
+TARGET_LINK_LIBRARIES(${TARGET_TPK_BACKEND} PRIVATE ${TARGET_LIBNAME_TPK})
-INSTALL(TARGETS ${TARGET_TPK} DESTINATION ${BINDIR})
+INSTALL(TARGETS ${TARGET_TPK_BACKEND} DESTINATION ${BINDIR})
+++ /dev/null
-/* Copyright 2015 Samsung Electronics, license APACHE-2.0, see LICENSE file */
-#include <iostream>
-#include "tpk/task.h"
-#include "common/utils/logging.h"
-
-
-int main(const int argc, char* argv[]) {
- tpk::Task t;
- if (!t.Init(argc, argv)) {
- std::cerr << "Task init failure" << std::endl;
- return -1;
- }
- if (!t.Run()) {
- std::cerr << "Task run failure" << std::endl;
- return -1;
- }
- return 0;
-}
+++ /dev/null
-/* Copyright 2015 Samsung Electronics, license APACHE-2.0, see LICENSE file */
-#include "tpk/task.h"
-#ifdef HOSTTEST
-#include "test/mock_pkgmgr_installer.h"
-#else
-#include "common/app_installer.h"
-#include "common/step/step_configure.h"
-#include "common/step/step_backup_icons.h"
-#include "common/step/step_backup_manifest.h"
-#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_backup.h"
-#include "common/step/step_check_old_certificate.h"
-#include "common/step/step_generate_xml.h"
-#include "common/step/step_old_manifest.h"
-#include "common/step/step_parse.h"
-#include "common/step/step_register_app.h"
-#include "common/step/step_remove_icons.h"
-#include "common/step/step_remove_files.h"
-#include "common/step/step_revoke_security.h"
-#include "common/step/step_register_security.h"
-#include "common/step/step_check_signature.h"
-#include "common/step/step_unregister_app.h"
-#include "common/step/step_unzip.h"
-#include "common/step/step_update_app.h"
-#include "common/step/step_update_security.h"
-#include "common/utils/logging.h"
-#include "tpk/step/step_copy_manifest_xml.h"
-#include "tpk/step/step_create_symbolic_link.h"
-#include "tpk/step/step_parse.h"
-#endif
-
-namespace ci = common_installer;
-
-namespace {
-
-const char kPkgType[] = "tpk";
-
-} // namespace
-
-namespace tpk {
-
-Task::Task() {
-}
-
-Task::~Task() {
-}
-
-bool Task::Init(int argc, char** argv) {
- query_interface_.reset(new TpkAppQueryInterface());
- pkgmgr_ = ci::PkgMgrInterface::Create(argc, argv, query_interface_.get());
- if (!pkgmgr_) {
- LOG(ERROR) << "Cannot connect to PkgMgrInstaller";
- return false;
- }
- return true;
-}
-
-bool Task::Run() {
- switch (pkgmgr_->GetRequestType()) {
- case ci::RequestType::Install:
- return Install();
- case ci::RequestType::Update:
- return Update();
- case ci::RequestType::Uninstall:
- return Uninstall();
- case ci::RequestType::Reinstall:
- return Reinstall();
- case ci::RequestType::Recovery:
- // TODO(t.iwanek): recovery mode invocation...
- return false;
- default:
- break;
- }
- return false;
-}
-
-bool Task::Install() {
- ci::AppInstaller ai(kPkgType, pkgmgr_);
-
- ai.AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- ai.AddStep<ci::filesystem::StepUnzip>();
- ai.AddStep<tpk::parse::StepParse>();
- ai.AddStep<ci::security::StepCheckSignature>();
- ai.AddStep<ci::filesystem::StepCopy>();
- ai.AddStep<ci::filesystem::StepCreateStorageDirectories>();
- ai.AddStep<tpk::filesystem::StepCreateSymbolicLink>();
- ai.AddStep<ci::filesystem::StepCreateIcons>();
- ai.AddStep<ci::security::StepRegisterSecurity>();
- ai.AddStep<tpk::filesystem::StepCopyManifestXml>();
- ai.AddStep<ci::pkgmgr::StepRegisterApplication>();
-
- return ai.Run() == ci::AppInstaller::Result::OK;
-}
-
-bool Task::Update() {
- ci::AppInstaller ai(kPkgType, pkgmgr_);
-
- ai.AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- ai.AddStep<ci::filesystem::StepUnzip>();
- ai.AddStep<tpk::parse::StepParse>();
- ai.AddStep<ci::security::StepCheckSignature>();
- ai.AddStep<ci::security::StepCheckOldCertificate>();
- ai.AddStep<ci::backup::StepOldManifest>();
- ai.AddStep<ci::backup::StepBackupManifest>();
- ai.AddStep<ci::backup::StepBackupIcons>();
- ai.AddStep<ci::backup::StepCopyBackup>();
- ai.AddStep<ci::filesystem::StepCreateStorageDirectories>();
- // TODO(t.iwanek): handle coping storage directories
- ai.AddStep<tpk::filesystem::StepCreateSymbolicLink>();
- ai.AddStep<ci::filesystem::StepCreateIcons>();
- ai.AddStep<ci::security::StepUpdateSecurity>();
- ai.AddStep<tpk::filesystem::StepCopyManifestXml>();
- ai.AddStep<ci::pkgmgr::StepUpdateApplication>();
-
- return ai.Run() == ci::AppInstaller::Result::OK;
-}
-
-bool Task::Uninstall() {
- ci::AppInstaller ai(kPkgType, pkgmgr_);
-
- ai.AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- ai.AddStep<ci::parse::StepParse>();
- ai.AddStep<ci::backup::StepBackupManifest>();
- ai.AddStep<ci::pkgmgr::StepUnregisterApplication>();
- ai.AddStep<ci::security::StepRevokeSecurity>();
- ai.AddStep<ci::filesystem::StepRemoveFiles>();
- ai.AddStep<ci::filesystem::StepRemoveIcons>();
-
- return ai.Run() == ci::AppInstaller::Result::OK;
-}
-
-bool Task::Reinstall() {
- return false;
-}
-
-} // namespace tpk
-
+++ /dev/null
-/* Copyright 2015 Samsung Electronics, license APACHE-2.0, see LICENSE file */
-#ifndef TPK_TASK_H_
-#define TPK_TASK_H_
-
-#include <memory>
-
-#ifdef HOSTTEST
-#include "test/mock_pkgmgr_installer.h"
-#endif
-#include "common/utils/logging.h"
-
-#include "common/pkgmgr_interface.h"
-#include "tpk/tpk_app_query_interface.h"
-
-namespace tpk {
-
-class Task {
- public:
- Task();
- ~Task();
- bool Init(int argc, char** argv);
- bool Run();
-
- private:
- bool Install();
- bool Update();
- bool Uninstall();
- bool Reinstall();
-
- common_installer::PkgMgrPtr pkgmgr_;
- std::unique_ptr<TpkAppQueryInterface> query_interface_;
-
- SCOPE_LOG_TAG(TpkTask)
-}; // class Task
-
-} // namespace tpk
-
-#endif // TPK_TASK_H_
--- /dev/null
+/* Copyright 2015 Samsung Electronics, license APACHE-2.0, see LICENSE file */
+
+#include <iostream>
+
+#include "common/pkgmgr_interface.h"
+#include "common/utils/logging.h"
+#include "tpk/tpk_app_query_interface.h"
+#include "tpk/tpk_installer.h"
+
+namespace ci = common_installer;
+
+int main(const int argc, char* argv[]) {
+ tpk::TpkAppQueryInterface interface;
+ ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &interface);
+ if (!pkgmgr) {
+ LOG(ERROR) << "Failed to create pkgmgr interface";
+ return -1;
+ }
+ tpk::TpkInstaller t(pkgmgr);
+ if (t.Run() != ci::AppInstaller::Result::OK) {
+ LOG(ERROR) << "TpkInstaller run failure";
+ return -1;
+ }
+ return 0;
+}
--- /dev/null
+/* Copyright 2015 Samsung Electronics, license APACHE-2.0, see LICENSE file */
+#include "tpk/tpk_installer.h"
+#include "common/app_installer.h"
+#include "common/step/step_configure.h"
+#include "common/step/step_backup_icons.h"
+#include "common/step/step_backup_manifest.h"
+#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_backup.h"
+#include "common/step/step_check_old_certificate.h"
+#include "common/step/step_fail.h"
+#include "common/step/step_generate_xml.h"
+#include "common/step/step_old_manifest.h"
+#include "common/step/step_parse.h"
+#include "common/step/step_register_app.h"
+#include "common/step/step_remove_icons.h"
+#include "common/step/step_remove_files.h"
+#include "common/step/step_revoke_security.h"
+#include "common/step/step_register_security.h"
+#include "common/step/step_check_signature.h"
+#include "common/step/step_unregister_app.h"
+#include "common/step/step_unzip.h"
+#include "common/step/step_update_app.h"
+#include "common/step/step_update_security.h"
+#include "common/utils/logging.h"
+#include "tpk/step/step_copy_manifest_xml.h"
+#include "tpk/step/step_create_symbolic_link.h"
+#include "tpk/step/step_parse.h"
+
+namespace ci = common_installer;
+
+namespace {
+
+const char kPkgType[] = "tpk";
+
+} // namespace
+
+namespace tpk {
+
+TpkInstaller::TpkInstaller(common_installer::PkgMgrPtr pkgmgr)
+ : AppInstaller(kPkgType, pkgmgr) {
+ Prepare();
+}
+
+TpkInstaller::~TpkInstaller() {
+}
+
+void TpkInstaller::Prepare() {
+ switch (pkgmgr_->GetRequestType()) {
+ case ci::RequestType::Install:
+ InstallSteps();
+ break;
+ case ci::RequestType::Update:
+ UpdateSteps();
+ break;
+ case ci::RequestType::Uninstall:
+ UninstallSteps();
+ break;
+ case ci::RequestType::Reinstall:
+ ReinstallSteps();
+ break;
+ case ci::RequestType::Recovery:
+ AddStep<ci::configuration::StepFail>();
+ // TODO(t.iwanek): recovery mode invocation...
+ break;
+ default:
+ AddStep<ci::configuration::StepFail>();
+ break;
+ }
+}
+
+void TpkInstaller::InstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::filesystem::StepUnzip>();
+ AddStep<tpk::parse::StepParse>();
+ AddStep<ci::security::StepCheckSignature>();
+ AddStep<ci::filesystem::StepCopy>();
+ AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ AddStep<tpk::filesystem::StepCreateSymbolicLink>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::security::StepRegisterSecurity>();
+ AddStep<tpk::filesystem::StepCopyManifestXml>();
+ AddStep<ci::pkgmgr::StepRegisterApplication>();
+}
+
+void TpkInstaller::UpdateSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::filesystem::StepUnzip>();
+ AddStep<tpk::parse::StepParse>();
+ AddStep<ci::security::StepCheckSignature>();
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::backup::StepOldManifest>();
+ AddStep<ci::backup::StepBackupManifest>();
+ AddStep<ci::backup::StepBackupIcons>();
+ AddStep<ci::backup::StepCopyBackup>();
+ AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ // TODO(t.iwanek): handle coping storage directories
+ AddStep<tpk::filesystem::StepCreateSymbolicLink>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::security::StepUpdateSecurity>();
+ AddStep<tpk::filesystem::StepCopyManifestXml>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+}
+
+void TpkInstaller::UninstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::parse::StepParse>();
+ AddStep<ci::backup::StepBackupManifest>();
+ AddStep<ci::pkgmgr::StepUnregisterApplication>();
+ AddStep<ci::filesystem::StepRemoveFiles>();
+ AddStep<ci::filesystem::StepRemoveIcons>();
+ AddStep<ci::security::StepRevokeSecurity>();
+}
+
+void TpkInstaller::ReinstallSteps() {
+ AddStep<ci::configuration::StepFail>();
+}
+
+} // namespace tpk
+
--- /dev/null
+/* Copyright 2015 Samsung Electronics, license APACHE-2.0, see LICENSE file */
+
+#ifndef TPK_TPK_INSTALLER_H_
+#define TPK_TPK_INSTALLER_H_
+
+#include "common/app_installer.h"
+#include "common/pkgmgr_interface.h"
+#include "common/utils/logging.h"
+
+namespace tpk {
+
+/**
+ * @brief The TpkInstaller class
+ * Handles request of tpk packages.
+ *
+ * This class is main class for installation/update/deinstallation of tpk
+ * packages. Pkgmgr request is parsed within and sequence of steps is built to
+ * be run.
+ */
+class TpkInstaller : public common_installer::AppInstaller {
+ public:
+ explicit TpkInstaller(common_installer::PkgMgrPtr pkgmgr);
+ ~TpkInstaller();
+ void Prepare();
+
+ private:
+ void InstallSteps();
+ void UpdateSteps();
+ void UninstallSteps();
+ void ReinstallSteps();
+
+ SCOPE_LOG_TAG(TpkInstaller)
+};
+
+} // namespace tpk
+
+#endif // TPK_TPK_INSTALLER_H_