extra package: skip installing duplicate packages
authorChulHo Song <ch81.song@samsung.com>
Fri, 4 Dec 2015 07:56:11 +0000 (16:56 +0900)
committerChulHo Song <ch81.song@samsung.com>
Wed, 9 Dec 2015 06:43:10 +0000 (15:43 +0900)
Do not install same version of the packages. Newer version of the
packages will be upgraded, older version of the packages will be
failed to install.

Change-Id: Ib5cc8b781aee56d39447b6cb46689e948b68045c
Signed-off-by: ChulHo Song <ch81.song@samsung.com>
(cherry picked from commit 58a790efcd2d468ef01987cde3866276ffa445fd)

tizen/src/util/extra_pkgs_install.c

index 49af34d72006b4ea9268dc164e82c7c2733fa68c..6f4f8e092f1ebe1ff3cf40535320ce87d2f57561 100644 (file)
@@ -113,6 +113,41 @@ static void send_to_emuld(char* addon, char* pkgs)
     }
 }
 
+#ifdef CONFIG_WIN32
+static char *strcasestr(const char *haystack, const char *needle)
+{
+    size_t length_needle;
+    size_t length_haystack;
+    size_t i;
+
+    if (!haystack || !needle)
+        return NULL;
+
+    length_needle = strnlen(needle, MAX_PKG_LIST);
+    length_haystack = strnlen(haystack, MAX_PKG_LIST);
+
+    for (i = 0; i < length_haystack; i++)
+    {
+        size_t j;
+        for (j = 0; j < length_needle; j++)
+        {
+            unsigned char c1;
+            unsigned char c2;
+
+            c1 = haystack[i+j];
+            c2 = needle[j];
+            if (toupper(c1) != toupper(c2))
+            goto next;
+        }
+        return (char *) haystack + i;
+    next:
+        ;
+    }
+
+    return NULL;
+}
+#endif // CONFIG_WIN32
+
 void epi_init(void)
 {
     int pkg_count = 0;
@@ -123,8 +158,9 @@ void epi_init(void)
     struct dirent *sub_dir_entry = NULL;
     char addon[MAX_PATH_PKG_LIST];
     char pkgs[MAX_PKG_LIST];
+    char pkg_list[MAX_PKG_LIST];
     char *ext;
-    charaddon_path = get_addon_path();
+    char *addon_path = get_addon_path();
 
     if (!addon_path) {
         return;
@@ -136,6 +172,8 @@ void epi_init(void)
         return;
     }
 
+    memset(pkg_list, 0, sizeof(pkg_list));
+
     while ((dir_entry = readdir(main_dir))) {
         if ((strncasecmp(dir_entry->d_name ,".", 1) != 0) &&
             (strncasecmp(dir_entry->d_name ,"..", 2) != 0)) {
@@ -165,10 +203,13 @@ void epi_init(void)
 
                     ext = &sub_dir_entry->d_name[strlen(sub_dir_entry->d_name) - 4];
                     if (strcmp(EXT_RPM, ext))
-                            continue;
+                        continue;
+                    if (strcasestr(pkg_list, sub_dir_entry->d_name))
+                        continue;
 
                     pkg_count++;
                     add_addon_pkgs_name(pkgs, sub_dir_entry->d_name);
+                    add_addon_pkgs_name(pkg_list, sub_dir_entry->d_name);
                     LOG_TRACE("reading addon sub directory: %s\n", sub_dir_entry->d_name);
                 }
             }
@@ -188,4 +229,7 @@ void epi_init(void)
     }
 
     closedir(main_dir);
+    free(addon_path);
+
+    LOG_INFO("pkg_list: %s\n", pkg_list);
 }