implement TEP install, update 78/50978/7
authorVBS <jungh.yeon@samsung.com>
Tue, 3 Nov 2015 11:33:55 +0000 (20:33 +0900)
committerVBS <jungh.yeon@samsung.com>
Wed, 11 Nov 2015 06:59:15 +0000 (15:59 +0900)
[app-installer][pkgmgr-info][pkgmgr-server][pkgmgr-tool][slp-pkgmgr]

Signed-off-by: VBS <jungh.yeon@samsung.com>
Change-Id: Ia93fe112076574f9b1f10da10c9e565a29528160

CMakeLists.txt
client/src/pkgmgr.c
comm/CMakeLists.txt
comm/pkgmgr_installer.c
comm/pkgmgr_installer.h
comm/pkgmgr_installer_config.h
packaging/pkgmgr.spec
types/include/package-manager-types.h

index d468828..d49500f 100644 (file)
@@ -26,3 +26,4 @@ ADD_SUBDIRECTORY(client)
 ADD_SUBDIRECTORY(types)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/package-manager-debug.h DESTINATION include)
+
index 63fd017..cd410c2 100644 (file)
@@ -86,6 +86,8 @@ typedef struct _pkgmgr_client_t {
                } listening;
        } info;
        void *new_event_cb;
+       char *tep_path;
+       char *tep_move;
 } pkgmgr_client_t;
 
 typedef struct _iter_data {
@@ -797,6 +799,7 @@ API pkgmgr_client *pkgmgr_client_new(client_type ctype)
        /* Manage pc */
        pc->ctype = ctype;
        pc->status_type = PKGMGR_CLIENT_STATUS_ALL;
+       pc->tep_path = NULL;
 
        if (pc->ctype == PC_REQUEST) {
                pc->info.request.cc = comm_client_new();
@@ -855,6 +858,16 @@ API int pkgmgr_client_free(pkgmgr_client *pc)
                return PKGMGR_R_EINVAL;
        }
 
+       if (mpc->tep_path) {
+               free(mpc->tep_path);
+               mpc->tep_path = NULL;
+       }
+
+       if (mpc->tep_move) {
+               free(mpc->tep_move);
+               mpc->tep_move = NULL;
+       }
+
        free(mpc);
        mpc = NULL;
        return PKGMGR_R_OK;
@@ -896,6 +909,18 @@ static char *__get_type_from_path(const char *pkg_path)
        return strdup(pkg_type);
 }
 
+API int pkgmgr_client_set_tep_path(pkgmgr_client *pc, char *tep_path, char *tep_move)
+{
+       retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
+       retvm_if(tep_path == NULL, PKGMGR_R_EINVAL, "tep path is NULL");
+       pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
+
+       mpc->tep_path = strdup(tep_path);
+       mpc->tep_move = strdup(tep_move);
+
+       return PKGMGR_R_OK;
+}
+
 API int pkgmgr_client_usr_install(pkgmgr_client *pc, const char *pkg_type,
                const char *descriptor_path, const char *pkg_path,
                const char *optional_file, pkgmgr_mode mode,
@@ -904,9 +929,12 @@ API int pkgmgr_client_usr_install(pkgmgr_client *pc, const char *pkg_type,
        GVariant *result;
        int ret = PKGMGR_R_ECOMM;
        char *req_key = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *args = NULL;
        int req_id;
        pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc;
        char *pkgtype;
+       char *temp = NULL;
 
        if (pc == NULL || pkg_path == NULL) {
                ERR("invalid parameter");
@@ -923,15 +951,32 @@ API int pkgmgr_client_usr_install(pkgmgr_client *pc, const char *pkg_type,
                return PKGMGR_R_EINVAL;
        }
 
+       if (mpc->tep_path != NULL && access(mpc->tep_path, F_OK) != 0) {
+               ERR("failed to access: %s", mpc->tep_path);
+               return PKGMGR_R_EINVAL;
+       }
+
        /* TODO: check pkg's type on server-side */
        if (pkg_type == NULL)
                pkgtype = __get_type_from_path(pkg_path);
        else
                pkgtype = strdup(pkg_type);
 
+       /* build arguments */
+       builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+       if (mpc->tep_path) {
+               g_variant_builder_add(builder, "s", "-e");
+               g_variant_builder_add(builder, "s", mpc->tep_path);
+               g_variant_builder_add(builder, "s", "-M");
+               g_variant_builder_add(builder, "s", mpc->tep_move);
+       }
+
+       args = g_variant_new("as", builder);
+       g_variant_builder_unref(builder);
+
        result = comm_client_request(mpc->info.request.cc, "install",
-                       g_variant_new("(uss)", uid, pkgtype, pkg_path));
-       free(pkgtype);
+                       g_variant_new("(uss@as)", uid, pkgtype, pkg_path, args));
+
        if (result == NULL)
                return PKGMGR_R_ECOMM;
        g_variant_get(result, "(i&s)", &ret, &req_key);
index 6101f7d..82d41d8 100644 (file)
@@ -62,19 +62,19 @@ configure_file(pkgmgr-installer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-install
 
 
 ## Install
-INSTALL(TARGETS 
-                       pkgmgr_installer_client 
+INSTALL(TARGETS
+                       pkgmgr_installer_client
                        pkgmgr_installer
             DESTINATION ${LIB_INSTALL_DIR}
                COMPONENT RuntimeLibraries)
-INSTALL(FILES 
-                       comm_client.h 
+INSTALL(FILES
+                       comm_client.h
                        comm_config.h
                        pkgmgr_installer.h
                DESTINATION include/pkgmgr)
 
 
-INSTALL(FILES 
-               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc 
-               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc 
+INSTALL(FILES
+               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc
+               ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc
         DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
index ac67c58..239862d 100644 (file)
@@ -57,6 +57,9 @@ struct pkgmgr_installer {
        char *optional_data;
        char *caller_pkgid;
        uid_t target_uid;
+       char *tep_path;
+       int tep_move;
+       int is_tep_included;
 
        GDBusConnection *conn;
 };
@@ -137,6 +140,8 @@ API pkgmgr_installer *pkgmgr_installer_new(void)
                return NULL;
        }
 
+       pi->tep_path = NULL;
+       pi->tep_move = 0;
        pi->request_type = PKGMGR_REQ_INVALID;
 
        return pi;
@@ -155,6 +160,8 @@ API int pkgmgr_installer_free(pkgmgr_installer *pi)
                free(pi->optional_data);
        if (pi->caller_pkgid)
                free(pi->caller_pkgid);
+       if (pi->tep_path)
+               free(pi->tep_path);
 
        if (pi->conn) {
                g_dbus_connection_flush_sync(pi->conn, NULL, NULL);
@@ -209,6 +216,28 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi,
                        if (pi->pkgmgr_info)
                                free(pi->pkgmgr_info);
                        pi->pkgmgr_info = strndup(optarg, MAX_STRLEN);
+                       DBG("option is [i] pkgid[%s]", pi->pkgmgr_info );
+                       if (pi->pkgmgr_info && strlen(pi->pkgmgr_info)==0){
+                               free(pi->pkgmgr_info);
+                       }else{
+                               mode = 'i';
+                       }
+                       break;
+
+               case 'e':       /* install */
+                       if (pi->tep_path)
+                               free(pi->tep_path);
+                       pi->tep_path = strndup(optarg, MAX_STRLEN);
+                       pi->is_tep_included = 1;
+                       DBG("option is [e] tep_path[%s]", pi->tep_path);
+                       break;
+
+               case 'M':       /* install */
+                       if (strcmp(optarg, "tep_move") == 0)
+                               pi->tep_move = 1;
+                       else
+                               pi->tep_move = 0;
+                       DBG("option is [M] tep_move[%d]", pi->tep_move);
                        break;
 
                case 'd':       /* uninstall */
@@ -313,6 +342,18 @@ API const char *pkgmgr_installer_get_request_info(pkgmgr_installer *pi)
        return pi->pkgmgr_info;
 }
 
+API const char *pkgmgr_installer_get_tep_path(pkgmgr_installer *pi)
+{
+       CHK_PI_RET(PKGMGR_REQ_INVALID);
+       return pi->tep_path;
+}
+
+API int pkgmgr_installer_get_tep_move_type(pkgmgr_installer *pi)
+{
+       CHK_PI_RET(PKGMGR_REQ_INVALID);
+       return pi->tep_move;
+}
+
 API const char *pkgmgr_installer_get_session_id(pkgmgr_installer *pi)
 {
        CHK_PI_RET(PKGMGR_REQ_INVALID);
index 666e9f6..86a3f13 100644 (file)
@@ -253,6 +253,74 @@ int main(int argc, char **argv)
 const char *pkgmgr_installer_get_request_info(pkgmgr_installer *pi);
 
 /**
+       @brief          Get TEP path
+       @pre            pkgmgr_installer_receive_request() must be called.
+       @post           None
+       @see            pkgmgr_installer_receive_request
+       @param[in]      pi      pkgmgr_installer object
+       @return         TEP path if exists
+       @retval         NULL    on function failure
+       @remark         Returned string must not be modified.
+       @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+       pkgmgr_installer *pi;
+       int r = 0;
+       char *tep_path = NULL;
+
+       pi = pkgmgr_installer_new();
+       if(!pi) return -1;
+       if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+               r = -1;
+               goto CLEANUP_RET;
+       }
+       tep_path = (char *) pkgmgr_installer_get_tep_path(pi);
+
+       // Do something...
+
+       pkgmgr_installer_free(pi);
+       return r;
+}
+@endcode
+ */
+const char *pkgmgr_installer_get_tep_path(pkgmgr_installer *pi);
+
+/**
+       @brief          Get TEP move type
+       @pre            pkgmgr_installer_receive_request() must be called.
+       @post           None
+       @see            pkgmgr_installer_receive_request
+       @param[in]      pi      pkgmgr_installer object
+       @return         integer value indicates tep move type(0: copy TEP file / 1: move TEP file)
+       @retval         0       on function failure
+       @remark         Returned string must not be modified.
+       @code
+#include <pkgmgr_installer.h>
+int main(int argc, char **argv)
+{
+       pkgmgr_installer *pi;
+       int r = 0;
+       int tep_move_type = -1;
+
+       pi = pkgmgr_installer_new();
+       if(!pi) return -1;
+       if(pkgmgr_installer_receive_request(pi, argc, argv)) {
+               r = -1;
+               goto CLEANUP_RET;
+       }
+       tep_move_type = pkgmgr_installer_get_tep_move_type(pi);
+
+       // Do something...
+
+       pkgmgr_installer_free(pi);
+       return r;
+}
+@endcode
+ */
+int pkgmgr_installer_get_tep_move_type(pkgmgr_installer *pi);
+
+/**
        @brief          Get session ID for a certain session
        @pre            pkgmgr_installer_receive_request() must be called.
        @post           None
@@ -281,7 +349,7 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
 @endcode
  */
 const char *pkgmgr_installer_get_session_id(pkgmgr_installer *pi);
@@ -315,7 +383,7 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
 @endcode
  */
 const char *pkgmgr_installer_get_license_path(pkgmgr_installer *pi);
@@ -385,7 +453,7 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
        @endcode
  */
 int pkgmgr_installer_is_quiet(pkgmgr_installer *pi);
@@ -458,7 +526,7 @@ int main(int argc, char **argv)
 const char *pkgmgr_installer_get_caller_pkgid(pkgmgr_installer *pi);
 
 /**
-       @brief          Send a process status signal 
+       @brief          Send a process status signal
        @pre            None
        @post           None
        @see            None
@@ -493,7 +561,7 @@ int main(int argc, char **argv)
 
        pkgmgr_installer_free(pi);
        return r;
-}      
+}
        @endcode
  */
 int pkgmgr_installer_send_signal(pkgmgr_installer *pi,
index f3ae324..fa0b198 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
 #endif
 
 /* Supported options */
-const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:q";
+const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:e:M:q";
 const struct option long_opts[] = {
        { "session-id", 1, NULL, 'k' },
        { "license-path", 1, NULL, 'l' },
@@ -44,6 +44,8 @@ const struct option long_opts[] = {
        { "optional-data", 0, NULL, 'o' },
        { "reinstall", 0, NULL, 'r' },
        { "caller-pkgid", 1, NULL, 'p' },
+       { "tep-path", 1, NULL, 'e' },
+       { "tep-move", 1, NULL, 'M' },
        { "smack", 1, NULL, 's' },
        { 0, 0, 0, 0 }  /* sentinel */
 };
index 3ef163b..f0b271a 100644 (file)
@@ -81,7 +81,6 @@ Requires:   %{name} = %{version}-%{release}
 %description types-devel
 Package Manager client types develpoment package for packaging
 
-
 %prep
 %setup -q
 cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{SOURCE1005} %{SOURCE1006} .
index ecce193..b56f9fc 100644 (file)
@@ -61,13 +61,13 @@ extern "C" {
 
 /**
  * @mainpage
- * 
+ *
  * This is package manager
  *
  * Packaeg manager is used to install/uninstall the packages.\n
  * package includes dpkg, java, widget, etc. and it can be added\n
  * Security is considered on current package manager\n
- * 
+ *
  */
 
 /**
@@ -83,8 +83,9 @@ extern "C" {
 #define PKG_VALUE_STRING_LEN_MAX 512
 #define PKG_URL_STRING_LEN_MAX 1024
 #define PKG_LABEL_STRING_LEN_MAX 128
+#define PKG_PATH_STRING_LEN_MAX 512
 
-/** 
+/**
  *@brief application's structure retrieved by package-manager
  */
 typedef struct _package_manager_pkg_info_t {