modify the way of preload decision 64/58864/5 accepted/tizen/mobile/20160205.064207 accepted/tizen/tv/20160205.064222 accepted/tizen/wearable/20160205.064242 submit/tizen/20160205.051501
authorjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 4 Feb 2016 07:42:22 +0000 (16:42 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 4 Feb 2016 13:02:41 +0000 (22:02 +0900)
Requires:
https://review.tizen.org/gerrit/#/c/58863

Change-Id: Ic9109f137237fd26973033093c677f213604fdbf
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/tpk/step/step_create_symbolic_link.cc
src/tpk/step/step_parse_preload.cc
src/unit_tests/smoke_test.cc

index 649df19ee0fdfb15d1aa758cbad2b361be648bed..7ba86fe9e2510edb43d7fefa31d157b24b3e911f 100644 (file)
@@ -33,7 +33,7 @@ bool CreateSymLink(application_x* app, InstallerContext* context) {
     return false;
   }
 
-  if (strcmp(app->ui_gadget, "true") == 0) {
+  if (app->ui_gadget && strcmp(app->ui_gadget, "true") == 0) {
     // Ug-client path
     // Make a symlink with the name of appid, pointing /usr/bin/ug-client
     bf::path app_exec_path(app->exec);
@@ -56,10 +56,11 @@ bool CreateSymLink(application_x* app, InstallerContext* context) {
     // Exec path
     // Make a symlink with the name of appid, pointing exec file
     bf::path symlink_path = bindir / bf::path(app->appid);
-    if (!bf::exists(symlink_path)) {
+    bf::path app_exec_path(app->exec);
+    if (!bf::exists(symlink_path) && bf::exists(app_exec_path)) {
       LOG(DEBUG) << "Creating symlink " << symlink_path << " pointing " <<
-          app->exec;
-      bf::create_symlink(bf::path(app->exec), symlink_path, boost_error);
+          app_exec_path;
+      bf::create_symlink(app_exec_path, symlink_path, boost_error);
       if (boost_error) {
         LOG(ERROR) << "Symlink creation failure: " << symlink_path;
         return false;
@@ -74,12 +75,17 @@ bool SetExecPermission(application_x* app) {
   boost::system::error_code boost_error;
   // Give an execution permission to the original executable
   LOG(DEBUG) << "Giving exec permission to " << app->exec;
-  bf::permissions(bf::path(app->exec), bf::owner_all |
-      bf::group_read | bf::group_exe |
-      bf::others_read | bf::others_exe, boost_error);
-  if (boost_error) {
-    LOG(ERROR) << "Permission change failure";
-    return false;
+  bf::path app_exec_path(app->exec);
+  if (bf::exists(app_exec_path)) {
+    bf::permissions(app_exec_path, bf::owner_all |
+        bf::group_read | bf::group_exe |
+        bf::others_read | bf::others_exe, boost_error);
+    if (boost_error) {
+      LOG(ERROR) << "Permission change failure";
+      return false;
+    }
+  } else {
+    LOG(WARNING) << "file does not exist";
   }
 
   return true;
index 786e5e2630211488259a4b3b2cae782e43789477..d080b4cd4158079a3462b711acd4fdfda740e6f6 100644 (file)
@@ -28,31 +28,21 @@ namespace bf = boost::filesystem;
 Step::Status StepParsePreload::process() {
   const char* preload_manifest_val = context_->manifest_data.get()->preload;
 
-  bool is_preload = false;
+  if (strcmp(preload_manifest_val, "true") != 0) {
+    bool is_preload = context_->is_preload_request.get();
 
-  if (context_->installation_mode.get() == InstallationMode::OFFLINE) {
-    if (strcmp(preload_manifest_val, "false") != 0) {
-          is_preload = true;
-    }
-  } else {
-    if (context_->request_type.get() == RequestType::ManifestDirectInstall ||
-        context_->request_type.get() == RequestType::ManifestDirectUpdate) {
-      if (strcmp(preload_manifest_val, "true") == 0) {
-        is_preload = true;
-      }
-    }
-  }
-
-  if (is_preload) {
-    context_->manifest_data.get()->preload = strdup("true");
+    LOG(INFO) << "is_preload : (" << is_preload << ")";
+    if (is_preload) {
+      context_->manifest_data.get()->preload = strdup("true");
 
-    if (getuid() != 0) {
-      LOG(ERROR) << "You're not authorized to install preload app: "
-          << context_->pkgid.get().c_str();
-      return Status::OPERATION_NOT_ALLOWED;
+      if (getuid() != 0) {
+        LOG(ERROR) << "You're not authorized to install preload app: "
+            << context_->pkgid.get().c_str();
+        return Status::OPERATION_NOT_ALLOWED;
+      }
+    } else {
+      context_->manifest_data.get()->preload = strdup("false");
     }
-  } else {
-    context_->manifest_data.get()->preload = strdup("false");
   }
 
   return Status::OK;
index 9e605e68d7e00c06477fe7b6461a1532b098a33f..2f8256ef4760309ee879747561c9417b3308d562 100644 (file)
@@ -64,7 +64,7 @@ class StepCrash : public ci::Step {
 };
 
 void RemoveAllRecoveryFiles() {
-  bf::path root_path = ci::GetRootAppPath();
+  bf::path root_path = ci::GetRootAppPath(false);
   if (!bf::exists(root_path))
     return;
   for (auto& dir_entry : boost::make_iterator_range(
@@ -79,7 +79,7 @@ void RemoveAllRecoveryFiles() {
 }
 
 bf::path FindRecoveryFile() {
-  bf::path root_path = ci::GetRootAppPath();
+  bf::path root_path = ci::GetRootAppPath(false);
   for (auto& dir_entry : boost::make_iterator_range(
          bf::directory_iterator(root_path), bf::directory_iterator())) {
     if (bf::is_regular_file(dir_entry)) {
@@ -94,7 +94,7 @@ bf::path FindRecoveryFile() {
 bool ValidateFileContentInPackage(const std::string& pkgid,
                                   const std::string& relative,
                                   const std::string& expected) {
-  bf::path root_path = ci::GetRootAppPath();
+  bf::path root_path = ci::GetRootAppPath(false);
   bf::path file_path = root_path / pkgid / relative;
   if (!bf::exists(file_path)) {
     LOG(ERROR) << file_path << " doesn't exist";
@@ -115,7 +115,7 @@ bool ValidateFileContentInPackage(const std::string& pkgid,
 }
 
 void ValidatePackageFS(const std::string& pkgid, const std::string& appid) {
-  bf::path root_path = ci::GetRootAppPath();
+  bf::path root_path = ci::GetRootAppPath(false);
   bf::path package_path = root_path / pkgid;
   bf::path binary_path = package_path / "bin" / appid;
   bf::path data_path = package_path / "data";
@@ -144,7 +144,7 @@ void ValidatePackageFS(const std::string& pkgid, const std::string& appid) {
 }
 
 void PackageCheckCleanup(const std::string& pkgid, const std::string& appid) {
-  bf::path root_path = ci::GetRootAppPath();
+  bf::path root_path = ci::GetRootAppPath(false);
   bf::path package_path = root_path / pkgid;
   ASSERT_FALSE(bf::exists(package_path));
 
@@ -332,7 +332,7 @@ TEST_F(SmokeTest, DeltaMode_Tpk) {
   ValidatePackage(pkgid, appid);
 
   // Check delta modifications
-  bf::path root_path = ci::GetRootAppPath();
+  bf::path root_path = ci::GetRootAppPath(false);
   ASSERT_FALSE(bf::exists(root_path / pkgid / "DELETED"));
   ASSERT_TRUE(bf::exists(root_path / pkgid / "ADDED"));
   ASSERT_TRUE(bf::exists(root_path / pkgid / "bin" / "native"));