mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 15:28:28 +00:00
Adjust scripting
This commit is contained in:
parent
9bb2243b56
commit
8df942f96e
@ -16,11 +16,6 @@ static void set_path() {
|
|||||||
setenv("PATH", buf, 1);
|
setenv("PATH", buf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_mirror_path() {
|
|
||||||
setenv("PATH", BBPATH ":/sbin:" MIRRDIR "/system/bin:"
|
|
||||||
MIRRDIR "/system/xbin:" MIRRDIR "/vendor/bin", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exec_common_script(const char *stage) {
|
void exec_common_script(const char *stage) {
|
||||||
char path[4096];
|
char path[4096];
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
@ -37,13 +32,13 @@ void exec_common_script(const char *stage) {
|
|||||||
continue;
|
continue;
|
||||||
LOGI("%s.d: exec [%s]\n", stage, entry->d_name);
|
LOGI("%s.d: exec [%s]\n", stage, entry->d_name);
|
||||||
exec_t exec {
|
exec_t exec {
|
||||||
.pre_exec = pfs ? set_mirror_path : set_path,
|
.pre_exec = set_path,
|
||||||
.fork = pfs ? xfork : fork_dont_care
|
.fork = pfs ? fork_no_zombie : fork_dont_care
|
||||||
};
|
};
|
||||||
if (pfs)
|
if (pfs)
|
||||||
exec_command_sync(exec, MIRRDIR "/system/bin/sh", entry->d_name);
|
exec_command_sync(exec, "/system/bin/sh", entry->d_name);
|
||||||
else
|
else
|
||||||
exec_command(exec, MIRRDIR "/system/bin/sh", entry->d_name);
|
exec_command(exec, "/system/bin/sh", entry->d_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,18 +56,18 @@ void exec_module_script(const char *stage, const vector<string> &module_list) {
|
|||||||
continue;
|
continue;
|
||||||
LOGI("%s: exec [%s.sh]\n", module, stage);
|
LOGI("%s: exec [%s.sh]\n", module, stage);
|
||||||
exec_t exec {
|
exec_t exec {
|
||||||
.pre_exec = pfs ? set_mirror_path : set_path,
|
.pre_exec = set_path,
|
||||||
.fork = pfs ? xfork : fork_dont_care
|
.fork = pfs ? fork_no_zombie : fork_dont_care
|
||||||
};
|
};
|
||||||
if (pfs)
|
if (pfs)
|
||||||
exec_command_sync(exec, MIRRDIR "/system/bin/sh", path);
|
exec_command_sync(exec, "/system/bin/sh", path);
|
||||||
else
|
else
|
||||||
exec_command(exec, MIRRDIR "/system/bin/sh", path);
|
exec_command(exec, "/system/bin/sh", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char migrate_script[] =
|
static const char migrate_script[] =
|
||||||
"IMG=/data/adb/tmp.img;"
|
"IMG=%s;"
|
||||||
"MNT=/dev/img_mnt;"
|
"MNT=/dev/img_mnt;"
|
||||||
"e2fsck -yf $IMG;"
|
"e2fsck -yf $IMG;"
|
||||||
"mkdir -p $MNT;"
|
"mkdir -p $MNT;"
|
||||||
@ -86,13 +81,14 @@ static const char migrate_script[] =
|
|||||||
" losetup -d /dev/block/loop${num};"
|
" losetup -d /dev/block/loop${num};"
|
||||||
" break;"
|
" break;"
|
||||||
"done;"
|
"done;"
|
||||||
"rm -rf $IMG";
|
"rm -rf $IMG;";
|
||||||
|
|
||||||
void migrate_img(const char *img) {
|
void migrate_img(const char *img) {
|
||||||
LOGI("* Migrating %s\n", img);
|
LOGI("* Migrating %s\n", img);
|
||||||
exec_t exec { .pre_exec = set_path };
|
exec_t exec { .pre_exec = set_path };
|
||||||
rename(img, "/data/adb/tmp.img");
|
char cmds[sizeof(migrate_script) + 128];
|
||||||
exec_command_sync(exec, "/system/bin/sh", "-c", migrate_script);
|
sprintf(cmds, migrate_script, img);
|
||||||
|
exec_command_sync(exec, "/system/bin/sh", "-c", cmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char install_script[] =
|
static const char install_script[] =
|
||||||
@ -106,13 +102,13 @@ static const char install_script[] =
|
|||||||
" fi;"
|
" fi;"
|
||||||
" break;"
|
" break;"
|
||||||
"done;"
|
"done;"
|
||||||
"rm -f $APK";
|
"rm -f $APK;";
|
||||||
|
|
||||||
void install_apk(const char *apk) {
|
void install_apk(const char *apk) {
|
||||||
setfilecon(apk, "u:object_r:" SEPOL_FILE_DOMAIN ":s0");
|
setfilecon(apk, "u:object_r:" SEPOL_FILE_DOMAIN ":s0");
|
||||||
LOGI("apk_install: %s\n", apk);
|
LOGI("apk_install: %s\n", apk);
|
||||||
exec_t exec { .pre_exec = set_mirror_path };
|
exec_t exec { .pre_exec = set_path };
|
||||||
char cmds[sizeof(install_script) + 4096];
|
char cmds[sizeof(install_script) + 4096];
|
||||||
sprintf(cmds, install_script, apk);
|
sprintf(cmds, install_script, apk);
|
||||||
exec_command_sync(exec, MIRRDIR "/system/bin/sh", "-c", cmds);
|
exec_command_sync(exec, "/system/bin/sh", "-c", cmds);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user