static int get_pkgtype_file_name(const char* file_name);
static int kill_gdbserver_if_running(const char* process_cmd);
static int verify_gdbserver_exist();
-static int get_pkg_tmp_dir(char* pkg_tmp_dir);
+static int get_pkg_tmp_dir(char* pkg_tmp_dir, int len);
int da(int argc, char ** argv) {
char full_cmd[PATH_MAX] = "shell:/usr/bin/da_command";
char cap_buffer[CAPBUF_SIZE] = {0,};
uint16_t len = 0;
int ret = -1;
+ char* failmsg = NULL;
snprintf(full_cmd, sizeof(full_cmd), "capability:");
- int fd = sdb_connect(full_cmd);
+ int fd = sdb_connect_getfailmsg(full_cmd, &failmsg);
if (fd >= 0) {
readx(fd, &len, sizeof(uint16_t));
if (len > CAPBUF_SIZE-1) {
if (ret == 1) {
return ret;
}
+ } else {
+ D("This platform does not support the capability service.\n");
+ if (failmsg != NULL) {
+ D("sdb_connect() fail message : %s\n", failmsg);
+ SAFE_FREE(failmsg);
+ }
}
/* This routine is temporarily coded in a state that the app
char* srcpath = argv[1];
const char* filename = sdb_dirstop(srcpath);
- char destination[PATH_MAX];
- if(get_pkg_tmp_dir(destination) < 0) {
+ char destination[PATH_MAX] = {0,};
+ if(get_pkg_tmp_dir(destination, sizeof(destination)) < 0) {
return 1;
}
return 1;
}
-// Get the package temporary path. Returns minus if exception happens.
-static int get_pkg_tmp_dir(char* pkg_tmp_dir){
+static int get_pkg_tmp_dir_from_capability(char* pkg_tmp_dir, int len) {
+ char cap_buffer[CAPBUF_SIZE] = {0,};
+ const char* GET_CAPABILITY_CMD = "capability:";
+ int fd = -1;
+ int cap_data_size = 0;
+ int ret = -1;
+ char* failmsg = NULL;
- char buf[512] = {};
+ fd = sdb_connect_getfailmsg(GET_CAPABILITY_CMD, &failmsg);
+ if(fd < 0) {
+ D("This platform does not support the capability service.\n");
+ if (failmsg != NULL) {
+ D("sdb_connect() fail message : %s\n", failmsg);
+ SAFE_FREE(failmsg);
+ }
+ return -1;
+ }
+
+ readx(fd, &cap_data_size, sizeof(uint16_t));
+ if (cap_data_size > CAPBUF_SIZE-1) {
+ cap_data_size = CAPBUF_SIZE-1;
+ }
+ readx(fd, cap_buffer, cap_data_size);
+ sdb_close(fd);
+
+ ret = parse_capability_key_value(cap_buffer, "sdk_toolpath", pkg_tmp_dir, len);
+ if (ret > 0) {
+ D("capability sdk_toolpath = %s\n", pkg_tmp_dir);
+
+ if (!strncmp(pkg_tmp_dir, "unknown", 7)) {
+ D("sdk_toolpath is not available value : %s\n", pkg_tmp_dir);
+ ret = -1;
+ } else {
+ int dir_len = strlen(pkg_tmp_dir);
+ if(dir_len > 0 && dir_len < len
+ && pkg_tmp_dir[dir_len -1] != '/' && pkg_tmp_dir[dir_len -1] != '\\') {
+ pkg_tmp_dir[dir_len] = '/';
+ }
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+static int get_pkg_tmp_dir_from_pkgcmd(char* pkg_tmp_dir, int len) {
+ char pkgcmd_out_data[512] = {0,};
const char* SHELL_GET_PKG_TMP_DIR_CMD ="shell:/usr/bin/pkgcmd -a | head -1 | awk '{print $5}'";
- int fd = sdb_connect(SHELL_GET_PKG_TMP_DIR_CMD);
+ int fd = -1;
+ int ret = -1;
+ fd = sdb_connect(SHELL_GET_PKG_TMP_DIR_CMD);
if(fd < 0) {
+ D("failed to get the package temporary path from pkgcmd\n");
return -1;
}
- if (read_line(fd, buf, sizeof(buf)) > 0) {
- D("package dir = %s\n", buf);
- append_file(pkg_tmp_dir, buf, "/tmp/", PATH_MAX);
- D("package tmp dir = %s\n", pkg_tmp_dir);
- sdb_close(fd);
- return 0;
+
+ if (read_line(fd, pkgcmd_out_data, sizeof(pkgcmd_out_data)) > 0) {
+ D("\'pkgcmd -a\' result = %s\n", pkgcmd_out_data);
+ append_file(pkg_tmp_dir, pkgcmd_out_data, "/tmp/", len);
+ ret = 0;
}
- print_error(SDB_MESSAGE_ERROR, F(ERR_PACKAGE_GET_TEMP_PATH_FAIL, buf), NULL);
sdb_close(fd);
- return -1;
+ return ret;
+}
+
+// Get the package temporary path. Returns minus if exception happens.
+static int get_pkg_tmp_dir(char* pkg_tmp_dir, int len){
+ int ret = -1;
+
+ ret = get_pkg_tmp_dir_from_capability(pkg_tmp_dir, len);
+ if (ret < 0) {
+ D("failed to get the package temporary path from capability\n");
+ D("retry using the pkgcmd shell command.\n");
+ ret = get_pkg_tmp_dir_from_pkgcmd(pkg_tmp_dir, len);
+ }
+
+ if (ret < 0) {
+ print_error(SDB_MESSAGE_ERROR, ERR_PACKAGE_GET_TEMP_PATH_FAIL, NULL);
+ } else {
+ D("package tmp dir = %s\n", pkg_tmp_dir);
+ }
+
+ return ret;
}
// Returns 0 if pkg type is wgt. Returns 1 if pkg type is tpk. Returns minus if exception happens.