fixed: exit status of package installation
authorJinhyung Choi <jinhyung2.choi@samsung.com>
Thu, 22 Jan 2015 05:19:25 +0000 (14:19 +0900)
committerJinhyung Choi <jinhyung2.choi@samsung.com>
Thu, 22 Jan 2015 06:04:49 +0000 (15:04 +0900)
Change-Id: I5b1049bde133a09dd774e70cc67e6c7dafc07c03
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
packaging/emuld.spec
src/common.cpp

index 0c91149f87c8c108d99ac2bc580ff4e8f43f85e1..609db3baabfa2ae1a3effd8730b0527515b368b0 100644 (file)
@@ -1,5 +1,5 @@
 Name: emuld
-Version: 0.8.7
+Version: 0.8.8
 Release: 0
 Summary: Emulator daemon
 License: Apache-2.0
index becc17bac664ae13a6fe4553d2f95eeabfd0484c..7cdc241b3c50e1ccc7f6429277db75b048d2acd4 100644 (file)
@@ -186,55 +186,37 @@ void send_default_suspend_req(void)
     send_to_ecs(IJTYPE_SUSPEND, 5, 15, NULL);
 }
 
-static bool do_validate(char* pkgs)
+static bool do_rpm_execute(char* pkgs)
 {
     char buf[MAX_PKGS_BUF];
+    int ret = 0;
 
     FILE* fp = popen(pkgs, "r");
     if (fp == NULL) {
-        LOGERR("Failed to popen %s", pkgs);
+        LOGERR("[rpm] Failed to popen %s", pkgs);
         return false;
     }
 
     memset(buf, 0, sizeof(buf));
     while(fgets(buf, sizeof(buf), fp)) {
         LOGINFO("[rpm]%s", buf);
-        if (!strncmp(buf, IJTYPE_PACKAGE, 7)) {
-            pclose(fp);
-            return false;
-        }
         memset(buf, 0, sizeof(buf));
     }
 
-    pclose(fp);
-    return true;
-}
-
-static bool do_install(char* pkgs)
-{
-    char buf[MAX_PKGS_BUF];
-    int ret = 0;
-
-    FILE* fp = popen(pkgs, "r");
-    if (fp == NULL) {
-        LOGERR("Failed to popen %s", pkgs);
+    ret = pclose(fp);
+    if (ret == -1) {
+        LOGINFO("[rpm] pclose error: %d", errno);
         return false;
     }
 
-    memset(buf, 0, sizeof(buf));
-    while(fgets(buf, sizeof(buf), fp)) {
-        LOGINFO("[rpm] %s", buf);
-        memset(buf, 0, sizeof(buf));
+    if (ret >= 0 && WIFEXITED(ret) && WEXITSTATUS(ret) == 0) {
+        LOGINFO("[rpm] RPM execution success: %s", pkgs);
+        return true;
     }
 
-    ret = pclose(fp);
-    LOGINFO("[rpm] return value: %d", ret);
-
-    if (ret != 0) {
-        return false;
-    }
+    LOGINFO("[rpm] RPM execution fail: [%x,%x,%x] %s", ret, WIFEXITED(ret), WEXITSTATUS(ret), pkgs);
 
-    return true;
+    return false;
 }
 
 static void remove_package(char* data)
@@ -305,10 +287,8 @@ static bool do_package(int action, char* data)
     strcat(pkg_list, " ");
     strcat(pkg_list, "2>&1");
 
-    LOGINFO("[cmd]%s", pkg_list);
-    if (action == 1 && do_validate(pkg_list)) {
-        return true;
-    } else if (action == 2 && do_install(pkg_list)) {
+    LOGINFO("[cmd] %s", pkg_list);
+    if ((action == 1 || action == 2) && do_rpm_execute(pkg_list)) {
         return true;
     }