Commit 8de03eef authored by topjohnwu's avatar topjohnwu

Allow modules to have custom uninstaller script

parent 8df942f9
......@@ -482,6 +482,9 @@ static void collect_modules() {
if (access("remove", F_OK) == 0) {
chdir("..");
LOGI("%s: remove\n", entry->d_name);
sprintf(buf, "%s/uninstall.sh", entry->d_name);
if (access(buf, F_OK) == 0)
exec_script(buf);
rm_rf(entry->d_name);
continue;
}
......
......@@ -16,6 +16,14 @@ static void set_path() {
setenv("PATH", buf, 1);
}
void exec_script(const char *script) {
exec_t exec {
.pre_exec = set_path,
.fork = fork_no_zombie
};
exec_command_sync(exec, "/system/bin/sh", script);
}
void exec_common_script(const char *stage) {
char path[4096];
DIR *dir;
......
......@@ -69,6 +69,7 @@ void boot_complete(int client);
* Scripting *
*************/
void exec_script(const char *script);
void exec_common_script(const char *stage);
void exec_module_script(const char *stage, const std::vector<std::string> &module_list);
void migrate_img(const char *img);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment