SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
## Targets
-SET(TARGET_RPK_INSTALLER "rpk-insatller")
+SET(TARGET_LIBNAME_RPK "rpk-installer")
+SET(TARGET_LIBNAME_RPK_ARCHIVE_INFO "rpk")
+SET(TARGET_LIBNAME_RPK_MANIFEST_HANDLERS "rpk-manifest-handlers")
ENABLE_TESTING()
SET(TARGET_RPK_INSTALLER_UNIT_TEST "rpk-installer-unit-test")
PKG_CHECK_MODULES(APP_INSTALLERS_DEPS REQUIRED app-installers)
PKG_CHECK_MODULES(GMOCK_DEPS REQUIRED gmock)
PKG_CHECK_MODULES(PKGMGR_DEPS REQUIRED pkgmgr)
+PKG_CHECK_MODULES(MANIFEST_PARSER_DEPS REQUIRED manifest-parser)
+PKG_CHECK_MODULES(MANIFEST_PARSER_UTILS_DEPS REQUIRED manifest-parser-utils)
-ADD_SUBDIRECTORY(src)
\ No newline at end of file
+FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem)
+
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(test)
Source0: %{name}-%{version}.tar.gz
Source1001: %{name}.manifest
BuildRequires: cmake
+BuildRequires: boost-devel
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(app-installers)
+BuildRequires: pkgconfig(manifest-parser)
BuildRequires: pkgconfig(pkgmgr)
%if 0%{?gcov:1}
%description
This package contains rpk-installer library
+%package -n rpk-installer-devel
+Summary: Rpk-installer development files
+Group: Application Framework/Package Management
+Requires: %{name} = %{version}
+
+%description devel
+This package contains header files of rpk-installer library
%prep
%setup -q
%endif
%check
+export LD_LIBRARY_PATH=../../src/rpk:../../src/rpk_manifest_handlers
ctest -V
%if 0%{?gcov:1}
lcov -c --ignore-errors graph --no-external -q -d . -o rpk-insatller.info
%defattr(-,root,root,-)
%{_libdir}/*
%{_bindir}/*
+%{_sysconfdir}/package-manager/backendlib/librpk.so
+
+#%files -n rpk-installer-devel
+%files devel
+%{_includedir}/app-installers/rpk/*.h
+#%{_includedir}/app-installers/rpk/*/*/*.h
+%{_includedir}/rpk_manifest_handlers/*.h
+%{_libdir}/librpk-manifest-handlers.so
+%{_libdir}/pkgconfig/rpk-installer.pc
+%{_libdir}/pkgconfig/rpk-manifest-handlers.pc
+
#################################################
# rpk-installer-gcov
-ADD_SUBDIRECTORY(unit_tests)
+ADD_SUBDIRECTORY(lib)
+ADD_SUBDIRECTORY(rpk)
+ADD_SUBDIRECTORY(rpk_manifest_handlers)
--- /dev/null
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} LIB_SRCS)
+ADD_LIBRARY(${TARGET_LIBNAME_RPK_ARCHIVE_INFO} SHARED ${LIB_SRCS})
+
+TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_RPK_ARCHIVE_INFO} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+APPLY_PKG_CONFIG(${TARGET_LIBNAME_RPK_ARCHIVE_INFO} PUBLIC
+ APP_INSTALLERS_DEPS
+ PKGMGR_DEPS
+ MANIFEST_PARSER_DEPS
+)
+
+INSTALL(TARGETS ${TARGET_LIBNAME_RPK_ARCHIVE_INFO} DESTINATION ${SYSCONF_INSTALL_DIR}/package-manager/backendlib)
+INSTALL(FILES rpk_archive_info.h DESTINATION ${INCLUDEDIR}/app-installers/rpk/)
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2020 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 "lib/rpk_archive_info.h"
+
+bool RpkArchiveInfo::LoadArchiveInfo() {
+ return true;
+}
--- /dev/null
+// Copyright (c) 2020 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 LIB_RPK_ARCHIVE_INFO_H_
+#define LIB_RPK_ARCHIVE_INFO_H_
+
+#include <boost/filesystem/path.hpp>
+
+#include <common/archive_info.h>
+#include <manifest_parser/utils/logging.h>
+
+#include <string>
+
+namespace bf = boost::filesystem;
+
+class RpkArchiveInfo : public common_installer::ArchiveInfo {
+ public:
+ explicit RpkArchiveInfo(std::string path)
+ : common_installer::ArchiveInfo(path) { }
+ bool LoadArchiveInfo() override;
+
+ SCOPE_LOG_TAG(RpkArchiveInfo)
+};
+
+#endif // LIB_RPK_ARCHIVE_INFO_H_
--- /dev/null
+// Copyright (c) 2020 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 <package-manager-plugin.h>
+
+#include "lib/rpk_archive_info.h"
+
+namespace {
+
+int GetPackageArchiveInfo(const char* path,
+ package_manager_pkg_detail_info_t* info) {
+ RpkArchiveInfo archive_info(path);
+ if (!archive_info.LoadArchiveInfo())
+ return -1;
+ if (!archive_info.GetPkgDetailInfo(info))
+ return -1;
+ return 0;
+}
+
+void PluginOnUnload() {
+}
+
+} // namespace
+
+extern "C" int pkg_plugin_on_load(pkg_plugin_set* set) {
+ if (set == nullptr)
+ return -1;
+ set->plugin_on_unload = PluginOnUnload;
+ set->pkg_is_installed = nullptr;
+ set->get_installed_pkg_list = nullptr;
+ set->get_pkg_detail_info = nullptr;
+ set->get_pkg_detail_info_from_package = GetPackageArchiveInfo;
+ return 0;
+}
--- /dev/null
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} RPK_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/configuration RPK_STEP_CONFIGURATION_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/filesystem RPK_STEP_FILESYSTEM_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/pkgmgr RPK_STEP_PKGMGR_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/security RPK_STEP_SECURITY_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../lib LIB_SRCS)
+
+ADD_LIBRARY(${TARGET_LIBNAME_RPK} SHARED
+ ${RPK_SRCS}
+ ${RPK_STEP_CONFIGURATION_SRCS}
+ ${RPK_STEP_FILESYSTEM_SRCS}
+ ${RPK_STEP_PKGMGR_SRCS}
+ ${RPK_STEP_SECURITY_SRCS}
+ ${LIB_SRCS})
+
+TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_RPK} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
+
+APPLY_PKG_CONFIG(${TARGET_LIBNAME_RPK} PUBLIC
+ APP_INSTALLERS_DEPS
+ PKGMGR_DEPS
+)
+
+INSTALL(TARGETS ${TARGET_LIBNAME_RPK} DESTINATION ${LIB_INSTALL_DIR})
+
+# Export devel package
+CONFIGURE_FILE(rpk-installer.pc.in rpk-installer.pc @ONLY)
+INSTALL(FILES rpk-installer.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(DIRECTORY ./ DESTINATION ${INCLUDEDIR}/app-installers/rpk/
+ FILES_MATCHING PATTERN "*.h")
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=@PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: rpk-installer
+Description: Rpk-installer library
+Version: @FULLVER@
+Requires: app-installers pkgmgr manifest-parser
+Libs: -L${libdir} -lrpk-installer
+Cflags: -I${includedir}/app-installers/
--- /dev/null
+// Copyright (c) 2020 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 "rpk/rpk_app_query_interface.h"
+
+#include <string>
+
+namespace rpk {
+
+std::string RpkAppQueryInterface::GetManifestFileName() const {
+ return {};
+}
+
+std::string RpkAppQueryInterface::GetPkgIdFromPath(
+ const std::string& path) const {
+ return {};
+}
+
+} // namespace rpk
--- /dev/null
+// Copyright (c) 2020 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 RPK_RPK_APP_QUERY_INTERFACE_H_
+#define RPK_RPK_APP_QUERY_INTERFACE_H_
+
+#include <common/app_query_interface.h>
+
+#include <string>
+
+namespace rpk {
+
+class RpkAppQueryInterface : public common_installer::AppQueryInterface {
+ private:
+ std::string GetPkgIdFromPath(const std::string& path) const override;
+ std::string GetManifestFileName() const override;
+};
+
+} // namespace rpk
+
+#endif // RPK_RPK_APP_QUERY_INTERFACE_H_
--- /dev/null
+/* Copyright 2020 Samsung Electronics, license APACHE-2.0, see LICENSE file */
+#include "rpk/rpk_installer.h"
+
+#include <common/installer/app_installer.h>
+
+//#include "lib/rpk_archive_info.h"
+
+namespace ci = common_installer;
+
+namespace {
+
+const char kPkgType[] = "rpk";
+
+} // namespace
+
+namespace rpk {
+
+RpkInstaller::RpkInstaller(common_installer::PkgMgrPtr pkgmgr)
+ : AppInstaller(kPkgType, pkgmgr) {
+}
+
+RpkInstaller::~RpkInstaller() {
+}
+
+std::unique_ptr<ci::ArchiveInfo> RpkInstaller::GetArchiveInfo() {
+ return nullptr;
+}
+
+void RpkInstaller::InstallSteps() {
+ AppInstaller::InstallSteps();
+}
+
+void RpkInstaller::UpdateSteps() {
+ AppInstaller::UpdateSteps();
+}
+
+void RpkInstaller::UninstallSteps() {
+ AppInstaller::UninstallSteps();
+}
+
+void RpkInstaller::RecoverySteps() {
+ AppInstaller::RecoverySteps();
+}
+
+void RpkInstaller::ManifestDirectInstallSteps() {
+ AppInstaller::ManifestDirectInstallSteps();
+}
+
+void RpkInstaller::ManifestDirectUpdateSteps() {
+ AppInstaller::ManifestDirectUpdateSteps();
+}
+
+void RpkInstaller::ManifestPartialInstallSteps() {
+ AppInstaller::ManifestPartialInstallSteps();
+}
+
+void RpkInstaller::ManifestPartialUpdateSteps() {
+ AppInstaller::ManifestPartialUpdateSteps();
+}
+
+void RpkInstaller::PartialUninstallSteps() {
+ AppInstaller::PartialUninstallSteps();
+}
+
+void RpkInstaller::ReadonlyUpdateInstallSteps() {
+ AppInstaller::ReadonlyUpdateInstallSteps();
+}
+
+void RpkInstaller::ReadonlyUpdateUninstallSteps() {
+ AppInstaller::ReadonlyUpdateUninstallSteps();
+}
+
+void RpkInstaller::RecoverDBSteps() {
+ AppInstaller::RecoverDBSteps();
+}
+
+} // namespace rpk
--- /dev/null
+/* Copyright 2020 Samsung Electronics, license APACHE-2.0, see LICENSE file */
+
+#ifndef RPK_RPK_INSTALLER_H_
+#define RPK_RPK_INSTALLER_H_
+
+#include <common/installer/app_installer.h>
+#include <common/pkgmgr_interface.h>
+#include <manifest_parser/utils/logging.h>
+
+namespace rpk {
+
+/**
+ * @brief The RpkInstaller class
+ * Handles request of rpk packages.
+ *
+ * This class is main class for installation/update/deinstallation of rpk
+ * packages. Pkgmgr request is parsed within and sequence of steps is built to
+ * be run.
+ */
+class RpkInstaller : public common_installer::AppInstaller {
+ public:
+ explicit RpkInstaller(common_installer::PkgMgrPtr pkgmgr);
+ ~RpkInstaller();
+ std::unique_ptr<common_installer::ArchiveInfo> GetArchiveInfo() override;
+
+ protected:
+ void InstallSteps() override;
+ void UpdateSteps() override;
+ void UninstallSteps() override;
+ void RecoverySteps() override;
+ void ManifestDirectInstallSteps() override;
+ void ManifestDirectUpdateSteps() override;
+ void ManifestPartialInstallSteps() override;
+ void ManifestPartialUpdateSteps() override;
+ void PartialUninstallSteps() override;
+ void ReadonlyUpdateInstallSteps() override;
+ void ReadonlyUpdateUninstallSteps() override;
+ void RecoverDBSteps() override;
+
+ private:
+ SCOPE_LOG_TAG(RpkInstaller)
+};
+
+} // namespace rpk
+
+#endif // RPK_RPK_INSTALLER_H_
--- /dev/null
+# Target - sources
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SRCS)
+
+# Target - definition
+ADD_LIBRARY(${TARGET_LIBNAME_RPK_MANIFEST_HANDLERS} SHARED
+ ${SRCS}
+)
+
+# Target - includes
+TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_RPK_MANIFEST_HANDLERS} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
+
+# Target - deps
+APPLY_PKG_CONFIG(${TARGET_LIBNAME_RPK_MANIFEST_HANDLERS} PUBLIC
+ Boost
+ MANIFEST_PARSER_UTILS_DEPS
+)
+
+# Extra
+SET_TARGET_PROPERTIES(${TARGET_LIBNAME_RPK_MANIFEST_HANDLERS} PROPERTIES VERSION ${FULLVER})
+SET_TARGET_PROPERTIES(${TARGET_LIBNAME_RPK_MANIFEST_HANDLERS} PROPERTIES SOVERSION ${MAJORVER})
+
+# Install
+INSTALL(TARGETS ${TARGET_LIBNAME_RPK_MANIFEST_HANDLERS} DESTINATION ${LIB_INSTALL_DIR})
+
+# Install includes
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDEDIR}
+ FILES_MATCHING PATTERN "*.h")
+
+# Configure and install pkgconfig file
+CONFIGURE_FILE(rpk-manifest-handlers.pc.in rpk-manifest-handlers.pc @ONLY)
+INSTALL(FILES rpk-manifest-handlers.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=@PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: rpk-manifest-handlers
+Description: Manifest handlers for rpk manifest file parser
+Version: @FULLVER@
+Requires: manifest-parser
+Libs: -L${libdir} -lrpk-manifest-handlers
+Cflags: -I${includedir}
--- /dev/null
+// Copyright (c) 2020 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 "rpk_manifest_handlers/rpk_config_parser.h"
+
+#include <utility>
+#include <string>
+#include <vector>
+
+#include "manifest_parser/manifest_handler.h"
+#include "manifest_parser/utils/iri_util.h"
+#include "manifest_parser/utils/logging.h"
+
+namespace rpk {
+namespace parse {
+
+RPKConfigParser::RPKConfigParser() {
+ std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
+ };
+
+ std::unique_ptr<parser::ManifestHandlerRegistry> registry(
+ new parser::ManifestHandlerRegistry(handlers));
+
+ parser_.reset(new parser::ManifestParser(std::move(registry)));
+}
+
+std::shared_ptr<const parser::ManifestData> RPKConfigParser::GetManifestData(
+ const std::string& key) const {
+ return parser_->GetManifestData(key);
+}
+
+const std::string& RPKConfigParser::GetErrorMessage() const {
+ if (!error_.empty())
+ return error_;
+ return parser_->GetErrorMessage();
+}
+
+bool RPKConfigParser::ParseManifest(const boost::filesystem::path& path) {
+ if (!parser_->ParseManifest(path))
+ return false;
+
+ return true;
+}
+
+} // namespace parse
+} // namespace rpk
--- /dev/null
+// Copyright (c) 2020 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 RPK_MANIFEST_HANDLERS_RPK_CONFIG_PARSER_H_
+#define RPK_MANIFEST_HANDLERS_RPK_CONFIG_PARSER_H_
+
+#include <boost/filesystem/path.hpp>
+
+#include <memory>
+#include <string>
+
+#include "manifest_parser/manifest_parser.h"
+
+namespace rpk {
+namespace parse {
+
+/**
+ * @brief The RPKConfigParser class
+ * Parser class of rpk package tizen-manifest.xml manifest file.
+ *
+ * Instance of this class may be used to parse single configuration file.
+ * Depending on boolean result of @ref ParseManifest method, client code may
+ * call:
+ * - on success -> @ref GetManifestData(), passing the key of ManifestData
+ * instance that it is interested in.
+ * - on failure -> @ref GetErrorMessage(), to get value of error which was set
+ * during the processing of config.xml
+ *
+ * To investigate which key do you need to get certain parsed piece of data,
+ * check the key reported by handler's @ref ManifestHandler::Key() method.
+ * Key returned by this method is the key to access data set by handler.
+ */
+class RPKConfigParser {
+ public:
+ RPKConfigParser();
+
+ std::shared_ptr<const parser::ManifestData> GetManifestData(
+ const std::string& key) const;
+ const std::string& GetErrorMessage() const;
+ bool ParseManifest(const boost::filesystem::path& path);
+
+ private:
+ std::unique_ptr<parser::ManifestParser> parser_;
+ std::string error_;
+};
+
+} // namespace parse
+} // namespace rpk
+
+#endif // RPK_MANIFEST_HANDLERS_RPK_CONFIG_PARSER_H_
--- /dev/null
+ADD_SUBDIRECTORY(unit_tests)
${UNIT_TESTS_SRCS}
)
-TARGET_INCLUDE_DIRECTORIES(${TARGET_RPK_INSTALLER_UNIT_TEST} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
-
APPLY_PKG_CONFIG(${TARGET_RPK_INSTALLER_UNIT_TEST} PUBLIC
GMOCK_DEPS
+ MANIFEST_PARSER_DEPS
)
-#TARGET_LINK_LIBRARIES(${TARGET_RPK_INSTALLER_UNIT_TEST} PUBLIC ${TARGET_RPK_INSTALLER} )
+TARGET_LINK_LIBRARIES(${TARGET_RPK_INSTALLER_UNIT_TEST} PUBLIC ${TARGET_LIBNAME_RPK})
+TARGET_LINK_LIBRARIES(${TARGET_RPK_INSTALLER_UNIT_TEST} PUBLIC ${TARGET_LIBNAME_RPK_MANIFEST_HANDLERS})
+
SET_TARGET_PROPERTIES(${TARGET_RPK_INSTALLER_UNIT_TEST} PROPERTIES COMPILE_FLAGS "-fPIE")
SET_TARGET_PROPERTIES(${TARGET_RPK_INSTALLER_UNIT_TEST} PROPERTIES LINK_FLAGS "-pie")
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <common/app_query_interface.h>
+
+#include <cstdio>
+
+#include "rpk/rpk_app_query_interface.h"
+
+class RpkAppQueryInterfaceTest : public ::testing::Test {
+ public:
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(RpkAppQueryInterfaceTest, DummyTest) {
+ std::unique_ptr<common_installer::AppQueryInterface> ptr =
+ std::make_unique<rpk::RpkAppQueryInterface>();
+ EXPECT_EQ(ptr->GetPkgId(""), "");
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <cstdio>
+
+#include "rpk_manifest_handlers/rpk_config_parser.h"
+
+class RpkManifestHandlersTest : public ::testing::Test {
+ public:
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(RpkManifestHandlersTest, DummyTest) {
+ rpk::parse::RPKConfigParser config_parser;
+ EXPECT_EQ(config_parser.GetManifestData(""), nullptr);
+}