From: Rahul Dadhich Date: Mon, 19 Feb 2018 11:15:04 +0000 (+0530) Subject: Added support to install addon rpms X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1915072d3c39136eb71a46951175b400cb854417;p=sdk%2Femulator%2Fqemu.git Added support to install addon rpms Change-Id: Ibf370b82caf5f0e3fefd3e4874e1db27fbbea6f4 Signed-off-by: Rahul Dadhich (cherry picked from commit 79f89e67b04bbcb584703657ea92d9b18dd7d5be) --- diff --git a/tizen/src/ecs/ecs_msg_injector.c b/tizen/src/ecs/ecs_msg_injector.c index 7c11918..e5a0fdc 100644 --- a/tizen/src/ecs/ecs_msg_injector.c +++ b/tizen/src/ecs/ecs_msg_injector.c @@ -355,7 +355,7 @@ void ecs_suspend_lock_state(int state) msgproc_injector_req(NULL, &msg); } -static bool do_push_package(char *cmd) +static bool do_execute_command(char *cmd) { char buf[MAX_PKGS_LIST]; FILE *fp = popen(cmd, "r"); @@ -423,7 +423,7 @@ static bool push_package(const char *data) LOG_INFO("[pkgs] SDB push command: %s\n", cmd); - if (do_push_package(cmd)) { + if (do_execute_command(cmd)) { LOG_INFO("[pkgs] SDB push SUCCESS\n"); return true; } @@ -450,7 +450,7 @@ static bool push_package(const char *data) #endif while (index != MAX_SDB_TRIAL) { - if (do_push_package(cmd)) { + if (do_execute_command(cmd)) { LOG_INFO("[pkgs] SDB push SUCCESS.\n"); return true; } @@ -480,6 +480,94 @@ static void show_error_popup(char *data) error_report("%s", fail_msg); } +static void set_read_write_mode(void) +{ +#ifndef CONFIG_WIN32 + const char *sdb_path = "../../../../../tools/sdb"; +#else + const char *sdb_path = "..\\..\\..\\..\\..\\tools\\sdb.exe"; +#endif + const char *bin_dir = get_bin_path(); + char cmd[MAX_PKGS_LIST]; + int ret = 0; + + memset(cmd, 0, sizeof(cmd)); +#ifndef CONFIG_WIN32 + ret = sprintf(cmd, "\"%s%s\" -s emulator-%d root on", +#else + ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d root on\"", +#endif + bin_dir, sdb_path, get_vm_device_serial_number()); + if (ret < 0) { + LOG_SEVERE("SDB root on command is Wrong : %s\n", cmd); + return; + } + if (!do_execute_command(cmd)) { + LOG_SEVERE("SDB root on FAILED"); + return; + } + + memset(cmd, 0, sizeof(cmd)); +#ifndef CONFIG_WIN32 + ret = sprintf(cmd, "\"%s%s\" -s emulator-%d shell \"mount -o remount,rw /\"", +#else + ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d shell \"mount -o remount,rw /\"\"", +#endif + bin_dir, sdb_path, get_vm_device_serial_number()); + if (ret < 0) { + LOG_INFO("SDB mount command is wrong: %s\n", cmd); + return; + } + if (!do_execute_command(cmd)) { + LOG_INFO("mount FAILED\n"); + return; + } +} + +static void *set_read_mode(void *args) +{ +#ifndef CONFIG_WIN32 + const char *sdb_path = "../../../../../tools/sdb"; +#else + const char *sdb_path = "..\\..\\..\\..\\..\\tools\\sdb.exe"; +#endif + const char *bin_dir = get_bin_path(); + char cmd[MAX_PKGS_LIST]; + int ret = 0; + + memset(cmd, 0, sizeof(cmd)); +#ifndef CONFIG_WIN32 + ret = sprintf(cmd, "\"%s%s\" -s emulator-%d shell \"mount -o remount,ro /\"", +#else + ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d shell \"mount -o remount,ro /\"\"", +#endif + bin_dir, sdb_path, get_vm_device_serial_number()); + if (ret < 0) { + LOG_INFO("SDB mount command is wrong: %s\n", cmd); + return NULL; + } + if (!do_execute_command(cmd)) { + LOG_INFO("mount FAILED\n"); + return NULL; + } + memset(cmd, 0, sizeof(cmd)); +#ifndef CONFIG_WIN32 + ret = sprintf(cmd, "\"%s%s\" -s emulator-%d root off", +#else + ret = sprintf(cmd, "cmd /S /C \"\"%s%s\" -s emulator-%d root off\"", +#endif + bin_dir, sdb_path, get_vm_device_serial_number()); + if (ret < 0) { + LOG_SEVERE("SDB root off command is Wrong : %s\n", cmd); + return NULL; + } + if (!do_execute_command(cmd)) { + LOG_SEVERE("SDB root off FAILED"); + return NULL; + } + return NULL; +} + static void *push_pkgs_thread(void *args) { char *pkg_data = (char *)args; @@ -497,6 +585,9 @@ static void *push_pkgs_thread(void *args) return NULL; } + /*Set read write mode */ + set_read_write_mode(); + /* request to install rpms */ LOG_INFO("[pkgs] Request to install : %s\n", data); send_msg_to_guest(MSG_TYPE_PACKAGE, 0, 2, data, strlen(data) + 1); @@ -523,8 +614,16 @@ static void do_package(char *cat, type_action action, const char *data) qemu_thread_create(&sdb_thread_id, "sdb_push", push_pkgs_thread, (void *)pkgs, QEMU_THREAD_DETACHED); } else if (action == 3) { LOG_INFO("[pkgs] Package Installation Success: %s\n", data); + + /*Set read mode */ + qemu_thread_create(&sdb_thread_id, "sdb_push", set_read_mode, NULL, QEMU_THREAD_DETACHED); + } else if (action == 4) { LOG_INFO("[pkgs] Package Installation Failed: %s\n", data); + + /*Set read mode */ + qemu_thread_create(&sdb_thread_id, "sdb_push", set_read_mode, NULL, QEMU_THREAD_DETACHED); + show_error_popup((char *)data); } else { LOG_SEVERE("unknown pkgs action: %d\n", action);