1 // Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/pkgmgr/step_check_removable.h"
13 #include "common/installer/app_installer.h"
14 #include "common/pkgmgr_dependency.h"
15 #include "common/utils/pkgmgr_query.h"
17 namespace common_installer {
20 Step::Status StepCheckRemovable::process() {
21 if (context_->force_remove.get())
24 PkgQueryInterface pkg_query(context_->pkgid.get().c_str(),
26 if (!pkg_query.IsValid()) {
27 LOG(ERROR) << "This package is not installed";
28 return Status::INVALID_VALUE;
30 bool removable = pkg_query.IsRemovablePackage();
31 if (pkg_query.GetLastOperationError() != PMINFO_R_OK)
32 return Status::INVALID_VALUE;
35 LOG(ERROR) << "This package is not removable";
36 return Status::OPERATION_NOT_ALLOWED;
39 std::string pkg_type = pkg_query.Type();
40 // rpm package installed by tpk-backend
41 if (pkg_type == "rpm")
43 if (pkg_type != context_->pkg_type.get()) {
44 LOG(ERROR) << "Wrong use of backend : package's type [" << pkg_query.Type()
45 << "] mismatched backend [" << context_->pkg_type.get() << "]";
46 return Status::OPERATION_NOT_ALLOWED;
52 Step::Status StepCheckRemovable::precheck() {
53 if (context_->pkgid.get().empty())
54 return Status::INVALID_VALUE;
59 } // namespace common_installer