Sync to the latest code 2.2_release submit/tizen_2.2/20130814.090124 submit/tizen_2.2/20130814.101757
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Mon, 5 Aug 2013 07:16:39 +0000 (16:16 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Mon, 5 Aug 2013 07:16:39 +0000 (16:16 +0900)
Change-Id: Ie701e8b2b3299d481c0c119064ff0ddfcf07b9d4
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
15 files changed:
client/src/pkgmgr.c
comm/comm_client_dbus.c
comm/comm_config.h
comm/pkgmgr_installer.c
comm/pkgmgr_installer.h
packaging/pkgmgr.spec
packaging/pkgmgr_recovery.service [new file with mode: 0644]
server/src/pkgmgr-server.c
tool/CMakeLists.txt
tool/pkg_fota.c
tool/pkg_getsize.c
tool/pkg_info.c
tool/pkg_initdb.c
tool/pkg_recovery.sh.in [new file with mode: 0644]
tool/pkg_smack.c

index d83e837..abbf993 100755 (executable)
@@ -695,12 +695,9 @@ static int __app_list_cb (const pkgmgr_appinfo_h handle,
 
 static int __sync_process(char *req_key)
 {
-       int ret =0;
        char info_file[PKG_STRING_LEN_MAX] = {'\0', };
        int result = 0;
        int check_cnt = 0;
-       FILE *fp;
-       char buffer[PKG_ARGC_MAX] = {'\0', };
 
        snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_TMP_PATH, req_key);
        while(1)
index 5af48a9..be00470 100755 (executable)
@@ -260,27 +260,27 @@ comm_client_request(
                                      DBUS_TYPE_STRING, &args,
                                      DBUS_TYPE_STRING, &cookie,
                                      DBUS_TYPE_INVALID)) {
-               r = COMM_RET_ERROR;
+               r = -3;
                ERR("dbus_message_append_args fail");
                goto ERROR_CLEANUP;
        }
 
-       /* Send message */
+       /* Send message , timeout -1 = _DBUS_DEFAULT_TIMEOUT_VALUE (25 * 1000) 25 seconds*/
        if (is_block == 1){
                if(!dbus_connection_send_with_reply_and_block(cc->conn, msg,
-                                                             10000, NULL)) {
+                                                             -1, NULL)) {
                        ERR("try send msg to dbus by timeout");
                        sleep(1);
                        if(!dbus_connection_send_with_reply_and_block(cc->conn, msg,
-                                                                         10000, NULL)) {
-                               r = COMM_RET_ERROR;
+                                                                         -1, NULL)) {
+                               r = -4;
                                ERR("dbus_connection_send_with_reply_and_block fail");
                                goto ERROR_CLEANUP;
                        }
                }
        } else {
                if (!dbus_connection_send(cc->conn, msg, NULL)) {
-                       r = COMM_RET_ERROR;
+                       r = -5;
                        ERR("dbus_connection_send fail");
                        goto ERROR_CLEANUP;
                }
index d60d71f..90ba69f 100755 (executable)
 
 #ifndef NDEBUG
 #ifdef USE_DLOG
+#undef LOG_TAG
+#ifndef LOG_TAG
 #define LOG_TAG "PKGMGR"
+#endif                         /* LOG_TAG */
 #include <dlog.h>
 #define dbg(fmtstr, args...) \
        do { SLOGI("[comm]%s:%d:%s(): " \
index 4233c8e..387630a 100755 (executable)
@@ -65,15 +65,6 @@ struct pkgmgr_installer {
        DBusConnection *conn;
 };
 
-static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
-
-static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
-{
-       int *p = (int*)data;
-       *p = atoi(coltxt[0]);
-       _LOGE("exist value is %d\n", *p);
-       return 0;
-}
 /* API */
 
 API pkgmgr_installer *pkgmgr_installer_new(void)
index 11e9bb5..5e02a17 100755 (executable)
@@ -43,7 +43,6 @@ extern "C" {
 #include <dlog.h>
 
 
-#define _LOGE(fmt, arg...) LOGE(fmt,##arg)
 
 /**
  * pkgmgr_installer is an opaque type for an object
index 0764e6e..0655550 100755 (executable)
@@ -1,11 +1,12 @@
 #sbs-git:slp/pkgs/s/slp-pkgmgr pkgmgr 0.1.103 29b53909a5d6e8728429f0a188177eac691cb6ce
 Name:       pkgmgr
 Summary:    Packager Manager client library package
-Version:    0.2.105
+Version:    0.2.112
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
+Source1:       pkgmgr_recovery.service
 BuildRequires:  cmake
 BuildRequires:  unzip
 BuildRequires:  gettext-tools
@@ -97,6 +98,9 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/pkgmgr_recovery.service
+ln -s ../pkgmgr_recovery.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/pkgmgr_recovery.service
 
 %post
 /sbin/ldconfig
@@ -113,7 +117,12 @@ update-mime-database /usr/share/mime
 
 %posttrans
 #init DB
+mkdir -p /usr/share/packages
+mkdir -p /opt/share/packages
+mkdir -p /opt/share/packages/.recovery
+
 mkdir -p /usr/share/applications
+mkdir -p /opt/share/applications
 mkdir -p /opt/dbspace/
 
 pkg_smack
@@ -157,6 +166,9 @@ mkdir -p /usr/etc/package-manager/server
 %exclude %{_libdir}/libpkgmgr_backend_lib_sample.so
 %exclude /usr/etc/package-manager/server/queue_status
 %attr(0700,root,root) /etc/opt/upgrade/pkgmgr.patch.sh
+%attr(0700,root,root) /usr/etc/package-manager/pkg_recovery.sh
+%{_libdir}/systemd/system/multi-user.target.wants/pkgmgr_recovery.service
+%{_libdir}/systemd/system/pkgmgr_recovery.service
 
 %files client
 %manifest pkgmgr-client.manifest
diff --git a/packaging/pkgmgr_recovery.service b/packaging/pkgmgr_recovery.service
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
index 2a4a3ee..6347f5c 100755 (executable)
@@ -82,6 +82,8 @@ FILE *___log = NULL;
 #define LOCALEDIR "/usr/share/locale"
 #endif
 
+#define PACKAGE_RECOVERY_DIR "/opt/share/packages/.recovery"
+
 #define DESKTOP_W   720.0
 
 #define NO_MATCHING_FILE 11
@@ -205,11 +207,74 @@ static void __unset_backend_mode(int position)
        backend_mode = backend_mode & ~(1<<position);
 }
 
+static void __set_recovery_mode(char *pkgid, char *pkg_type)
+{
+       char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
+       char buffer[MAX_PKG_NAME_LEN] = { 0 };
+       char *pkgid_tmp = NULL;
+       FILE *rev_file = NULL;
+
+       if (pkgid == NULL) {
+               DBG("pkgid is null\n");
+               return;
+       }
+
+       /*if pkgid has a "/"charactor, that is a path name for installation, then extract pkgid from absolute path*/
+       if (strstr(pkgid, "/")) {
+               pkgid_tmp = strrchr(pkgid, '/') + 1;
+               if (pkgid_tmp == NULL) {
+                       DBG("pkgid_tmp[%s] is null\n", pkgid);
+                       return;
+               }
+               snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid_tmp);
+       } else {
+               snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid);
+       }
+
+       rev_file = fopen(recovery_file, "w");
+       if (rev_file== NULL) {
+               DBG("rev_file[%s] is null\n", recovery_file);
+               return;
+       }
+
+       snprintf(buffer, MAX_PKG_NAME_LEN, "pkgid : %s\n", pkgid);
+       fwrite(buffer, sizeof(char), strlen(buffer), rev_file);
+
+       fclose(rev_file);
+}
+
+static void __unset_recovery_mode(char *pkgid, char *pkg_type)
+{
+       int ret = -1;
+       char recovery_file[MAX_PKG_NAME_LEN] = { 0, };
+       char *pkgid_tmp = NULL;
+
+       if (pkgid == NULL) {
+               DBG("pkgid is null\n");
+               return;
+       }
+
+       /*if pkgid has a "/"charactor, that is a path name for installation, then extract pkgid from absolute path*/
+       if (strstr(pkgid, "/")) {
+               pkgid_tmp = strrchr(pkgid, '/') + 1;
+               if (pkgid_tmp == NULL) {
+                       DBG("pkgid_tmp[%s] is null\n", pkgid);
+                       return;
+               }
+               snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid_tmp);
+       } else {
+               snprintf(recovery_file, MAX_PKG_NAME_LEN, "%s/%s", PACKAGE_RECOVERY_DIR, pkgid);
+       }
+
+       ret = remove(recovery_file);
+       if (ret < 0)
+               DBG("remove recovery_file[%s] fail\n", recovery_file);
+}
+
 static int __check_privilege_by_cookie(const char *e_cookie, int req_type)
 {
        guchar *cookie = NULL;
        gsize size;
-       char *smack_label = NULL;
        int ret = PMINFO_R_OK;  //temp to success , it should be PMINFO_R_ERROR
 
        if (e_cookie == NULL)   {
@@ -916,6 +981,7 @@ static void sighandler(int signo)
                                if (cpid == (ptr + i)->pid) {
                                        __set_backend_free(i);
                                        __set_backend_mode(i);
+                                       __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
                                        break;
                                }
                        }
@@ -928,6 +994,7 @@ static void sighandler(int signo)
                                if (cpid == (ptr + i)->pid) {
                                        __set_backend_free(i);
                                        __set_backend_mode(i);
+                                       __unset_recovery_mode((ptr + i)->pkgid, (ptr + i)->pkgtype);
                                        strncpy(pname, (ptr + i)->pkgid, MAX_PKG_NAME_LEN-1);
                                        strncpy(ptype, (ptr + i)->pkgtype, MAX_PKG_TYPE_LEN-1);
                                        strncpy(args, (ptr + i)->args, MAX_PKG_ARGS_LEN-1);
@@ -1417,6 +1484,7 @@ pop:
                goto pop;
        }
        __set_backend_busy((pos + num_of_backends - 1) % num_of_backends);
+       __set_recovery_mode(item->pkgid, item->pkg_type);
 
        switch (item->req_type) {
        case COMM_REQ_TO_INSTALLER:
index f13acac..5e40994 100755 (executable)
@@ -60,6 +60,9 @@ install(TARGETS pkgmgr-install DESTINATION bin)
 configure_file(org.tizen.pkgmgr-install.xml.in ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.xml @ONLY)
 install(FILES ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.xml DESTINATION /usr/share/packages/)
 
+configure_file(pkg_recovery.sh.in pkg_recovery.sh @ONLY)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkg_recovery.sh DESTINATION /usr/etc/package-manager/)
+
 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.wac.xml DESTINATION /usr/share/mime/packages/)
 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.tpk.xml DESTINATION /usr/share/mime/packages/)
 
index dd02e4e..cbfdb04 100644 (file)
@@ -196,10 +196,10 @@ static int pkg_fota_change_perm(const char *db_file)
        snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
 
        for (i = 0; files[i]; i++) {
-               ret = chown(files[i], OWNER_ROOT, GROUP_MENU);
+               ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
                if (ret == -1) {
                        strerror_r(errno, buf, sizeof(buf));
-                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, GROUP_MENU, buf);
+                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
                        return -1;
                }
 
index 34f02fd..7177c05 100644 (file)
@@ -49,7 +49,6 @@ static int _pkg_getsize(int argc, char **argv)
        pkgmgrinfo_pkginfo_h handle = NULL;
        int size = -1;
        int get_type = -1;
-       char buf[MAX_PKG_BUF_LEN] = {'\0'};
        char *pkeyid = NULL;
 
        /*make new pkgmgr_installer handle*/
index 5749b01..c7158e9 100755 (executable)
@@ -63,6 +63,153 @@ static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data
 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
 int app_func(const pkgmgr_appinfo_h handle, void *user_data);
 
+static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *user_data)
+{
+       int ret = -1;
+       char *type = NULL;
+       char *version = NULL;
+       char *author_name = NULL;
+       char *author_email = NULL;
+       char *author_href = NULL;
+       char *root_path = NULL;
+       char *mainappid = NULL;
+       pkgmgr_install_location location = 0;
+       char *icon = NULL;
+       char *label = NULL;
+       char *desc = NULL;
+       bool removable = 0;
+       bool preload = 0;
+       bool readonly = 0;
+       bool update = 0;
+       bool system = 0;
+       int size = -1;
+       int installed_time = -1;
+
+       ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+       if (ret < 0) {
+               printf("Failed to get pkg type\n");
+       }
+       if (type)
+               printf("Type: %s\n", type);
+
+       ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
+       if (ret < 0) {
+               printf("Failed to get version\n");
+       }
+       if (version)
+               printf("Version: %s\n", version);
+
+       ret = pkgmgrinfo_pkginfo_get_install_location(handle, &location);
+       if (ret < 0) {
+               printf("Failed to get install location\n");
+       }
+       printf("Install Location: %d\n", location);
+
+       ret = pkgmgrinfo_pkginfo_get_package_size(handle, &size);
+       if (ret < 0) {
+               printf("Failed to get package size \n");
+       }
+       printf("Package Size: %d\n", size);
+
+       ret = pkgmgrinfo_pkginfo_get_icon(handle, &icon);
+       if (ret < 0) {
+               printf("Failed to get icon\n");
+       }
+       if (icon)
+               printf("Icon: %s\n", icon);
+
+       ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
+       if (ret < 0) {
+               printf("Failed to get label\n");
+       }
+       if (label)
+               printf("Label: %s\n", label);
+
+       ret = pkgmgrinfo_pkginfo_get_description(handle, &desc);
+       if (ret < 0) {
+               printf("Failed to get description\n");
+       }
+       if (desc)
+               printf("Description: %s\n", desc);
+
+       ret = pkgmgrinfo_pkginfo_get_author_name(handle, &author_name);
+       if (ret < 0) {
+               printf("Failed to get author name\n");
+       }
+       if (author_name)
+               printf("Author Name: %s\n", author_name);
+
+       ret = pkgmgrinfo_pkginfo_get_author_email(handle, &author_email);
+       if (ret < 0) {
+               printf("Failed to get author email\n");
+       }
+       if (author_email)
+               printf("Author Email: %s\n", author_email);
+
+       ret = pkgmgrinfo_pkginfo_get_author_href(handle, &author_href);
+       if (ret < 0) {
+               printf("Failed to get author href\n");
+       }
+       if (author_href)
+               printf("Author Href: %s\n", author_href);
+
+       ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
+       if (ret < 0) {
+               printf("Failed to get root_path\n");
+       }
+       if (author_href)
+               printf("root_path : %s\n", root_path);
+
+       ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid);
+       if (ret < 0) {
+               printf("Failed to get mainappid\n");
+       }
+       if (author_href)
+               printf("mainappid : %s\n", mainappid);
+
+       ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
+       if (ret < 0) {
+               printf("Failed to get install time\n");
+       }
+       printf("Install time: %d\n", installed_time);
+
+       ret = pkgmgrinfo_pkginfo_is_removable(handle, &removable);
+       if (ret < 0) {
+               printf("Failed to get removable\n");
+       }
+       else
+               printf("Removable: %d\n", removable);
+
+       ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
+       if (ret < 0) {
+               printf("Failed to get preload\n");
+       }
+       else
+               printf("Preload: %d\n", preload);
+
+       ret = pkgmgrinfo_pkginfo_is_readonly(handle, &readonly);
+       if (ret < 0) {
+               printf("Failed to get readonly\n");
+       }
+       else
+               printf("Readonly: %d\n", readonly);
+
+       ret = pkgmgrinfo_pkginfo_is_update(handle, &update);
+       if (ret < 0) {
+               printf("Failed to get update\n");
+       }
+       else
+               printf("update: %d\n", update);
+
+       ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
+       if (ret < 0) {
+               printf("Failed to get system\n");
+       }
+       else
+               printf("system: %d\n", system);
+
+       return 0;
+}
 int __get_app_id(const pkgmgrinfo_appinfo_h handle, void *user_data)
 {
        char *appid = NULL;
@@ -720,7 +867,6 @@ static int __add_arg_filter(char *key, char *value)
        int ret = 0;
        int choice = -1;
        int val = -1;
-       int count = 0;
        pkgmgrinfo_appinfo_filter_h handle;
        ret = pkgmgrinfo_appinfo_filter_create(&handle);
        if (ret > 0) {
@@ -972,6 +1118,8 @@ static int __get_certinfo_from_db(char *pkgid)
                        return -1;
                }
        }
+
+       return -1;
 }
 
 static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid)
@@ -1844,126 +1992,19 @@ static int __get_app_list(char *pkgid)
 
 static int __get_pkg_info(char *pkgid)
 {
-       pkgmgr_pkginfo_h handle;
+       pkgmgrinfo_pkginfo_h handle;
        int ret = -1;
-       char *type = NULL;
-       char *version = NULL;
-       char *author_name = NULL;
-       char *author_email = NULL;
-       char *author_href = NULL;
-       pkgmgr_install_location location = 0;
-       char *icon = NULL;
-       char *label = NULL;
-       char *desc = NULL;
-       bool removable = 0;
-       bool preload = 0;
-       bool readonly = 0;
-       int size = -1;
-       int installed_time = -1;
 
        printf("Get Pkg Info Called [%s]\n", pkgid);
-       ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
        if (ret < 0) {
                printf("Failed to get handle\n");
                return -1;
        }
 
-       ret = pkgmgr_pkginfo_get_type(handle, &type);
-       if (ret < 0) {
-               printf("Failed to get pkg type\n");
-       }
-       if (type)
-               printf("Type: %s\n", type);
-
-       ret = pkgmgr_pkginfo_get_version(handle, &version);
-       if (ret < 0) {
-               printf("Failed to get version\n");
-       }
-       if (version)
-               printf("Version: %s\n", version);
-
-       ret = pkgmgr_pkginfo_get_install_location(handle, &location);
-       if (ret < 0) {
-               printf("Failed to get install location\n");
-       }
-       printf("Install Location: %d\n", location);
-
-       ret = pkgmgr_pkginfo_get_package_size(handle, &size);
-       if (ret < 0) {
-               printf("Failed to get package size \n");
-       }
-       printf("Package Size: %d\n", size);
-
-       ret = pkgmgr_pkginfo_get_icon(handle, &icon);
-       if (ret < 0) {
-               printf("Failed to get icon\n");
-       }
-       if (icon)
-               printf("Icon: %s\n", icon);
-
-       ret = pkgmgr_pkginfo_get_label(handle, &label);
-       if (ret < 0) {
-               printf("Failed to get label\n");
-       }
-       if (label)
-               printf("Label: %s\n", label);
-
-       ret = pkgmgr_pkginfo_get_description(handle, &desc);
-       if (ret < 0) {
-               printf("Failed to get description\n");
-       }
-       if (desc)
-               printf("Description: %s\n", desc);
-
-       ret = pkgmgr_pkginfo_get_author_name(handle, &author_name);
-       if (ret < 0) {
-               printf("Failed to get author name\n");
-       }
-       if (author_name)
-               printf("Author Name: %s\n", author_name);
-
-       ret = pkgmgr_pkginfo_get_author_email(handle, &author_email);
-       if (ret < 0) {
-               printf("Failed to get author email\n");
-       }
-       if (author_email)
-               printf("Author Email: %s\n", author_email);
-
-       ret = pkgmgr_pkginfo_get_author_href(handle, &author_href);
-       if (ret < 0) {
-               printf("Failed to get author href\n");
-       }
-       if (author_href)
-               printf("Author Href: %s\n", author_href);
-
-       ret = pkgmgr_pkginfo_is_removable(handle, &removable);
-       if (ret < 0) {
-               printf("Failed to get removable\n");
-       }
-       else
-               printf("Removable: %d\n", removable);
-
-       ret = pkgmgr_pkginfo_is_preload(handle, &preload);
-       if (ret < 0) {
-               printf("Failed to get preload\n");
-       }
-       else
-               printf("Preload: %d\n", preload);
+       __get_pkgmgrinfo_pkginfo(handle, NULL);
 
-       ret = pkgmgr_pkginfo_is_readonly(handle, &readonly);
-       if (ret < 0) {
-               printf("Failed to get readonly\n");
-       }
-       else
-               printf("Readonly: %d\n", readonly);
-
-       ret = pkgmgr_pkginfo_get_installed_time(handle, &installed_time);
-       if (ret < 0) {
-               printf("Failed to get install time\n");
-       }
-       printf("Install time: %d\n", installed_time);
-
-       pkgmgr_pkginfo_destroy_pkginfo(handle);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
        return 0;
 }
 
index 88a0036..bbd4939 100755 (executable)
@@ -123,16 +123,18 @@ int initdb_load_directory(const char *directory)
        struct dirent entry, *result;
        int ret;
        char buf[BUFSZE];
+       int total_cnt = 0;
+//     int ok_cnt = 0;
 
        // desktop file
        dir = opendir(directory);
        if (!dir) {
                if (strerror_r(errno, buf, sizeof(buf)) == 0)
-                       _E("Failed to access the [%s] because %s\n", directory, buf);
+                       _E("Failed to access the [%s] because %s", directory, buf);
                return -1;
        }
 
-       _D("Loading manifest files from %s\n", directory);
+       _D("Loading manifest files from %s", directory);
 
        for (ret = readdir_r(dir, &entry, &result);
                        ret == 0 && result != NULL;
@@ -140,36 +142,39 @@ int initdb_load_directory(const char *directory)
                char *manifest;
 
                if (entry.d_name[0] == '.') continue;
+               total_cnt++;
 
                manifest = _manifest_to_package(entry.d_name);
                if (!manifest) {
-                       _E("Failed to convert file to package[%s]\n", entry.d_name);
+                       _E("Failed to convert file to xml[%s]", entry.d_name);
                        continue;
                }
 
                snprintf(buf, sizeof(buf), "%s/%s", directory, manifest);
 
-               fprintf(stderr, "pkg_initdb : manifest file %s\n", buf);
-
                ret = pkgmgr_parser_check_manifest_validation(buf);
                if (ret < 0) {
-                       _E("check manifest validation failed code[%d] %s\n", ret, buf);
-                       fprintf(stderr, "check manifest validation failed code[%d] %s\n", ret, buf);
+                       _E("manifest validation failed : %s", buf);
                        free(manifest);
                        continue;
                }
 
-
                /*temporarily fixed due to glib abort */
-               // pkgmgr_parser_parse_manifest_for_installation(buf, NULL);
-
                char buf2[BUFSZE];
                snprintf(buf2, sizeof(buf2), "/usr/bin/pkginfo --imd %s", buf);
                system(buf2);
-
+#if 0
+               ret = pkgmgr_parser_parse_manifest_for_installation(buf, NULL);
+               if (ret < 0) {
+                       _E("Failed to add a xml[%s]", buf);
+               } else {
+                       ok_cnt++;
+               }
+#endif
                free(manifest);
        }
 
+//     _D("Package-XML process : Success [%d], fail[%d], total[%d] \n", ok_cnt, total_cnt-ok_cnt, total_cnt);
        closedir(dir);
 
        return 0;
@@ -194,10 +199,10 @@ static int initdb_change_perm(const char *db_file)
        snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
 
        for (i = 0; files[i]; i++) {
-               ret = chown(files[i], OWNER_ROOT, GROUP_MENU);
+               ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
                if (ret == -1) {
                        strerror_r(errno, buf, sizeof(buf));
-                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, GROUP_MENU, buf);
+                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
                        return -1;
                }
 
@@ -251,26 +256,24 @@ int main(int argc, char *argv[])
                return 0;
        }
 
-       ret = initdb_load_directory(OPT_MANIFEST_DIRECTORY);
+       ret = initdb_load_directory(USR_MANIFEST_DIRECTORY);
        if (ret == -1) {
-               _E("cannot load opt manifest directory.");
+               _E("cannot load usr manifest directory.");
        }
 
-       ret = initdb_load_directory(USR_MANIFEST_DIRECTORY);
+       ret = initdb_load_directory(OPT_MANIFEST_DIRECTORY);
        if (ret == -1) {
-               _E("cannot load usr manifest directory.");
+               _E("cannot load opt manifest directory.");
        }
 
        ret = initdb_change_perm(PACKAGE_INFO_DB_FILE);
        if (ret == -1) {
                _E("cannot chown.");
-               return -1;
        }
 
        ret = initdb_update_preload_info();
        if (ret == -1) {
                _E("cannot update preload info.");
-               return -1;
        }
 
        const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
diff --git a/tool/pkg_recovery.sh.in b/tool/pkg_recovery.sh.in
new file mode 100644 (file)
index 0000000..e9b2ad1
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+
+_pkg_recovery_path="/opt/share/packages/.recovery"
+_pkg_recovery_file="/opt/share/packages/.recovery/*"
+
+FILE_LIST=`ls $_pkg_recovery_path`
+if [ -n "$FILE_LIST" ]; then
+       echo "There are packages to recovery"
+       /usr/bin/wrt-installer -v
+       /usr/bin/osp-installer -v
+
+       echo "delete recovery files"
+       rm $_pkg_recovery_file
+else
+    echo "There is no packages to recovery."
+fi
+
index 2918228..bfc12ed 100755 (executable)
@@ -330,13 +330,13 @@ static void __apply_shared_privileges(char *pkgname, int flag)
                __pkg_smack_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/
        memset(dirpath, '\0', BUFF_SIZE);
 
-       /*/shared/res dir. setup path */
+       /*/shared/res dir. Dont setup path but change smack access to "_" */
        if (flag == 0)
                snprintf(dirpath, BUFF_SIZE, "/usr/apps/%s/shared/res", pkgname);
        else
                snprintf(dirpath, BUFF_SIZE, "/opt/usr/apps/%s/shared/res", pkgname);
        if (__is_dir(dirpath))
-               __pkg_smack_setup_path(pkgname, dirpath, RPM_PATH_PUBLIC_RO, NULL);
+               __pkg_smack_change_smack_label(dirpath, "_", 0);/*0 is SMACK_LABEL_ACCESS*/
        memset(dirpath, '\0', BUFF_SIZE);
 
        /*/shared/data dir. setup path and change group to 'app'*/