From 418e3421f24f3301ea61e5050e979c51ef2c3471 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 15 Jul 2016 11:37:24 +0900 Subject: [PATCH 01/16] Delete certinfo first when save certinfo Change-Id: I35f5dccda6620b699fde963c2cb8ee9563838f6c Signed-off-by: Sangyoon Jang --- src/pkg_info.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pkg_info.c b/src/pkg_info.c index b8ec796..e0af4ef 100644 --- a/src/pkg_info.c +++ b/src/pkg_info.c @@ -1208,6 +1208,12 @@ static int __set_certinfo_in_db(char *pkgid, uid_t uid) choice = __get_integer_input_data(); switch (choice) { case 0: + ret = pkgmgr_installer_delete_certinfo(pkgid); + if (ret < 0) { + printf("pkgmgr_installer_delete_certinfo failed\n"); + pkgmgr_installer_destroy_certinfo_set_handle(handle); + return -1; + } ret = pkgmgr_installer_save_certinfo(pkgid, handle, uid); if (ret < 0) { printf("pkgmgr_installer_save_certinfo failed\n"); -- 2.7.4 From 7ba260e65b88ff454ba080ba72d799d9821b9f42 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 7 Jul 2016 19:13:07 +0900 Subject: [PATCH 02/16] Implement pkg enable/disable Related changes [slp-pkgmgr] https://review.tizen.org/gerrit/78917 [pkgmgr-server] https://review.tizen.org/gerrit/78918 [app-installers] https://review.tizen.org/gerrit/78919 [tpk-backend] https://review.tizen.org/gerrit/#/c/79070/ Change-Id: Ia3f1b3eb5dcdf85b2a761af7e42e71a44d42f401 Signed-off-by: Junghyun Yeon --- src/pkg_cmd.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/pkg_cmd.c b/src/pkg_cmd.c index 38b72f3..f0b23ae 100644 --- a/src/pkg_cmd.c +++ b/src/pkg_cmd.c @@ -786,10 +786,19 @@ static int __process_request(uid_t uid) largv[1] = data.label; ret = pkgmgr_client_usr_activate_appv(pc, data.pkgid, largv, uid); } - } else - /* enable package which belongs to this user */ + } else { + ret = pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_INSTALL); + if (ret != PKGMGR_R_OK) { + printf("Failed to set status type[%d]\n", ret); + break; + } + ret = pkgmgr_client_listen_status(pc, __return_cb, NULL); + if (ret < 0) { + printf("Failed to set callback[%d]\n", ret); + break; + } ret = pkgmgr_client_usr_activate(pc, data.pkg_type, data.pkgid, uid); - + } if (ret < 0) break; @@ -820,16 +829,25 @@ static int __process_request(uid_t uid) else /* disable app which belongs to this user */ ret = pkgmgr_client_usr_deactivate_app(pc, data.pkgid, __app_return_cb, uid); - } else + } else { + ret = pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_UNINSTALL); + if (ret != PKGMGR_R_OK) { + printf("Failed to set status type[%d]\n", ret); + break; + } + ret = pkgmgr_client_listen_status(pc, __return_cb, NULL); + if (ret < 0) { + printf("Failed to set callback[%d]\n", ret); + break; + } /* disable package which belongs to this user*/ ret = pkgmgr_client_usr_deactivate(pc, data.pkg_type, data.pkgid, uid); - + } if (ret < 0) break; g_main_loop_run(main_loop); ret = data.result; - break; case MOVE_REQ: -- 2.7.4 From ed046ec00622f4b14eca9db28c79842f606d5d4f Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 12 Jul 2016 14:10:41 +0900 Subject: [PATCH 03/16] Fix coding rule Change-Id: I940cde64906f58b631d966bd250acb07021cc479 Signed-off-by: Junghyun Yeon --- src/pkg_cmd.c | 9 ++++----- src/pkg_info.c | 2 +- src/pkg_rsc_slice.c | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pkg_cmd.c b/src/pkg_cmd.c index f0b23ae..84ead6b 100644 --- a/src/pkg_cmd.c +++ b/src/pkg_cmd.c @@ -482,7 +482,7 @@ static int __pkgmgr_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data) printf("%s\tpkg_type [%s]\tpkgid [%s]\tname [%s]\tversion [%s]\tstorage [%s]\n", for_all_users ? "system apps" : "user apps ", pkg_type, pkgid, pkg_label, pkg_version, - (storage == PMINFO_EXTERNAL_STORAGE) ? "external":"internal"); + (storage == PMINFO_EXTERNAL_STORAGE) ? "external" : "internal"); return ret; } @@ -1053,12 +1053,11 @@ static int __process_request(uid_t uid) break; } - if (strcmp(data.pkgid, PKG_SIZE_INFO_TOTAL) == 0) { + if (strcmp(data.pkgid, PKG_SIZE_INFO_TOTAL) == 0) ret = pkgmgr_client_get_total_package_size_info(pc, __total_pkg_size_info_recv_cb, NULL); - - } else { + else ret = pkgmgr_client_get_package_size_info(pc, data.pkgid, __pkg_size_info_recv_cb, NULL); - } + if (ret < 0) { data.result = PKGCMD_ERR_FATAL_ERROR; break; diff --git a/src/pkg_info.c b/src/pkg_info.c index e0af4ef..63a97ce 100644 --- a/src/pkg_info.c +++ b/src/pkg_info.c @@ -1851,7 +1851,7 @@ static int __get_app_info(char *appid) component == PMINFO_WATCH_APP) { printf("component: %s\n", component == PMINFO_UI_APP ? "uiapp" : component == PMINFO_WIDGET_APP ? - "widgetapp": "watchapp"); + "widgetapp" : "watchapp"); if (icon) printf("Icon: %s\n", icon); if (label) diff --git a/src/pkg_rsc_slice.c b/src/pkg_rsc_slice.c index 275420d..67b1093 100644 --- a/src/pkg_rsc_slice.c +++ b/src/pkg_rsc_slice.c @@ -43,7 +43,6 @@ static int __process_slice(void); static void __print_usage(); -//static int __is_authorized(); struct rsc_tool_args_t { char res_path[PATH_MAX]; -- 2.7.4 From f5b3c835d2613d3b7692944eacba43e9497a8c63 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 14 Jul 2016 09:33:07 +0900 Subject: [PATCH 04/16] remove not-support function Submit with: https://review.tizen.org/gerrit/#/c/76806/ Change-Id: I09e260a35bdfa71a0d6f06e443bbfc6f754e789a Signed-off-by: jongmyeongko --- src/pkg_info.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/pkg_info.c b/src/pkg_info.c index 63a97ce..0f2c12f 100644 --- a/src/pkg_info.c +++ b/src/pkg_info.c @@ -1665,19 +1665,6 @@ static int __get_app_control_list(char *appid) return 0; } -static int __set_app_enabled(char *appid, bool enabled) -{ - int ret = -1; - - ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled); - if (ret < 0) { - printf("Failed to get handle\n"); - return -1; - } - - return 0; -} - static int __get_app_list(char *pkgid, uid_t uid) { int ret = -1; @@ -1958,21 +1945,7 @@ int main(int argc, char *argv[]) goto end; } } else if (argc == 4) { - if (strcmp(argv[1], "--setappenabled") == 0) { - ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0") == 0) ? false : true); - if (ret == -1) { - printf("set app enabled failed\n"); - goto end; - } - goto end; - } else if (strcmp(argv[1], "--setpkgenabled") == 0) { - ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0") == 0) ? false : true); - if (ret == -1) { - printf("set pkg enabled failed\n"); - goto end; - } - goto end; - } else if (strcmp(argv[1], "--cmp-pkgcert") == 0) { + if (strcmp(argv[1], "--cmp-pkgcert") == 0) { ret = __compare_pkg_certinfo_from_db(argv[2], argv[3], getuid()); if (ret == -1) { printf("compare certinfo from db failed\n"); -- 2.7.4 From c1faacc36098379ac74b580fb6e8aca1fb9c383f Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 18 Aug 2016 15:58:27 +0900 Subject: [PATCH 05/16] Remove unused csc codes Related change [slp-pkgmgr] : https://review.tizen.org/gerrit/#/c/84349/ Change-Id: I4e01e28777e516799b33cd2fc914b5bfdcd4cffa Signed-off-by: Junghyun Yeon --- src/pkg_cmd.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/pkg_cmd.c b/src/pkg_cmd.c index 84ead6b..d5b4f81 100644 --- a/src/pkg_cmd.c +++ b/src/pkg_cmd.c @@ -64,7 +64,7 @@ static int __convert_to_absolute_path(char *path); /* Supported options */ /* Note: 'G' is reserved */ -const char *short_options = "iurwmcgxCkaADL:lsd:p:t:n:T:S:e:M:X:Y:Z:qhG"; +const char *short_options = "iurwmcgxCkaADL:lsd:p:t:n:T:e:M:X:Y:Z:qhG"; const struct option long_options[] = { {"install", 0, NULL, 'i'}, {"uninstall", 0, NULL, 'u'}, @@ -90,7 +90,6 @@ const struct option long_options[] = { {"package-name", 1, NULL, 'n'}, {"move-type", 1, NULL, 'T'}, {"getsize-type", 1, NULL, 'T'}, - {"csc", 1, NULL, 'S'}, {"tep-path", 1, NULL, 'e'}, {"tep-move", 1, NULL, 'M'}, {"global", 0, NULL, OPTVAL_GLOBAL}, @@ -106,7 +105,6 @@ enum pm_tool_request_e { UNINSTALL_REQ, REINSTALL_REQ, MOUNT_INSTALL_REQ, - CSC_REQ, GETSIZE_REQ, CLEAR_REQ, MOVE_REQ, @@ -775,17 +773,9 @@ static int __process_request(uid_t uid) if (data.global) /* enable global app for this user only */ ret = pkgmgr_client_activate_global_app_for_uid(pc, data.pkgid, __app_return_cb, getuid()); - else if (strlen(data.label) == 0) + else /* enable app which belongs to this user */ ret = pkgmgr_client_usr_activate_app(pc, data.pkgid, __app_return_cb, uid); - else { - /* deprecated? */ - printf("label [%s]\n", data.label); - char *largv[3] = {NULL, }; - largv[0] = "-l"; - largv[1] = data.label; - ret = pkgmgr_client_usr_activate_appv(pc, data.pkgid, largv, uid); - } } else { ret = pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_INSTALL); if (ret != PKGMGR_R_OK) { @@ -1000,13 +990,6 @@ static int __process_request(uid_t uid) ret = -1; break; - case CSC_REQ: - ret = pkgmgr_client_usr_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, uid, - data.des_path, NULL, (void *)data.pkg_path); - if (ret < 0) - data.result = PKGCMD_ERRCODE_ERROR; - break; - case GETSIZE_REQ: if (data.pkgid[0] == '\0') { printf("Please provide the arguments.\n"); @@ -1165,14 +1148,6 @@ int main(int argc, char *argv[]) data.request = MOVE_REQ; break; - case 'S': /* csc packages */ - data.request = CSC_REQ; - if (optarg) - snprintf(data.des_path, sizeof(data.des_path), - "%s", optarg); - printf("csc file is %s\n", data.des_path); - break; - case 'A': /* activate */ data.request = ACTIVATE_REQ; break; -- 2.7.4 From 8762fcc74c6bea6c5d2e29a7e9e896946b29b705 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Fri, 19 Aug 2016 16:59:33 +0200 Subject: [PATCH 06/16] Add global symlink error handling to pkgcmd Requires: https://review.tizen.org/gerrit/84635 Change-Id: Ifd8439ba2e678dfd0bba9a674ee75a9996bccced --- src/pkg_cmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pkg_cmd.c b/src/pkg_cmd.c index d5b4f81..a705938 100644 --- a/src/pkg_cmd.c +++ b/src/pkg_cmd.c @@ -151,6 +151,9 @@ static void __error_no_to_string(int errnumber, char **errstr) if (errstr == NULL) return; switch (errnumber) { + case PKGCMD_ERRCODE_GLOBALSYMLINK_ERROR: + *errstr = PKGCMD_ERRCODE_GLOBALSYMLINK_ERROR_STR; + break; case PKGCMD_ERRCODE_GRANT_PERMISSION_ERROR: *errstr = PKGCMD_ERRCODE_GRANT_PERMISSION_ERROR_STR; break; -- 2.7.4 From 326333f345ac18316a5fcd731f2b9611dd2ae35f Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 25 Aug 2016 11:03:12 +0900 Subject: [PATCH 07/16] Move message buffer definition to c file The change fixes build with -fno-common and enables Address Sanitizer. Change-Id: I146d7c9052e92e86f133882e5c734f21c99a4ef1 Signed-off-by: Sangyoon Jang --- src/delta.c | 1 + src/delta.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/delta.c b/src/delta.c index a462766..fbc5968 100644 --- a/src/delta.c +++ b/src/delta.c @@ -206,6 +206,7 @@ void __create_diff_file(char *old_tpk_path, char *new_tpk_path) GList *next_iterator_old_tpk = NULL; GList *next_iterator_new_tpk = NULL; int ret = -1; + char message[MAX_MESSAGE_LEN]; list_dir_old_tpk = __list_directory(old_tpk_path, old_tpk_path, list_dir_old_tpk); list_dir_new_tpk = __list_directory(new_tpk_path, new_tpk_path, list_dir_new_tpk); diff --git a/src/delta.h b/src/delta.h index 4d1d171..b9afc21 100644 --- a/src/delta.h +++ b/src/delta.h @@ -25,7 +25,6 @@ #define UNZIPFILE "_FILES" #define MAX_MESSAGE_LEN 1024 #define BUF_SIZE 1024 -char message[MAX_MESSAGE_LEN]; void __create_diff_file(char *old_tpk_path, char *new_tpk_path); int __xsystem(const char *argv[]); -- 2.7.4 From 63f0eaf1f7152e58acfa88e9014adcd833589a24 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 19 Aug 2016 14:03:21 +0900 Subject: [PATCH 08/16] Add package_app_info.app_installed_storage filter at pkg_info Change-Id: I0abcba105bc5ef87f6c70599b0e33a424fa5e68d Signed-off-by: Junghyun Yeon --- src/pkg_info.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pkg_info.c b/src/pkg_info.c index 0f2c12f..b28e9e8 100644 --- a/src/pkg_info.c +++ b/src/pkg_info.c @@ -389,6 +389,7 @@ static int __add_app_filter(uid_t uid) printf("17 --> filter by app screenreader\n"); printf("18 --> filter by app ui-gadget [0|1]\n"); printf("19 --> filter by app support disable [0|1]\n"); + printf("20 --> filter by app installed storage\n"); choice = __get_integer_input_data(); switch (choice) { case 0: @@ -613,6 +614,17 @@ static int __add_app_filter(uid_t uid) goto err; } break; + case 20: + value = __get_string_input_data(); + ret = pkgmgrinfo_appinfo_filter_add_string(handle, + PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE, value); + if (ret < 0) { + printf("pkgmgrinfo_appinfo_filter_add_string() failed\n"); + ret = -1; + goto err; + } + break; + default: printf("Invalid filter property\n"); ret = -1; -- 2.7.4 From 5107bddf03b25c1732ae1747a5ef6104062332d0 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 10 Aug 2016 16:03:58 +0900 Subject: [PATCH 09/16] Implement pkg db upgrade tool Related changes [app-installers] : https://review.tizen.org/gerrit/#/c/86789/ [tpk-backend] : https://review.tizen.org/gerrit/#/c/86846/ [wgt-backend] : https://review.tizen.org/gerrit/#/c/87472/ Change-Id: Ib285356186fc052436530731c7a322b74137b79d Signed-off-by: Junghyun Yeon --- CMakeLists.txt | 2 + data/300.pkgmgr.patch.sh.in | 101 ++++++++++++++++++++++++++++++++++++++++++++ packaging/pkgmgr-tool.spec | 2 + 3 files changed, 105 insertions(+) create mode 100644 data/300.pkgmgr.patch.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index b7a96db..0c33e87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,3 +71,5 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/pkgmgr-unzip-pkg.sh.in pkgmgr-un INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr-unzip-pkg.sh DESTINATION ${SYSCONF_INSTALL_DIR}/package-manager/) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/data/pkgmgr-create-delta.sh.in pkgmgr-create-delta.sh @ONLY) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr-create-delta.sh DESTINATION ${SYSCONF_INSTALL_DIR}/package-manager/) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/300.pkgmgr.patch.sh.in 300.pkgmgr.patch.sh @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/300.pkgmgr.patch.sh DESTINATION /usr/share/upgrade/scripts/) diff --git a/data/300.pkgmgr.patch.sh.in b/data/300.pkgmgr.patch.sh.in new file mode 100644 index 0000000..fd6067e --- /dev/null +++ b/data/300.pkgmgr.patch.sh.in @@ -0,0 +1,101 @@ +#!/bin/sh +#---------------------------------- +# upgrade script for pkgmgr +#---------------------------------- + +#backup previous db +mv /opt/dbspace/.pkgmgr_parser.db /opt/dbspace/.pkgmgr_parser_backup.db + +#copy user app's manifest file and change owner, smack label +sqlite3 /opt/dbspace/.pkgmgr_parser_backup.db "SELECT package FROM package_info WHERE package_preload='false' COLLATE NOCASE AND package_type='tpk'" | +awk '{ +system("cp --no-preserve=ownership /opt/usr/apps/" $1 "/tizen-manifest.xml /opt/usr/home/owner/.applications/manifest/" $1 ".xml") +system("chown owner:users /opt/usr/home/owner/.applications/manifest/" $1 ".xml") +system("chsmack -a User::Home /opt/usr/home/owner/.applications/manifest/" $1 ".xml") +system("rm /opt/share/packages/" $1 ".xml") +}' + +#remove pkg folder which is not registered at pkg db +rm -r /opt/usr/apps/media-server +rm -r /opt/usr/apps/org.tizen.indicator_shm +rm -r /opt/usr/apps/org.tizen.sound-player +rm -r /opt/usr/apps/tmp + +#remove wgt app's xml at /opt/share/packages before pkg_initdb +sqlite3 /opt/dbspace/.pkgmgr_parser_backup.db "SELECT package FROM package_info WHERE package_preload='false' COLLATE NOCASE AND package_type='wgt'" | +awk '{system("rm /opt/share/packages/" $1 ".xml")}' + +pkg_initdb + +#delete userdata of packages which are removed from 3.0 +sqlite3 /opt/dbspace/.pkgmgr_parser.db "ATTACH DATABASE '/opt/dbspace/.pkgmgr_parser_backup.db' AS backup; +SELECT package from backup.package_info WHERE package_preload='true' COLLATE NOCASE AND +package NOT IN (SELECT package FROM package_info)" | +awk '{ system("rm -r " "/opt/usr/apps/" $1)}' + +#move preload package's userdata +sqlite3 /opt/dbspace/.pkgmgr_parser.db "ATTACH DATABASE '/opt/dbspace/.pkgmgr_parser_backup.db' AS backup; +SELECT package from backup.package_info WHERE package IN (SELECT package FROM package_info)" | +awk '{ +system("cp -r -f --no-preserve=ownership /opt/usr/apps/" $1 "/cache/ /opt/usr/home/owner/apps_rw/" $1) +system("chown -R owner:users /opt/usr/home/owner/apps_rw/" $1 "/cache") +system("chsmack -r -a User::Pkg::" $1 " /opt/usr/home/owner/apps_rw/" $1 "/cache") +system("cp -r -f --no-preserve=ownership /opt/usr/apps/" $1 "/data/ /opt/usr/home/owner/apps_rw/" $1) +system("chown -R owner:users /opt/usr/home/owner/apps_rw/" $1 "/data") +system("chsmack -r -a User::Pkg::" $1 " /opt/usr/home/owner/apps_rw/" $1 "/data") +system("cp -r -f --no-preserve=ownership /opt/usr/apps/" $1 "/shared/ /opt/usr/home/owner/apps_rw/" $1) +system("chown -R owner:users /opt/usr/home/owner/apps_rw/" $1 "/shared") +system("chsmack -r -a User::Home /opt/usr/home/owner/apps_rw/" $1 "/shared") +system("chsmack -r -a User::Pkg::" $1 "::SharedRO /opt/usr/home/owner/apps_rw/" $1 "/shared/data") +system("rm -r /opt/usr/apps/" $1) +}' + +#check preload package which is disabled and enable it +sqlite3 /opt/dbspace/.pkgmgr_parser.db "ATTACH DATABASE '/opt/dbspace/.pkgmgr_parser_backup.db' AS backup; +SELECT package from backup.package_info WHERE package_preload='true' COLLATE NOCASE AND +package_disable='true' COLLATE NOCASE AND +package IN (SELECT package from package_info)" | +awk '{ system("tpk-backend -D " $1 " --preload")}' + +#copy userdata for userapp +sqlite3 /opt/dbspace/.pkgmgr_parser_backup.db "SELECT package FROM package_info WHERE package_preload='false' COLLATE NOCASE" | +awk '{ +system("mv /opt/usr/apps/" $1 "/ /opt/usr/home/owner/apps_rw/") +system("chown -R owner:users /opt/usr/home/owner/apps_rw/" $1) +system("chsmack -r -a User::Home /opt/usr/home/owner/apps_rw/" $1) +system("chsmack -r -a User::Pkg::" $1 " /opt/usr/home/owner/apps_rw/" $1 "/cache") +system("chsmack -r -a User::Pkg::" $1 " /opt/usr/home/owner/apps_rw/" $1 "/data") +system("chsmack -r -a User::Pkg::" $1 "::RO /opt/usr/home/owner/apps_rw/" $1 "/bin") +system("chsmack -r -a User::Pkg::" $1 "::RO /opt/usr/home/owner/apps_rw/" $1 "/lib") +system("chsmack -r -a User::Pkg::" $1 "::RO /opt/usr/home/owner/apps_rw/" $1 "/res") +system("chsmack -r -a User::Pkg::" $1 "::SharedRO /opt/usr/home/owner/apps_rw/" $1 "/shared/data") +system("chsmack -r -a User::Author::1 /opt/usr/home/owner/apps_rw/" $1 "/shared/trusted") +}' + +#userdb init +pkg_initdb --uid 5001 + +#manifest direct install for user wgt apps +sqlite3 /opt/dbspace/.pkgmgr_parser_backup.db "SELECT package FROM package_info WHERE package_preload='false' COLLATE NOCASE AND package_type='wgt'" | +awk '{ +system("wgt-backend -y " $1 " -u 5001") +system("mkdir /opt/usr/home/owner/apps_rw/" $1 "/cache") +system("chown owner:users /opt/usr/home/owner/apps_rw/" $1 "/cache") +system("chsmack -a User::Pkg::" $1 " /opt/usr/home/owner/apps_rw/" $1 "/cache") +}' + +#disable user package +sqlite3 /opt/dbspace/user/5001/.pkgmgr_parser.db "ATTACH DATABASE '/opt/dbspace/.pkgmgr_parser_backup.db' AS backup; +SELECT package FROM backup.package_info WHERE package_preload='false' COLLATE NOCASE AND +package_disable='true' COLLATE NOCASE AND package_type='tpk' AND +package IN (select package from package_info)" | +awk '{ system("tpk-backend -D " $1 " -u 5001")}' + +sqlite3 /opt/dbspace/user/5001/.pkgmgr_parser.db "ATTACH DATABASE '/opt/dbspace/.pkgmgr_parser_backup.db' AS backup; +SELECT package FROM backup.package_info WHERE package_preload='false' COLLATE NOCASE AND +package_disable='true' COLLATE NOCASE AND package_type='wgt' AND +package IN (select package from package_info)" | +awk '{ system("wgt-backend -D " $1 " -u 5001")}' + +#remove backups +rm -r /opt/dbspace/.pkgmgr_parser_backup.db diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 7b9b010..60a8361 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -78,6 +78,7 @@ fi %defattr(-,root,root,-) %dir %{_sysconfdir}/opt/upgrade %{_sysconfdir}/opt/upgrade/pkgmgr.patch.sh +/usr/share/upgrade/scripts/300.pkgmgr.patch.sh %{_bindir}/pkgcmd %{_bindir}/pkg_getsize %{_bindir}/pkg_clearcache @@ -88,4 +89,5 @@ fi %{_datadir}/mime/packages/mime.tpk.xml %attr(0700,root,root) /etc/package-manager/pkgmgr-unzip-pkg.sh %attr(0700,root,root) /etc/package-manager/pkgmgr-create-delta.sh +%attr(0700,root,root) /usr/share/upgrade/scripts/300.pkgmgr.patch.sh /usr/share/license/%{name} -- 2.7.4 From 388c38ad327d90b467b3853b4f0826f4226cd10d Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 20 Sep 2016 09:45:36 +0900 Subject: [PATCH 10/16] Seperate pkgmgr client for listen and request Change-Id: If7158a733a14b2d33e5c4e687d06a5b3d5b3cb6c Signed-off-by: Junghyun Yeon --- src/pkg_cmd.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/pkg_cmd.c b/src/pkg_cmd.c index a705938..f2191de 100644 --- a/src/pkg_cmd.c +++ b/src/pkg_cmd.c @@ -539,6 +539,7 @@ static int __process_request(uid_t uid) { int ret = -1; pkgmgr_client *pc = NULL; + pkgmgr_client *listen_pc = NULL; char buf[1024] = {'\0'}; int pid = -1; char pkg_old[PATH_MAX] = {0, }; @@ -780,12 +781,13 @@ static int __process_request(uid_t uid) /* enable app which belongs to this user */ ret = pkgmgr_client_usr_activate_app(pc, data.pkgid, __app_return_cb, uid); } else { - ret = pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_INSTALL); - if (ret != PKGMGR_R_OK) { - printf("Failed to set status type[%d]\n", ret); + listen_pc = pkgmgr_client_new(PC_LISTENING); + if (listen_pc == NULL) { + printf("PkgMgr Client Creation Failed\n"); + ret = -1; break; } - ret = pkgmgr_client_listen_status(pc, __return_cb, NULL); + ret = pkgmgr_client_listen_status(listen_pc, __return_cb, NULL); if (ret < 0) { printf("Failed to set callback[%d]\n", ret); break; @@ -823,17 +825,17 @@ static int __process_request(uid_t uid) /* disable app which belongs to this user */ ret = pkgmgr_client_usr_deactivate_app(pc, data.pkgid, __app_return_cb, uid); } else { - ret = pkgmgr_client_set_status_type(pc, PKGMGR_CLIENT_STATUS_UNINSTALL); - if (ret != PKGMGR_R_OK) { - printf("Failed to set status type[%d]\n", ret); + listen_pc = pkgmgr_client_new(PC_LISTENING); + if (listen_pc == NULL) { + printf("PkgMgr Client Creation Failed\n"); + ret = -1; break; } - ret = pkgmgr_client_listen_status(pc, __return_cb, NULL); + ret = pkgmgr_client_listen_status(listen_pc, __return_cb, NULL); if (ret < 0) { printf("Failed to set callback[%d]\n", ret); break; } - /* disable package which belongs to this user*/ ret = pkgmgr_client_usr_deactivate(pc, data.pkg_type, data.pkgid, uid); } if (ret < 0) @@ -1070,6 +1072,12 @@ static int __process_request(uid_t uid) pkgmgr_client_free(pc); pc = NULL; } + + if (listen_pc) { + pkgmgr_client_free(listen_pc); + listen_pc = NULL; + } + return ret; } -- 2.7.4 From 41d37f851abe65ffd3ac1b650e63477c40aac856 Mon Sep 17 00:00:00 2001 From: Piotr Dabrowski Date: Wed, 21 Sep 2016 14:07:14 +0200 Subject: [PATCH 11/16] Add --clear-all option to pkgcmd Usage: pkgcmd --clear-all pkgcmd --clear-all -t wgt pkgcmd --clear-all -t tpk Change-Id: Idae766ed8b98f04efe4667cdba2f3fc232434430 --- src/pkg_cmd.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 106 insertions(+), 18 deletions(-) diff --git a/src/pkg_cmd.c b/src/pkg_cmd.c index f2191de..332dca2 100644 --- a/src/pkg_cmd.c +++ b/src/pkg_cmd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: Jayoun Lee , Sewook Park , * Jaeho Lee , Shobhit Srivastava @@ -53,6 +53,7 @@ #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) #define OPTVAL_GLOBAL 1000 +#define OPTVAL_CLEAR_ALL 1001 static int __process_request(uid_t uid); static void __print_usage(); @@ -72,6 +73,7 @@ const struct option long_options[] = { {"mount-install", 0, NULL, 'w'}, {"move", 0, NULL, 'm'}, {"clear", 0, NULL, 'c'}, + {"clear-all", 0, NULL, OPTVAL_CLEAR_ALL}, {"getsize", 0, NULL, 'g'}, {"activate", 0, NULL, 'A'}, {"deactivate", 0, NULL, 'D'}, @@ -107,6 +109,7 @@ enum pm_tool_request_e { MOUNT_INSTALL_REQ, GETSIZE_REQ, CLEAR_REQ, + CLEAR_ALL_REQ, MOVE_REQ, ACTIVATE_REQ, DEACTIVATE_REQ, @@ -382,16 +385,20 @@ static int __is_app_installed(char *pkgid, uid_t uid) static void __print_usage() { - printf("\nPackage Manager Tool Version: %s\n\n", PKG_TOOL_VERSION); + printf("\nPackage Manager Tool Version: %s\n", PKG_TOOL_VERSION); + + printf("\n"); printf("-i, --install install the package\n"); printf("-u, --uninstall uninstall the package\n"); printf("-r, --reinstall reinstall the package\n"); printf("-w, --mount-install mount install the package\n"); printf("-c, --clear clear user data\n"); + printf(" --clear-all clear user data for all packages or packages type\n"); printf("-m, --move move package\n"); printf("-g, --getsize get size of given package\n"); - printf("-T, --getsize-type get type [0 : total size /1: data size]\n"); - printf("-l, --list display list of installed packages available for the current user [i.e. User's specific Apps and Global Apps] \n"); + printf("-T, --getsize-type get type [0: total size / 1: data size]\n"); + printf("-l, --list display list of installed packages available for the current user\n"); + printf(" i.e. user's specific apps and global apps\n"); printf("-s, --show show detail package info\n"); printf("-a, --app-path show app installation path\n"); printf("-C, --check check if applications belonging to a package are running or not\n"); @@ -400,33 +407,37 @@ static void __print_usage() printf("-p, --package-path provide package path\n"); printf("-n, --package-name provide package name\n"); printf("-t, --package-type provide package type\n"); - printf("-T, --move-type provide move type [0 : move to internal /1: move to external]\n"); - printf("--global Global Mode [Warning user should be privilegied to use this mode] \n"); - printf("-e, --tep-path provide TEP package path\n"); - printf("-M, --tep-move decide move/copy of TEP package[0:copy TEP package /1 : move TEP package, \n"); + printf("-T, --move-type provide move type [0: move to internal / 1: move to external]\n"); + printf(" --global Global Mode [Warning: user should be privilegied to use this mode]\n"); + printf("-e, --tep-path provide TEP package path\n"); + printf("-M, --tep-move decide move/copy of TEP package [0: copy TEP package / 1: move TEP package]\n"); printf("-G, --debug-mode install the package with debug mode for sdk\n"); - printf("-h, --help . print this help\n\n"); + printf("-h, --help print this help\n"); + printf("\n"); printf("Usage: pkgcmd [options]\n"); printf("pkgcmd -i -t (-d ) -p (--global)\n"); printf("pkgcmd -u -n (--global)\n"); - printf("pkgcmd -r -t -n (--global) \n"); + printf("pkgcmd -r -t -n (--global)\n"); printf("pkgcmd -w -t (-d ) -p (--global)\n"); - printf("pkgcmd -l (-t ) \n"); + printf("pkgcmd -l (-t )\n"); printf("pkgcmd -s -t -p \n"); printf("pkgcmd -s -t -n \n"); - printf("pkgcmd -m -t -T -n \n\n"); - printf("pkgcmd -g -T -n \n"); - printf("pkgcmd -C -n \n"); - printf("pkgcmd -k -n \n"); - printf("pkgcmd -X -Y -Z \n"); - + printf("pkgcmd -m -t -T -n \n"); + printf("pkgcmd -g -T -n \n"); + printf("pkgcmd -C -n \n"); + printf("pkgcmd -k -n \n"); + printf("pkgcmd --clear-all (-t )\n"); + printf("pkgcmd -X -Y -Z \n"); + + printf("\n"); printf("Example:\n"); printf("pkgcmd -u -n org.example.hello\n"); printf("pkgcmd -i -t tpk -p /tmp/org.example.hello-1.0.0-arm.tpk\n"); printf("pkgcmd -r -t tpk -n org.example.hello\n"); printf("pkgcmd -w -t tpk -p /tmp/org.example.hello-1.0.0-arm.tpk\n"); printf("pkgcmd -c -t tpk -n org.example.hello\n"); + printf("pkgcmd --clear-all -t wgt\n"); printf("pkgcmd -m -t tpk -T 1 -n org.example.hello\n"); printf("pkgcmd -C -n org.example.hello\n"); printf("pkgcmd -k -n org.example.hello\n"); @@ -436,8 +447,8 @@ static void __print_usage() printf("pkgcmd -l -t tpk\n"); printf("pkgcmd -g -T 0 -n org.example.hello\n"); + printf("\n"); exit(0); - } static int __pkgmgr_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data) @@ -535,6 +546,40 @@ static void __total_pkg_size_info_recv_cb(pkgmgr_client *pc, const pkg_size_info g_main_loop_quit(main_loop); } +static int __pkgmgr_list_clear_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data) +{ + int ret = -1; + char *pkgid = NULL; + char *pkg_type = NULL; + + ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); + if (ret == -1) { + printf("Failed to get pkgmgrinfo_pkginfo_get_pkgid\n"); + return ret; + } + ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type); + if (ret == -1) { + printf("Failed to get pkgmgrinfo_pkginfo_get_type\n"); + return ret; + } + + pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle; + uid_t uid = uid_info->uid; + + pkgmgr_client *pc = pkgmgr_client_new(PC_REQUEST); + if (pc == NULL) { + printf("PkgMgr Client Creation Failed\n"); + return -1; + } + ret = pkgmgr_client_usr_clear_user_data(pc, pkg_type, pkgid, PM_QUIET, + uid); + if (ret >= 0) + ret = data.result; + pkgmgr_client_free(pc); + + return ret; +} + static int __process_request(uid_t uid) { int ret = -1; @@ -757,6 +802,45 @@ static int __process_request(uid_t uid) ret = data.result; break; + case CLEAR_ALL_REQ: + if (data.pkg_type[0] == '\0') { + ret = 0; + if (uid != GLOBAL_USER) + ret = pkgmgrinfo_pkginfo_get_usr_list(__pkgmgr_list_clear_cb, NULL, uid); + else + ret = pkgmgrinfo_pkginfo_get_list(__pkgmgr_list_clear_cb, NULL); + + if (ret == -1) + printf("no packages found\n"); + break; + } else { + pkgmgrinfo_pkginfo_filter_h handle; + + ret = pkgmgrinfo_pkginfo_filter_create(&handle); + if (ret == -1) { + printf("Failed to get package filter handle\n"); + break; + } + + ret = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, data.pkg_type); + if (ret == -1) { + printf("Failed to add package type filter\n"); + pkgmgrinfo_pkginfo_filter_destroy(handle); + break; + } + + if (uid != GLOBAL_USER) + ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkgmgr_list_clear_cb, NULL, uid); + else + ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgmgr_list_clear_cb, NULL); + + if (ret != PMINFO_R_OK) + printf("no package filter list\n"); + + pkgmgrinfo_pkginfo_filter_destroy(handle); + break; + } + case ACTIVATE_REQ: if (data.pkg_type[0] == '\0' || data.pkgid[0] == '\0') { printf("Please provide the arguments.\n"); @@ -1147,6 +1231,10 @@ int main(int argc, char *argv[]) data.request = CLEAR_REQ; break; + case OPTVAL_CLEAR_ALL: /* clear all */ + data.request = CLEAR_ALL_REQ; + break; + case 'g': /* get pkg size */ data.request = GETSIZE_REQ; break; -- 2.7.4 From 8ce39b52921b350709a8ff6374143671b1ff4862 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 30 Sep 2016 16:57:26 +0900 Subject: [PATCH 12/16] Add PATH environment at upgrade script Change-Id: Ia68545090275f8821f313c619503749810ff1a45 Signed-off-by: Junghyun Yeon --- data/300.pkgmgr.patch.sh.in | 1 + 1 file changed, 1 insertion(+) diff --git a/data/300.pkgmgr.patch.sh.in b/data/300.pkgmgr.patch.sh.in index fd6067e..df5ca4b 100644 --- a/data/300.pkgmgr.patch.sh.in +++ b/data/300.pkgmgr.patch.sh.in @@ -1,4 +1,5 @@ #!/bin/sh +PATH=/bin:/usr/bin:/sbin:/usr/sbin #---------------------------------- # upgrade script for pkgmgr #---------------------------------- -- 2.7.4 From a98825170d1a98612cd8b49e6108d47d6e5cea6b Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Fri, 30 Sep 2016 15:26:51 +0900 Subject: [PATCH 13/16] Change the access label of pkgcmd, pkginfo to User::Shell Change-Id: I59294aad74fc6c8c3ad5f0f96954df9c8504edba Signed-off-by: jongmyeongko --- packaging/pkgmgr-tool.manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/pkgmgr-tool.manifest b/packaging/pkgmgr-tool.manifest index b33b4cc..62a58f5 100644 --- a/packaging/pkgmgr-tool.manifest +++ b/packaging/pkgmgr-tool.manifest @@ -4,9 +4,9 @@ - + - + -- 2.7.4 From c5784032fe509958ea69e454e0c929fba331bc90 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 20 Oct 2016 11:29:52 +0900 Subject: [PATCH 14/16] Remove updating mime database This will be moved to installer-app package. Change-Id: I06e4ea64c030257441cd39c31b86a82d80c63d33 Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 3 --- data/mime.tpk.xml | 10 ---------- data/mime.wac.xml | 12 ------------ packaging/pkgmgr-tool.spec | 4 ---- 4 files changed, 29 deletions(-) delete mode 100644 data/mime.tpk.xml delete mode 100644 data/mime.wac.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c33e87..bcdf03d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,9 +62,6 @@ ADD_EXECUTABLE(rsc-slice src/pkg_rsc_slice.c) TARGET_LINK_LIBRARIES(rsc-slice ${pkgs_test_LDFLAGS}) INSTALL(TARGETS rsc-slice DESTINATION bin) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mime.wac.xml DESTINATION /usr/share/mime/packages/) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mime.tpk.xml DESTINATION /usr/share/mime/packages/) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/pkgmgr.patch.sh.in pkgmgr.patch.sh @ONLY) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr.patch.sh DESTINATION ${SYSCONF_INSTALL_DIR}/opt/upgrade/) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/pkgmgr-unzip-pkg.sh.in pkgmgr-unzip-pkg.sh @ONLY) diff --git a/data/mime.tpk.xml b/data/mime.tpk.xml deleted file mode 100644 index 3aedf49..0000000 --- a/data/mime.tpk.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Tizen Package - TPK - Tizen PacKage - - - diff --git a/data/mime.wac.xml b/data/mime.wac.xml deleted file mode 100644 index 099c661..0000000 --- a/data/mime.wac.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - WAC Widget - WAC 위젯 - WGT - wac WidGeT - - - - diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 60a8361..a419c35 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -54,8 +54,6 @@ cp LICENSE %{buildroot}/usr/share/license/%{name} %post /sbin/ldconfig -# Update mime database to support package mime types -update-mime-database %{_datadir}/mime chsmack -a '*' %{TZ_SYS_RW_PACKAGES} %posttrans @@ -85,8 +83,6 @@ fi %{_bindir}/pkginfo %{_bindir}/rsc-slice %attr(0755,root,root) %{_bindir}/install_preload_tpk -%{_datadir}/mime/packages/mime.wac.xml -%{_datadir}/mime/packages/mime.tpk.xml %attr(0700,root,root) /etc/package-manager/pkgmgr-unzip-pkg.sh %attr(0700,root,root) /etc/package-manager/pkgmgr-create-delta.sh %attr(0700,root,root) /usr/share/upgrade/scripts/300.pkgmgr.patch.sh -- 2.7.4 From c6e55a5049a5666a4d2fe9063e41c10e2deacecc Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Tue, 25 Oct 2016 19:12:59 +0900 Subject: [PATCH 15/16] support preload install for wgt pkg. Change-Id: I4e3abed6be5aa4578ab264503b509141e378c099 Signed-off-by: jongmyeongko --- CMakeLists.txt | 6 +-- packaging/pkgmgr-tool.manifest | 2 +- packaging/pkgmgr-tool.spec | 4 +- ...install_preload_tpk.c => install_preload_pkg.c} | 60 ++++++++++++---------- 4 files changed, 40 insertions(+), 32 deletions(-) rename src/{install_preload_tpk.c => install_preload_pkg.c} (67%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcdf03d..3eb3f0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,9 +54,9 @@ ADD_EXECUTABLE(pkg_clearcache src/pkg_clearcache.c) TARGET_LINK_LIBRARIES(pkg_clearcache ${pkgs_test_LDFLAGS}) INSTALL(TARGETS pkg_clearcache DESTINATION bin) -ADD_EXECUTABLE(install_preload_tpk src/install_preload_tpk.c) -TARGET_LINK_LIBRARIES(install_preload_tpk ${pkgs_test_LDFLAGS}) -INSTALL(TARGETS install_preload_tpk DESTINATION bin) +ADD_EXECUTABLE(install_preload_pkg src/install_preload_pkg.c) +TARGET_LINK_LIBRARIES(install_preload_pkg ${pkgs_test_LDFLAGS}) +INSTALL(TARGETS install_preload_pkg DESTINATION bin) ADD_EXECUTABLE(rsc-slice src/pkg_rsc_slice.c) TARGET_LINK_LIBRARIES(rsc-slice ${pkgs_test_LDFLAGS}) diff --git a/packaging/pkgmgr-tool.manifest b/packaging/pkgmgr-tool.manifest index 62a58f5..7f2bbf1 100644 --- a/packaging/pkgmgr-tool.manifest +++ b/packaging/pkgmgr-tool.manifest @@ -3,7 +3,7 @@ - + diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index a419c35..b07df42 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -61,7 +61,7 @@ if [ ! -f %{TZ_SYS_DB}/.pkgmgr_parser.db ] then pkg_initdb fi -install_preload_tpk +install_preload_pkg if [ -f /tmp/.preload_install_error ] then if [ ! -d /tmp/.postscript/error ] @@ -82,7 +82,7 @@ fi %{_bindir}/pkg_clearcache %{_bindir}/pkginfo %{_bindir}/rsc-slice -%attr(0755,root,root) %{_bindir}/install_preload_tpk +%attr(0755,root,root) %{_bindir}/install_preload_pkg %attr(0700,root,root) /etc/package-manager/pkgmgr-unzip-pkg.sh %attr(0700,root,root) /etc/package-manager/pkgmgr-create-delta.sh %attr(0700,root,root) /usr/share/upgrade/scripts/300.pkgmgr.patch.sh diff --git a/src/install_preload_tpk.c b/src/install_preload_pkg.c similarity index 67% rename from src/install_preload_tpk.c rename to src/install_preload_pkg.c index b270b55..ea797ca 100644 --- a/src/install_preload_tpk.c +++ b/src/install_preload_pkg.c @@ -37,18 +37,21 @@ #ifdef _E #undef _E #endif -#define _E(fmt, arg...) fprintf(stderr, "[TPK_PRELOAD_INSTALL][E][%s,%d] \ +#define _E(fmt, arg...) fprintf(stderr, "[PKG_PRELOAD_INSTALL][E][%s,%d] \ "fmt"\n", __FUNCTION__, __LINE__, ##arg); #ifdef _D #undef _D #endif -#define _D(fmt, arg...) fprintf(stderr, "[TPK_PRELOAD_INSTALL][D][%s,%d] \ +#define _D(fmt, arg...) fprintf(stderr, "[PKG_PRELOAD_INSTALL][D][%s,%d] \ "fmt"\n", __FUNCTION__, __LINE__, ##arg); -#define BACKEND_CMD "/usr/bin/tpk-backend" +#define TPK_BACKEND_CMD "/usr/bin/tpk-backend" +#define WGT_BACKEND_CMD "/usr/bin/wgt-backend" +#define TPK_DIR tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-tpk") +#define WGT_DIR tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-wgt") -static int _install_preload_tpk(const char *directory) +static int _install_preload_pkg(const char *backend, const char *directory) { DIR *dir; struct dirent file_info, *result; @@ -59,7 +62,7 @@ static int _install_preload_tpk(const char *directory) dir = opendir(directory); if (!dir) { if (errno == ENOENT) { - _D("The directory for preloaded tpks doesn't exist"); + _D("The directory for preloaded pkgs doesn't exist"); return 0; } else { _E("Failed to access the [%s] because [%s]", directory, @@ -68,7 +71,7 @@ static int _install_preload_tpk(const char *directory) } } - _D("Loading tpk files from %s", directory); + _D("Loading pkg files from %s", directory); for (ret = readdir_r(dir, &file_info, &result); ret == 0 && result != NULL; @@ -78,14 +81,14 @@ static int _install_preload_tpk(const char *directory) snprintf(file_path, sizeof(file_path), "%s/%s", directory, file_info.d_name); - _D("tpk file %s", file_path); + _D("pkg file %s", file_path); pid_t pid = fork(); if (pid == 0) { - execl(BACKEND_CMD, BACKEND_CMD, "-i", file_path, + execl(backend, backend, "-i", file_path, "--preload", (char *)NULL); } else if (pid < 0) { - _E("failed to fork and execute %s!", BACKEND_CMD); + _E("failed to fork and execute %s!", backend); closedir(dir); return -1; } @@ -113,7 +116,7 @@ static int _install_preload_tpk(const char *directory) static int _is_authorized(uid_t uid) { - /* install_preload_tpk should be called by as root privilege. */ + /* install_preload_pkg should be called by as root privilege. */ if ((uid_t) OWNER_ROOT == uid) return 1; else @@ -123,7 +126,6 @@ static int _is_authorized(uid_t uid) int main(int argc, char *argv[]) { char err_msg[BUFSZE]; - const char *dir = tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-tpk"); int handle = -1; int ret = 0; @@ -132,21 +134,27 @@ int main(int argc, char *argv[]) return -1; } - if (_install_preload_tpk(dir) < 0) { - handle = open("/tmp/.preload_install_error", - O_WRONLY | O_CREAT | O_APPEND | O_TRUNC, 0644); - if (handle == -1) { - _E("Failed to open error file"); - return -1; - } - snprintf(err_msg, sizeof(err_msg), - "install_preload_tpk error!\n"); - ret = write(handle, err_msg, strlen(err_msg)); - if (ret == -1) - _E("Failed to write an error message. (%d)", errno); - close(handle); - return -1; - } + if (_install_preload_pkg(TPK_BACKEND_CMD, TPK_DIR) < 0) + goto error; + + if (_install_preload_pkg(WGT_BACKEND_CMD, WGT_DIR) < 0) + goto error; return 0; + +error: + handle = open("/tmp/.preload_install_error", + O_WRONLY | O_CREAT | O_APPEND | O_TRUNC, 0644); + if (handle == -1) { + _E("Failed to open error file"); + return -1; + } + snprintf(err_msg, sizeof(err_msg), + "install_preload_pkg error!\n"); + ret = write(handle, err_msg, strlen(err_msg)); + if (ret == -1) + _E("Failed to write an error message. (%d)", errno); + close(handle); + + return -1; } -- 2.7.4 From 88269ed8dae16cc9751ef0ac2306587bbe6688d0 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 3 Nov 2016 23:36:49 +0900 Subject: [PATCH 16/16] apply the temporary upgrade solution Change-Id: I46d14d6e4dc0efefdbf53a2a6199bd5d1e28f7db Signed-off-by: jongmyeongko --- data/pkgmgr.patch.sh.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/data/pkgmgr.patch.sh.in b/data/pkgmgr.patch.sh.in index d0c2da0..e9819dd 100644 --- a/data/pkgmgr.patch.sh.in +++ b/data/pkgmgr.patch.sh.in @@ -4,5 +4,12 @@ echo "--------------------------------------" source /etc/tizen-platform.conf -/bin/rm $TZ_SYS_DB/.pkgmgr_parser.db +# temporary upgrade tactic +mv $TZ_SYS_DB/.pkgmgr_parser.db $TZ_SYS_DB/.pkgmgr_parser_backup.db +mv $TZ_SYS_DB/user/5001/.pkgmgr_parser.db $TZ_SYS_DB/user/5001/.pkgmgr_parser_backup.db + $TZ_SYS_BIN/pkg_initdb +$TZ_SYS_BIN/pkg_initdb --uid 5001 + +rm -rf $TZ_SYS_DB/.pkgmgr_parser_backup.db +rm -rf $TZ_SYS_DB/user/5001/.pkgmgr_parser_backup.db -- 2.7.4