From 2907c3b50d068a762bf6d2cfd73060fdbb4bdef7 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 4 Jan 2018 13:14:21 +0900 Subject: [PATCH 01/16] Release version 0.4.7 Changes: - Add sciprts for missed column - Fix memory leak Change-Id: I729ab8bcb2831bf19d58f8ea64b3df021a3e4d67 Signed-off-by: Sangyoon Jang --- packaging/pkgmgr-tool.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 198b930..e76777a 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -1,6 +1,6 @@ Name: pkgmgr-tool Summary: Packager Manager Tool package -Version: 0.4.6 +Version: 0.4.7 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 143f9451ede8d91debcdc487398884f3a418dcc9 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Mon, 15 Jan 2018 17:40:35 +0900 Subject: [PATCH 02/16] Fix memory leak Signed-off-by: Seungha Son Change-Id: I8b6ddb7c8576917662d1788e0f08794c5bc65ef1 --- src/pkg_upgrade.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pkg_upgrade.c b/src/pkg_upgrade.c index ebbd787..6ff2bf0 100644 --- a/src/pkg_upgrade.c +++ b/src/pkg_upgrade.c @@ -876,6 +876,7 @@ static int __process_rw_fota(const char *directory) _LOG("can not get pkg version[%s]\n", pkg_info->pkgid); pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + pkgmgr_client_free_pkginfo(pkg_info); continue; } @@ -889,6 +890,7 @@ static int __process_rw_fota(const char *directory) _LOG("can not compare pkg version[%s]\n", pkg_info->pkgid); pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + pkgmgr_client_free_pkginfo(pkg_info); continue; } @@ -896,6 +898,7 @@ static int __process_rw_fota(const char *directory) /* package version is not update on FOTA. */ _LOG("pkg is not updated\n"); pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + pkgmgr_client_free_pkginfo(pkg_info); gettimeofday(&tv, NULL); endtime = tv.tv_sec * 1000l + @@ -907,7 +910,6 @@ static int __process_rw_fota(const char *directory) } _LOG("pkg is updated, need to upgrade\n"); - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); } else { char flag_path[BUF_SIZE] = { 0, }; snprintf(flag_path, BUF_SIZE, "%s/%s", @@ -922,6 +924,7 @@ static int __process_rw_fota(const char *directory) total_time += (int)(endtime - starttime); _LOG("finish request [time : %d ms]\n", (int)(endtime - starttime)); + pkgmgr_client_free_pkginfo(pkg_info); continue; } @@ -936,7 +939,10 @@ static int __process_rw_fota(const char *directory) else _LOG("fail request : %d\n", ret); - pkgmgr_client_free_pkginfo(pkg_info); + if (pkg_info) + pkgmgr_client_free_pkginfo(pkg_info); + if (handle) + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); gettimeofday(&tv, NULL); endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l; -- 2.7.4 From 0498583f5857fe2e78a6c4c13fe555fcc100ee54 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 19 Jan 2018 16:49:32 +0900 Subject: [PATCH 03/16] Release version 0.4.8 Changes: - Fix memory leak Change-Id: I6eb83aecab77c1f899321c8b8b93a5c31c6f617f Signed-off-by: Junghyun Yeon --- packaging/pkgmgr-tool.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index e76777a..1543002 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -1,6 +1,6 @@ Name: pkgmgr-tool Summary: Packager Manager Tool package -Version: 0.4.7 +Version: 0.4.8 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 178a00e769e934ff159bd1b08f715916e4791a8f Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 8 Jan 2018 17:35:11 +0900 Subject: [PATCH 04/16] Perform pkg_upgrade after migrating pkg databases Change-Id: I75e1415d73a0c23b8bf51cb3299056ff1ea8d746 Signed-off-by: Junghyun Yeon --- data/700.pkgmgr.patch.sh.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/700.pkgmgr.patch.sh.in b/data/700.pkgmgr.patch.sh.in index a972fac..cfdfa0f 100644 --- a/data/700.pkgmgr.patch.sh.in +++ b/data/700.pkgmgr.patch.sh.in @@ -3,3 +3,5 @@ source /etc/tizen-platform.conf exec "/etc/package-manager/updates/update.sh" + +/usr/bin/pkg_upgrade -rof \ No newline at end of file -- 2.7.4 From 22924d582509ec419b2909cc715be249f38724fb Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Tue, 24 Oct 2017 11:01:10 +0900 Subject: [PATCH 05/16] add get support-mode info on pkginfo Change-Id: Ia397280a23110fbff30ac039f03eeb0d97baf1e1 (cherry picked from commit 31a67a8d1b528b9eaa7e21185c9625951ce68ad2) --- src/pkg_info.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pkg_info.c b/src/pkg_info.c index 8973bb6..6a50d57 100644 --- a/src/pkg_info.c +++ b/src/pkg_info.c @@ -1779,6 +1779,7 @@ static int __get_pkg_info(char *pkgid, uid_t uid) static int __get_app_info(char *appid) { int ret = -1; + int support_mode = 0; char *exec = NULL; char *app_id = NULL; char *apptype = NULL; @@ -1869,6 +1870,10 @@ static int __get_app_info(char *appid) if (ret < 0) printf("Failed to get preload\n"); + ret = pkgmgrinfo_appinfo_get_support_mode(handle, &support_mode); + if (ret < 0) + printf("Failed to get support_mode\n"); + if (app_id) printf("Appid: %s\n", app_id); @@ -1911,6 +1916,7 @@ static int __get_app_info(char *appid) printf("Enabled: %d\n", enabled); printf("Preload: %d\n", preload); + printf("Support_mode: %d\n", support_mode); pkgmgrinfo_appinfo_destroy_appinfo(handle); -- 2.7.4 From 3478f81b0af4659aa8ca61ad6f52f753ee8dac3d Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 2 Feb 2018 14:03:05 +0900 Subject: [PATCH 06/16] Release version 0.4.9 Changes: - Perform pkg_upgrade after migrating pkg databases - add get support-mode info on pkginfo Change-Id: Iad3bfbcbf50c3758a5e2991529da550ab9482e2c Signed-off-by: Junghyun Yeon --- packaging/pkgmgr-tool.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 1543002..407806e 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -1,6 +1,6 @@ Name: pkgmgr-tool Summary: Packager Manager Tool package -Version: 0.4.8 +Version: 0.4.9 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 440c786113792f6ac095cbf1427df3f15608e9cd Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 5 Feb 2018 15:04:11 +0900 Subject: [PATCH 07/16] Fix double free Change-Id: I9f745a5211e066ec2cd6cc70d81bd2efcf87bb35 Signed-off-by: Sangyoon Jang --- src/pkg_cleardata.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pkg_cleardata.c b/src/pkg_cleardata.c index 1f8159a..de1f341 100644 --- a/src/pkg_cleardata.c +++ b/src/pkg_cleardata.c @@ -72,11 +72,9 @@ static int __get_sdcard_path(char **sdpath) return -1; ret = storage_get_primary_sdcard(&storage_id, sdpath); - if (ret != STORAGE_ERROR_NONE) { - if (*sdpath) - free(*sdpath); + if (ret != STORAGE_ERROR_NONE) return -1; - } + return 0; } -- 2.7.4 From 7a99be6bf3f44e9fae85356d890b67ffb19b810f Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 9 Feb 2018 10:58:45 +0900 Subject: [PATCH 08/16] Release version 0.4.10 Changes: - Fix double free Change-Id: Id6b2b4c3444362772f2aa1dff2a4b9cba425d92c Signed-off-by: Sangyoon Jang --- packaging/pkgmgr-tool.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 407806e..9265b46 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -1,6 +1,6 @@ Name: pkgmgr-tool Summary: Packager Manager Tool package -Version: 0.4.9 +Version: 0.4.10 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 3d7a398eb1151eea61d640f5fe3724d3de6af7e2 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 19 Feb 2018 16:47:26 +0900 Subject: [PATCH 09/16] Fix pkg_upgrade tool - Change filter to get preload pkg to retrieve readonlyupdate pkgs. - When pkg is readonlyupdated but not included at image, set its db attribute properly to treat as normal pkg.(TODO) - When pkg is readnolyupdated and update image has same version, readonlyupdate should be uninstalled except its rwdata. Related changes: [pkgmgr-info] : https://review.tizen.org/gerrit/#/c/170323/ Change-Id: I9ae7f5567034a5c44c0eb8cd62a0b138e6626d27 Signed-off-by: Junghyun Yeon --- src/pkg_upgrade.c | 173 +++++++++++++++++++++++++++++++++--------------------- src/pkg_upgrade.h | 11 ++++ 2 files changed, 116 insertions(+), 68 deletions(-) diff --git a/src/pkg_upgrade.c b/src/pkg_upgrade.c index 6ff2bf0..6ca29db 100644 --- a/src/pkg_upgrade.c +++ b/src/pkg_upgrade.c @@ -50,6 +50,7 @@ #define PKGID_LIST_FROM_XML_FILE \ tzplatform_mkpath(TZ_SYS_GLOBALUSER_DATA, \ "pkgmgr/fota/pkgid_list_from_xml.txt") +#define DBPATH tzplatform_mkpath(TZ_SYS_DB, "/.pkgmgr_parser.db") #define PRELOAD_RW_TPK_PATH \ tzplatform_mkpath(TZ_SYS_RO_APP, ".preload-rw-tpk") @@ -176,9 +177,9 @@ static int __remove_pkgid_list() } static int __make_pkgid_list(const char *file_path, char *pkgid, - char *version, char *type) + char *version, char *type, bool is_update) { - FILE *fp;\ + FILE *fp; if (NULL == pkgid) return 0; @@ -187,10 +188,13 @@ static int __make_pkgid_list(const char *file_path, char *pkgid, if (NULL == fp) return -1; - fprintf(fp, "%s\"%s\" %s\"%s\" %s\"%s\":\n", TOKEN_PKGID_STR, - pkgid, TOKEN_VERSION_STR, version, TOKEN_TYPE_STR, type); + fprintf(fp, "%s\"%s\" %s\"%s\" %s\"%s\" %s\"%s\":\n", + TOKEN_PKGID_STR, pkgid, + TOKEN_VERSION_STR, version, + TOKEN_TYPE_STR, type, + TOKEN_UPDATE_STR, (is_update) ? "true" : "false"); - fclose(fp);\ + fclose(fp); return 0; } @@ -201,6 +205,7 @@ static int __pkgid_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data) char *pkgid = NULL; char *version = NULL; char *type = NULL; + bool is_update = false; ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); err_if(ret < 0, "pkgmgrinfo_pkginfo_get_pkgid failed"); @@ -211,7 +216,11 @@ static int __pkgid_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data) ret = pkgmgrinfo_pkginfo_get_type(handle, &type); err_if(ret < 0, "pkgmgrinfo_pkginfo_get_type failed"); - ret = __make_pkgid_list((char *)user_data, pkgid, version, type); + ret = pkgmgrinfo_pkginfo_is_update(handle, &is_update); + err_if(ret < 0, "pkgmgrinfo_pkginfo_is_update failed"); + + ret = __make_pkgid_list((char *)user_data, pkgid, + version, type, is_update); return ret; } @@ -268,7 +277,7 @@ static char *__getvalue(const char *pBuf, const char *pKey, int depth) } static int __compare_pkgid(char *file_path, char *fota_pkgid, - char *fota_version) + char *fota_version, bool *is_updated) { retvm_if(file_path == NULL, -1, "file_path is null.\n"); retvm_if(fota_pkgid == NULL, -1, "fota_pkgid is null.\n"); @@ -279,6 +288,7 @@ static int __compare_pkgid(char *file_path, char *fota_pkgid, char buf[BUF_SIZE] = {0}; char *pkgid = NULL; char *version = NULL; + char *update = NULL; int compare = PMINFO_VERSION_SAME; fp = fopen(file_path, "r"); @@ -294,13 +304,24 @@ static int __compare_pkgid(char *file_path, char *fota_pkgid, } version = __getvalue(buf, TOKEN_VERSION_STR, 1); - if (version == NULL) { FREE_AND_NULL(pkgid); _LOG("compare_data is null\n"); continue; } + update = __getvalue(buf, TOKEN_UPDATE_STR, 1); + if (update == NULL) { + FREE_AND_NULL(pkgid); + FREE_AND_NULL(version); + _LOG("compare_data is null\n"); + continue; + } + if (!strncmp(update, "true", strlen("true"))) + *is_updated = true; + else + *is_updated = false; + if (strcmp(pkgid, fota_pkgid) == 0) { ret = pkgmgrinfo_compare_package_version(version, fota_version, &compare); @@ -313,17 +334,20 @@ static int __compare_pkgid(char *file_path, char *fota_pkgid, ret = PKG_IS_UPDATED; FREE_AND_NULL(pkgid); FREE_AND_NULL(version); + FREE_AND_NULL(update); break; } FREE_AND_NULL(pkgid); FREE_AND_NULL(version); + FREE_AND_NULL(update); ret = PKG_IS_SAME; break; } FREE_AND_NULL(pkgid); FREE_AND_NULL(version); + FREE_AND_NULL(update); memset(buf, 0x00, BUF_SIZE); } @@ -348,7 +372,7 @@ static int __compare_builtin_removable_pkgid(const char *pkgid) while (fgets(buf, BUF_SIZE, fp) != NULL) { __str_trim(buf); - if (strcmp(buf + strlen("/opt/usr/apps/"), pkgid) == 0) { + if (strstr(buf, pkgid) != NULL) { _LOG("pkgid[%s] will be processed by builtin cmd.\n", pkgid); ret = -1; @@ -384,33 +408,7 @@ char *__manifest_to_package(const char *manifest) return package; } -static int __verify_uninstall_operation(char *pkgid) -{ - int ret = 0; - bool update = false; - bool system = false; - pkgmgrinfo_pkginfo_h handle = NULL; - - ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); - retvm_if(ret < 0, 0, "Failed to get handle\n"); - - ret = pkgmgrinfo_pkginfo_is_update(handle, &update); - tryvm_if(ret < 0, ret = 0, "Failed to get update\n"); - - ret = pkgmgrinfo_pkginfo_is_system(handle, &system); - tryvm_if(ret < 0, ret = 0, "Failed to get system\n"); - - if (system && update) - ret = -1; - else - ret = 0; - -catch: - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - return ret; -} - -static void __send_args_to_backend(char *pkgid, int compare_result) +static void __send_args_to_backend(char *pkgid, int operation) { int ret = 0; @@ -419,35 +417,47 @@ static void __send_args_to_backend(char *pkgid, int compare_result) struct timeval tv; gettimeofday(&tv, NULL); starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l; + char buf[BUF_SIZE]; const char *install_ro[] = { "/usr/bin/tpk-backend", "-y", pkgid, "--preload", "--partial-rw", NULL }; const char *uninstall_ro[] = { "/usr/bin/tpk-backend", "-d", pkgid, - "--preload", "--force-remove", "--partial-rw", NULL }; - - if (compare_result == PKG_IS_SAME) + "--preload", "--force-remove", + "--partial-rw", NULL }; + const char *uninstall_ro_update[] = { "/usr/bin/tpk-backend", "-d", + pkgid, "--keep-rwdata", NULL }; + const char *db_update_to_normal_pkg[] = {"/usr/bin/sqlite3", + NULL, NULL, NULL}; + + if (operation == PKG_NEED_NOTHING) return; if (__compare_builtin_removable_pkgid(pkgid) < 0) return; - switch (compare_result) { - case PKG_IS_INSERTED: - case PKG_IS_UPDATED: + switch (operation) { + case PKG_NEED_INSTALL: + case PKG_NEED_ROUPDATE: ret = __xsystem(install_ro); break; - - case PKG_IS_NOT_EXIST: - ret = __verify_uninstall_operation(pkgid); - if (ret < 0) { - _LOG("pkgid[%s] is updated system, " - "Do not uninstall it\n", pkgid); - return; - } - + case PKG_NEED_UNINSTALL: ret = __xsystem(uninstall_ro); break; - default: + case PKG_NEED_UPDATE_TO_RW: + snprintf(buf, sizeof(buf), + "UPDATE package_info SET " \ + "package_preload='false', " \ + "package_system='false' "\ + "WHERE package='%s'", pkgid); + db_update_to_normal_pkg[1] = strdup(DBPATH); + db_update_to_normal_pkg[2] = strdup(buf); + ret = __xsystem(db_update_to_normal_pkg); + FREE_AND_NULL(db_update_to_normal_pkg[1]); + FREE_AND_NULL(db_update_to_normal_pkg[2]); + break; + case PKG_NEED_RWUNINSTALL: + case PKG_NEED_UPDATE_TO_RO: + ret = __xsystem(uninstall_ro_update); break; } @@ -585,7 +595,7 @@ static int __find_preload_pkgid_from_xml(const char *file_path, type = strdup("tpk"); ret = __make_pkgid_list((char *)file_path, pkgid, - version, type); + version, type, false); if (ret < 0) _LOG("Make file Fail : %s => %s, %s\n", buf, pkgid, version); @@ -618,9 +628,9 @@ static int __find_preload_pkgid_from_db(const char *file_path) "(PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD) failed\n"); ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, - PMINFO_PKGINFO_PROP_PACKAGE_READONLY, 1); + PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM, 1); tryvm_if(ret < 0, ret = -1, "pkgmgrinfo_pkginfo_filter_add_bool" - "(PMINFO_PKGINFO_PROP_PACKAGE_READONLY) failed\n"); + "(PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM) failed\n"); ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkgid_list_cb, (void *)file_path); @@ -649,6 +659,9 @@ static int __find_matched_pkgid_from_list(const char *source_file, int total_pkg_cnt = 0; int compare_result = 0; + int operation = PKG_NEED_NOTHING; + + bool db_update; fp = fopen(source_file, "r"); retvm_if(fp == NULL, -1, "Fail get : %s\n", source_file); @@ -665,19 +678,30 @@ static int __find_matched_pkgid_from_list(const char *source_file, version = __getvalue(buf, TOKEN_VERSION_STR, 1); compare_result = __compare_pkgid((char *)target_file, pkgid, - version); + version, &db_update); if (compare_result == PKG_IS_NOT_EXIST) { _LOG("pkgid[%s] is installed, Start install\n", pkgid); - compare_result = PKG_IS_INSERTED; + operation = PKG_NEED_INSTALL; insert_pkg_cnt++; } else if (compare_result == PKG_IS_SAME) { - same_pkg_cnt++; + if (db_update) { + operation = PKG_NEED_RWUNINSTALL; + update_pkg_cnt++; + } else { + operation = PKG_NEED_NOTHING; + same_pkg_cnt++; + } } else if (compare_result == PKG_IS_UPDATED) { + if (db_update) { + operation = PKG_NEED_UPDATE_TO_RO; + } else { + operation = PKG_NEED_ROUPDATE; + } update_pkg_cnt++; } total_pkg_cnt++; - __send_args_to_backend(pkgid, compare_result); + __send_args_to_backend(pkgid, operation); memset(buf, 0x00, BUF_SIZE); FREE_AND_NULL(pkgid); @@ -706,8 +730,10 @@ static int __find_deleted_pkgid_from_list(const char *source_file, char buf[BUF_SIZE] = {0}; char *pkgid = NULL; char *version = NULL; - + char *update = NULL; + bool xml_update; int deleted_pkg_cnt = 0; + int modified_pkg_cnt = 0; int total_pkg_cnt = 0; int compare_result = 0; @@ -727,24 +753,35 @@ static int __find_deleted_pkgid_from_list(const char *source_file, version = __getvalue(buf, TOKEN_VERSION_STR, 1); compare_result = __compare_pkgid((char *)target_file, pkgid, - version); + version, &xml_update); if (compare_result == PKG_IS_NOT_EXIST) { - _LOG("pkgid[%s] is uninstall, Start uninstall\n", - pkgid); - __send_args_to_backend(pkgid, compare_result); - - deleted_pkg_cnt++; + update = __getvalue(buf, TOKEN_UPDATE_STR, 1); + if (update == NULL) { + FREE_AND_NULL(pkgid); + FREE_AND_NULL(version); + continue; + } + if (!strncmp(update, "false", strlen("false"))) { + __send_args_to_backend(pkgid, + PKG_NEED_UNINSTALL); + deleted_pkg_cnt++; + } else { + __send_args_to_backend(pkgid, + PKG_NEED_UPDATE_TO_RW); + modified_pkg_cnt++; + } } total_pkg_cnt++; memset(buf, 0x00, BUF_SIZE); FREE_AND_NULL(pkgid); FREE_AND_NULL(version); + FREE_AND_NULL(update); } _LOG("-------------------------------------------------------\n"); - _LOG("[Total pkg=%d, deleted package=%d]\n", - total_pkg_cnt, deleted_pkg_cnt); + _LOG("[Total pkg=%d, deleted package=%d, modified package=%d]\n", + total_pkg_cnt, deleted_pkg_cnt, modified_pkg_cnt); _LOG("-------------------------------------------------------\n"); if (fp != NULL) diff --git a/src/pkg_upgrade.h b/src/pkg_upgrade.h index 49dd981..e8d0e2f 100644 --- a/src/pkg_upgrade.h +++ b/src/pkg_upgrade.h @@ -25,6 +25,7 @@ #define TOKEN_PATH_STR "path=" #define TOKEN_OPERATION_STR "op=" #define TOKEN_REMOVE_STR "removable=" +#define TOKEN_UPDATE_STR "update=" #define SEPERATOR_END '"' #define SEPERATOR_MID ':' @@ -95,6 +96,16 @@ typedef enum { PKG_IS_INSERTED } COMPARE_RESULT; +typedef enum { + PKG_NEED_NOTHING = 0, + PKG_NEED_INSTALL, + PKG_NEED_UNINSTALL, + PKG_NEED_ROUPDATE, + PKG_NEED_UPDATE_TO_RW, + PKG_NEED_RWUNINSTALL, + PKG_NEED_UPDATE_TO_RO +} UPGRADE_OPRATION; + enum rpm_request_type { INSTALL_REQ, UNINSTALL_REQ, -- 2.7.4 From 76dfffc64ea16f40f8a0dcb4363c6ff73ee99a4b Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 27 Mar 2018 17:49:52 +0900 Subject: [PATCH 10/16] Release version 0.4.11 Changes: - Fix pkg_upgrade tool Change-Id: Ia04fd60bf5c69857fd493d8781fc4bf61fddb92b Signed-off-by: Junghyun Yeon --- packaging/pkgmgr-tool.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 9265b46..6e53f97 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -1,6 +1,6 @@ Name: pkgmgr-tool Summary: Packager Manager Tool package -Version: 0.4.10 +Version: 0.4.11 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From daa01f95b8b914d5ea7071a8962914c9dbdc03eb Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Mon, 2 Apr 2018 18:49:11 +0900 Subject: [PATCH 11/16] Remove unused dependency in the spec file Change-Id: I65abc4d1992ca2a4aac9ef89e264b122555b5537 Signed-off-by: Semun Lee --- packaging/pkgmgr-tool.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 6e53f97..b070beb 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -12,7 +12,6 @@ Requires: smack BuildRequires: cmake BuildRequires: gettext-tools -BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(dlog) -- 2.7.4 From 572642b7ca91fa64c23d4205113ecb84ac6357dd Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 12 Apr 2018 14:41:33 +0900 Subject: [PATCH 12/16] Release version 0.4.12 Changes: - Remove unused dependency in the spec file Change-Id: I3b5a5c03be2b21a0e00b264258e127db4ff4bddf Signed-off-by: Junghyun Yeon --- packaging/pkgmgr-tool.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index b070beb..cf23411 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -1,6 +1,6 @@ Name: pkgmgr-tool Summary: Packager Manager Tool package -Version: 0.4.11 +Version: 0.4.12 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From c76830fde6e2a41168d7269c6a5685f5b5a8f753 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 25 Apr 2018 15:37:42 +0900 Subject: [PATCH 13/16] Change execute label of pkgcmd to "System" - Shell's privilege will be reduced to prevent sending dbus signal directly so pkgcmd's execute label should be set to work properly. Change-Id: I5185b8fe45f0c820c5c26a12925b4e47501d7b43 Signed-off-by: Junghyun Yeon --- packaging/pkgmgr-tool.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.manifest b/packaging/pkgmgr-tool.manifest index 64f527a..332bf70 100644 --- a/packaging/pkgmgr-tool.manifest +++ b/packaging/pkgmgr-tool.manifest @@ -4,7 +4,7 @@ - + -- 2.7.4 From c16c3a6c57f4f57c478f0a42f4eba009d70ed6ef Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 11 May 2018 15:44:49 +0900 Subject: [PATCH 14/16] Release version 0.4.13 Changes: - Change execute label of pkgcmd to "System" Change-Id: I7f2b6f58b9a83360c91eced73dd06263b1286312 Signed-off-by: Junghyun Yeon --- packaging/pkgmgr-tool.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index cf23411..0837b77 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -1,6 +1,6 @@ Name: pkgmgr-tool Summary: Packager Manager Tool package -Version: 0.4.12 +Version: 0.4.13 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 25d073f69a2cdfc3316ac3d26e70087c1bab9b2f Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 4 May 2018 13:17:12 +0900 Subject: [PATCH 15/16] Fix pkg_upgrade tool to handle wgt packages Change-Id: I7490454a0d08303f141cadc2ae3ca573fffe55fa Signed-off-by: Sangyoon Jang --- src/pkg_upgrade.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/pkg_upgrade.c b/src/pkg_upgrade.c index 6ca29db..eb7b1c9 100644 --- a/src/pkg_upgrade.c +++ b/src/pkg_upgrade.c @@ -408,7 +408,8 @@ char *__manifest_to_package(const char *manifest) return package; } -static void __send_args_to_backend(char *pkgid, int operation) +static void __send_args_to_backend(char *pkgid, const char *pkgtype, + int operation) { int ret = 0; @@ -418,13 +419,14 @@ static void __send_args_to_backend(char *pkgid, int operation) gettimeofday(&tv, NULL); starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l; char buf[BUF_SIZE]; + char backend_cmd[BUF_SIZE]; - const char *install_ro[] = { "/usr/bin/tpk-backend", "-y", pkgid, + const char *install_ro[] = { backend_cmd, "-y", pkgid, "--preload", "--partial-rw", NULL }; - const char *uninstall_ro[] = { "/usr/bin/tpk-backend", "-d", pkgid, + const char *uninstall_ro[] = { backend_cmd, "-d", pkgid, "--preload", "--force-remove", "--partial-rw", NULL }; - const char *uninstall_ro_update[] = { "/usr/bin/tpk-backend", "-d", + const char *uninstall_ro_update[] = { backend_cmd, "-d", pkgid, "--keep-rwdata", NULL }; const char *db_update_to_normal_pkg[] = {"/usr/bin/sqlite3", NULL, NULL, NULL}; @@ -435,6 +437,9 @@ static void __send_args_to_backend(char *pkgid, int operation) if (__compare_builtin_removable_pkgid(pkgid) < 0) return; + snprintf(backend_cmd, sizeof(backend_cmd), "/usr/bin/%s-backend", + pkgtype); + switch (operation) { case PKG_NEED_INSTALL: case PKG_NEED_ROUPDATE: @@ -652,6 +657,7 @@ static int __find_matched_pkgid_from_list(const char *source_file, char buf[BUF_SIZE] = {0}; char *pkgid = NULL; char *version = NULL; + char *pkgtype = NULL; int same_pkg_cnt = 0; int update_pkg_cnt = 0; @@ -676,6 +682,7 @@ static int __find_matched_pkgid_from_list(const char *source_file, continue; version = __getvalue(buf, TOKEN_VERSION_STR, 1); + pkgtype = __getvalue(buf, TOKEN_TYPE_STR, 1); compare_result = __compare_pkgid((char *)target_file, pkgid, version, &db_update); @@ -701,11 +708,12 @@ static int __find_matched_pkgid_from_list(const char *source_file, } total_pkg_cnt++; - __send_args_to_backend(pkgid, operation); + __send_args_to_backend(pkgid, pkgtype, operation); memset(buf, 0x00, BUF_SIZE); FREE_AND_NULL(pkgid); FREE_AND_NULL(version); + FREE_AND_NULL(pkgtype); } _LOG("-------------------------------------------------------\n"); @@ -730,6 +738,7 @@ static int __find_deleted_pkgid_from_list(const char *source_file, char buf[BUF_SIZE] = {0}; char *pkgid = NULL; char *version = NULL; + char *pkgtype = NULL; char *update = NULL; bool xml_update; int deleted_pkg_cnt = 0; @@ -751,6 +760,7 @@ static int __find_deleted_pkgid_from_list(const char *source_file, continue; version = __getvalue(buf, TOKEN_VERSION_STR, 1); + pkgtype = __getvalue(buf, TOKEN_TYPE_STR, 1); compare_result = __compare_pkgid((char *)target_file, pkgid, version, &xml_update); @@ -762,11 +772,11 @@ static int __find_deleted_pkgid_from_list(const char *source_file, continue; } if (!strncmp(update, "false", strlen("false"))) { - __send_args_to_backend(pkgid, + __send_args_to_backend(pkgid, pkgtype, PKG_NEED_UNINSTALL); deleted_pkg_cnt++; } else { - __send_args_to_backend(pkgid, + __send_args_to_backend(pkgid, pkgtype, PKG_NEED_UPDATE_TO_RW); modified_pkg_cnt++; } @@ -776,6 +786,7 @@ static int __find_deleted_pkgid_from_list(const char *source_file, memset(buf, 0x00, BUF_SIZE); FREE_AND_NULL(pkgid); FREE_AND_NULL(version); + FREE_AND_NULL(pkgtype); FREE_AND_NULL(update); } @@ -861,7 +872,7 @@ static int __process_ro_fota() return 0; } -static int __process_rw_fota(const char *directory) +static int __process_rw_fota(const char *directory, const char *pkgtype) { retvm_if(directory == NULL, -1, "directory is null\n"); @@ -870,12 +881,13 @@ static int __process_rw_fota(const char *directory) DIR *dir; struct dirent *entry = NULL; long total_time = 0; + char backend_cmd[BUF_SIZE]; dir = opendir(directory); retvm_if(dir == NULL, -1, "Failed to access the [%s]\n", directory); _LOG("=======================================================\n"); - _LOG("RW preload package fota\n"); + _LOG("RW preload package fota (%s)\n", pkgtype); _LOG("=======================================================\n"); while ((entry = readdir(dir)) != NULL) { @@ -968,8 +980,10 @@ static int __process_rw_fota(const char *directory) _LOG("pkgid[%s] is new\n", pkg_info->pkgid); } - const char *install_rw[] = { "/usr/bin/tpk-backend", "-y", + const char *install_rw[] = { backend_cmd, "-y", pkg_info->pkgid, "--preload-rw", NULL }; + snprintf(backend_cmd, sizeof(backend_cmd), + "/usr/bin/%s-backend", pkgtype); ret = __xsystem(install_rw); if (ret == 0) _LOG("success request\n"); @@ -1005,10 +1019,10 @@ int main(int argc, char *argv[]) retvm_if(ret < 0, EXIT_FAILURE, "__process_ro_fota is failed.\n"); } else if (strcmp(argv[1], "-rwf") == 0) { - ret = __process_rw_fota(PRELOAD_RW_TPK_PATH); + ret = __process_rw_fota(PRELOAD_RW_TPK_PATH, "tpk"); retvm_if(ret < 0, EXIT_FAILURE, "PRELOAD_RW_TPK_PATH is failed.\n"); - ret = __process_rw_fota(PRELOAD_RW_WGT_PATH); + ret = __process_rw_fota(PRELOAD_RW_WGT_PATH, "wgt"); retvm_if(ret < 0, EXIT_FAILURE, "PRELOAD_RW_WGT_PATH is failed.\n"); } else { -- 2.7.4 From 7b8ec945fdb3e5e7653eb1ef2fb62587585645d4 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 4 May 2018 13:28:05 +0900 Subject: [PATCH 16/16] Add upgrade script for version 30002 Change-Id: I9520d7568fc61a841329cf62282cde107d92701d Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 2 ++ data/updates/upgrade_to_30002.sh.in | 25 +++++++++++++++++++++++++ packaging/pkgmgr-tool.spec | 1 + 3 files changed, 28 insertions(+) create mode 100644 data/updates/upgrade_to_30002.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index a27b62e..dc9b6fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,3 +86,5 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/updates/upgrade_to_30000.sh.in u INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/upgrade_to_30000.sh DESTINATION /etc/package-manager/updates/) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/updates/upgrade_to_30001.sh.in upgrade_to_30001.sh $ONLY) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/upgrade_to_30001.sh DESTINATION /etc/package-manager/updates/) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/updates/upgrade_to_30002.sh.in upgrade_to_30002.sh $ONLY) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/upgrade_to_30002.sh DESTINATION /etc/package-manager/updates/) diff --git a/data/updates/upgrade_to_30002.sh.in b/data/updates/upgrade_to_30002.sh.in new file mode 100644 index 0000000..9576898 --- /dev/null +++ b/data/updates/upgrade_to_30002.sh.in @@ -0,0 +1,25 @@ +#!/bin/sh +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +source /etc/tizen-platform.conf + +PARSER_DB_NAME=.pkgmgr_parser.db +PARSER_DB_PATH=$TZ_SYS_DB/$PARSER_DB_NAME + +function migrate_parser_db() { + local dbpath=$1 + + echo -e "ALTER TABLE package_app_app_control ADD visibility TEXT NOT NULL DEFAULT 'local-only'" | sqlite3 $dbpath +} + +function migrate_user_db() { + #get each user db path and call migrate_parser_db for each of it + + find $TZ_SYS_DB/user -name $PARSER_DB_NAME | while read DBPATH + do + migrate_parser_db $DBPATH + done +} + +migrate_parser_db $PARSER_DB_PATH +migrate_user_db diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 0837b77..af62bb4 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -73,6 +73,7 @@ update-mime-database %{_datadir}/mime %attr(0700,root,root) /etc/package-manager/updates/update.sh %attr(0700,root,root) /etc/package-manager/updates/upgrade_to_30000.sh %attr(0700,root,root) /etc/package-manager/updates/upgrade_to_30001.sh +%attr(0700,root,root) /etc/package-manager/updates/upgrade_to_30002.sh %attr(0700,root,root) /usr/share/upgrade/scripts/701.app2sd.patch.sh %attr(0700,root,root) %{_sysconfdir}/opt/upgrade/pkgmgr.patch.sh %attr(0700,root,root) /usr/share/fixed_multiuser/scripts/pkgmgr-clear-skel.sh -- 2.7.4