return package;
}
-static void __send_args_to_backend(char *pkgid, int operation)
+static void __send_args_to_backend(char *pkgid, const char *pkgtype,
+ int operation)
{
int ret = 0;
gettimeofday(&tv, NULL);
starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
char buf[BUF_SIZE];
+ char backend_cmd[BUF_SIZE];
- const char *install_ro[] = { "/usr/bin/tpk-backend", "-y", pkgid,
+ const char *install_ro[] = { backend_cmd, "-y", pkgid,
"--preload", "--partial-rw", NULL };
- const char *uninstall_ro[] = { "/usr/bin/tpk-backend", "-d", pkgid,
+ const char *uninstall_ro[] = { backend_cmd, "-d", pkgid,
"--preload", "--force-remove",
"--partial-rw", NULL };
- const char *uninstall_ro_update[] = { "/usr/bin/tpk-backend", "-d",
+ const char *uninstall_ro_update[] = { backend_cmd, "-d",
pkgid, "--keep-rwdata", NULL };
const char *db_update_to_normal_pkg[] = {"/usr/bin/sqlite3",
NULL, NULL, NULL};
if (__compare_builtin_removable_pkgid(pkgid) < 0)
return;
+ snprintf(backend_cmd, sizeof(backend_cmd), "/usr/bin/%s-backend",
+ pkgtype);
+
switch (operation) {
case PKG_NEED_INSTALL:
case PKG_NEED_ROUPDATE:
char buf[BUF_SIZE] = {0};
char *pkgid = NULL;
char *version = NULL;
+ char *pkgtype = NULL;
int same_pkg_cnt = 0;
int update_pkg_cnt = 0;
continue;
version = __getvalue(buf, TOKEN_VERSION_STR, 1);
+ pkgtype = __getvalue(buf, TOKEN_TYPE_STR, 1);
compare_result = __compare_pkgid((char *)target_file, pkgid,
version, &db_update);
}
total_pkg_cnt++;
- __send_args_to_backend(pkgid, operation);
+ __send_args_to_backend(pkgid, pkgtype, operation);
memset(buf, 0x00, BUF_SIZE);
FREE_AND_NULL(pkgid);
FREE_AND_NULL(version);
+ FREE_AND_NULL(pkgtype);
}
_LOG("-------------------------------------------------------\n");
char buf[BUF_SIZE] = {0};
char *pkgid = NULL;
char *version = NULL;
+ char *pkgtype = NULL;
char *update = NULL;
bool xml_update;
int deleted_pkg_cnt = 0;
continue;
version = __getvalue(buf, TOKEN_VERSION_STR, 1);
+ pkgtype = __getvalue(buf, TOKEN_TYPE_STR, 1);
compare_result = __compare_pkgid((char *)target_file, pkgid,
version, &xml_update);
continue;
}
if (!strncmp(update, "false", strlen("false"))) {
- __send_args_to_backend(pkgid,
+ __send_args_to_backend(pkgid, pkgtype,
PKG_NEED_UNINSTALL);
deleted_pkg_cnt++;
} else {
- __send_args_to_backend(pkgid,
+ __send_args_to_backend(pkgid, pkgtype,
PKG_NEED_UPDATE_TO_RW);
modified_pkg_cnt++;
}
memset(buf, 0x00, BUF_SIZE);
FREE_AND_NULL(pkgid);
FREE_AND_NULL(version);
+ FREE_AND_NULL(pkgtype);
FREE_AND_NULL(update);
}
return 0;
}
-static int __process_rw_fota(const char *directory)
+static int __process_rw_fota(const char *directory, const char *pkgtype)
{
retvm_if(directory == NULL, -1, "directory is null\n");
DIR *dir;
struct dirent *entry = NULL;
long total_time = 0;
+ char backend_cmd[BUF_SIZE];
dir = opendir(directory);
retvm_if(dir == NULL, -1, "Failed to access the [%s]\n", directory);
_LOG("=======================================================\n");
- _LOG("RW preload package fota\n");
+ _LOG("RW preload package fota (%s)\n", pkgtype);
_LOG("=======================================================\n");
while ((entry = readdir(dir)) != NULL) {
_LOG("pkgid[%s] is new\n", pkg_info->pkgid);
}
- const char *install_rw[] = { "/usr/bin/tpk-backend", "-y",
+ const char *install_rw[] = { backend_cmd, "-y",
pkg_info->pkgid, "--preload-rw", NULL };
+ snprintf(backend_cmd, sizeof(backend_cmd),
+ "/usr/bin/%s-backend", pkgtype);
ret = __xsystem(install_rw);
if (ret == 0)
_LOG("success request\n");
retvm_if(ret < 0, EXIT_FAILURE,
"__process_ro_fota is failed.\n");
} else if (strcmp(argv[1], "-rwf") == 0) {
- ret = __process_rw_fota(PRELOAD_RW_TPK_PATH);
+ ret = __process_rw_fota(PRELOAD_RW_TPK_PATH, "tpk");
retvm_if(ret < 0, EXIT_FAILURE,
"PRELOAD_RW_TPK_PATH is failed.\n");
- ret = __process_rw_fota(PRELOAD_RW_WGT_PATH);
+ ret = __process_rw_fota(PRELOAD_RW_WGT_PATH, "wgt");
retvm_if(ret < 0, EXIT_FAILURE,
"PRELOAD_RW_WGT_PATH is failed.\n");
} else {