PM_REQUEST_MAX
}pkgmgr_request_service_type;
+typedef enum {
+ PM_GET_TOTAL_SIZE= 0,
+ PM_GET_DATA_SIZE = 1,
+}pkgmgr_getsize_type;
+
/**
* @brief This API creates pkgmgr client.
*
if (ret != 0) {
char *errstr = NULL;
__error_to_string(ret, &errstr);
- snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = fail[%s]\n", cnt, pkgtype, errstr);
+ snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = fail[%s]\n", cnt, errstr);
}
else
- snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = success\n", cnt, pkgtype);
+ snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = success\n", cnt);
fwrite(buf, 1, strlen(buf), file);
}
return ret;
}
-static int __get_size_process(pkgmgr_client * pc, char *pkgid, pkgmgr_handler event_cb)
+static int __get_size_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb)
{
char *req_key = NULL;
int req_id = 0;
int len = 0;
char *temp = NULL;
int i = 0;
+ char buf[128] = {'\0'};
pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
req_id = _get_request_id();
__add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL);
+
+ snprintf(buf, 128, "%d", get_type);
argv[argcnt++] = installer_path;
/* argv[1] */
argv[argcnt++] = strdup("-k");
argv[argcnt++] = strdup("-d");
/* argv[4] */
argv[argcnt++] = strdup(pkgid);
+ /* argv[5] */
+ argv[argcnt++] = strdup("-t");
+ /* argv[6] */
+ argv[argcnt++] = strdup(buf);
/*** add quote in all string for special charactor like '\n'*** FIX */
for (i = 0; i < argcnt; i++) {
return ret;
}
-static int __move_pkg_process(pkgmgr_client * pc, char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb)
+static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb)
{
char *req_key = NULL;
int req_id = 0;
tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
tryvm_if((service_mode < PM_MOVE_TO_INTERNAL) || (service_mode > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
- ret = __move_pkg_process(pc, pkgid, service_mode, event_cb);
+ ret = __move_pkg_process(pc, pkgid, (pkgmgr_move_type)service_mode, event_cb);
if (ret < 0)
_LOGE("__move_pkg_process fail \n");
else
case PM_REQUEST_GET_SIZE:
tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
+ tryvm_if((service_mode < PM_GET_TOTAL_SIZE) || (service_mode > PM_GET_DATA_SIZE), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
- ret = __get_size_process(pc, pkgid, event_cb);
+ ret = __get_size_process(pc, pkgid, (pkgmgr_getsize_type)service_mode, event_cb);
if (ret < 0)
_LOGE("__get_size_process fail \n");
else
#sbs-git:slp/pkgs/s/slp-pkgmgr pkgmgr 0.1.103 29b53909a5d6e8728429f0a188177eac691cb6ce
Name: pkgmgr
Summary: Packager Manager client library package
-Version: 0.2.85
+Version: 0.2.87
Release: 1
Group: System/Libraries
License: Apache License, Version 2.0
{"package-type", 1, NULL, 't'},
{"package-name", 1, NULL, 'n'},
{"move-type", 1, NULL, 'T'},
+ {"getsize-type", 1, NULL, 'T'},
{"csc", 1, NULL, 'S'},
{"quiet", 0, NULL, 'q'},
{"help", 0, NULL, 'h'},
char des_path[PKG_NAME_STRING_LEN_MAX];
char label[PKG_NAME_STRING_LEN_MAX];
int quiet;
- int move_type;
+ int type;
int result;
};
typedef struct pm_tool_args_t pm_tool_args;
printf("-c, --clear clear user data\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\n");
printf("-s, --show show detail package info\n");
printf("-a, --app-path show app installation path\n");
printf("pkgcmd -s -t <pkg type> -p <pkg path> (-q)\n");
printf("pkgcmd -s -t <pkg type> -n <pkg name> (-q)\n");
printf("pkgcmd -m -t <pkg type> -T <move type> -n <pkg name> (-q)\n\n");
- printf("pkgcmd -g -n <pkgid> \n");
+ printf("pkgcmd -g -T <getsize type> -n <pkgid> \n");
printf("Example:\n");
- printf("pkgcmd -u -t rpm -n org.tizen.calculator\n");
- printf("pkgcmd -i -t rpm -p /mnt/nfs/org.tizen.calculator_0.1.2-95_armel.rpm\n");
- printf("pkgcmd -r -t rpm -p org.tizen.calculator\n");
- printf("pkgcmd -c -t rpm -n org.tizen.hello\n");
- printf("pkgcmd -m -t rpm -T 1 -n org.tizen.hello\n");
- printf("pkgcmd -C -t rpm -n org.tizen.hello\n");
- printf("pkgcmd -k -t rpm -n org.tizen.hello\n");
+ printf("pkgcmd -u -n com.samsung.calculator\n");
+ printf("pkgcmd -i -t rpm -p /mnt/nfs/com.samsung.calculator_0.1.2-95_armel.rpm\n");
+ printf("pkgcmd -r -t rpm -n com.samsung.calculator\n");
+ printf("pkgcmd -c -t rpm -n com.samsung.hello\n");
+ printf("pkgcmd -m -t rpm -T 1 -n com.samsung.hello\n");
+ printf("pkgcmd -C -t rpm -n com.samsung.hello\n");
+ printf("pkgcmd -k -t rpm -n com.samsung.hello\n");
printf("pkgcmd -a\n");
- printf("pkgcmd -a -t rpm -n org.tizen.hello\n");
+ printf("pkgcmd -a -t rpm -n com.samsung.hello\n");
printf("pkgcmd -l\n");
printf("pkgcmd -l -t tpk\n");
- printf("pkgcmd -g -n com.samsung.calculator\n");
+ printf("pkgcmd -g -T 0 -n com.samsung.calculator\n");
exit(0);
ret = -1;
break;
}
- if (data.move_type < 0 || data.move_type > 1) {
+ if (data.type < 0 || data.type > 1) {
printf("Invalid move type...See usage\n");
ret = -1;
break;
printf("package is not installed\n");
break;
}
- ret = pkgmgr_client_move(pc, data.pkg_type, data.pkgid, data.move_type, mode);
+ ret = pkgmgr_client_move(pc, data.pkg_type, data.pkgid, data.type, mode);
if (ret < 0)
break;
ret = data.result;
ret = -1;
break;
}
- if (data.move_type < 0 || data.move_type > 1) {
+ if (data.type < 0 || data.type > 1) {
printf("Invalid move type...See usage\n");
ret = -1;
break;
printf("package is not installed\n");
break;
}
- ret = pkgmgr_client_request_service(PM_REQUEST_MOVE, data.move_type, pc, NULL, data.pkgid, NULL, __return_cb, NULL);
+ ret = pkgmgr_client_request_service(PM_REQUEST_MOVE, data.type, pc, NULL, data.pkgid, NULL, __return_cb, NULL);
if (ret < 0)
break;
g_main_loop_run(main_loop);
data.result = PKGCMD_ERR_ARGUMENT_INVALID;
break;
}
+ if (data.type < 0 || data.type > 1) {
+ printf("Invalid get type...See usage\n");
+ ret = -1;
+ break;
+ }
g_type_init();
main_loop = g_main_loop_new(NULL, FALSE);
break;
}
- ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, 0, pc, NULL, data.pkgid, NULL, __return_cb, NULL);
+ ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, data.type, pc, NULL, data.pkgid, NULL, __return_cb, NULL);
if (ret < 0){
data.result = PKGCMD_ERR_FATAL_ERROR;
- if (access(data.pkg_path, F_OK) != 0)
- data.result = PKGCMD_ERR_PACKAGE_NOT_FOUND;
break;
}
g_main_loop_run(main_loop);
memset(data.label, '\0', PKG_TYPE_STRING_LEN_MAX);
data.quiet = 0;
data.result = 0;
- data.move_type = -1;
+ data.type = -1;
while (1) {
c = getopt_long(argc, argv, short_options, long_options,
&opt_idx);
break;
case 'T': /* move type */
- data.move_type = atoi(optarg);
+ data.type = atoi(optarg);
break;
case 'h': /* help */
char *pkgid = NULL;
char *type = NULL;
pkgmgr_installer *pi = NULL;
- pkgmgrinfo_pkginfo_h handle;
+ pkgmgrinfo_pkginfo_h handle = NULL;
int size = 0;
+ int get_type = -1;
char buf[MAX_PKG_BUF_LEN] = {'\0'};
/*make new pkgmgr_installer handle*/
pkgid = pkgmgr_installer_get_request_info(pi);
tryvm_if(pkgid == NULL, ret = PMINFO_R_ERROR, "pkgmgr_installer_get_request_info failed");
+ get_type = pkgmgr_installer_get_move_type(pi);
+ tryvm_if(pkgid < 0, ret = PMINFO_R_ERROR, "pkgmgr_installer_get_request_info failed");
+
/*get pkgmgr handle from pkgid*/
ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_pkginfo_get_pkginfo[pkgid=%s] failed", pkgid);
ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_pkginfo_get_type[pkgid=%s] failed", pkgid);
- /*get size info from handle*/
- ret = pkgmgrinfo_pkginfo_get_total_size(handle, &size);
- tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_pkginfo_get_total_size[pkgid=%s] failed", pkgid);
+ /*get size info from handle
+ typedef enum {
+ PM_GET_TOTAL_SIZE= 0,
+ PM_GET_DATA_SIZE = 1,
+ }pkgmgr_getsize_type;
+
+ */
+ if (get_type == 0) {
+ ret = pkgmgrinfo_pkginfo_get_total_size(handle, &size);
+ tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_pkginfo_get_total_size[pkgid=%s] failed", pkgid);
+ } else {
+ ret = pkgmgrinfo_pkginfo_get_data_size(handle, &size);
+ tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgrinfo_pkginfo_get_data_size[pkgid=%s] failed", pkgid);
+ }
snprintf(buf, MAX_PKG_BUF_LEN - 1, "%d", size);
#define USR_MANIFEST_DIRECTORY "/usr/share/packages"
#define PACKAGE_INFO_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db"
+#define PKG_PARSER_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_parser.db-journal"
+#define PKG_CERT_DB_FILE "/opt/dbspace/.pkgmgr_cert.db"
+#define PKG_CERT_DB_FILE_JOURNAL "/opt/dbspace/.pkgmgr_cert.db-journal"
+#define PKG_INFO_DB_LABEL "pkgmgr::db"
+
#ifdef _E
#undef _E
#endif
return total;
}
+static int initdb_xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
char* _manifest_to_package(const char* manifest)
return -1;
}
+ const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+ initdb_xsystem(argv_parser);
+ const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+ initdb_xsystem(argv_parserjn);
+ const char *argv_cert[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE, NULL };
+ initdb_xsystem(argv_cert);
+ const char *argv_certjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE_JOURNAL, NULL };
+ initdb_xsystem(argv_certjn);
+
return 0;
}