Tizen 2.4.0 rev3 SDK Public Release submit/tizen_2.4/20160302.062320
authorjk7744.park <jk7744.park@samsung.com>
Wed, 24 Feb 2016 09:33:37 +0000 (18:33 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Wed, 24 Feb 2016 09:33:37 +0000 (18:33 +0900)
17 files changed:
CMakeLists.txt
backend/inc/coretpk-installer.h
backend/inc/rpm-installer.h
backend/src/coretpk/coretpk-dbus.c
backend/src/coretpk/coretpk-installer.c
backend/src/coretpk/inc/coretpk-installer-internal.h
backend/src/coretpk/xml-parser/coretpk-parser-hybrid.c
backend/src/coretpk/xml-parser/coretpk-parser.c
backend/src/rpm/rpm-installer-tool.c
backend/src/rpm/rpm-installer.c
common/installer-util.c
frontend/inc/rpm-frontend.h
frontend/src/rpm-appcore-intf.c
frontend/src/rpm-cmdline.c
inc/installer-type.h
inc/installer-util.h
packaging/rpm-installer.spec

index 3367598..d6d2040 100755 (executable)
@@ -41,10 +41,6 @@ IF(_APPFW_FEATURE_SUPPORT_ONLYCAP)
         ADD_DEFINITIONS("-D_APPFW_FEATURE_SUPPORT_ONLYCAP")
 ENDIF(_APPFW_FEATURE_SUPPORT_ONLYCAP)
 
-IF(_APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY)
-       ADD_DEFINITIONS("-D_APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY")
-ENDIF(_APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY)
-
 IF(TIZEN_FULL_VERSION)
         ADD_DEFINITIONS("-DTIZEN_FULL_VERSION=\"${TIZEN_FULL_VERSION}\"")
 ELSE(TIZEN_FULL_VERSION)
index b0ccce7..849f971 100755 (executable)
@@ -33,8 +33,6 @@ int _coretpk_installer_prepare_package_install_with_debug(const char *pkgid, con
 int _coretpk_installer_prepare_package_uninstall(const char *pkgid);
 int _coretpk_installer_prepare_preload_install(const char* dirpath, const char *clientid, const cmdinfo* cmd_info);
 int _coretpk_installer_prepare_preload_uninstall(const char* pkgid);
-int _coretpk_installer_prepare_fota(char *fota_script, bool is_opt_pkg);
-int _coretpk_installer_prepare_csc(const char *csc_script);
 int _coretpk_installer_package_move(const char* pkgid, int movetype);
 int _coretpk_installer_request_hybrid(int hybridOperation, const char* pPkgPath, int apiVisibility);
 
@@ -49,7 +47,6 @@ int _coretpk_installer_prepare_delta_install(const char* dirpath, const char* cl
 
 #ifdef _APPFW_FEATURE_MOUNT_INSTALL
 int _coretpk_installer_prepare_mount_install(const char *pkg_file, const char *client_id, bool preload, const cmdinfo * cmd_info);
-int _coretpk_mount_install_parser_convert_manifest(const char *tizen_manifest, const char *pkgid, const char *clientid, bool hybrid, int api_visibility, const bundle *optional_data);
 #endif
 
 #ifdef __cplusplus
index 22607b9..eee0d58 100755 (executable)
@@ -119,6 +119,9 @@ extern "C" {
 
        int _rpm_install_corexml(const char *pkgfilepath, char *pkgid);
        int _rpm_process_cscxml(char *xml_path);
+       int _rpm_process_csc_coretpk(const char *xml_path);
+       int _rpm_process_fota(char *fota_script);
+       int _rpm_process_fota_for_rw(char *fota_script);
 
        int _ri_set_backend_state(int state);
        int _ri_get_backend_state();
index de21bfb..90b1833 100755 (executable)
@@ -37,6 +37,7 @@ int _coretpk_dbus_mount_file(char *mnt_path[], const char *pkgid)
        int func_ret = 0;
        int rv = 0;
        struct stat link_buf = {0,};
+       DBusError err;
 
        DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
        if(!conn){
@@ -82,6 +83,7 @@ func_out :
 
 int _coretpk_dbus_unmount_file(char *mnt_path)
 {
+       DBusError err;
        _LOGD("__tpk_unmount called [%s]", mnt_path);
 
        DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
index f870077..4da152b 100755 (executable)
@@ -30,7 +30,6 @@
 #include <glib.h>
 #include <openssl/sha.h>
 #include <openssl/evp.h>
-#include <openssl/md5.h>
 #include <vconf.h>
 #include <unzip.h>
 #include <sys/smack.h>
@@ -670,6 +669,35 @@ catch:
        return csc_package;
 }
 
+void __make_csc_flag(const char *pkg_id)
+{
+       int ret = 0;
+       FILE *file = NULL;
+       char flag_path[BUF_SIZE] = { 0, };
+
+       if (access(CSC_FLAG, F_OK) != 0) {
+               ret = mkdir(CSC_FLAG, DIRECTORY_PERMISSION_755);
+               if (ret < 0) {
+                       _LOGE("mkdir(%s) failed. [%d][%s]", CSC_FLAG, errno, strerror(errno));
+               }
+       }
+
+       snprintf(flag_path, BUF_SIZE, "%s/%s", CSC_FLAG, pkg_id);
+       _LOGD("flag_path=[%s]", flag_path);
+
+       file = fopen(flag_path, "w");
+       tryvm_if(file == NULL, ret = -1, "fopen(%s) failed. [%d][%s]", flag_path, errno, strerror(errno));
+
+       _LOGD("csc flag[%s] is created.", pkg_id);
+
+ catch:
+       if (file) {
+               fclose(file);
+       }
+
+       return;
+}
+
 int __remove_updates_csc_package(const char *pkgid, const char *csc_path)
 {
        retvm_if(pkgid == NULL, RPM_INSTALLER_ERR_WRONG_PARAM, "pkgid is NULL.");
@@ -680,8 +708,8 @@ int __remove_updates_csc_package(const char *pkgid, const char *csc_path)
 
        _LOGD("remove update for csc. path_str=[%s], remove_str=[%s]", path_str, remove_str);
 
-       __coretpk_installer_csc_uninstall(pkgid);
-       __coretpk_installer_csc_install(path_str, remove_str, csc_path);
+       _coretpk_installer_csc_uninstall(pkgid);
+       _coretpk_installer_csc_install(path_str, remove_str, csc_path);
 
        _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "start", "update");
 
@@ -719,7 +747,7 @@ static int __pkg_remove_update(const char *pkgid)
        }
 
        /* start */
-       _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "start", "uninstall");
+       _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "start", "update");
 
        /* terminate running app */
        __terminate_running_app(pkgid);
@@ -733,9 +761,6 @@ static int __pkg_remove_update(const char *pkgid)
        /* Remove origin rule */
        _ri_privilege_unregister_package(pkgid);
 
-       _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "end", "ok");
-       _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "start", "install");
-
        /* unzip pkg path from factory-reset data */
        memset(rootpath, '\0', BUF_SIZE);
        snprintf(rootpath, BUF_SIZE, "opt/usr/apps/%s/*", pkgid);       // relative path
@@ -972,88 +997,6 @@ end:
        return ret;
 }
 
-void __make_csc_flag(const char *pkg_id)
-{
-       int ret = 0;
-       FILE *file = NULL;
-       char flag_path[BUF_SIZE] = { 0, };
-
-       if (access(CSC_FLAG, F_OK) != 0) {
-               ret = mkdir(CSC_FLAG, DIRECTORY_PERMISSION_755);
-               if (ret < 0) {
-                       _LOGE("mkdir(%s) failed. [%d][%s]", CSC_FLAG, errno, strerror(errno));
-               }
-       }
-
-       snprintf(flag_path, BUF_SIZE, "%s/%s", CSC_FLAG, pkg_id);
-       _LOGD("flag_path=[%s]", flag_path);
-
-       file = fopen(flag_path, "w");
-       tryvm_if(file == NULL, ret = -1, "fopen(%s) failed. [%d][%s]", flag_path, errno, strerror(errno));
-
-       _LOGD("csc flag[%s] is created.", pkg_id);
-
- catch:
-       if (file) {
-               fclose(file);
-       }
-
-       return;
-}
-
-static int __compare_checksum(const char *chksum, const char *pkgfile)
-{
-       retvm_if(pkgfile == NULL, RPM_INSTALLER_ERR_WRONG_PARAM, "filepath is NULL.");
-       retvm_if(strlen(chksum) == 0, RPM_INSTALLER_ERR_WRONG_PARAM, "cert value is empty.");
-
-       MD5_CTX mdContext;
-       FILE *fp = NULL;
-       unsigned char data[1024] = {0, };
-       unsigned char md5_value[MD5_DIGEST_LENGTH] = {0, };
-       char *hash = NULL;
-       char temp[3] = { '\0', };
-       int bytes = 0;
-       int ret = -1;
-       int i;
-
-       fp = fopen(pkgfile, "r");
-       if (fp == NULL) {
-               printf("failed to open [%s]", pkgfile);
-               return -1;
-       }
-
-       MD5_Init(&mdContext);
-       while((bytes = fread(data, 1, 1024, fp)) != 0)
-               MD5_Update(&mdContext, data, bytes);
-       MD5_Final(md5_value, &mdContext);
-
-       hash = (char *)malloc(MD5_DIGEST_LENGTH * 2 + 1);
-       if (hash == NULL) {
-               _LOGE("failed to allocate memory");
-               ret = -1;
-               goto err;
-       }
-       memset(hash, '\0', MD5_DIGEST_LENGTH * 2 + 1);
-
-       for(i = 0; i < MD5_DIGEST_LENGTH; i++) {
-               snprintf(temp, 3, "%02x", md5_value[i]);
-               strncat(hash, temp, strlen(temp));
-       }
-
-       if (strcmp(chksum, hash) != 0) {
-               _LOGE("checksum verification failed [%s], [%s]", chksum, hash);
-               ret = -1;
-       } else
-               ret = 0;
-
-err:
-
-       fclose(fp);
-       FREE_AND_NULL(hash);
-
-       return ret;
-}
-
 int _coretpk_installer_remove_db_info(const char *pkgid)
 {
        int ret = 0;
@@ -1194,9 +1137,6 @@ int _coretpk_backend_interface(const char *reqcommand, const ri_frontend_cmdline
                _LOGE("reqcommand or data is NULL.");
                return -1;
        }
-
-       cmdinfo info;
-
 #ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
        /* '.tep' also gets installed after tpk installation,
           so to manage progress percentage, 'is_tpk_and_tep' is used */
@@ -1212,13 +1152,7 @@ int _coretpk_backend_interface(const char *reqcommand, const ri_frontend_cmdline
                        return _coretpk_installer_prepare_package_install_with_debug(data->pkgid, data->clientid, false, NULL);
                else
 #endif
-               if (data->pkg_chksum != NULL)
-                       strncpy(info.pkg_chksum, data->pkg_chksum, BUF_SIZE - 1);
-               else
-                       memset(info.pkg_chksum, '\0', BUF_SIZE);
-
-               info.support_disable = false;
-               return _coretpk_installer_prepare_package_install(data->pkgid, data->clientid, false, &info);
+                       return _coretpk_installer_prepare_package_install(data->pkgid, data->clientid, false, NULL);
        } else if (strncmp(reqcommand, CORETPK_UNINSTALL, strlen(CORETPK_UNINSTALL)) == 0) {
                return _coretpk_installer_prepare_package_uninstall(data->pkgid);
        } else if (strncmp(reqcommand, CORETPK_DIRECTORY_INSTALL, strlen(CORETPK_DIRECTORY_INSTALL)) == 0) {
@@ -1349,14 +1283,13 @@ pkginfo *_coretpk_installer_get_pkgfile_info(const char *pkgfile, int cmd)
                        }
                        goto err;
                }
+               _LOGD("TEMP_DIR=[%s]", TEMP_DIR);
 
                /* extract all the xml files */
                const char *unzip_argv[] = { "/usr/bin/unzip", "-oqq", pkgfile, xmls, "-d", TEMP_DIR, NULL };
                ret = _ri_xsystem(unzip_argv);
                if (ret != 0) {
-                       if( strerror_r(errno, buf, sizeof(buf)) == 0) {
-                               _LOGE("unzip (%s) failed. [%d][%s]", TEMP_DIR, errno, buf);
-                       }
+                       _LOGE("cannot find xml files in the package.");
                        goto err;
                }
 
@@ -1370,6 +1303,7 @@ pkginfo *_coretpk_installer_get_pkgfile_info(const char *pkgfile, int cmd)
                ret = RPM_INSTALLER_ERR_NO_MANIFEST;
                goto err;
        }
+       _LOGD("manifest=[%s]", tizen_manifest);
 
        info = _coretpk_parser_get_manifest_info(tizen_manifest);
        if (info == NULL) {
@@ -2794,14 +2728,6 @@ int _coretpk_installer_install_package(const char *pkgfile, const pkginfo * pkg_
                }
        }
 
-       if (strlen(pkg_file_info->pkg_chksum) != 0) {
-               if (__compare_checksum(pkg_file_info->pkg_chksum, pkgfile) != 0) {
-                       _LOGE("failed to compare checksum of pkg");
-                       ret = RPM_INSTALLER_ERR_PACKAGE_INVALID;
-                       goto err;
-               }
-       }
-
        if (__is_dir(pkgfile)) {
                _LOGD("Directory install(preload)");
                directory_install = true;
@@ -3214,8 +3140,6 @@ int _coretpk_installer_prepare_package_install(const char *pkg_file, const char
        pkg_file_info->is_preload = preload;
        if (cmd_info) {
                pkg_file_info->support_disable = cmd_info->support_disable;
-               if (strlen(cmd_info->pkg_chksum) != 0)
-                       strncpy(pkg_file_info->pkg_chksum, cmd_info->pkg_chksum, BUF_SIZE - 1);
        }
 
        ret = _coretpk_installer_install_package(pkg_file, pkg_file_info);
@@ -3329,7 +3253,7 @@ int _coretpk_installer_prepare_preload_install(const char *dirpath, const char *
 }
 
 #ifdef _APPFW_FEATURE_MOUNT_INSTALL
-int _coretpk_installer_mount_install_create_symbolic_links(const char *pkgfile, const char *pkgid, const char* orig_dir)
+int _coretpk_installer_mount_install_create_symbolic_links(const char *pkgfile, const char *pkgid)
 {
        int ret = PMINFO_R_OK;
        size_t filename_len;
@@ -3367,12 +3291,12 @@ int _coretpk_installer_mount_install_create_symbolic_links(const char *pkgfile,
                                }
 
                                filename_len = strlen(filename);
-                               _LOGE("Filename: [%s], len:[%d]", filename, filename_len);
+                               _LOGE("\n\nFilename: [%s], len:[%d]", filename, filename_len);
 
                                /* If it is 1st level directory (like opt/not internal like opt/usr/) or just a file then create symbolic links */
                                if( (((strchr(filename, '/') -filename) == filename_len -1) || (strchr(filename, '/') == NULL)) && strstr(filename, "bin/") == NULL) {
 
-                                       _LOGE("Creating symlink Filename: [%s]", filename);
+                                       _LOGE("Creating symlink Filename: [%s]\n\n", filename);
 
                                        if(((strchr(filename, '/') -filename) == filename_len -1)){
                                                filename[filename_len -1] = '\0';
@@ -3382,28 +3306,27 @@ int _coretpk_installer_mount_install_create_symbolic_links(const char *pkgfile,
                                        slink_from = strdup(tmp);
 
                                        memset(tmp, '\0', BUF_SIZE);
-                                       snprintf(tmp, BUF_SIZE, "%s/%s/%s/%s", OPT_USR_APPS, pkgid, orig_dir, filename);
+                                       snprintf(tmp, BUF_SIZE, "%s/%s/.pkg/%s", OPT_USR_APPS, pkgid, filename);
                                        slink_to = strdup(tmp);
 
                                        if ((ret = symlink(slink_to, slink_from)) < 0) {
                                                if (errno == EEXIST) {
-                                                       _LOGE("File with Symlink name present %s", slink_from);
-                                                       unlink(slink_from);
-                                                       ret = symlink(slink_to, slink_from);
-                                                       if(ret < 0)
-                                                               _LOGE("Symbolic link creation failed, error is [%s]", strerror(errno));
-                                                       _LOGE("Created symlink Filename: [%s]", filename);
+                                                       _LOGE("File with Symlink name present %s\n", slink_from);
                                                } else {
                                                        char buf[BUF_SIZE] = { 0, };
                                                        if( strerror_r(errno, buf, sizeof(buf)) == 0) {
-                                                               _LOGE("Symbolic link creation failed, error is [%s]", buf);
+                                                               _LOGE("Symbolic link creation failed, error is [%s]\n", buf);
                                                        }
                                                        goto catch;
                                                }
                                        }
+
                                        FREE_AND_NULL(slink_from);
                                        FREE_AND_NULL(slink_to);
+
                                }
+
+
                                FREE_AND_NULL(filename);
                        } while (unzGoToNextFile(uzf) == UNZ_OK);
                }
@@ -3425,24 +3348,27 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
 
        int ret = 0;
        int visibility = 0;
+       int install_status = APP2EXT_STATUS_SUCCESS;
        char root_path[BUF_SIZE] = { 0, };
        char tizen_manifest[BUF_SIZE] = { 0, };
        char system_manifest[BUF_SIZE] = { 0, };
        char cwd[BUF_SIZE] = { 0, };
        char rwmanifest[BUF_SIZE] = { 0, };
+       char res_xml[BUF_SIZE] = { 0, };
        char signature1[BUF_SIZE] = { 0, };
        char *temp = NULL;
        const char *pkgid = pkg_file_info->package_name;
        bool update = false;
        bool directory_install = false;
        pkgmgrinfo_pkginfo_h pkginfo_handle = NULL;
+       pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
+       app2ext_handle *handle = NULL;
        bundle *optional_data = NULL;
+
        char *mnt_path[2] = {NULL, };
        char tpk_path[BUF_SIZE] = {0, };
        char buf[BUF_SIZE] = { 0, };
-       char *filename = NULL;
-       bool is_MIC_env = false;
-       char tmp_dir[BUF_SIZE] = { 0, };
+
 
        optional_data = bundle_create();
        if (optional_data) {
@@ -3456,17 +3382,9 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
                directory_install = true;
        }
 
-       if(access(MIC_ENV, F_OK) != 0) {
-               is_MIC_env = true;
-               snprintf(tmp_dir, BUF_SIZE, "%s/%s/.tmp/", OPT_USR_APPS, pkgid);
-       }
-
        snprintf(root_path, BUF_SIZE, "%s/%s/", OPT_USR_APPS, pkgid);
        snprintf(tizen_manifest, BUF_SIZE, "%s/%s/%s", OPT_USR_APPS, pkgid, CORETPK_XML);
 
-       filename = strrchr(pkgfile, '/');
-       filename++;
-
        ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &pkginfo_handle);
        if (ret < 0) {
                _LOGD("------------------------------------------");
@@ -3475,10 +3393,6 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
 
                _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "start", "install");
 
-               if(access(root_path, F_OK) == 0) {
-                       _installer_util_delete_dir(root_path);
-               }
-
        } else {
                _LOGD("------------------------------------------");
                _LOGD("Update - [%s][%s]", pkgid, pkgfile);
@@ -3490,9 +3404,16 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
                /* terminate running app */
                __terminate_running_app(pkgid);
 
+               ret = pkgmgrinfo_pkginfo_get_installed_storage(pkginfo_handle, &storage);
+               if (ret != 0) {
+                       _LOGE("pkgmgrinfo_pkginfo_get_installed_storage(%s) failed.", pkgid);
+                       ret = RPM_INSTALLER_ERR_INTERNAL;
+                       goto err;
+               }
+
                /* remove dir for clean */
                if (directory_install == false) {
-                       __ri_remove_updated_dir(pkgid);
+                       _installer_util_delete_dir(root_path);
                }
        }
 
@@ -3503,6 +3424,23 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
 #endif
                _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "install_percent", "30");
 
+#if 0
+       /* install package */
+       if (directory_install == false) {
+               _LOGD("[start] unzip(%s)", pkgfile);
+               const char *unzip_argv[] = { "/usr/bin/unzip", "-o", pkgfile, "-d", root_path, NULL };
+               ret = _ri_xsystem(unzip_argv);
+               if (ret != 0) {
+                       _LOGE("failed to unzip for path=[%s], ret=[%d]", root_path, ret);
+                       ret = RPM_INSTALLER_ERR_UNZIP_FAILED;
+                       goto err;
+               }
+               _LOGD("[end] unzip(%s)", root_path);
+       }
+#else
+       if(access(root_path, F_OK) == 0){
+               _installer_util_delete_dir(root_path);
+       }
 
        ret = _installer_util_mkpath(root_path, DIRECTORY_PERMISSION_755);
        if(ret){
@@ -3533,55 +3471,38 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
        }
        _LOGD("[end] unzip(%s/bin)", tpk_path);
 
-       if(!is_MIC_env){
-               snprintf(tpk_path, BUF_SIZE, "%s/%s/.pkg", OPT_USR_APPS, pkgid);
-               _LOGE("tpk mount path: [%s]",tpk_path);
-               mnt_path[0] = strdup(tpk_path);
-               memset(tpk_path, 0, BUF_SIZE);
-
-               snprintf(tpk_path, BUF_SIZE, "%s/%s", USR_PACKAGES, filename);
-               _LOGE("tpk filename: [%s]",tpk_path);
-               mnt_path[1] = strdup(tpk_path);
+       snprintf(tpk_path, BUF_SIZE, "%s/%s/.pkg", OPT_USR_APPS, pkgid);
+       _LOGE("tpk mount path: [%s]",tpk_path);
+       mnt_path[0] = strdup(tpk_path);
+       memset(tpk_path, 0, BUF_SIZE);
 
-               ret = _coretpk_dbus_is_mount_done(mnt_path[0]);
-               if(ret != 1) {
-                       ret = _coretpk_dbus_mount_file(mnt_path, pkgid);
-                       if(ret){
-                               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
-                                       _LOGE("DBUS Error: err: [%s]", buf);
-                               }
-                               goto err;
-                       }
-                       ret = _coretpk_dbus_wait_for_tep_mount(mnt_path[0]);
-                       if(ret != 0){
-                               ret = RPM_INSTALLER_ERR_INTERNAL;
-                               _LOGE("Unable to mount the tpk file");
-                               goto err;
+       char *filename = strrchr(pkgfile, '/');
+       filename++;
+       snprintf(tpk_path, BUF_SIZE, "%s/%s", USR_PACKAGES, filename);
+       _LOGE("tpk filename: [%s]",tpk_path);
+       mnt_path[1] = strdup(tpk_path);
+
+       ret = _coretpk_dbus_is_mount_done(mnt_path[0]);
+       if(ret != 1) {
+               ret = _coretpk_dbus_mount_file(mnt_path, pkgid);
+               if(ret){
+                       if( strerror_r(errno, buf, sizeof(buf)) == 0) {
+                               _LOGE("DBUS Error: err: [%s]", buf);
                        }
+                       goto err;
                }
-               _coretpk_installer_mount_install_create_symbolic_links(pkgfile, pkgid, ".pkg");
-
-       }else {
-               /* Extract tpk to /opt/usr/apps/.tmp/ */
-               if (directory_install == false) {
-                       ret = _installer_util_mkpath(tmp_dir, DIRECTORY_PERMISSION_755);
-                       if(ret){
-                               _LOGE("unable to create dir, [%s], error: [%s]", tmp_dir, strerror(errno));
-                       }
-
-                       _LOGD("[start] unzip(%s) to (%s)", pkgfile, tmp_dir);
-                       const char *unzip_argv[] = { "/usr/bin/unzip", "-o", pkgfile, "-d", tmp_dir, NULL };
-                       ret = _ri_xsystem(unzip_argv);
-                       if (ret != 0) {
-                               _LOGE("failed to unzip for path=[%s], ret=[%d]", tmp_dir, ret);
-                               ret = RPM_INSTALLER_ERR_UNZIP_FAILED;
-                               goto err;
-                       }
-                       _LOGD("[end] unzip(%s)", tmp_dir);
-                       _coretpk_installer_mount_install_create_symbolic_links(pkgfile, pkgid, ".tmp");
+               ret = _coretpk_dbus_wait_for_tep_mount(mnt_path[0]);
+               if(ret != 0){
+                       ret = RPM_INSTALLER_ERR_INTERNAL;
+                       _LOGE("Unable to mount the tpk file");
+                       goto err;
                }
        }
 
+       _coretpk_installer_mount_install_create_symbolic_links(pkgfile, pkgid);
+
+#endif
+
        /* getcwd */
        temp = getcwd(cwd, BUF_SIZE);
        if ((temp == NULL) || (cwd[0] == '\0')) {
@@ -3700,15 +3621,14 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
        }
        _LOGD("manifest parsing done successfully.");
 
-       _LOGE("###: pkgmgr_parser_insert_mount_install_info START");
-
+       filename = strrchr(pkgfile, '/');
+       filename++;
        ret = pkgmgr_parser_insert_mount_install_info(pkgid, true, filename);
        if (ret < 0) {
                _LOGE("pkgmgr_parser_insert_mount_install_info(%s) failed.", pkgfile);
                ret = RPM_INSTALLER_ERR_INTERNAL;
                goto err;
        }
-       _LOGE("###: pkgmgr_parser_insert_mount_install_info END");
 
 
        /* search_ug_app */
@@ -3724,6 +3644,22 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
 #endif
                _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "install_percent", "60");
 
+#if 0
+       /* make directory */
+       ret = _coretpk_installer_make_directory(pkgid, pkg_file_info->is_preload);
+       if (ret != 0) {
+               _LOGE("failed to make the directory.");
+               goto err;
+       }
+
+       /* apply smack to app dir */
+       ret = _coretpk_installer_apply_smack(pkgid, 1);
+       if (ret != 0) {
+               _LOGE("failed to apply the smack.");
+               goto err;
+       }
+#else
+
        /* make directory */
        ret = _coretpk_installer_mount_install_make_directory(pkgid, pkg_file_info->is_preload);
        if (ret != 0) {
@@ -3738,6 +3674,8 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
                goto err;
        }
 
+#endif
+
        /* apply privilege for widget */
        if (pkg_file_info->is_widget == true) {
                const char *perm[] = { "http://developer.samsung.com/tizen/privilege/dynamicbox.provider", NULL };
@@ -3767,17 +3705,13 @@ int _coretpk_installer_mount_install_package(const char *pkgfile, const pkginfo
 
 err: ;
 
-       if(is_MIC_env) {
-               _installer_util_delete_dir(tmp_dir);
-               _coretpk_installer_mount_install_create_symbolic_links(pkgfile, pkgid, ".pkg");
-       }else {
-               int res = _coretpk_dbus_unmount_file(mnt_path[0]);
-               if(res){
-                       _LOGE("TPK Unmount Error");
-               }
-               FREE_AND_NULL(mnt_path[0]);
-               FREE_AND_NULL(mnt_path[1]);
+       int res = _coretpk_dbus_unmount_file(mnt_path[0]);
+       if(res){
+               _LOGE("TPK Unmount Error");
        }
+       sleep(2);
+       FREE_AND_NULL(mnt_path[0]);
+       FREE_AND_NULL(mnt_path[1]);
 
        if (optional_data) {
                bundle_free(optional_data);
@@ -3838,30 +3772,17 @@ int _coretpk_installer_prepare_mount_install(const char *pkg_file, const char *c
        pkginfo *pkg_file_info = NULL;
 
        char dest_tpk_path[BUF_SIZE] = {'\0'};
-       char abs_path[PATH_MAX+1] = {'\0'};
-       char *ptr = NULL;
-       char buf[BUF_SIZE] = {'\0'};
-
-       ptr = realpath(pkg_file, abs_path);
-       if(!ptr) {
-               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
-                       _LOGE("realpath() failed [%d][%s]", errno, buf);
-               }
-               ret = RPM_INSTALLER_ERR_INTERNAL;
-               goto catch;
-       }
 
        /* Copy ".tpk" file to /opt/usr/share/packages/xxx.tpk */
-       char *filename = strrchr(abs_path, '/');
+       char *filename = strrchr(pkg_file, '/');
        filename++;
-
        snprintf(dest_tpk_path, PKG_MAX_LEN, "%s/%s", USR_PACKAGES,filename);
-       if(strcmp(abs_path, dest_tpk_path) != 0){
-               ret = _installer_util_copy_file(abs_path, dest_tpk_path);
+       if(strcmp(pkg_file, dest_tpk_path) != 0){
+               ret = _installer_util_copy_file(pkg_file, dest_tpk_path);
        }
 
-       pkg_file_info = _coretpk_installer_get_pkgfile_info(abs_path, CORETPK_INSTALL_CMD);
-       tryvm_if(pkg_file_info == NULL, ret = RPM_INSTALLER_ERR_PACKAGE_INVALID, "_coretpk_installer_get_pkgfile_info(%s) failed.", abs_path);
+       pkg_file_info = _coretpk_installer_get_pkgfile_info(pkg_file, CORETPK_INSTALL_CMD);
+       tryvm_if(pkg_file_info == NULL, ret = RPM_INSTALLER_ERR_PACKAGE_INVALID, "_coretpk_installer_get_pkgfile_info(%s) failed.", pkg_file);
        tryvm_if(strlen(pkg_file_info->package_name) == 0, ret = RPM_INSTALLER_ERR_PACKAGE_INVALID, "package_name is invalid. (len=0)");
 
        if (client_id) {
@@ -3873,11 +3794,11 @@ int _coretpk_installer_prepare_mount_install(const char *pkg_file, const char *c
                pkg_file_info->support_disable = cmd_info->support_disable;
        }
 
-       ret = _coretpk_installer_mount_install_package(abs_path, pkg_file_info);
+       ret = _coretpk_installer_mount_install_package(pkg_file, pkg_file_info);
        if (ret != 0) {
-               _LOGE("_coretpk_installer_prepare_package_install(%s) failed. ret=[%d]", abs_path, ret);
+               _LOGE("_coretpk_installer_prepare_package_install(%s) failed. ret=[%d]", pkg_file, ret);
        } else {
-               _LOGD("[%s] is installed successfully.", abs_path);
+               _LOGD("[%s] is installed successfully.", pkg_file);
        }
 
 catch:
@@ -4017,13 +3938,10 @@ int __coretpk_installer_delta_apply_file(char *pkgid, char *file)
        char to_file[BUF_SIZE] = { 0 };
        char buf[BUF_SIZE] = { 0, };
        int i = 0;
-       char *path = NULL;
-       char *p = NULL;
-       int idx = 0;
 
        snprintf(delta_file, BUF_SIZE, "%s/%s%s/%s", OPT_USR_APPS, pkgid, DELTA_DIR, file);
        snprintf(to_file, BUF_SIZE, "%s/%s%s/%s", OPT_USR_APPS, pkgid, NEW_DIR, file);
-       snprintf(from_file, BUF_SIZE, "%s/%s/%s", OPT_USR_APPS, pkgid, file);
+       snprintf(from_file, BUF_SIZE, "%s/%s%s/%s", OPT_USR_APPS, pkgid, NEW_DIR, file);
 
        /* Check whether old file is present or not */
        if (access(from_file, F_OK) != 0) {
@@ -4038,30 +3956,6 @@ int __coretpk_installer_delta_apply_file(char *pkgid, char *file)
                goto catch;
        }
 
-       if (access(to_file, F_OK) != 0) {
-               path = strdup(to_file);
-               tryvm_if(path == NULL, ret = -1, "out of memory");
-               p = strrchr(path, '/');
-               tryvm_if(p == NULL, ret = -1, "strrchr(%s) failed.", path);
-
-               p++;
-               idx = strlen(path) - strlen(p);
-               path[idx] = '\0';
-
-               /* make the parent dir */
-               if (access(path, F_OK) != 0) {
-                       ret = _installer_util_mkpath(path, DIRECTORY_PERMISSION_755);
-                       if (ret < 0) {
-                               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
-                                       _LOGE("mkdir(%s) failed. [%d][%s]", path, errno, buf);
-                               }
-                               ret = RPM_INSTALLER_ERR_INTERNAL;
-                               goto catch;
-                       }
-                       _LOGD("create directory=[%s]", path);
-               }
-       }
-
        /* Check whether delta of file is present or not */
        if (access(DELTA_TOOL, F_OK | X_OK) != 0) {
                if( strerror_r(errno, buf, sizeof(buf)) == 0) {
@@ -4079,14 +3973,11 @@ int __coretpk_installer_delta_apply_file(char *pkgid, char *file)
        }
        ret = _ri_xsystem(delta_argv);
        if (ret != 0) {
-               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
-                       _LOGE("failed to apply delta for file [%s] [Error = %s]", file, buf);
-               }
+               _LOGE("failed to apply delta for file =[%s], ret=[%d]", file, ret);
                goto catch;
        }
 
 catch:
-       FREE_AND_NULL(path);
        return ret;
 }
 
@@ -4137,7 +4028,7 @@ int __coretpk_installer_delta_remove_file(char *pkgid, char *file)
        char dest_file[BUF_SIZE] = { 0 };
        struct stat stFileInfo = { 0 };
 
-       snprintf(dest_file, BUF_SIZE, "%s/%s/%s", OPT_USR_APPS, pkgid, file);
+       snprintf(dest_file, BUF_SIZE, "%s/%s%s/%s", OPT_USR_APPS, pkgid, NEW_DIR, file);
 
        if (access(dest_file, F_OK) == 0) {
                if (lstat(dest_file, &stFileInfo) < 0) {
@@ -4246,8 +4137,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
        char *pkgid = NULL;
        int visibility = 0;
        pkgmgrinfo_installed_storage storage;
-       bool is_remove_everything = false;
-       char signature1[BUF_SIZE] = { 0, };
 
        pkgid = deltainfo->pkg_info->package_name;
        if (!pkgid) {
@@ -4278,28 +4167,24 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
                ret = RPM_INSTALLER_ERR_INTERNAL;
                goto catch;
        }
-
-
-       _LOGD("------------------------------------------");
-       _LOGD("Delta package- Update - [%s][%s]", pkgid, pkg_file);
-       _LOGD("------------------------------------------");
-
-       /* terminate running app */
-       __terminate_running_app(pkgid);
-
-
        if ( storage == PMINFO_EXTERNAL_STORAGE ) {
                /*move app to internal storage temporarily for applying delta patch*/
                ret = __coretpk_installer_movepkg_for_delta_upgrade(pkgid, PM_MOVE_TO_INTERNAL);
                if (ret !=0) {
                        _LOGE("__coretpk_installer_movepkg_for_delta_upgrade PM_MOVE_TO_INTERNAL failed!, ret = %d", ret);
                        ret = RPM_INSTALLER_ERR_INTERNAL;
-                       is_remove_everything = true;
                        goto catch;
                }
        }
        _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "install_percent", "20");
 
+       _LOGD("------------------------------------------");
+       _LOGD("Delta package- Update - [%s][%s]", pkgid, pkg_file);
+       _LOGD("------------------------------------------");
+
+       /* terminate running app */
+       __terminate_running_app(pkgid);
+
        /* creates directory for delta package */
        snprintf(delta_pkg_path, BUF_SIZE, "%s/%s%s", OPT_USR_APPS, pkgid, DELTA_DIR);
        ret = _installer_util_create_dir(delta_pkg_path, DIRECTORY_PERMISSION_644);
@@ -4330,6 +4215,7 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
 
        _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "install_percent", "30");
 
+       /* Copy the content of package to an intermediate directory */
        snprintf(appdir, BUF_SIZE, "%s/%s", OPT_USR_APPS, pkgid);
        snprintf(new_appdir, BUF_SIZE, "%s/%s%s", OPT_USR_APPS, pkgid, NEW_DIR);
 
@@ -4339,6 +4225,8 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
                goto catch;
        }
 
+       ret = _installer_util_copy_dir(appdir, new_appdir);
+
        /* Apply the patches of modified files */
        file_list = deltainfo->modify_files_list;
        char *file_path = NULL;
@@ -4353,46 +4241,36 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
                file_list = file_list->next;
        }
 
-       /* Add new files */
-       file_list = deltainfo->add_files_list;
+       /* Add new files and removed unwanted files */
+
+       file_list = deltainfo->remove_files_list;
        while (file_list) {
                file_path = (char *)file_list->data;
-               ret = __coretpk_installer_delta_add_file(pkgid, file_path);
+               ret = __coretpk_installer_delta_remove_file(pkgid, file_path);
                if (ret != 0) {
-                       _LOGE("Adding file failed [%s]", file_path);
+                       _LOGE("Removing file failed[%s]", file_path);
                        ret = RPM_INSTALLER_ERR_INTERNAL;
                        goto catch;
                }
                file_list = file_list->next;
        }
 
-       ret = _installer_util_copy_dir(new_appdir, appdir);
-       if (ret != 0) {
-               _LOGE("Removing file failed[%s]", file_path);
-               ret = RPM_INSTALLER_ERR_INTERNAL;
-               is_remove_everything = true;
-               goto catch;
-       }
-
-       /* Remove unwanted files */
-       file_list = deltainfo->remove_files_list;
+       file_list = deltainfo->add_files_list;
        while (file_list) {
                file_path = (char *)file_list->data;
-               ret = __coretpk_installer_delta_remove_file(pkgid, file_path);
+               ret = __coretpk_installer_delta_add_file(pkgid, file_path);
                if (ret != 0) {
-                       _LOGE("Removing file failed[%s]", file_path);
+                       _LOGE("Adding file failed [%s]", file_path);
                        ret = RPM_INSTALLER_ERR_INTERNAL;
-                       is_remove_everything = true;
                        goto catch;
                }
                file_list = file_list->next;
        }
 
-       ret = _coretpk_installer_verify_signatures(appdir, pkgid, &visibility, NULL);
+       ret = _coretpk_installer_verify_signatures(new_appdir, pkgid, &visibility, NULL);
        if (ret < 0) {
                _LOGE("failed to verify signature and certificate, pkgid=[%s].", pkgid);
                ret = RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED;
-               is_remove_everything = true;
                goto catch;
        } else {
                _LOGD("signature and certificate are verified successfully.");
@@ -4400,7 +4278,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
                if (ret < 0) {
                        _LOGE("@Failed to verify public key verifying[%s].", pkgid);
                        ret = RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED;
-                       is_remove_everything = true;
                        goto catch;
                }
                _LOGD("#author public key verifying success");
@@ -4413,7 +4290,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
        /* Check privilege and visibility */
        ret = _coretpk_installer_verify_privilege_list(pkgid, deltainfo->pkg_info, visibility);
        if (ret != 0) {
-               is_remove_everything = true;
                goto catch;
        }
 
@@ -4423,7 +4299,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
        if (ret != 0) {
                _LOGE("_coretpk_parser_convert_manifest(%s) failed.", pkgid);
                ret = RPM_INSTALLER_ERR_NO_MANIFEST;
-               is_remove_everything = true;
                goto catch;
        }
 
@@ -4431,7 +4306,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
        if (ret < 0) {
                _LOGE("invalid manifest file(schema)");
                ret = RPM_INSTALLER_ERR_INVALID_MANIFEST;
-               is_remove_everything = true;
                goto catch;
        }
 
@@ -4439,7 +4313,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
        if (ret < 0) {
                _LOGE("failed to parse the manifest.");
                ret = RPM_INSTALLER_ERR_INTERNAL;
-               is_remove_everything = true;
                goto catch;
        }
        _ri_unregister_cert(pkgid);
@@ -4451,13 +4324,21 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
        /* register cert info */
        _ri_register_cert(pkgid);
 
+       /* delete app's old */
+       if (access(appdir, F_OK) == 0)
+               _installer_util_delete_dir(appdir);
+
+       ret = rename(new_appdir, appdir);
+       if (ret != 0) {
+               _LOGE("renaming failed src[%s], dest[%s]", new_appdir, appdir);
+               goto catch;
+       }
        _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "install_percent", "80");
 
        /* make directory */
        ret = _coretpk_installer_make_directory(pkgid, false);
        if (ret != 0) {
                _LOGE("failed to make the directory.");
-               is_remove_everything = true;
                goto catch;
        }
 
@@ -4465,7 +4346,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
        ret = _coretpk_installer_apply_smack(pkgid, 1);
        if (ret != 0) {
                _LOGE("failed to apply the smack.");
-               is_remove_everything = true;
                goto catch;
        }
 
@@ -4482,7 +4362,6 @@ int __coretpk_installer_install_delta(const char *pkg_file, delta_info * deltain
                if (ret !=0) {
                        _LOGE("__coretpk_installer_movepkg_for_delta_upgrade  PM_MOVE_TO_SDCARD failed!, ret = %d", ret);
                        ret = RPM_INSTALLER_ERR_INTERNAL;
-                       is_remove_everything = true;
                        goto catch;
                }
        }
@@ -4495,39 +4374,7 @@ catch:
        if (ret == RPM_INSTALLER_SUCCESS) {
                _LOGD("[#]end : _coretpk_installer_install_delta");
                _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "end", "ok");
-
-               // signature1.xml
-               snprintf(signature1, BUF_SIZE, "%s/%s/%s", OPT_USR_APPS, pkgid, SIGNATURE1_XML);
-               if (access(signature1, F_OK) == 0) {
-                       _LOGD("signature1 file is deleted. [%s]", signature1);
-                       (void)remove(signature1);
-               }
        } else {
-
-               /*TODO:need to add recovery logic*/
-
-               if(is_remove_everything) {
-                       /* remove db info */
-                       _coretpk_installer_remove_db_info(pkgid);
-
-                       /* remove xml */
-                       if (access(system_manifest, F_OK) == 0) {
-                               (void)remove(system_manifest);
-                       }
-
-                       /* remove app dir(root_path) */
-                       if (__is_dir(appdir)) {
-                               _installer_util_delete_dir(appdir);
-                       }
-
-                       /* remove ext app dir(/opt/storage/sdcard/apps/pkgid) */
-                       char extpath[BUF_SIZE] = { '\0' };
-                       snprintf(extpath, BUF_SIZE, "%s/%s", OPT_STORAGE_SDCARD_APP_ROOT, pkgid);
-                       if (__is_dir(extpath)) {
-                               _installer_util_delete_dir(extpath);
-                       }
-               }
-
                char *errorstr = NULL;
                _ri_error_no_to_string(ret, &errorstr);
                _ri_broadcast_status_notification(pkgid, PKGTYPE_TPK, "error", errorstr);
@@ -4983,7 +4830,7 @@ int _coretpk_installer_package_reinstall(const char *pkgid, const char *clientid
                snprintf(manifest, BUF_SIZE, "%s/%s", dirpath, CORETPK_XML);
 
                /*compare package's api version with platform version*/
-               pkg_file_info = _coretpk_parser_get_manifest_info(manifest);
+               pkg_file_info = _coretpk_installer_get_pkgfile_info(manifest, NULL);
                if (pkg_file_info == NULL) {
                        _LOGE("failed to get pkginfo from manifest[%s]", manifest);
                        ret = RPM_INSTALLER_ERR_INTERNAL;
@@ -5108,13 +4955,69 @@ err:
        return ret;
 }
 
-int __coretpk_installer_csc_install(const char *path_str, const char *remove_str, const char *csc_script)
+
+int __check_installed_package(pkginfo *info)
+{
+       int ret = 0;
+       pkginfo *dbinfo = NULL;
+       char *pkgid = info->package_name;
+
+       dbinfo = _rpm_installer_get_pkgname_info(pkgid);
+       /* install case */
+       if (dbinfo == NULL) {
+               _LOGD("[##]csc-core : no existing version. csc install case.");
+               return 0;
+       }
+
+       ret = _installer_util_compare_version(dbinfo->version, info->version);
+       if (ret < VERSION_NEW) {
+               /* csc version is not updated so keep existing version */
+               _LOGD("[##]csc-core : csc version is not updated. keep existing version.");
+               if (dbinfo) {
+                       free(dbinfo);
+                       dbinfo = NULL;
+               }
+               return -1;
+       }
+
+       /* upgrade case */
+       _LOGD("[##]csc-core : csc version is updated. csc upgrade case.");
+       /* remove for clean */
+       __ri_remove_updated_dir(pkgid);
+
+       /* unregister cert info */
+       _ri_unregister_cert(pkgid);
+
+       ret = _ri_privilege_unregister_package(pkgid);
+       if (ret < 0) {
+               _LOGE("[##]csc-core : _ri_privilege_unregister_package fail[pkgid=%s].", pkgid);
+       }
+
+       ret = pkgmgr_parser_parse_manifest_for_uninstallation(pkgid, NULL);
+       if (ret < 0) {
+               _LOGE("[##]csc-core : parse uninstall fail[manifest=%s].", pkgid);
+       }
+
+       ret = _ri_smack_reload(pkgid, UNINSTALL_REQ);
+       if (ret != 0) {
+               _LOGE("[##]csc-core : _ri_smack_reload failed[pkgid=%s].", pkgid);
+       }
+
+       if (dbinfo) {
+               free(dbinfo);
+               dbinfo = NULL;
+       }
+
+       return 0;
+}
+
+int _coretpk_installer_csc_install(const char *path_str, const char *remove_str, const char *csc_script)
 {
        retvm_if(path_str == NULL, RPM_INSTALLER_ERR_WRONG_PARAM, "path_str is NULL.");
        retvm_if(remove_str == NULL, RPM_INSTALLER_ERR_WRONG_PARAM, "remove_str is NULL.");
        retvm_if(csc_script == NULL, RPM_INSTALLER_ERR_WRONG_PARAM, "csc_script is NULL.");
 
-       /* ex) rpm-backend -c path=/tmp/org.tizen.corebasicapp2-1.0.0-arm.tpk:op=install:removable=true */
+       /* ex) rpm-backend -k csc-core -s path=/tmp/org.tizen.corebasicapp2-1.0.0-arm.tpk:op=install:removable=true */
 
        int ret = 0;
        pkginfo *info = NULL;
@@ -5128,7 +5031,8 @@ int __coretpk_installer_csc_install(const char *path_str, const char *remove_str
        int visibility = 0;
        bundle *optional_data = NULL;
        char buf[BUF_SIZE] = { 0, };
-       bool is_update = false;
+
+       _LOGD("[##]csc-core : start csc_install[path=%s]", path_str);
 
        info = _coretpk_installer_get_pkgfile_info(path_str, CORETPK_CSC_CMD);
        if (info == NULL || (strlen(info->package_name) == 0)) {
@@ -5137,27 +5041,23 @@ int __coretpk_installer_csc_install(const char *path_str, const char *remove_str
                goto err;
        }
 
+       _LOGD("[##]csc-core : get pkgid [%s]", info->package_name);
+
        dbinfo = _rpm_installer_get_pkgname_info(info->package_name);
        if (dbinfo != NULL) {
                _LOGE("csc_upgrade case!");
+               free(info);
+               free(dbinfo);
 
-               ret = _installer_util_compare_version(dbinfo->version, info->version);
-               if (ret < VERSION_NEW) {
-                       /* csc version is not update. */
-                       _LOGD("[##]csc-core : do not update. csc version is not updated.");
-                       ret = RPM_INSTALLER_SUCCESS;
-                       goto err;
-               }
-
-               is_update = true;
+               return _coretpk_installer_csc_upgrade(path_str, remove_str, csc_script);
        } else {
                snprintf(flag_path, BUF_SIZE, "%s/%s", CSC_FLAG, info->package_name);
                if (access(flag_path, F_OK) == 0) {
                        _LOGD("csc install >> user uninstall case [%s]", info->package_name);
                        _LOGD("keep the status. So need not install csc.");
 
-                       ret = RPM_INSTALLER_SUCCESS;
-                       goto err;
+                       free(info);
+                       return 0;
                } else {
                        _LOGD("first csc install case [%s]", info->package_name);
                }
@@ -5168,16 +5068,17 @@ int __coretpk_installer_csc_install(const char *path_str, const char *remove_str
                bundle_add_str(optional_data, "csc_path", csc_script);
        }
 
-       snprintf(buff, BUF_SIZE, "%s/%s/", OPT_USR_APPS, info->package_name);
+       ret = __check_installed_package(info);
+       if (ret < 0) {
+               _LOGE("do not install or upgrade. keep exsiting version.");
+               ret = 0;
+               goto err;
+       }
 
-       if (is_update == false) {
-               /* If the directory which will be installed exists, remove it. */
-               if (__is_dir(buff)) {
-                       _installer_util_delete_dir(buff);
-               }
-       } else {
-               /* remove dir for clean */
-               __ri_remove_updated_dir(info->package_name);
+       /* If the directory which will be installed exists, remove it. */
+       snprintf(buff, BUF_SIZE, "%s/%s/", OPT_USR_APPS, info->package_name);
+       if (__is_dir(buff)) {
+               _installer_util_delete_dir(buff);
        }
 
        _LOGD("[##]csc-core : real path [%s]", buff);
@@ -5265,26 +5166,13 @@ int __coretpk_installer_csc_install(const char *path_str, const char *remove_str
        csc_tags[1] = "preload=true";
        csc_tags[2] = NULL;
 
-       /* call parser api */
-       if (is_update == false) {
-               ret = pkgmgr_parser_parse_manifest_for_installation(manifest, csc_tags);
-               if (ret < 0) {
-                       _LOGD("fota-info : failed to parse the manifest[%s].", manifest);
-               }
-       } else {
-               ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
-               if (ret < 0) {
-                       _LOGD("fota-info : failed to parse the manifest[%s].", manifest);
-               }
-
-               /* clean cert */
-               _ri_unregister_cert(info->package_name);
-               _ri_privilege_unregister_package(info->package_name);
+       ret = pkgmgr_parser_parse_manifest_for_installation(manifest, csc_tags);
+       if (ret < 0) {
+               _LOGE("pkgmgr_parser_parse_manifest_for_installation(%s) failed.", manifest);
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
        }
 
-       /* search_ug_app */
-       _coretpk_installer_search_ui_gadget(info->package_name);
-
        _LOGD("[##]csc-core : register manifest success");
 
        /* register cert info */
@@ -5343,11 +5231,6 @@ err:
                info = NULL;
        }
 
-       if (dbinfo) {
-               free(dbinfo);
-               dbinfo = NULL;
-       }
-
        if (optional_data) {
                bundle_free(optional_data);
        }
@@ -5355,332 +5238,242 @@ err:
        return ret;
 }
 
-int __coretpk_installer_csc_uninstall(const char *pkgid)
+int _coretpk_installer_csc_upgrade(const char *path_str, const char *remove_str, const char *csc_script)
 {
-       /* ex) rpm-backend -c path=org.tizen.corebasicapp:op=uninstall:removable=true */
+       retvm_if(path_str == NULL, RPM_INSTALLER_ERR_WRONG_PARAM, "path_str is NULL.");
+       retvm_if(remove_str == NULL, RPM_INSTALLER_ERR_WRONG_PARAM, "remove_str is NULL.");
 
        int ret = 0;
-       char flag_path[BUF_SIZE] = { 0, };
-
-       ret = _coretpk_installer_prepare_preload_uninstall(pkgid);
-
-       /* remove csc flag */
-       snprintf(flag_path, BUF_SIZE, "%s/%s", CSC_FLAG, pkgid);
-       if (access(flag_path, F_OK) == 0) {
-               (void)remove(flag_path);
-               _LOGD("flag_path is removed. [%s]", flag_path);
-       } else {
-               _LOGD("flag_path is not existed. [%s]", flag_path);
-       }
+       pkginfo *info = NULL;
+       pkginfo *dbinfo = NULL;
+       char buff[BUF_SIZE] = { '\0' };
+       char manifest[BUF_SIZE] = { '\0' };
+       char cwd[BUF_SIZE] = { '\0' };
+       char *temp = NULL;
+       char *csc_tags[3] = { NULL, };
+       int visibility = 0;
+       char *pkgid = NULL;
+       bundle *optional_data = NULL;
+       char buf[BUF_SIZE] = { 0, };
 
-       return ret;
-}
+       _LOGD("[##]csc-core : start csc_upgrade[path=%s]", path_str);
 
-int _coretpk_installer_prepare_csc(const char *csc_script)
-{
-       int ret = 0;
-       int op_type = 0;
-
-       char *path_str = NULL;
-       char *op_str = NULL;
-       char *remove_str = NULL;
-       char csc_str[BUF_SIZE] = { '\0' };
-       snprintf(csc_str, BUF_SIZE - 1, "%s:", csc_script);
-
-       /* get params from csc script */
-       path_str = _installer_util_get_str(csc_str, TOKEN_PATH_STR);
-       op_str = _installer_util_get_str(csc_str, TOKEN_OPERATION_STR);
-       remove_str = _installer_util_get_str(csc_str, TOKEN_REMOVE_STR);
-       if ((path_str == NULL) || (op_str == NULL) || (remove_str == NULL)) {
-               _LOGE("csc-info : input param is null[%s, %s, %s]\n", path_str, op_str, remove_str);
-               goto end;
+       optional_data = bundle_create();
+       if (optional_data) {
+               bundle_add_str(optional_data, "csc_path", csc_script);
        }
 
-       /* get operation type */
-       if (strcmp(op_str, "install") == 0) {
-               op_type = INSTALL_REQ;
-       } else if (strcmp(op_str, "update") == 0) {
-               op_type = UPGRADE_REQ;
-       } else if (strcmp(op_str, "uninstall") == 0) {
-               op_type = UNINSTALL_REQ;
-       } else {
-               _LOGE("csc-info : operation error[%s]\n", op_str);
-               goto end;
+       info = _coretpk_installer_get_pkgfile_info(path_str, CORETPK_CSC_CMD);
+       if (info == NULL || (strlen(info->package_name) == 0)) {
+               _LOGE("_coretpk_installer_get_pkgfile_info(%s) failed.", path_str);
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
        }
 
-       switch (op_type) {
-       case INSTALL_REQ:
-               ret = __coretpk_installer_csc_install(path_str, remove_str, csc_script);
-               break;
+       pkgid = info->package_name;
 
-       case UPGRADE_REQ:
-               ret = __coretpk_installer_csc_install(path_str, remove_str, csc_script);
-               break;
+       _LOGD("[##]csc-core : get pkgid [%s]", pkgid);
 
-       case UNINSTALL_REQ:
-               ret = __coretpk_installer_csc_uninstall(path_str);
-               break;
+       dbinfo = _rpm_installer_get_pkgname_info(info->package_name);
+       if (dbinfo == NULL) {
+               _LOGE("_rpm_installer_get_pkgname_info(%s) failed.", info->package_name);
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
        }
 
-       if (ret < 0)
-               _LOGE("csc-info : csc fail [pkgid=%s, operation=%d]\n", path_str, op_type);
-
-end:
-       if (path_str)
-               free(path_str);
-       if (op_str)
-               free(op_str);
-       if (remove_str)
-               free(remove_str);
-
-       return ret;
-}
+       if (strcmp(info->version, dbinfo->version) <= 0) {
+               /* csc version is not update. */
+               _LOGD("[##]csc-core : do not update. csc version is not updated.");
+               ret = RPM_INSTALLER_SUCCESS;
+               goto err;
+       }
 
+       _LOGD("[##]csc-core : compare version is done. version is updated.");
 
-static int __coretpk_installer_fota_install(const char *pkgid, bool is_update, bool is_opt_pkg)
-{
-       int ret = 0;
-       int visibility = 0;
-       char manifest[BUF_SIZE] = { 0, };
-       char root_path[BUF_SIZE] = { 0, };
-       char signature[BUF_SIZE] = { 0, };
+       /* remove dir for clean */
+       __ri_remove_updated_dir(pkgid);
 
-       char *usr_fota_argv[] = { "fota=true", NULL };
-       char *opt_fota_argv[3] = { NULL, };
-       opt_fota_argv[0] = "removable=true";
-       opt_fota_argv[1] = "preload=true";
-       opt_fota_argv[2] = NULL;
-
-       _LOGD("fota-info : pkgid[%s], is_opt_pkg[%d] fota start.", pkgid, is_opt_pkg);
+       snprintf(buff, BUF_SIZE, "%s/%s/", OPT_USR_APPS, pkgid);
+       const char *unzip_argv[] = { "/usr/bin/unzip", "-oqq", path_str, "-d", buff, NULL };
+       ret = _ri_xsystem(unzip_argv);
+       if (ret != 0) {
+               _LOGE("failed to unzip for [%s, %d].", buff, ret);
+               goto err;
+       }
 
-       /* clean directory and file */
-       if (is_update == true) {
-               _LOGD("fota-info : package is updated.");
+       _LOGD("[##]csc-core : unzip success[%s]", buff);
 
-               __ri_remove_updated_dir(pkgid);
-               snprintf(manifest, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
-               (void)remove(manifest);
-               memset(manifest, '\0', BUF_SIZE);
+       /* getcwd */
+       temp = getcwd(cwd, BUF_SIZE);
+       if ((temp == NULL) || (cwd[0] == '\0')) {
+               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
+                       _LOGE("getcwd() failed. [%d][%s]", errno, buf);
+               }
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
        }
+       _LOGD("#Current working directory is %s.", cwd);
 
-       /* unzip pkg path from factoryrest data */
-       if (is_opt_pkg == true) {
-               snprintf(root_path, BUF_SIZE, "opt/usr/apps/%s/*", pkgid); // relative path
-               const char *pkg_argv[] = { "/usr/bin/unzip", "-oX", OPT_ZIP_FILE, root_path, "-d", "/", NULL };
-               ret = _ri_xsystem(pkg_argv);
-               if (ret != 0) {
-                       _LOGE("fota-info : fail to unzip [root path = %s, ret = %d].\n", root_path, ret);
-               } else {
-                       _LOGE("fota-info : success to unzip [root path = %s].\n", root_path);
+       /* change dir */
+       ret = chdir(buff);
+       if (ret != 0) {
+               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
+                       _LOGE("chdir(%s) failed. [%d][%s]", buff, errno, buf);
                }
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
+       }
 
-               memset(root_path, '\0', BUF_SIZE);
-               snprintf(root_path, BUF_SIZE, "opt/share/packages/%s.xml", pkgid); // relative path
-               const char *xml_argv[] = { "/usr/bin/unzip", "-oX", OPT_ZIP_FILE, root_path, "-d", "/", NULL };
-               ret = _ri_xsystem(xml_argv);
-               if (ret != 0) {
-                       _LOGE("fota-info : fail to unzip [xml path = %s, ret = %d].\n", root_path, ret);
-               } else {
-                       _LOGE("fota-info : success to unzip [xml path = %s].\n", root_path);
-               }
+       /* check for signature and certificate */
+       ret = _coretpk_installer_verify_signatures(buff, pkgid, &visibility, NULL);
+       if (ret != 0) {
+               _LOGE("_coretpk_installer_verify_signatures(%s, %s) failed.", buff, pkgid);
+               goto err;
        }
+       _LOGD("#signature and certificate verifying success");
 
-       /* get  SHARE_PACKAGES file */
-       if (is_opt_pkg == true) {
-               snprintf(manifest, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
-       } else {
-               snprintf(manifest, BUF_SIZE, "%s/%s.xml", USR_SHARE_PACKAGES, pkgid);
+       /* chdir */
+       ret = chdir(cwd);
+       if (ret != 0) {
+               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
+                       _LOGE("chdir(%s) failed. [%d][%s]", cwd, errno, buf);
+               }
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
        }
 
-       /* access  SHARE_PACKAGES file */
-       if (access(manifest, F_OK) == 0) {
-               _LOGD("fota-info : success to access manefest[%s].", manifest);
-       } else {
-               _LOGD("fota-info : fail to access manefest[%s].", manifest);
+       /* convert manifest and copy the file to /opt/share/packages */
+       snprintf(manifest, BUF_SIZE, "%s/%s/%s", OPT_USR_APPS, pkgid, CORETPK_XML);
+       ret = _coretpk_parser_convert_manifest(manifest, pkgid, NULL, false, visibility, optional_data);
+       if (ret != 0) {
+               _LOGE("_coretpk_parser_convert_manifest(%s, %s) failed.", manifest, pkgid);
+               ret = RPM_INSTALLER_ERR_INVALID_MANIFEST;
+               goto err;
        }
 
-       /* call parser api */
-       if (is_update == false) {
-               ret = pkgmgr_parser_parse_manifest_for_installation(manifest, usr_fota_argv);
-               if (ret < 0) {
-                       _LOGD("fota-info : failed to parse the manifest[%s].", manifest);
-               }
-       } else {
-               ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, opt_fota_argv);
-               if (ret < 0) {
-                       _LOGD("fota-info : failed to parse the manifest[%s].", manifest);
-               }
+       _LOGD("[##]csc-core : manifest converting success");
 
-               /* clean cert */
-               _ri_unregister_cert(pkgid);
-               _ri_privilege_unregister_package(pkgid);
+       /* check the manifest file. */
+       memset(manifest, '\0', sizeof(manifest));
+       snprintf(manifest, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
+       /* compare manifest.xml with schema file(/usr/etc/package-manager/preload/manifest.xsd) */
+       ret = pkgmgr_parser_check_manifest_validation(manifest);
+       if (ret < 0) {
+               _LOGE("pkgmgr_parser_check_manifest_validation(%s) failed.", manifest);
+               ret = RPM_INSTALLER_ERR_INVALID_MANIFEST;
+               goto err;
        }
 
-       _LOGD("fota-info : success to parse the manifest.");
+       _LOGD("[##]csc-core : manifest validation success");
 
-       /* search_ug_app */
-       _coretpk_installer_search_ui_gadget(pkgid);
+       /* set csc tag. */
+       if (strcmp(remove_str, "true") == 0)
+               csc_tags[0] = "removable=true";
+       else
+               csc_tags[0] = "removable=false";
 
-       /* get  root path */
-       memset(root_path, '\0', BUF_SIZE);
-       if (is_opt_pkg == true) {
-               snprintf(root_path, BUF_SIZE, "%s/%s", OPT_USR_APPS, pkgid);
-       } else {
-               snprintf(root_path, BUF_SIZE, "%s/%s", USR_APPS, pkgid);
-       }
+       csc_tags[1] = "preload=true";
+       csc_tags[2] = NULL;
 
-       /* change  root path */
-       ret = chdir(root_path);
-       if (ret != 0) {
-               char buf[BUF_SIZE] = { 0, };
-               if( strerror_r(errno, buf, sizeof(buf)) == 0) {
-                       _LOGE("fota-info : chdir(%s) failed. [%s]", root_path, buf);
-               }
+       /* remove exist csc dbinfo */
+       ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
+       if (ret < 0) {
+               _LOGE("pkgmgr_parser_parse_manifest_for_uninstallation(%s) failed.", manifest);
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
        }
 
-       /* verify signature */
-       snprintf(signature, BUF_SIZE, "%s/signature1.xml", root_path);
-       ret = _ri_verify_sig_and_cert(signature, &visibility, false, NULL);
-       if (ret == 0) {
-               _LOGD("fota-info : success to verify signature1 .");
-       } else {
-               _LOGD("fota-info : fail to verify signature1 [ret = %d].", ret);
+       /* insert new csc info */
+       ret = pkgmgr_parser_parse_manifest_for_installation(manifest, csc_tags);
+       if (ret < 0) {
+               _LOGE("pkgmgr_parser_parse_manifest_for_installation(%s) failed.", manifest);
+               ret = RPM_INSTALLER_ERR_INTERNAL;
+               goto err;
        }
 
-       /* verify author */
-       memset(signature, '\0', BUF_SIZE);
-       snprintf(signature, BUF_SIZE, "%s/author-signature.xml", root_path);
-       ret = _ri_verify_sig_and_cert(signature, &visibility, false, NULL);
-       if (ret == 0) {
-               _LOGD("fota-info : success to verify author-signature [visibility = %d].", visibility);
-               _ri_register_cert(pkgid);
-       } else {
-               _LOGD("fota-info : fail to verify author-signature [visibility = %d, ret = %d].", visibility, ret);
-       }
+       _LOGD("[##]csc-core : register manifest success");
 
-       /* make pkg directory */
-       ret = _coretpk_installer_make_directory(pkgid, true);
+       /* search_ug_app */
+       _coretpk_installer_search_ui_gadget(pkgid);
+
+       /* unregister cert info */
+       _ri_unregister_cert(pkgid);
+
+       /* register cert info */
+       _ri_register_cert(pkgid);
+
+       /* make directory */
+       ret = _coretpk_installer_make_directory(pkgid, false);
        if (ret != 0) {
-               _LOGE("fota-info : fail to make_directory [pkgid = %s, ret = %d]\n", pkgid, ret);
-       } else {
-               _LOGD("fota-info : success to _make_directory.");
+               _LOGE("_coretpk_installer_make_directory(%s) failed.", pkgid);
+               goto err;
        }
 
-       /* apply smack to pkg dir */
+       _LOGD("[##]csc-core : make directory success");
+
+       /* Remove origin rule */
+       _ri_privilege_unregister_package(pkgid);
+
+       /* apply smack to app dir */
        ret = _coretpk_installer_apply_smack(pkgid, 1);
        if (ret != 0) {
-               _LOGE("fota-info : fail to apply_smack [pkgid = %s, ret = %d]\n", pkgid, ret);
-       } else {
-               _LOGD("fota-info : success to apply_smack.");
+               _LOGE("_coretpk_installer_apply_smack(%s) failed.", pkgid);
+               goto err;
        }
 
-       /* apply privilege to pkg dir */
+       _LOGD("[##]csc-core : apply_smack success");
+
+       /* apply smack by privilege */
        ret = _ri_apply_privilege(pkgid, visibility, NULL);
-       if (ret < 0) {
-               _LOGE("fota-info : fail to apply_privilege [pkgid = %s, ret = %d]\n", pkgid, ret);
-       } else {
-               _LOGD("fota-info : success to apply_privilege.");
+       if (ret != 0) {
+               _LOGE("_ri_apply_privilege(%s) failed. ret=[%d]", pkgid, ret);
        }
 
-       _LOGD("fota-info : pkgid[%s] fota finish[ret = %d].", pkgid, ret);
-
-       return ret;
-}
-
-static int __coretpk_installer_fota_uninstall(char *pkgid)
-{
-       _LOGD("fota-info : pkgid[%s] start uninstallation\n", pkgid);
-
-       int ret = 0;
-       char pkgpath[BUF_SIZE] = { '\0' };
-
-       /* del root path dir */
-       snprintf(pkgpath, BUF_SIZE, "%s/%s", OPT_USR_APPS, pkgid);
-       _installer_util_delete_dir(pkgpath);
-
-       memset(pkgpath, '\0', BUF_SIZE);
-       snprintf(pkgpath, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
-       (void)remove(pkgpath);
+       _LOGD("[##]csc-core : apply_privilege success");
 
-       /* del root path dir for ext */
-       memset(pkgpath, '\0', BUF_SIZE);
-       snprintf(pkgpath, BUF_SIZE, "%s/%s", OPT_STORAGE_SDCARD_APP_ROOT, pkgid);
-       if (__is_dir(pkgpath)) {
-               _installer_util_delete_dir(pkgpath);
+       ret = RPM_INSTALLER_SUCCESS;
+err:
+       if (ret == 0) {
+               _LOGD("[##]csc-core : update csc core success");
+       } else {
+               _LOGD("[##]csc-core : update csc core fail");
        }
 
-       /* Unregister cert info */
-       _ri_unregister_cert(pkgid);
-
-       ret = _ri_privilege_unregister_package(pkgid);
-       if (ret < 0) {
-               _LOGE("fota-info : _ri_privilege_unregister_package fail[smack_label=%s]\n", pkgid);
+       if (info) {
+               _installer_util_free_pkg_info(info);
+               info = NULL;
        }
 
-       ret = pkgmgr_parser_parse_manifest_for_uninstallation(pkgid, NULL);
-       if (ret < 0) {
-               _LOGE("fota-info : uninstall fail[pkgid=%s]\n", pkgid);
+       if (dbinfo) {
+               free(dbinfo);
+               dbinfo = NULL;
        }
 
-       _LOGD("fota-info : pkgid[%s] uninstall success\n", pkgid);
+       if (optional_data) {
+               bundle_free(optional_data);
+       }
 
        return ret;
 }
 
-int _coretpk_installer_prepare_fota(char *fota_script, bool is_opt_pkg)
+int _coretpk_installer_csc_uninstall(const char *pkgid)
 {
-       int ret = 0;
-       int op_type = 0;
-       char *pkgid = NULL;
-       char *op_str = NULL;
+       /* ex) rpm-backend -k csc-core -s path=org.tizen.corebasicapp:op=uninstall:removable=true */
 
-       char csc_str[BUF_SIZE] = { '\0' };
-       snprintf(csc_str, BUF_SIZE - 1, "%s:", fota_script);
+       int ret = 0;
+       char flag_path[BUF_SIZE] = { 0, };
 
-       /* get params from fota script */
-       pkgid = _installer_util_get_str(csc_str, TOKEN_PATH_STR);
-       op_str = _installer_util_get_str(csc_str, TOKEN_OPERATION_STR);
-       if ((pkgid == NULL) || (op_str == NULL)) {
-               _LOGE("fota-info : input param is null[%s, %s]\n", pkgid, op_str);
-               goto end;
-       }
-       _LOGD("fota-info : path=%s, op=%s\n", pkgid, op_str);
+       ret = _coretpk_installer_prepare_preload_uninstall(pkgid);
 
-       /* get operation type */
-       if (strcmp(op_str, "install") == 0) {
-               op_type = INSTALL_REQ;
-       } else if (strcmp(op_str, "update") == 0) {
-               op_type = UPGRADE_REQ;
-       } else if (strcmp(op_str, "uninstall") == 0) {
-               op_type = UNINSTALL_REQ;
+       /* remove csc flag */
+       snprintf(flag_path, BUF_SIZE, "%s/%s", CSC_FLAG, pkgid);
+       if (access(flag_path, F_OK) == 0) {
+               (void)remove(flag_path);
+               _LOGD("flag_path is removed. [%s]", flag_path);
        } else {
-               _LOGE("fota-info : operation error[%s, %s]\n", pkgid, op_str);
-               goto end;
-       }
-
-       switch (op_type) {
-       case INSTALL_REQ:
-               ret = __coretpk_installer_fota_install(pkgid, false, is_opt_pkg);
-               break;
-
-       case UPGRADE_REQ:
-               ret = __coretpk_installer_fota_install(pkgid, true, is_opt_pkg);
-               break;
-
-       case UNINSTALL_REQ:
-               ret = __coretpk_installer_fota_uninstall(pkgid);
-               break;
+               _LOGD("flag_path is not existed. [%s]", flag_path);
        }
 
-       if (ret < 0)
-               _LOGE("fota-info : Fota fail [pkgid=%s, operation=%d]\n", pkgid, op_type);
-
-end:
-       if (pkgid)
-               free(pkgid);
-       if (op_str)
-               free(op_str);
-
        return ret;
 }
 
index 184eb56..77794f0 100755 (executable)
@@ -44,6 +44,10 @@ extern "C" {
 
 int _coretpk_installer_package_reinstall(const char *dirpath, const char *clientid);
 
+int _coretpk_installer_csc_install(const char *path_str, const char *remove_str, const char *csc_script);
+int _coretpk_installer_csc_upgrade(const char *path_str, const char *remove_str, const char *csc_script);
+int _coretpk_installer_csc_uninstall(const char *pkgid);
+
 pkginfo *_coretpk_installer_get_pkgfile_info(const char *pkgfile, int cmd);
 
 int _coretpk_installer_change_mode(const char* path, int mode);
@@ -62,9 +66,6 @@ int _coretpk_installer_remove_db_info(const char *pkgid);
 int __coretpk_patch_trimmed_api_version(const char *api_version, char **trim_api_version);
 int __coretpk_patch_padded_api_version(const char *api_version, char **pad_api_version);
 
-int __coretpk_installer_csc_install(const char *path_str, const char *remove_str, const char *csc_script);
-int __coretpk_installer_csc_uninstall(const char *pkgid);
-
 #ifdef _APPFW_FEATURE_MOUNT_INSTALL
 int _coretpk_dbus_mount_file(char *mnt_path[], const char *pkgid);
 int _coretpk_dbus_unmount_file(char *mnt_path);
index 431f408..1c23257 100755 (executable)
@@ -603,14 +603,6 @@ int _coretpk_installer_request_hybrid(int hybridOperation, const char *pPkgPath,
        __coretpk_parser_hybrid_convert_api_visibility(privilegeLevel, &apiVisibility);
        _LOGD("hybrid_convert_api_visibility(%d => %d) is done.", privilegeLevel, apiVisibility);
 
-       /* Check privilege and visibility */
-       ret = _coretpk_installer_verify_privilege_list((char*)info->package_name, info, apiVisibility);
-       if (ret != 0) {
-               _LOGD("_coretpk_installer_verify_privilege_list(%s) failed.", info->package_name);
-               _installer_util_free_pkg_info(info);
-               return -1;
-       }
-
        // convert core xml
        ret = _coretpk_installer_hybrid_convert_manifest(core_xml, info->package_name, apiVisibility);
        if (ret != 0) {
index cf0e7ce..c432972 100755 (executable)
@@ -505,36 +505,6 @@ static int __coretpk_parser_remove_onboot_autorestart(xmlDocPtr doc)
        return 0;
 }
 
-static int __coretpk_parser_remove_mouse_event(xmlDocPtr doc)
-{
-       int ret;
-
-       retv_if(doc == NULL, RPM_INSTALLER_ERR_WRONG_PARAM);
-
-       ret = __coretpk_parser_remove_attribute(doc, (xmlChar *) "//*[name() = 'widget']/*[name() = 'box']/*[name() = 'size']/@mouse_event");
-       if (ret == -1) {
-               _LOGE("failed to remove mouse_event attribute");
-               return -1;
-       }
-
-       return 0;
-}
-
-static int __coretpk_parser_remove_support_mode(xmlDocPtr doc)
-{
-       int ret;
-
-       retv_if(doc == NULL, RPM_INSTALLER_ERR_WRONG_PARAM);
-
-       ret = __coretpk_parser_remove_attribute(doc, (xmlChar *) "//@support-mode");
-       if (ret == -1) {
-               _LOGE("failed to remove support-mode attribute");
-               return -1;
-       }
-
-       return 0;
-}
-
 static int __coretpk_parser_check_api_version(char *api_version, unsigned int required_major, unsigned int required_minor, unsigned int required_micro, int *result)
 {
        char *api_version_dup;
@@ -669,15 +639,12 @@ int _coretpk_parser_convert_manifest(const char *tizen_manifest, const char *pkg
        __coretpk_parser_get_value(context, "//*[name() ='manifest']", "api-version", api_version, sizeof(api_version));
        __coretpk_parser_check_api_version(api_version, 2, 4, 0, &result);
 
-       if (!((api_visibility & CERT_SVC_VISIBILITY_PARTNER) ||
-               (api_visibility & CERT_SVC_VISIBILITY_PARTNER_OPERATOR) ||
-               (api_visibility & CERT_SVC_VISIBILITY_PARTNER_MANUFACTURER) ||
-               (api_visibility & CERT_SVC_VISIBILITY_PLATFORM))) {
-               if (result == 0 || result == -1) {
+       if (result == 0 || result == -1) {
+               if (!((api_visibility & CERT_SVC_VISIBILITY_PARTNER) ||
+                       (api_visibility & CERT_SVC_VISIBILITY_PARTNER_OPERATOR) ||
+                       (api_visibility & CERT_SVC_VISIBILITY_PARTNER_MANUFACTURER) ||
+                       (api_visibility & CERT_SVC_VISIBILITY_PLATFORM)))
                        __coretpk_parser_remove_onboot_autorestart(doc);
-                       __coretpk_parser_remove_mouse_event(doc);
-               }
-               __coretpk_parser_remove_support_mode(doc);
        }
 #endif
 
@@ -1234,10 +1201,8 @@ int _coretpk_mount_install_parser_convert_manifest(const char *tizen_manifest, c
                if (!((api_visibility & CERT_SVC_VISIBILITY_PARTNER) ||
                        (api_visibility & CERT_SVC_VISIBILITY_PARTNER_OPERATOR) ||
                        (api_visibility & CERT_SVC_VISIBILITY_PARTNER_MANUFACTURER) ||
-                       (api_visibility & CERT_SVC_VISIBILITY_PLATFORM))) {
+                       (api_visibility & CERT_SVC_VISIBILITY_PLATFORM)))
                        __coretpk_parser_remove_onboot_autorestart(doc);
-                       __coretpk_parser_remove_mouse_event(doc);
-               }
        }
 
        (void)remove(system_manifest);
index ba12956..fd519e8 100755 (executable)
@@ -62,6 +62,7 @@ static int __ri_clear_private_data(char *pkgid);
 static int __ri_move_package(char *pkgid, int move_type);
 static inline int __ri_read_proc(const char *path, char *buf, int size);
 static inline int __ri_find_pid_by_cmdline(const char *dname, const char *cmdline, const char *priv);
+static bool __ri_is_another_instance_running(const char *exepath);
 
 static int __ri_uninstall_package(char *pkgid)
 {
@@ -155,6 +156,37 @@ static inline int __ri_find_pid_by_cmdline(const char *dname, const char *cmdlin
        return pid;
 }
 
+static bool __ri_is_another_instance_running(const char *exepath)
+{
+       DIR *dp;
+       struct dirent entry, *result;
+       int pid;
+       int ret;
+       char buf[256] = { 0, };
+       dp = opendir("/proc");
+       if (dp == NULL) {
+               return 0;
+       }
+       for (ret = readdir_r(dp, &entry, &result);
+                       ret == 0 && result != NULL;
+                       ret = readdir_r(dp, &entry, &result)) {
+               if (!isdigit(entry.d_name[0]))
+                       continue;
+               ret = aul_app_get_cmdline_bypid((pid_t)atoi(entry.d_name), buf, 256);
+               if (ret != 0)
+                       continue;
+               pid = __ri_find_pid_by_cmdline(entry.d_name, buf, exepath);
+               if (pid > 0) {
+                       closedir(dp);
+                       return 1;
+               }
+       }
+
+       closedir(dp);
+       return 0;
+
+}
+
 static int __ri_native_recovery(int lastbackstate)
 {
        char *pn = NULL;
@@ -249,9 +281,7 @@ static int __ri_check_root_path(const char *pkgid)
 
        snprintf(dirpath, BUF_SIZE, "%s/%s", USR_APPS, pkgid);
 
-       if (stat(pkgid, &stFileInfo) < 0) {
-               return 0;
-       }
+       (void)stat(dirpath, &stFileInfo);
 
        if (S_ISDIR(stFileInfo.st_mode)) {
                return 0;                               /* it means "/usr/apps/pkgid" */
@@ -447,14 +477,7 @@ int _ri_init_db(const char *xml_path)
 
        // smack
        _LOGD("apply smack for rpm");
-#ifdef _APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY
        __ri_make_directory(pkg_id);
-#else
-       ret = _coretpk_installer_make_directory(pkg_id, true);
-       if (ret < 0) {
-               _LOGE("_coretpk_installer_make_directory failed. ret=[%d]", ret);
-       }
-#endif
        _ri_apply_smack(pkg_id, __ri_check_root_path(pkg_id), smack_label);
 
        spend_time = __check_time(check_time);
@@ -615,6 +638,34 @@ static int __ri_process_smack(char *keyid, char *pkgid)
                        _LOGD("install csc xml success\n");
                }
 
+               /* check csc coretpk */
+       } else if (strcmp(keyid, "csc-core") == 0) {
+               _LOGD("csc for coretpk\n");
+               ret = _rpm_process_csc_coretpk(pkgid);
+               if (ret != 0) {
+                       _LOGE("install coretpk csc failed with err(%d)\n", ret);
+               } else {
+                       _LOGD("install coretpk csc success\n");
+               }
+
+               /* check fota */
+       } else if (strcmp(keyid, "rpm-fota") == 0) {
+               _LOGD("fota process for rpm\n");
+               ret = _rpm_process_fota(pkgid);
+               if (ret != 0) {
+                       _LOGE("fota process failed with err(%d)\n", ret);
+               } else {
+                       _LOGD("fota process success\n");
+               }
+               /* check fota */
+       } else if (strcmp(keyid, "rpm-rw-fota") == 0) {
+               _LOGD("rw fota process for rpm\n");
+               ret = _rpm_process_fota_for_rw(pkgid);
+               if (ret != 0) {
+                       _LOGE("rw fota process failed with err(%d)\n", ret);
+               } else {
+                       _LOGD("rw fota process success\n");
+               }
                /* Check initdb */
        } else if (strcmp(keyid, "rpm_initdb") == 0) {
                _LOGD("initdb request for rpms");
@@ -747,7 +798,6 @@ int _rpm_backend_interface(char *keyid, char *pkgid, char *reqcommand, char *cli
                 * or something went wrong in last execution
                 * Check for it
                 */
-                /*
                if (__ri_is_another_instance_running(RPM)) {
                        if (data.pkgid) {
                                _ri_broadcast_status_notification(data.pkgid, PKGTYPE_RPM, "error", "Another Instance Running");
@@ -767,8 +817,7 @@ int _rpm_backend_interface(char *keyid, char *pkgid, char *reqcommand, char *cli
                                data.cmd_string = NULL;
                        }
                        return ret;
-               } else */
-               {
+               } else {
                        int lastbackstate;
 
                        /* check the current state of backend */
index 1596037..462390f 100755 (executable)
@@ -290,7 +290,14 @@ static void __ri_free_cert_chain()
 
 static void __ri_xmlsec_debug_print(const char *file, int line, const char *func, const char *errorObject, const char *errorSubject, int reason, const char *msg)
 {
-       _SLOGE("[%s(%d)] : [%s] : [%s] : [%d] : [%s]", func, line, errorObject, errorSubject, reason, msg);
+       char total[BUF_SIZE];
+       snprintf(total, sizeof(total), "[%s(%d)] : [%s] : [%s] : [%s]", func, line, errorObject, errorSubject, msg);
+       if (reason != 256) {
+               fprintf(stderr, "## [validate error]: %s\n", total);
+               _LOGE("%s", total);
+       } else {
+               _LOGE("%s", total);
+       }
 }
 
 static int __ri_verify_file(xmlSecKeysMngrPtr sec_key_mngr, const char *sigxmlfile)
@@ -734,12 +741,10 @@ int __is_dir(const char *dirname)
        struct stat stFileInfo;
        if (dirname == NULL) {
                _LOGE("dirname is null\n");
-               return 0;
+               return -1;
        }
 
-       if (stat(dirname, &stFileInfo) < 0) {
-               return 0;
-       }
+       (void)stat(dirname, &stFileInfo);
 
        if (S_ISDIR(stFileInfo.st_mode)) {
                return 1;
@@ -1069,6 +1074,236 @@ char *__strlwr(char *str)
        return str;
 }
 
+static int __ri_install_fota(const char *pkgid)
+{
+       int ret = 0;
+       int visibility = 0;
+       char manifest[BUF_SIZE] = { 0, };
+       char rw_manifest[BUF_SIZE] = { 0, };
+       char root_path[BUF_SIZE] = { 0, };
+       char signature_file[BUF_SIZE] = { 0, };
+       char *fota_version = NULL;
+       char *temp[] = { "fota=true", NULL };
+       pkginfo *db_info = NULL;
+       char *smack_label = NULL;
+
+       _LOGD("fota-info : pkgid[%s] start installation.", pkgid);
+
+       snprintf(manifest, BUF_SIZE, "%s/%s.xml", USR_SHARE_PACKAGES, pkgid);
+       snprintf(rw_manifest, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
+
+       _LOGD("fota-info : pkgid[%s] has manefest[%s].", pkgid, manifest);
+
+       if (access(rw_manifest, F_OK) == 0) {
+               _LOGD("fota-info : [%s] is existed.", rw_manifest);
+
+               // compare version(db, fota)
+               db_info = _rpm_installer_get_pkgname_info(pkgid);
+               if (db_info != NULL) {
+                       __get_version_from_xml(manifest, &fota_version);
+                       if (fota_version != NULL) {
+                               _LOGD("fota-info : dbinfo version=[%s], fota version=[%s]", db_info->version, fota_version);
+
+                               ret = _installer_util_compare_version(db_info->version, fota_version);
+                               if (ret == VERSION_NEW) {
+                                       _LOGD("fota is new version. [%s]", manifest);
+                               } else {
+                                       _LOGD("fota is not new version. [%s]", manifest);
+                               }
+                       } else {
+                               _LOGE("fota-info : __get_version_from_xml(%s) failed.", manifest);
+                       }
+
+                       if(fota_version){
+                               free(fota_version);
+                       }
+
+                       if (db_info) {
+                               free(db_info);
+                       }
+
+                       if (ret != VERSION_NEW) {
+                               _LOGD("fota-info : [%s] installation skip. [version is not new]", pkgid);
+                               return 0;
+                       }
+               } else {
+                       _LOGE("fota-info : _rpm_installer_get_pkgname_info(%s) failed.", pkgid);
+               }
+       }
+
+       ret = pkgmgr_parser_parse_manifest_for_installation(manifest, temp);
+       if (ret < 0) {
+               _LOGE("fota-info : installation fail. [manifest=%s]", manifest);
+               ret = -1;
+               goto end;
+       }
+       _LOGD("fota-info : pkgid[%s] installation success.", pkgid);
+
+       snprintf(root_path, BUF_SIZE, "%s/%s", USR_APPS, pkgid);
+       ret = _ri_verify_signatures(root_path, pkgid, false);
+       if (ret == 0) {
+               _LOGD("fota-info : certificate register(%s).", pkgid);
+               _ri_register_cert(pkgid);
+       }
+
+       __ri_make_directory(pkgid);
+
+       ret = __get_smack_label_from_db(pkgid, &smack_label);
+       _LOGD("smack_label[%s], ret[%d]\n", smack_label, ret);
+
+       __rpm_apply_smack(pkgid, 0, smack_label);
+
+       snprintf(signature_file, BUF_SIZE, "%s/%s", root_path, SIGNATURE1_XML);
+       if (access(signature_file, F_OK) != 0){
+               _LOGE("[%s] is not present", signature_file);
+       } else {
+               ret = _ri_get_visibility_from_signature_file(signature_file, &visibility, false);
+               if (ret != 0) {
+                       _LOGE("Couldnt get visiblity [%d], ret: %d", visibility, ret);
+                       ret = RPM_INSTALLER_ERR_INTERNAL;
+                       goto end;
+               } else{
+                       _LOGD("visibility : %d", visibility);
+               }
+       }
+
+       ret = _ri_apply_privilege(pkgid, visibility, smack_label);
+       if (ret < 0) {
+               _LOGE("fota-info : _ri_apply_privilege fail[pkgid=%s]\n", pkgid);
+               ret = -1;
+               goto end;
+       }
+       _LOGD("fota-info : pkgid[%s] apply smack success\n", pkgid);
+
+end:
+       FREE_AND_NULL(smack_label);
+
+       return ret;
+}
+
+static int __ri_upgrade_fota(const char *pkgid)
+{
+       _LOGD("fota-info : pkgid[%s] start upgrade.", pkgid);
+
+       int ret = 0;
+       int visibility = 0;
+       char manifest[BUF_SIZE] = { 0, };
+       char root_path[BUF_SIZE] = { 0, };
+       char signature_file[BUF_SIZE] = { 0, };
+       char *temp[] = { "fota=true", NULL };
+       char *smack_label = NULL;
+
+       /* del manifest */
+       snprintf(manifest, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
+       (void)remove(manifest);
+       memset(manifest, '\0', BUF_SIZE);
+
+       snprintf(manifest, BUF_SIZE, "%s/%s.xml", USR_SHARE_PACKAGES, pkgid);
+       _LOGD("fota-info : pkgid[%s] has manefest[%s].", pkgid, manifest);
+
+       if (access(manifest, F_OK) != 0) {
+               _LOGE("fota-info : can not access[manifest=%s].", manifest);
+               ret = -1;
+               goto end;
+       }
+
+       ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, temp);
+       if (ret < 0) {
+               _LOGE("fota-info : upgrade fail[manifest=%s].", manifest);
+               ret = -1;
+               goto end;
+       }
+
+       snprintf(root_path, BUF_SIZE, "%s/%s", USR_APPS, pkgid);
+       ret = _ri_verify_signatures(root_path, pkgid, false);
+       if (ret == 0) {
+               _LOGD("fota-info : certificate register(%s).", pkgid);
+               _ri_register_cert(pkgid);
+       }
+
+       __ri_make_directory(pkgid);
+
+       ret = __get_smack_label_from_db(pkgid, &smack_label);
+       _LOGD("smack_label[%s], ret[%d]\n", smack_label, ret);
+
+       __rpm_apply_smack(pkgid, 0, smack_label);
+
+       snprintf(signature_file, BUF_SIZE, "%s/%s", root_path, SIGNATURE1_XML);
+       if (access(signature_file, F_OK) != 0){
+               _LOGE("[%s] is not present", signature_file);
+       } else {
+               ret = _ri_get_visibility_from_signature_file(signature_file, &visibility, false);
+               if (ret != 0) {
+                       _LOGE("Couldnt get visiblity [%d], ret: %d", visibility, ret);
+                       ret = RPM_INSTALLER_ERR_INTERNAL;
+                       goto end;
+               } else{
+                       _LOGD("visibility : %d", visibility);
+               }
+       }
+
+       ret = _ri_apply_privilege(pkgid, visibility, smack_label);
+       if (ret < 0) {
+               _LOGE("fota-info : _ri_apply_privilege fail[pkgid=%s].", pkgid);
+       }
+
+       _LOGD("fota-info : pkgid[%s] upgrade success.", pkgid);
+
+end:
+       FREE_AND_NULL(smack_label);
+
+       return ret;
+}
+
+static int __ri_uninstall_fota(char *pkgid)
+{
+       _LOGD("fota-info : pkgid[%s] start uninstallation\n", pkgid);
+
+       int ret = 0;
+       char buff[BUF_SIZE] = { '\0' };
+       char *smack_label = NULL;
+
+       /* del root path dir */
+       snprintf(buff, BUF_SIZE, "%s/%s", OPT_USR_APPS, pkgid);
+       if (__is_dir(buff)) {
+               _installer_util_delete_dir(buff);
+       }
+
+       /* del root path dir for ext */
+       char extpath[BUF_SIZE] = { '\0' };
+       snprintf(extpath, BUF_SIZE, "%s/%s", OPT_STORAGE_SDCARD_APP_ROOT, pkgid);
+       if (__is_dir(extpath)) {
+               _installer_util_delete_dir(extpath);
+       }
+
+       /* Unregister cert info */
+       _ri_unregister_cert(pkgid);
+
+       ret = __get_smack_label_from_db(pkgid, &smack_label);
+       _LOGD("smack_label[%s], ret[%d]\n", smack_label, ret);
+
+       ret = _ri_privilege_unregister_package(smack_label);
+       if (ret < 0) {
+               _LOGE("fota-info : _ri_privilege_unregister_package fail[smack_label=%s]\n", smack_label);
+       }
+
+       ret = pkgmgr_parser_parse_manifest_for_uninstallation(pkgid, NULL);
+       if (ret < 0) {
+               _LOGE("fota-info : uninstall fail[pkgid=%s]\n", pkgid);
+       }
+
+       ret = _ri_smack_reload(smack_label, UNINSTALL_REQ);
+       if (ret != 0) {
+               _LOGD("_ri_smack_reload failed.");
+       }
+
+       _LOGD("fota-info : pkgid[%s] uninstall success\n", pkgid);
+
+       FREE_AND_NULL(smack_label);
+
+       return ret;
+}
+
 static char *__getvalue(const char *pBuf, const char *pKey)
 {
        const char *p = NULL;
@@ -1515,8 +1750,7 @@ int _ri_get_visibility_from_signature_file(const char *sigfile, int *visibility,
 
                err = cert_svc_load_buf_to_context(ctx, (unsigned char *)certval);
                if (err != 0) {
-                       _LOGE("cert_svc_load_buf_to_context() failed. err = [%d]", err);
-                       _SLOGE("cert_svc_load_buf_to_context() failed. cert = [%s]", certval);
+                       _LOGE("cert_svc_load_buf_to_context() failed. cert = [%s], err = [%d]", certval, err);
                        ret = RPM_INSTALLER_ERR_INTERNAL;
                        goto end;
                }
@@ -1524,8 +1758,7 @@ int _ri_get_visibility_from_signature_file(const char *sigfile, int *visibility,
                if (save_ca_path) {
                        err = __ri_create_cert_chain(SIG_DIST1, SIG_SIGNER, certval);
                        if (err) {
-                               _LOGE("__ri_create_cert_chain() failed. sigtype = [%d]", (int)SIG_DIST1);
-                               _SLOGE("__ri_create_cert_chain() failed. cert = [%s]", certval);
+                               _LOGE("__ri_create_cert_chain() failed. sigtype = [%d], certval = [%s]", SIG_DIST1, certval);
                                __ri_free_cert_chain();
                                ret = RPM_INSTALLER_ERR_INTERNAL;
                                goto end;
@@ -1557,8 +1790,7 @@ int _ri_get_visibility_from_signature_file(const char *sigfile, int *visibility,
                if (save_ca_path) {
                        err = __ri_create_cert_chain(SIG_DIST1, SIG_INTERMEDIATE, certval);
                        if (err) {
-                               _LOGE("__ri_create_cert_chain() failed. sigtype = [%d]", (int)SIG_DIST1);
-                               _SLOGE("__ri_create_cert_chain() failed. cert = [%s]", certval);
+                               _LOGE("__ri_create_cert_chain() failed. sigtype = [%d], certval = [%s]", SIG_DIST1, certval);
                                __ri_free_cert_chain();
                                ret = RPM_INSTALLER_ERR_INTERNAL;
                                goto end;
@@ -1570,10 +1802,10 @@ int _ri_get_visibility_from_signature_file(const char *sigfile, int *visibility,
                goto end;
        }
 
-       err = cert_svc_verify_package_certificate(ctx, &validity, sigfile);
+       err = cert_svc_verify_certificate(ctx, &validity);
 
        if (err != 0) {
-               _LOGE("cert_svc_verify_package_certificate() failed.");
+               _LOGE("cert_svc_verify_certificate() failed.");
                ret = RPM_INSTALLER_ERR_INTERNAL;
                goto end;
        }
@@ -1637,7 +1869,7 @@ int _ri_verify_sig_and_cert(const char *sigfile, int *visibility, bool need_veri
        else {
                _LOGE("Unsupported signature type! [%s]", sigfile);
                cert_svc_cert_context_final(ctx);
-               return RPM_INSTALLER_ERR_SIG_INVALID;
+               return RPM_INSTALLER_ERR_INTERNAL;
        }
 
        if (sigtype == SIG_DIST1 && ca_path != NULL && strlen(ca_path) != 0) {
@@ -1674,16 +1906,14 @@ int _ri_verify_sig_and_cert(const char *sigfile, int *visibility, bool need_veri
 
                err = cert_svc_load_buf_to_context(ctx, (unsigned char *)certval);
                if (err != 0) {
-                       _LOGE("cert_svc_load_buf_to_context() failed. err = [%d]", err);
-                       _SLOGE("cert_svc_load_buf_to_context() failed. cert = [%s]", certval);
+                       _LOGE("cert_svc_load_buf_to_context() failed. cert = [%s], err = [%d]", certval, err);
                        ret = RPM_INSTALLER_ERR_CERT_INVALID;
                        goto end;
                }
 
                err = __ri_create_cert_chain(sigtype, SIG_SIGNER, certval);
                if (err) {
-                       _LOGE("__ri_create_cert_chain() failed. sigtype = [%d]", sigtype);
-                       _SLOGE("__ri_create_cert_chain() failed. cert = [%s]", certval);
+                       _LOGE("__ri_create_cert_chain() failed. sigtype = [%d], certval = [%s]", sigtype, certval);
                        __ri_free_cert_chain();
                        ret = RPM_INSTALLER_ERR_CERT_INVALID;
                        goto end;
@@ -1723,8 +1953,7 @@ int _ri_verify_sig_and_cert(const char *sigfile, int *visibility, bool need_veri
 
                err = __ri_create_cert_chain(sigtype, SIG_INTERMEDIATE, certval);
                if (err) {
-                       _LOGE("__ri_create_cert_chain() failed. sigtype = [%d]", sigtype);
-                       _SLOGE("__ri_create_cert_chain() failed. cert = [%s]", certval);
+                       _LOGE("__ri_create_cert_chain() failed. sigtype = [%d], certval = [%s]", sigtype, certval);
                        __ri_free_cert_chain();
                        ret = RPM_INSTALLER_ERR_CERT_INVALID;
                        goto end;
@@ -1735,9 +1964,9 @@ int _ri_verify_sig_and_cert(const char *sigfile, int *visibility, bool need_veri
                goto end;
        }
 
-       err = cert_svc_verify_package_certificate(ctx, &validity, sigfile);
+       err = cert_svc_verify_certificate(ctx, &validity);
        if (err != 0 && (need_verify == true)) {
-               _LOGE("cert_svc_verify_package_certificate() failed. err=[%d]", err);
+               _LOGE("cert_svc_verify_certificate() failed. err=[%d]", err);
                ret = err;
                goto end;
        }
@@ -1752,7 +1981,7 @@ int _ri_verify_sig_and_cert(const char *sigfile, int *visibility, bool need_veri
        err = cert_svc_get_visibility(ctx, visibility);
        if (err != 0) {
                _LOGE("cert_svc_get_visibility() failed. err = [%d]", err);
-               ret = RPM_INSTALLER_ERR_CERT_INVALID;
+               ret = RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED;
                goto end;
        }
        _LOGD("cert_svc_get_visibility() returns visibility=[%d]", *visibility);
@@ -1770,20 +1999,17 @@ verify_sig:
        if (root_ca_path != NULL && strlen(root_ca_path) != 0) {
                _LOGD("Root CA cert path=[%s]", root_ca_path);
 
-               if (need_verify == true) {
-                       err = __ri_xmlsec_verify_signature(sigfile, root_ca_path);
-                       if (err < 0) {
-                               _LOGE("__ri_xmlsec_verify_signature(%s) failed.", sigfile);
-                               ret = RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED;
-                               goto end;
-                       }
+               err = __ri_xmlsec_verify_signature(sigfile, root_ca_path);
+               if (err < 0 && (need_verify == true)) {
+                       _LOGE("__ri_xmlsec_verify_signature(%s) failed.", sigfile);
+                       ret = RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED;
+                       goto end;
                }
 
                crt = __ri_get_cert_from_file(root_ca_path);
                err = __ri_create_cert_chain(sigtype, SIG_ROOT, crt);
                if (err) {
-                       _LOGE("__ri_create_cert_chain() failed. sigtype = [%d]", sigtype);
-                       _SLOGE("__ri_create_cert_chain() failed. cert = [%s]", crt);
+                       _LOGE("__ri_create_cert_chain(%d) failed.", sigtype);
                        __ri_free_cert_chain();
                        ret = RPM_INSTALLER_ERR_CERT_INVALID;
                        goto end;
@@ -2022,6 +2248,243 @@ catch:
        return ret;
 }
 
+static int __ri_install_fota_for_rw(char *pkgid)
+{
+       int ret = 0;
+       int home_dir = 1;
+       char buff[BUF_SIZE] = { '\0' };
+       char *smack_label = NULL;
+       int visibility = 0;
+       char signature_file[BUF_SIZE] = {0, };
+
+       _LOGD("fota-info : pkgid[%s] start installation\n", pkgid);
+
+       /* unzip pkg path from factoryrest data */
+       snprintf(buff, BUF_SIZE, "opt/usr/apps/%s/*", pkgid); // relative path
+       const char *pkg_argv[] = { "/usr/bin/unzip", "-oX", OPT_ZIP_FILE, buff, "-d", "/", NULL };
+       ret = _ri_xsystem(pkg_argv);
+       if (ret != 0) {
+               _LOGE("fota-info : unzip root path[%s] is fail .\n", buff);
+       } else {
+               _LOGE("fota-info : unzip root path[%s] is success\n", buff);
+       }
+
+       /* unzip manifest from factoryrest data */
+       memset(buff, '\0', BUF_SIZE);
+       snprintf(buff, BUF_SIZE, "opt/share/packages/%s.xml", pkgid); // relative path
+
+       const char *xml_argv[] = { "/usr/bin/unzip", "-oX", OPT_ZIP_FILE, buff, "-d", "/", NULL };
+       ret = _ri_xsystem(xml_argv);
+       if (ret != 0) {
+               _LOGE("fota-info : xml_argv fail for pkgid[%s] .\n", pkgid);
+       } else {
+               _LOGE("fota-info : xml_argv[%s] is success\n", pkgid);
+       }
+
+       /* get updated manifest path */
+       memset(buff, '\0', BUF_SIZE);
+       snprintf(buff, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
+       _LOGE("Manifest name is %s\n", buff);
+
+       /* apply smack for manifest */
+       ret = __get_smack_label_from_db(pkgid, &smack_label);
+       _LOGD("smack_label[%s], ret[%d]\n", smack_label, ret);
+
+       _ri_privilege_change_smack_label(buff, smack_label, 0); /* 0 is SMACK_LABEL_ACCESS */
+
+       /* register manifest */
+       char *fota_tags[3] = { NULL, };
+       fota_tags[0] = "removable=true";
+       fota_tags[1] = "preload=true";
+       fota_tags[2] = NULL;
+
+       ret = pkgmgr_parser_parse_manifest_for_installation(buff, fota_tags);
+       if (ret < 0) {
+               _LOGE("Parsing Manifest Failed\n");
+               ret = -1;
+               goto err;
+       } else {
+               _LOGE("Parsing Manifest Success\n");
+       }
+
+       memset(buff, '\0', BUF_SIZE);
+       snprintf(buff, BUF_SIZE, "%s/%s", OPT_USR_APPS, pkgid);
+       ret = _ri_verify_signatures(buff, pkgid, false);
+       if (ret == 0) {
+               _LOGE("fota-info : certificate register(%s).", pkgid);
+               _ri_register_cert(pkgid);
+       }
+
+       __ri_make_directory(pkgid);
+       ret = _coretpk_installer_apply_smack(pkgid, 0);
+       if (ret != 0) {
+               _LOGE("failed to apply the smack.");
+       }
+
+       snprintf(signature_file, BUF_SIZE, "%s/%s", buff, SIGNATURE1_XML);
+       if (access(signature_file, F_OK) != 0){
+               _LOGE("[%s] is not present", signature_file);
+       } else {
+               ret = _ri_get_visibility_from_signature_file(signature_file, &visibility, false);
+               if (ret != 0) {
+                       _LOGE("Couldnt get visiblity [%d], ret: %d", visibility, ret);
+                       ret = RPM_INSTALLER_ERR_INTERNAL;
+                       goto err;
+               } else {
+                       _LOGE("visibility : %d", visibility);
+               }
+       }
+
+       ret = _ri_apply_privilege(pkgid, visibility, smack_label);
+       if (ret < 0) {
+               _LOGE("fota-info : _ri_apply_privilege fail[pkgid=%s]\n", pkgid);
+       } else {
+               _LOGE("fota-info : pkgid[%s] apply smack success\n", pkgid);
+       }
+
+err:
+       FREE_AND_NULL(smack_label);
+
+       return ret;
+}
+
+static int __ri_upgrade_fota_for_rw(char *pkgid)
+{
+       int ret = 0;
+       int home_dir = 1;
+       char buff[BUF_SIZE] = { '\0' };
+       int visibility = 0;
+       char signature_file[BUF_SIZE] = {0, };
+       char *smack_label = NULL;
+
+       _LOGD("fota-info : pkgid[%s] start upgrade\n", pkgid);
+
+       /* unzip pkg dir from factoryrest data */
+       snprintf(buff, BUF_SIZE, "opt/usr/apps/%s/*", pkgid); // relative path
+       const char *pkg_argv[] = { "/usr/bin/unzip", "-oX", OPT_ZIP_FILE, buff, "-d", "/", NULL };
+       ret = _ri_xsystem(pkg_argv);
+       if (ret != 0) {
+               _LOGE("fota-info : unzip root path[%s] is fail .\n", buff);
+       } else {
+               _LOGD("fota-info : unzip root path[%s] is success\n", buff);
+       }
+
+       /* unzip manifest from factoryrest data */
+       memset(buff, '\0', BUF_SIZE);
+       snprintf(buff, BUF_SIZE, "opt/share/packages/%s.xml", pkgid); // relative path
+       const char *xml_argv[] = { "/usr/bin/unzip", "-oX", OPT_ZIP_FILE, buff, "-d", "/", NULL };
+       ret = _ri_xsystem(xml_argv);
+       if (ret != 0) {
+               _LOGE("fota-info : unzip manifest[%s] is fail .\n", buff);
+       } else {
+               _LOGD("fota-info : unzip manifest[%s] is success\n", buff);
+       }
+
+       /* get updated manifest path */
+       memset(buff, '\0', BUF_SIZE);
+       snprintf(buff, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
+       _LOGE("Manifest name is %s\n", buff);
+
+       /* apply smack for manifest */
+       ret = __get_smack_label_from_db(pkgid, &smack_label);
+       _LOGD("smack_label[%s], ret[%d]\n", smack_label, ret);
+
+       _ri_privilege_change_smack_label(buff, smack_label, 0); /* 0 is SMACK_LABEL_ACCESS */
+
+       /* register manifest */
+       ret = pkgmgr_parser_parse_manifest_for_upgrade(buff, NULL);
+       if (ret < 0) {
+               _LOGE("Parsing Manifest Failed\n");
+               ret = -1;
+               goto err;
+       } else {
+               _LOGD("Parsing Manifest Success\n");
+       }
+
+       memset(buff, '\0', BUF_SIZE);
+       snprintf(buff, BUF_SIZE, "%s/%s", OPT_USR_APPS, pkgid);
+       ret = _ri_verify_signatures(buff, pkgid, false);
+       if (ret == 0) {
+               _LOGE("fota-info : certificate register(%s).", pkgid);
+               /* Register new cert info */
+               _ri_unregister_cert(pkgid);
+               _ri_register_cert(pkgid);
+       }
+
+       __ri_make_directory(pkgid);
+       ret = _coretpk_installer_apply_smack(pkgid, 0);
+       if (ret != 0) {
+               _LOGE("failed to apply the smack.");
+       }
+
+       snprintf(signature_file, BUF_SIZE, "%s/%s", buff, SIGNATURE1_XML);
+       if (access(signature_file, F_OK) != 0){
+               _LOGE("[%s] is not present", signature_file);
+       } else {
+               ret = _ri_get_visibility_from_signature_file(signature_file, &visibility, false);
+               if (ret != 0) {
+                       _LOGE("Couldnt get visiblity [%d], ret: %d", visibility, ret);
+                       ret = RPM_INSTALLER_ERR_INTERNAL;
+                       goto err;
+               } else {
+                       _LOGE("visibility : %d", visibility);
+               }
+       }
+
+       ret = _ri_apply_privilege(pkgid, visibility, smack_label);
+       if (ret < 0) {
+               _LOGE("fota-info : _ri_apply_privilege fail[pkgid=%s]\n", pkgid);
+       } else {
+               _LOGE("fota-info : pkgid[%s] apply smack success\n", pkgid);
+       }
+
+err:
+       FREE_AND_NULL(smack_label);
+
+       return ret;
+}
+
+static int __ri_uninstall_fota_for_rw(char *pkgid)
+{
+       int ret = 0;
+       char buff[BUF_SIZE] = { '\0' };
+       char *smack_label = NULL;
+
+       _LOGD("fota-info : pkgid[%s] start uninstall\n", pkgid);
+
+       ret = __get_smack_label_from_db(pkgid, &smack_label);
+       _LOGD("smack_label[%s], ret[%d]\n", smack_label, ret);
+
+       /* del root path dir */
+       snprintf(buff, BUF_SIZE, "%s/%s", OPT_USR_APPS, pkgid);
+
+       if (__is_dir(buff)) {
+               _installer_util_delete_dir(buff);
+       }
+
+       /* del manifest */
+       memset(buff, '\0', BUF_SIZE);
+       snprintf(buff, BUF_SIZE, "%s/%s.xml", OPT_SHARE_PACKAGES, pkgid);
+       (void)remove(buff);
+
+       /* del db info */
+       ret = pkgmgr_parser_parse_manifest_for_uninstallation(pkgid, NULL);
+       if (ret < 0) {
+               _LOGE("Parsing Manifest Failed\n");
+       }
+
+       /* execute privilege APIs */
+       _ri_privilege_revoke_permissions(smack_label);
+       _ri_privilege_unregister_package(smack_label);
+
+       /* Unregister cert info */
+       _ri_unregister_cert(pkgid);
+
+       FREE_AND_NULL(smack_label);
+
+       return 0;
+}
+
 /**
  * callback for the pkgmgrinfo_appinfo_get_list used in _rpm_uninstall_pkg()
  */
@@ -3545,6 +4008,177 @@ end:
        return ret;
 }
 
+int _rpm_process_csc_coretpk(const char *csc_script)
+{
+       int ret = 0;
+       int op_type = 0;
+
+       char *path_str = NULL;
+       char *op_str = NULL;
+       char *remove_str = NULL;
+       char csc_str[BUF_SIZE] = { '\0' };
+       snprintf(csc_str, BUF_SIZE - 1, "%s:", csc_script);
+
+       /* get params from csc script */
+       path_str = _installer_util_get_str(csc_str, TOKEN_PATH_STR);
+       op_str = _installer_util_get_str(csc_str, TOKEN_OPERATION_STR);
+       remove_str = _installer_util_get_str(csc_str, TOKEN_REMOVE_STR);
+       if ((path_str == NULL) || (op_str == NULL) || (remove_str == NULL)) {
+               _LOGE("csc-info : input param is null[%s, %s, %s]\n", path_str, op_str, remove_str);
+               goto end;
+       }
+       _LOGD("csc-info : path=%s, op=%s, remove=%s\n", path_str, op_str, remove_str);
+
+       /* get operation type */
+       op_type = __ri_get_op_type(op_str);
+       if (op_type < 0) {
+               _LOGE("csc-info : operation error[%s, %s]\n", path_str, op_str);
+               goto end;
+       }
+
+       switch (op_type) {
+       case INSTALL_REQ:
+               ret = _coretpk_installer_csc_install(path_str, remove_str, csc_script);
+               break;
+
+       case UPGRADE_REQ:
+               ret = _coretpk_installer_csc_upgrade(path_str, remove_str, csc_script);
+               break;
+
+       case UNINSTALL_REQ:
+               ret = _coretpk_installer_csc_uninstall(path_str);
+               break;
+
+       default:
+               break;
+       }
+
+       if (ret < 0)
+               _LOGE("csc-info : csc fail [pkgid=%s, operation=%d]\n", path_str, op_type);
+
+end:
+       if (path_str)
+               free(path_str);
+       if (op_str)
+               free(op_str);
+       if (remove_str)
+               free(remove_str);
+
+       return ret;
+}
+
+int _rpm_process_fota(char *fota_script)
+{
+       int ret = 0;
+       int op_type = 0;
+       char *pkgid = NULL;
+       char *op_str = NULL;
+
+       char csc_str[BUF_SIZE] = { '\0' };
+       snprintf(csc_str, BUF_SIZE - 1, "%s:", fota_script);
+
+       /* get params from fota script */
+       pkgid = _installer_util_get_str(csc_str, TOKEN_PATH_STR);
+       op_str = _installer_util_get_str(csc_str, TOKEN_OPERATION_STR);
+       if ((pkgid == NULL) || (op_str == NULL)) {
+               _LOGE("fota-info : input param is null[%s, %s]\n", pkgid, op_str);
+               goto end;
+       }
+       _LOGD("fota-info : path=%s, op=%s\n", pkgid, op_str);
+
+       /* get operation type */
+       op_type = __ri_get_op_type(op_str);
+       if (op_type < 0) {
+               _LOGE("fota-info : operation error[%s, %s]\n", pkgid, op_str);
+               goto end;
+       }
+
+       switch (op_type) {
+       case INSTALL_REQ:
+               ret = __ri_install_fota(pkgid);
+               break;
+
+       case UPGRADE_REQ:
+               ret = __ri_upgrade_fota(pkgid);
+               break;
+
+       case UNINSTALL_REQ:
+               ret = __ri_uninstall_fota(pkgid);
+               break;
+
+       default:
+               break;
+       }
+
+       if (ret < 0)
+               _LOGE("fota-info : Fota fail [pkgid=%s, operation=%d]\n", pkgid, op_type);
+
+end:
+       if (pkgid)
+               free(pkgid);
+       if (op_str)
+               free(op_str);
+
+       return ret;
+}
+
+int _rpm_process_fota_for_rw(char *fota_script)
+{
+       int ret = 0;
+       int op_type = 0;
+       char *pkgid = NULL;
+       char *op_str = NULL;
+
+       char fota_str[BUF_SIZE] = { '\0' };
+       snprintf(fota_str, BUF_SIZE - 1, "%s:", fota_script);
+
+       /* get params from fota script */
+       pkgid = _installer_util_get_str(fota_str, TOKEN_PATH_STR);
+       op_str = _installer_util_get_str(fota_str, TOKEN_OPERATION_STR);
+       if ((pkgid == NULL) || (op_str == NULL)) {
+               _LOGE("fota-info : input param is null[%s, %s]\n", pkgid, op_str);
+               goto end;
+       }
+       _LOGD("fota-info : path=%s, op=%s\n", pkgid, op_str);
+
+       /* get operation type */
+       op_type = __ri_get_op_type(op_str);
+       if (op_type < 0) {
+               _LOGE("fota-info : operation error[%s, %s]\n", pkgid, op_str);
+               goto end;
+       }
+
+       switch (op_type) {
+       case INSTALL_REQ:
+               ret = __ri_install_fota_for_rw(pkgid);
+               break;
+
+       case UPGRADE_REQ:
+               ret = __ri_upgrade_fota_for_rw(pkgid);
+               break;
+
+       case UNINSTALL_REQ:
+               ret = __ri_uninstall_fota_for_rw(pkgid);
+               break;
+
+       default:
+               break;
+       }
+
+       if (ret < 0)
+               _LOGE("fota-info : Fota fail [pkgid=%s, operation=%d]\n", pkgid, op_type);
+
+end:
+       if (pkgid)
+               free(pkgid);
+       if (op_str)
+               free(op_str);
+
+       sync();
+
+       return ret;
+}
+
 int __ri_copy_smack_rule_file(int op, const char *pkgname, int is_system)
 {
        mode_t mode = DIR_PERMS;
index 5258c23..0b27ab0 100755 (executable)
@@ -47,7 +47,7 @@ int _installer_util_create_dir(const char* dirpath, mode_t mode)
        if (ret < 0) {
                if (access(dirpath, F_OK) == 0) {
                        _installer_util_delete_dir(dirpath);
-                       ret = _installer_util_mkpath(dirpath, mode);
+                       ret = mkdir(dirpath, mode);
                        if (ret < 0) {
                                if( strerror_r(errno, buf, sizeof(buf)) == 0) {
                                        _LOGE("mkdir(%s) failed. [%d][%s]", dirpath, errno, buf);
@@ -215,7 +215,7 @@ int _installer_util_copy_dir(const char *src_dir, const char *dest_dir)
        tryvm_if(dp == NULL, ret = -1, "opendir(%s) failed. [%d][%s]", src_dir, errno, buf);
 
        if (access(dest_dir, F_OK) != 0) {
-               ret = _installer_util_mkpath(dest_dir, DIRECTORY_PERMISSION_755);
+               ret = mkdir(dest_dir, DIRECTORY_PERMISSION_755);
                if (ret < 0) {
                        strerror_r(errno, buf, sizeof(buf));
                        LOGE("mkdir() err: [%s]", buf);
index 2032a12..4a2cb6a 100755 (executable)
@@ -67,7 +67,6 @@ struct ri_frontend_cmdline_arg_t {
        bool debug_mode;
 #endif
        char *optional_data;
-       char *pkg_chksum;
 };
 typedef struct ri_frontend_cmdline_arg_t ri_frontend_cmdline_arg;
 
index fc503d6..b28ba94 100755 (executable)
@@ -145,7 +145,6 @@ int main(int argc, char *argv[])
        }
        data->keyid = NULL;
        data->pkgid = NULL;
-       data->pkg_chksum = NULL;
 #ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
        data->tep_path = NULL;
 #endif
index 163689d..699f8b1 100755 (executable)
@@ -93,12 +93,6 @@ int _ri_parse_command_arg(int argc, char **argv)
 
                        ret = _coretpk_installer_prepare_preload_install(argv[2], NULL, NULL);
                        return ret;
-#ifdef _APPFW_FEATURE_MOUNT_INSTALL
-               } else if (!strcmp(argv[1], "-ipw")) { // preload
-                       _LOGD("Mount Based Preload Installation start.");
-                       ret = _coretpk_installer_prepare_mount_install(argv[2], NULL, false, NULL);
-                       return ret;
-#endif
                } else if (!strcmp(argv[1], "-ipd")) { // preload, support-disable
                        _LOGD("Preload Installation start.(support-disable)");
 
@@ -125,17 +119,12 @@ int _ri_parse_command_arg(int argc, char **argv)
                } else if (!strcmp(argv[1], "-c")) { // csc
                        _LOGD("CSC start.");
 
-                       ret = _coretpk_installer_prepare_csc(argv[2]);
+                       ret = _rpm_process_csc_coretpk(argv[2]);
                        return ret;
                } else if (!strcmp(argv[1], "-f")) { // fota
                        _LOGD("FOTA start.");
 
-                       ret = _coretpk_installer_prepare_fota(argv[2], false);
-                       return ret;
-               } else if (!strcmp(argv[1], "-F")) { // fota
-                       _LOGD("RW FOTA start.");
-
-                       ret = _coretpk_installer_prepare_fota(argv[2], true);
+                       ret = _rpm_process_fota(argv[2]);
                        return ret;
                } else if (!strcmp(argv[1], "-ix")) { // init_db
                        _LOGD("Init db start.");
@@ -256,7 +245,6 @@ int _ri_parse_cmdline(int argc, char **argv, ri_frontend_cmdline_arg *data)
        data->move_type = move_type;
        data->clientid = (char *)pkgmgr_installer_get_caller_pkgid(pi);
        data->optional_data = (char*)pkgmgr_installer_get_optional_data(pi);
-       data->pkg_chksum = (char *)pkgmgr_installer_get_pkg_chksum(pi);
 #ifdef _APPFW_FEATURE_SUPPORT_DEBUGMODE_FOR_SDK
        data->debug_mode = (bool)pkgmgr_installer_is_debug_mode(pi);
 #endif
index 6cbfbb8..fbbc0a1 100755 (executable)
@@ -66,11 +66,6 @@ extern "C" {
 #define RES_DIR_STR                                                                                            "res"
 #define SHARED_RES_DIR_STR                                                             "shared/res"
 
-#ifdef _APPFW_FEATURE_MOUNT_INSTALL
-#define MIC_ENV                                                                                                        "/tmp/alaunch/-2"
-#define PKG_NAME_STRING_LEN_MAX                                                                128
-#endif
-
 #define PRELOAD_WATCH_FACE_PATH                                                "/usr/apps/com.samsung.watchface"
 
 #define CORETPK_XML                                                                                            "tizen-manifest.xml"
@@ -107,7 +102,7 @@ static const int VERSION_NEW = 2;
 #ifdef _APPFW_FEATURE_DELTA_UPDATE
 #define CORETPK_DELTA_INSTALL                                  "coretpk-delta-install"
 #endif
-#ifdef _APPFW_FEATURE_MOUNT_INSTALL
+#ifdef _APPFW_FEATURE_DELTA_UPDATE
 #define CORETPK_MOUNT_INSTALL                                  "coretpk-mount-install"
 #endif
 #define CORETPK_MOVE                                                                                   "coretpk-move"
@@ -186,7 +181,6 @@ typedef struct pkginfo_t {
        char client_id[PKG_MAX_LEN];
        char api_version[BUF_SIZE];
        char sig_capath[BUF_SIZE];
-       char pkg_chksum[BUF_SIZE];
        bool is_widget;
        bool is_preload;
        bool support_disable;
@@ -202,7 +196,6 @@ typedef struct privilegeinfo_t {
 
 typedef struct cmdinfo_t {
        bool support_disable;
-       char pkg_chksum[BUF_SIZE];
 } cmdinfo;
 
 cert_chain list[MAX_CERT_NUM];
@@ -337,16 +330,6 @@ typedef struct delta_info_t{
        LOGD(fmt, ##arg);       \
 } while(0)
 
-#define        _SLOGE(fmt, arg...) do {        \
-       fprintf(stderr, "  ## "fmt"\n", ##arg); \
-       SECURE_LOGE(fmt, ##arg);        \
-} while(0)
-
-#define        _SLOGD(fmt, arg...) do {        \
-       fprintf(stderr, "  ## "fmt"\n", ##arg); \
-       SECURE_LOGD(fmt, ##arg);        \
-} while(0)
-
 #define        ret_if(expr) do {       \
        if (expr) {     \
                _LOGE("(%s) ", #expr);  \
index b0c9096..01f8796 100755 (executable)
@@ -47,7 +47,6 @@ int _installer_util_get_configuration_value(const char *value);
 char *_installer_util_get_str(const char *str, const char *pKey);
 int _installer_util_extract_version(const char* version, int* major, int* minor, int* macro);
 int _installer_util_compare_version(const char* old_version, const char* new_version);
-int _installer_util_mkpath(const char *s, mode_t mode);
 
 #ifdef _APPFW_FEATURE_DELTA_UPDATE
 int _installer_util_create_dir(const char *dir_path, mode_t mode);
index ac0b16e..f61047e 100755 (executable)
@@ -47,11 +47,9 @@ Requires:    cpio
 %if "%{?tizen_profile_name}" == "tv"
 %define appfw_feature_support_onlycap 0
 %define appfw_feature_support_debugmode_for_sdk 0
-%define appfw_feature_directory_permission_opt_only 1
 %else
 %define appfw_feature_support_onlycap 1
 %define appfw_feature_support_debugmode_for_sdk 1
-%define appfw_feature_directory_permission_opt_only 0
 %endif
 
 %description
@@ -107,12 +105,6 @@ _SUPPORT_DEBUGMODE_FOR_SDK=ON
 _SUPPORT_DEBUGMODE_FOR_SDK=OFF
 %endif
 
-%if 0%{?appfw_feature_directory_permission_opt_only}
-_APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY=ON
-%else
-_APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY=OFF
-%endif
-
 
 %if "%{?tizen_profile_name}" == "wearable"
 export CFLAGS="$CFLAGS -DWEARABLE"
@@ -130,8 +122,7 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
                                -D_APPFW_FEATURE_SYSMAN_MMC:BOOL=${_SYSMAN_MMC} \
                                -D_APPFW_FEATURE_MOUNT_INSTALL:BOOL=${_MOUNT_INSTALL} \
                                -D_APPFW_FEATURE_SUPPORT_DEBUGMODE_FOR_SDK:BOOL=${_SUPPORT_DEBUGMODE_FOR_SDK} \
-                               -D_APPFW_FEATURE_SUPPORT_ONLYCAP:BOOL=${_SUPPORT_ONLYCAP} \
-                               -D_APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY:BOOL=${_APPFW_FEATURE_DIRECTORY_PERMISSION_OPT_ONLY}
+                               -D_APPFW_FEATURE_SUPPORT_ONLYCAP:BOOL=${_SUPPORT_ONLYCAP}
 
 make %{?jobs:-j%jobs}