add force-remove feature for installer 24/63124/6
authorjongmyeongko <jongmyeong.ko@samsung.com>
Tue, 22 Mar 2016 07:22:09 +0000 (16:22 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 23 Mar 2016 01:58:14 +0000 (10:58 +0900)
usage(root only):
tpk-backend -d {pkgid} --preload --force-remove

Change-Id: I705cada8e5d41055371cb97101197d8b44f4074f
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/common/installer_context.h
src/common/pkgmgr_interface.cc
src/common/pkgmgr_interface.h
src/common/step/configuration/step_configure.cc
src/common/step/configuration/step_configure.h
src/common/step/configuration/step_parse_manifest.cc
src/common/step/pkgmgr/step_check_blacklist.cc
src/common/step/pkgmgr/step_check_removable.cc

index 53d2391..30bb474 100644 (file)
@@ -285,6 +285,11 @@ class InstallerContext {
    * \brief preload request received from pkgmgr_installer
    */
   Property<bool> is_preload_request;
+
+  /**
+   * \brief force-remove request received from pkgmgr_installer
+   */
+  Property<bool> force_remove;
 };
 
 }  // namespace common_installer
index eaa6e3e..925eb53 100644 (file)
@@ -154,4 +154,9 @@ bool PkgMgrInterface::GetIsPreloadRequest() {
       true:false;
 }
 
+bool PkgMgrInterface::GetIsForceRemoval() {
+  // root only
+  return (getuid() == 0 && pkgmgr_installer_get_force_removal(pi_) == 1);
+}
+
 }  // namespace common_installer
index a5690fb..8da3a5c 100644 (file)
@@ -110,6 +110,13 @@ class PkgMgrInterface {
   bool GetIsPreloadRequest();
 
   /**
+  * Returns True if the request is for force-remove. Otherwise, return false
+  *
+  * \return True if the request is for force-remove. Otherwise, return false
+  */
+  bool GetIsForceRemoval();
+
+  /**
    * Get Raw pointer to pkgmgr_installer object
    * NOTE: It should not be used (PkgMgrInterface can destroy it
    *
index a0c4d28..0f9d415 100644 (file)
@@ -52,6 +52,7 @@ Step::Status StepConfigure::process() {
       }
       break;
     case RequestType::Uninstall:
+      SetupIsForceRemoval();
       context_->pkgid.set(pkgmgr_->GetRequestInfo());
       context_->file_path.set(kStrEmpty);
       break;
@@ -199,5 +200,9 @@ void StepConfigure::SetupIsPreloadRequest() {
   context_->is_preload_request.set(pkgmgr_->GetIsPreloadRequest());
 }
 
+void StepConfigure::SetupIsForceRemoval() {
+  context_->force_remove.set(pkgmgr_->GetIsForceRemoval());
+}
+
 }  // namespace configuration
 }  // namespace common_installer
index d7561ef..902fc0d 100644 (file)
@@ -60,6 +60,7 @@ class StepConfigure : public Step {
   void SetupRequestType();
   void SetupFileCreationMask();
   void SetupIsPreloadRequest();
+  void SetupIsForceRemoval();
 
   PkgMgrPtr pkgmgr_;
 
index 8f119ea..cd98f89 100644 (file)
@@ -177,6 +177,10 @@ bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
     if (req_type == RequestType::ManifestDirectInstall ||
         req_type == RequestType::ManifestDirectUpdate)
       manifest->type = strdup("rpm");
+      if (!context_->is_preload_request.get()) {
+        LOG(ERROR) << "Non-preload rpm installation not allowed";
+        return false;
+      }
     else
       manifest->type = strdup("tpk");
   } else {
index a0b2ba0..ff033c1 100644 (file)
@@ -13,7 +13,8 @@ namespace common_installer {
 namespace pkgmgr {
 
 Step::Status StepCheckBlacklist::process() {
-  if (context_->installation_mode.get() == InstallationMode::OFFLINE)
+  if (context_->installation_mode.get() == InstallationMode::OFFLINE ||
+      context_->is_preload_request.get())
     return Status::OK;
   bool result;
   pkgmgr_client* pc = pkgmgr_client_new(PC_REQUEST);
index d2ff27c..12959b4 100644 (file)
@@ -13,8 +13,10 @@ namespace common_installer {
 namespace pkgmgr {
 
 Step::Status StepCheckRemovable::process() {
-  pkgmgrinfo_pkginfo_h handle;
+  if (context_->force_remove.get())
+      return Status::OK;
 
+  pkgmgrinfo_pkginfo_h handle;
   int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(context_->pkgid.get().c_str(),
       context_->uid.get(), &handle);
   if (ret != PMINFO_R_OK) {