const char kStrEmpty[] = "";
const char kAppFWUser[] = "app_fw";
+const char kRpmPkgType[] = "rpm";
+const char kRpmInstaller[] = "tpk";
StepConfigure::StepConfigure(InstallerContext* context, PkgMgrPtr pkgmgr)
: Step(context),
RequestType request_type = context_->request_type.get();
switch (request_type) {
case RequestType::Install:
- case RequestType::Update:
+ case RequestType::Update: {
context_->file_path.set(pkgmgr_->GetRequestInfo(context_->index.get()));
if (!pkgmgr_->GetTepPath().empty()) {
context_->tep_path.set(pkgmgr_->GetTepPath());
context_->is_tep_move.set(pkgmgr_->GetIsTepMove());
}
+ context_->pkgid.set(GetPkgIdFromFile());
break;
+ }
case RequestType::PartialUninstall:
case RequestType::Uninstall:
if (request_type == RequestType::PartialUninstall)
pkgmgr_->GetRecoveryCleanup()));
break;
case RequestType::MountInstall:
- case RequestType::MountUpdate:
+ case RequestType::MountUpdate: {
context_->file_path.set(pkgmgr_->GetRequestInfo(context_->index.get()));
if (!pkgmgr_->GetTepPath().empty()) {
context_->tep_path.set(pkgmgr_->GetTepPath());
context_->is_tep_move.set(pkgmgr_->GetIsTepMove());
}
+ context_->pkgid.set(GetPkgIdFromFile());
break;
+ }
case RequestType::ManifestPartialInstall:
case RequestType::ManifestPartialUpdate:
case RequestType::ManifestDirectInstall:
context_->xml_path.set(xml_path);
break;
}
- case RequestType::ReadonlyUpdateInstall:
+ case RequestType::ReadonlyUpdateInstall: {
context_->file_path.set(pkgmgr_->GetRequestInfo(context_->index.get()));
if (!pkgmgr_->GetTepPath().empty()) {
context_->tep_path.set(pkgmgr_->GetTepPath());
context_->is_tep_move.set(pkgmgr_->GetIsTepMove());
}
+ context_->pkgid.set(GetPkgIdFromFile());
break;
+ }
case RequestType::ReadonlyUpdateUninstall: {
context_->pkgid.set(pkgmgr_->GetRequestInfo(context_->index.get()));
bf::path original_path =
return Status::CONFIG_ERROR;
}
+ if (!CheckInvalidBackendUsage())
+ return Status::OPERATION_NOT_ALLOWED;
+
LOG(INFO) << "Request Type: " << GetRequestTypeString(request_type);
return Status::OK;
}
}
+std::string StepConfigure::GetPkgIdFromFile() {
+ auto app_query_interface = pkgmgr_->GetAppQueryInterface();
+ if (!app_query_interface)
+ return "";
+
+ return app_query_interface->GetPkgId(
+ pkgmgr_->GetRequestInfo(context_->index.get()));
+}
+
+bool StepConfigure::CheckInvalidBackendUsage() {
+ if (context_->pkgid.get().empty())
+ return true;
+
+ PkgQueryInterface pkg_query(context_->pkgid.get().c_str(),
+ context_->uid.get());
+ if (!pkg_query.IsValid()) {
+ LOG(INFO) << "pkg[" << context_->pkgid.get()
+ << "] is not installed, skip checking backend with installed pkg";
+ return true;
+ }
+
+ const std::string& backend_type = context_->pkg_type.get();
+ std::string installed_pkg_type = pkg_query.Type();
+ if (installed_pkg_type == kRpmPkgType)
+ installed_pkg_type = kRpmInstaller;
+
+ if (installed_pkg_type != backend_type) {
+ LOG(ERROR) << "Wrong use of backend : package's type [" << pkg_query.Type()
+ << "] mismatched backend [" << backend_type << "]";
+ return false;
+ }
+
+ return true;
+}
+
} // namespace configuration
} // namespace common_installer