Allow modules to have custom uninstaller script

This commit is contained in:
topjohnwu 2019-03-23 03:50:55 -04:00
parent 8df942f96e
commit 8de03eef3f
3 changed files with 12 additions and 0 deletions

View File

@ -482,6 +482,9 @@ static void collect_modules() {
if (access("remove", F_OK) == 0) { if (access("remove", F_OK) == 0) {
chdir(".."); chdir("..");
LOGI("%s: remove\n", entry->d_name); 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); rm_rf(entry->d_name);
continue; continue;
} }

View File

@ -16,6 +16,14 @@ static void set_path() {
setenv("PATH", buf, 1); 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) { void exec_common_script(const char *stage) {
char path[4096]; char path[4096];
DIR *dir; DIR *dir;

View File

@ -69,6 +69,7 @@ void boot_complete(int client);
* Scripting * * Scripting *
*************/ *************/
void exec_script(const char *script);
void exec_common_script(const char *stage); void exec_common_script(const char *stage);
void exec_module_script(const char *stage, const std::vector<std::string> &module_list); void exec_module_script(const char *stage, const std::vector<std::string> &module_list);
void migrate_img(const char *img); void migrate_img(const char *img);