Add new install option 27/212327/5
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 20 Aug 2019 08:23:58 +0000 (17:23 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 21 Aug 2019 05:21:59 +0000 (14:21 +0900)
This option will be used for fast installation without optimization

Related changes
    [app-installers] https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-installers/+/212328/
    [pkgmgr-tool] https://review.tizen.org/gerrit/#/c/platform/core/appfw/pkgmgr-tool/+/212326/
    [slp-pkgmgr] https://review.tizen.org/gerrit/#/c/platform/core/appfw/slp-pkgmgr/+/212327/

Change-Id: I239abf2e7b479dc11e679ecacf37e64d7ec9580f
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
client/include/package-manager.h
client/src/pkgmgr.c
client/src/pkgmgr_client_internal.h
installer/pkgmgr_installer.c
installer/pkgmgr_installer.h
installer/pkgmgr_installer_info.h

index fec595b..94da4e9 100644 (file)
@@ -1116,6 +1116,19 @@ int pkgmgr_client_usr_set_app_icon(pkgmgr_client *pc, char *appid, char *icon_pa
 int pkgmgr_client_set_debug_mode(pkgmgr_client *pc, bool debug_mode);
 
 /**
+ * @brief      Set skip optimization
+ *
+ * This API sets skip optimization value for request.\n
+ *
+ * @param[in]  pc      The pointer to pkgmgr_client instance
+ * @param[in]  skip_optimization       indicates the request is skip optimization or not
+ * @return     0 if success, error code(<0) if fail\n
+ * @retval     PKGMGR_R_OK     success
+ * @retval     PKGMGR_R_EINVAL invalid argument
+ */
+int pkgmgr_client_set_skip_optimization(pkgmgr_client *pc, bool skip_optimization);
+
+/**
  * @brief      Migrate legacy external image which is generated under 3.0
  *
  * This API request the migration of external image.\n
index 3fba80c..0ec420c 100644 (file)
@@ -450,6 +450,8 @@ API int pkgmgr_client_usr_install(pkgmgr_client *pc, const char *pkg_type,
        }
        if (client->debug_mode)
                g_variant_builder_add(builder, "s", "-G");
+       if (client->skip_optimization)
+               g_variant_builder_add(builder, "s", "-S");
 
        args = g_variant_new("as", builder);
        g_variant_builder_unref(builder);
@@ -2428,6 +2430,20 @@ API int pkgmgr_client_set_debug_mode(pkgmgr_client *pc, bool debug_mode)
        return PKGMGR_R_OK;
 }
 
+API int pkgmgr_client_set_skip_optimization(pkgmgr_client *pc, bool skip_optimization)
+{
+       struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
+
+       if (pc == NULL) {
+               ERR("invalid parameter");
+               return PKGMGR_R_EINVAL;
+       }
+
+       client->skip_optimization = skip_optimization;
+
+       return PKGMGR_R_OK;
+}
+
 API int pkgmgr_client_usr_migrate_external_image(pkgmgr_client *pc,
                const char *pkgid, uid_t uid)
 {
index 921ae65..bf799fc 100644 (file)
@@ -54,6 +54,7 @@ struct pkgmgr_client_t {
        char *tep_path;
        bool tep_move;
        bool debug_mode;
+       bool skip_optimization;
 };
 
 struct manifest_and_type {
index f69db39..52ef06a 100644 (file)
@@ -64,7 +64,7 @@
 #define OPTVAL_RECOVER_DB 1008
 
 /* 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:qG";
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:b:e:M:y:u:w:D:A:qGS";
 const struct option long_opts[] = {
        { "session-id", 1, NULL, 'k' },
        { "license-path", 1, NULL, 'l' },
@@ -83,6 +83,7 @@ const struct option long_opts[] = {
        { "mount-install", 1, NULL, 'w' },
        { "recovery", 1, NULL, 'b' },
        { "debug-mode", 0, NULL, 'G' },
+       { "skip-optimization", 0, NULL, 'S' },
        { "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 */
@@ -115,11 +116,13 @@ struct pkgmgr_installer {
        int partial_rw;
        int debug_mode;
        int skip_check_reference;
+       int skip_optimization;
        GDBusConnection *conn;
 };
 
 static uid_t g_target_uid;
 static int g_debug_mode;
+static int g_skip_optimization;
 static pkgmgr_privilege_level g_privilege_level = PM_PRIVILEGE_UNKNOWN;
 
 static const char *__get_signal_name(pkgmgr_installer *pi, const char *key,
@@ -386,6 +389,7 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi,
        pi->target_uid = getuid();
        g_target_uid = pi->target_uid;
        g_debug_mode = 0;
+       g_skip_optimization = 0;
        while (1) {
                c = getopt_long(argc, argv, short_opts, long_opts, &opt_idx);
                /* printf("c=%d %c\n", c, c); //debug */
@@ -607,6 +611,11 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi,
                        g_debug_mode = 1;
                        break;
 
+               case 'S': /* skip optimization */
+                       pi->skip_optimization = 1;
+                       g_skip_optimization = 1;
+                       break;
+
                        /* Otherwise */
                case '?':       /* Not an option */
                        break;
@@ -739,6 +748,12 @@ API int pkgmgr_installer_get_skip_check_reference(pkgmgr_installer *pi)
        return pi->skip_check_reference;
 }
 
+API int pkgmgr_installer_get_skip_optimization(pkgmgr_installer *pi)
+{
+       CHK_PI_RET(PKGMGR_REQ_INVALID);
+       return pi->skip_optimization;
+}
+
 API int pkgmgr_installer_send_app_uninstall_signal(pkgmgr_installer *pi,
                             const char *pkg_type,
                             const char *pkgid,
@@ -930,6 +945,12 @@ API int pkgmgr_installer_info_get_debug_mode(int *debug_mode)
        return 0;
 }
 
+API int pkgmgr_installer_info_get_skip_optimization(int *skip_optimization)
+{
+       *skip_optimization = g_skip_optimization;
+       return 0;
+}
+
 #define CASE_TO_STR(ERRCODE) case ERRCODE: return ERRCODE##_STR
 API const char *pkgmgr_installer_error_to_string(int error_code)
 {
index 930bdcc..b225e8d 100644 (file)
@@ -733,6 +733,41 @@ int main(int argc, char **argv)
 int pkgmgr_installer_get_skip_check_reference(pkgmgr_installer *pi);
 
 /**
+       @brief          Get skip optimization value
+       @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 debug mode
+       @retval         1 if a request is debug mode
+       @remark         None
+       @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+       pkgmgr_installer *pi;
+       int r = 0;
+       int skip_optimization = 0;
+
+       pi = pkgmgr_installer_new();
+       if(!pi) return -1;
+       if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+               r = -1;
+               goto CLEANUP_RET;
+       }
+       skip_optimization = pkgmgr_installer_get_skip_optimization(pi);
+
+       // Do something...
+
+       pkgmgr_installer_free(pi);
+       return r;
+}
+       @endcode
+*/
+int pkgmgr_installer_get_skip_optimization(pkgmgr_installer *pi);
+
+/**
        @brief          Send a app status signal
        @pre            None
        @post           None
index e40b4ec..ed36c7f 100644 (file)
@@ -98,6 +98,28 @@ int pkgmgr_installer_info_get_privilege_level(pkgmgr_privilege_level *level);
  */
 int pkgmgr_installer_info_get_debug_mode(int *debug_mode);
 
+/**
+ * @brief      Get skip optimization flag
+ * @pre                None
+ * @post       None
+ * @param[out] int     skip_optimization
+ * @return     0 if success, else retrun < 0
+ * @code
+       #include <pkgmgr_installer_info.h>
+       int main()
+       {
+               int skip_optimization;
+               if (pkgmgr_installer_info_get_skip_optimization(&skip_optimization) < 0) {
+                       printf("failed to get skip optimization\n");
+               }
+               if (skip_optimization)) {
+                       printf("skip optimization is enabled");
+               }
+       }
+ * @endcode
+ */
+int pkgmgr_installer_info_get_skip_optimization(int *skip_optimization);
+
 #ifdef __cplusplus
 }
 #endif