# Targets
SET(TARGET_LIBNAME_COMMON "app-installers")
SET(TARGET_PKGDIR_TOOL "pkgdir-tool")
+SET(TARGET_PKG_INSTALL_MANIFEST "pkg-install-manifest")
ADD_DEFINITIONS("-Wall")
ADD_DEFINITIONS("-Wextra")
PKG_CHECK_MODULES(TZPLATFORM_CONFIG_DEPS REQUIRED libtzplatform-config)
PKG_CHECK_MODULES(SECURITY_MANAGER_DEPS REQUIRED security-manager)
PKG_CHECK_MODULES(DELTA_MANIFEST_HANDLERS_DEPS REQUIRED delta-manifest-handlers)
+PKG_CHECK_MODULES(TPK_MANIFEST_HANDLERS_DEPS REQUIRED tpk-manifest-handlers)
PKG_CHECK_MODULES(MANIFEST_PARSER_UTILS_DEPS REQUIRED manifest-parser-utils)
PKG_CHECK_MODULES(CERT_SVC_DEPS_VCORE_DEPS REQUIRED cert-svc-vcore)
PKG_CHECK_MODULES(PKGMGR_PARSER_DEPS REQUIRED pkgmgr-parser)
</request>
<assign>
<filesystem path="/usr/bin/pkgdir-tool" exec_label="User" />
+ <filesystem path="/usr/bin/pkg-install-manifest" exec_label="User" />
</assign>
</manifest>
%manifest app-installers.manifest
%{_libdir}/libapp-installers.so*
%attr(6750,root,users) %{_bindir}/pkgdir-tool
+%{_bindir}/pkg-install-manifest
%license LICENSE
%files devel
ADD_SUBDIRECTORY(common)
+ADD_SUBDIRECTORY(pkg_install_manifest)
ADD_SUBDIRECTORY(pkgdir_tool)
ADD_SUBDIRECTORY(unit_tests)
pi_ = pkgmgr_installer_new();
if (!pi_) {
- LOG(ERROR) << "Cannot create pkgmgr_installer object";
- return ENOMEM;
+ LOG(WARNING) << "Cannot create pkgmgr_installer object. Will try offline";
+ // TODO(t.iwanek): app-installer should recognize offline installation and
+ // this information should be accesible in installation context
+ pi_ = pkgmgr_installer_offline_new();
+ if (!pi_) {
+ LOG(ERROR) << "Cannot create pkgmgr_installer object. Aborting.";
+ return ENOMEM;
+ }
}
int result = pkgmgr_installer_receive_request(pi_, argc, argv);
namespace common_installer {
RequestMode GetRequestMode() {
- return (getuid() == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) ?
+ return (getuid() == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) ||
+ getuid() == 0) ?
RequestMode::GLOBAL : RequestMode::USER;
}
context_->unpacked_dir_path.set(package_directory);
context_->pkg_path.set(package_directory);
context_->xml_path.set(xml_path);
- context_->privilege_level.set(common_installer::PrivilegeLevel::PUBLIC);
context_->pkg_type.set(kRpmPackageType); // temporary fix as rpm
break;
}
}
Step::Status StepConfigure::precheck() {
- if (getuid() == 0) {
- LOG(ERROR) << "App-installer should not run with superuser!";
- return Status::OPERATION_NOT_ALLOWED;
+ if (pkgmgr_->GetRequestType() != RequestType::ManifestDirectInstall &&
+ pkgmgr_->GetRequestType() != RequestType::ManifestDirectUpdate) {
+ if (getuid() == 0) {
+ LOG(ERROR) << "App-installer should not run with superuser!";
+ return Status::OPERATION_NOT_ALLOWED;
+ }
+ } else {
+ LOG(INFO) << "Allowing installation from root user for"
+ "manifest direct installation mode.";
}
return Status::OK;
}
--- /dev/null
+# Target - sources
+SET(SRCS
+ pkg_install_manifest.cc
+)
+
+# Target - definition
+ADD_EXECUTABLE(${TARGET_PKG_INSTALL_MANIFEST} "pkg_install_manifest.cc")
+# Target - includes
+TARGET_INCLUDE_DIRECTORIES(${TARGET_PKG_INSTALL_MANIFEST} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
+# Target - deps
+APPLY_PKG_CONFIG(${TARGET_PKG_INSTALL_MANIFEST} PUBLIC
+ TPK_MANIFEST_HANDLERS_DEPS
+ PKGMGR_DEPS
+ Boost
+)
+# Target - in-package deps
+TARGET_LINK_LIBRARIES(${TARGET_PKG_INSTALL_MANIFEST} PUBLIC ${TARGET_LIBNAME_COMMON})
+
+# Install
+INSTALL(TARGETS ${TARGET_PKG_INSTALL_MANIFEST} DESTINATION ${BINDIR})
--- /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 <boost/filesystem/path.hpp>
+#include <boost/program_options.hpp>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <manifest_parser/utils/logging.h>
+#include <tpk_manifest_handlers/package_handler.h>
+#include <tpk_manifest_handlers/tpk_config_parser.h>
+
+#include <iostream>
+
+#include "common/request.h"
+#include "common/utils/subprocess.h"
+
+namespace bf = boost::filesystem;
+namespace bpo = boost::program_options;
+namespace ci = common_installer;
+
+namespace {
+
+const char kBackendDirectoryPath[] = "/etc/package-manager/backend/";
+
+int InstallManifestOffline(const std::string& pkgid,
+ const std::string& type) {
+ bf::path backend_path(kBackendDirectoryPath);
+ backend_path /= type;
+ ci::Subprocess backend(backend_path.string());
+ backend.Run("-y", pkgid.c_str());
+ return backend.Wait();
+}
+
+} // namespace
+
+int main(int argc, char** argv) {
+ bpo::options_description options("Allowed options");
+ options.add_options()
+ ("xml-path,x", bpo::value<std::string>()->required(), "xml package path")
+ ("help,h", "display this help message");
+ bpo::variables_map opt_map;
+ try {
+ bpo::store(bpo::parse_command_line(argc, argv, options), opt_map);
+ if (opt_map.count("help")) {
+ std::cerr << options << std::endl;
+ return -1;
+ }
+ bpo::notify(opt_map);
+ } catch (const bpo::error& error) {
+ std::cerr << error.what() << std::endl;
+ return -1;
+ }
+
+ bf::path manifest_path(opt_map["xml-path"].as<std::string>());
+ tpk::parse::TPKConfigParser parser;
+ if (!parser.ParseManifest(manifest_path)) {
+ LOG(ERROR) << "Failed to parse tizen manifest file: "
+ << parser.GetErrorMessage();
+ return 1;
+ }
+ auto package_info = std::static_pointer_cast<const tpk::parse::PackageInfo>(
+ parser.GetManifestData(tpk::parse::PackageInfo::key()));
+ if (!package_info) {
+ LOG(ERROR) << "Failed to get package info";
+ return 1;
+ }
+ std::string type = package_info->type();
+ if (type.empty())
+ type = "tpk";
+
+ return InstallManifestOffline(package_info->package(), type);
+}