From 6bbd05b12e9d42faa86fc67c6c1fb732d57555fc Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Tue, 29 Nov 2016 22:04:27 +0900 Subject: [PATCH] Implement new options - keep-rwdata, partial-rw to support RO partition upgrade. Change-Id: I353fe232596f08b665c76c54405ab3f3284eeceb Signed-off-by: jongmyeongko --- installer/pkgmgr_installer.c | 34 ++++++++++++++++++--- installer/pkgmgr_installer.h | 71 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/installer/pkgmgr_installer.c b/installer/pkgmgr_installer.c index 71d0a0c..0e94bf8 100644 --- a/installer/pkgmgr_installer.c +++ b/installer/pkgmgr_installer.c @@ -56,6 +56,8 @@ #define OPTVAL_FORCE_REMOVAL 1001 #define OPTVAL_PRELOAD_RW 1002 #define OPTVAL_NO_REMOVAL 1003 +#define OPTVAL_KEEP_RWDATA 1004 +#define OPTVAL_PARTIAL_RW 1005 /* Supported options */ const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:b:e:M:y:u:w:D:A:q"; @@ -76,10 +78,12 @@ const struct option long_opts[] = { { "direct-manifest-install", 1, NULL, 'y' }, { "mount-install", 1, NULL, 'w' }, { "recovery", 1, NULL, 'b' }, - { "preload", 0, NULL, OPTVAL_PRELOAD }, - { "force-remove", 0, NULL, OPTVAL_FORCE_REMOVAL }, - { "preload-rw", 0, NULL, OPTVAL_PRELOAD_RW }, - { "no-remove", 0, NULL, OPTVAL_NO_REMOVAL }, + { "preload", 0, NULL, OPTVAL_PRELOAD }, /* for preload RO */ + { "force-remove", 0, NULL, OPTVAL_FORCE_REMOVAL }, /* for preload RO/RW */ + { "preload-rw", 0, NULL, OPTVAL_PRELOAD_RW }, /* for preload RW */ + { "no-remove", 0, NULL, OPTVAL_NO_REMOVAL }, /* for preload RW */ + { "keep-rwdata", 0, NULL, OPTVAL_KEEP_RWDATA }, /* for preload RW */ + { "partial-rw", 0, NULL, OPTVAL_PARTIAL_RW }, /* for preload RO */ { 0, 0, 0, 0 } /* sentinel */ }; @@ -99,6 +103,8 @@ struct pkgmgr_installer { int force_removal; int is_preload_rw; int no_removal; + int keep_rwdata; + int partial_rw; GDBusConnection *conn; }; @@ -386,6 +392,14 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi, pi->no_removal = 1; DBG("no-remove request [%d]", pi->no_removal); break; + case OPTVAL_KEEP_RWDATA: /* request for keep-rwdata */ + pi->keep_rwdata = 1; + DBG("keep-rwdata request [%d]", pi->keep_rwdata); + break; + case OPTVAL_PARTIAL_RW: /* request for partial-rw */ + pi->partial_rw = 1; + DBG("partial-rw request [%d]", pi->partial_rw); + break; case 'k': /* session id */ if (pi->session_id) free(pi->session_id); @@ -658,6 +672,18 @@ API int pkgmgr_installer_get_no_removal(pkgmgr_installer *pi) return pi->no_removal; } +API int pkgmgr_installer_get_keep_rwdata(pkgmgr_installer *pi) +{ + CHK_PI_RET(PKGMGR_REQ_INVALID); + return pi->keep_rwdata; +} + +API int pkgmgr_installer_get_partial_rw(pkgmgr_installer *pi) +{ + CHK_PI_RET(PKGMGR_REQ_INVALID); + return pi->partial_rw; +} + API int pkgmgr_installer_send_app_uninstall_signal(pkgmgr_installer *pi, const char *pkg_type, const char *pkgid, diff --git a/installer/pkgmgr_installer.h b/installer/pkgmgr_installer.h index a2920b8..f45cd1a 100644 --- a/installer/pkgmgr_installer.h +++ b/installer/pkgmgr_installer.h @@ -663,6 +663,77 @@ int pkgmgr_installer_get_force_removal(pkgmgr_installer *pi); int pkgmgr_installer_get_no_removal(pkgmgr_installer *pi); /** + @brief Get if the request is for keep-rwdata + @pre pkgmgr_installer_receive_request() must be called. + @post None + @see pkgmgr_installer_receive_request + @param[in] pi pkgmgr_installer object + @return Operation result + @retval 0 if a request is not for keep-rwdata + @retval 1 if a request is for keep-rwdata + @remark Keep RW-data of updated RO pkg. + @code +#include +int main(int argc, char **argv) +{ + pkgmgr_installer *pi; + int r = 0; + int force_remove = 0; + + pi = pkgmgr_installer_new(); + if(!pi) return -1; + if(pkgmgr_installer_receive_request(pi, argc, argv)) { + r = -1; + goto CLEANUP_RET; + } + force_remove = pkgmgr_installer_get_keep_rwdata(pi); + + // Do something... + + pkgmgr_installer_free(pi); + return r; +} + @endcode + */ +int pkgmgr_installer_get_keep_rwdata(pkgmgr_installer *pi); + +/** + @brief Get if the request is for partial-rw + @pre pkgmgr_installer_receive_request() must be called. + @post None + @see pkgmgr_installer_receive_request + @param[in] pi pkgmgr_installer object + @return Operation result + @retval 0 if a request is not for partial-rw + @retval 1 if a request is for partial-rw + @remark For install/update/uninstall of stubs of RO pkg + on RW partitions + @code +#include +int main(int argc, char **argv) +{ + pkgmgr_installer *pi; + int r = 0; + int force_remove = 0; + + pi = pkgmgr_installer_new(); + if(!pi) return -1; + if(pkgmgr_installer_receive_request(pi, argc, argv)) { + r = -1; + goto CLEANUP_RET; + } + force_remove = pkgmgr_installer_get_partial_rw(pi); + + // Do something... + + pkgmgr_installer_free(pi); + return r; +} + @endcode + */ +int pkgmgr_installer_get_partial_rw(pkgmgr_installer *pi); + +/** @brief Send a app status signal @pre None @post None -- 2.7.4