mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 07:57:39 +00:00
Bundle in stub APK into magiskinit
This commit is contained in:
parent
cabaae8403
commit
970a2e87b3
9
build.py
9
build.py
@ -147,6 +147,15 @@ def build_binary(args):
|
||||
with open(os.path.join('native', 'out', arch, 'binaries_arch_xz.h'), 'w') as out:
|
||||
with open(bin_file, 'rb') as src:
|
||||
xz_dump(src, out, 'magisk_xz')
|
||||
|
||||
stub_apk = os.path.join(config['outdir'], 'stub-release.apk')
|
||||
if not os.path.exists(stub_apk):
|
||||
error('Build release stub APK before building "magiskinit"')
|
||||
|
||||
with open(os.path.join('native', 'out', 'binaries_xz.h'), 'w') as out:
|
||||
with open(stub_apk, 'rb') as src:
|
||||
xz_dump(src, out, 'manager_xz')
|
||||
|
||||
flags += ' B_INIT=1'
|
||||
other = True
|
||||
|
||||
|
@ -72,6 +72,7 @@ LOCAL_STATIC_LIBRARIES := libsepol liblzma
|
||||
LOCAL_C_INCLUDES := \
|
||||
jni/include \
|
||||
jni/magiskpolicy \
|
||||
out \
|
||||
out/$(TARGET_ARCH_ABI) \
|
||||
$(LIBSEPOL) \
|
||||
$(LIBLZMA)
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <lzma.h>
|
||||
#include <cil/cil.h>
|
||||
|
||||
#include "binaries_xz.h"
|
||||
#include "binaries_arch_xz.h"
|
||||
|
||||
#include "magiskrc.h"
|
||||
@ -327,6 +328,14 @@ static int dump_magisk(const char *path, mode_t mode) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dump_manager(const char *path, mode_t mode) {
|
||||
unlink(path);
|
||||
int fd = creat(path, mode);
|
||||
int ret = unxz(manager_xz, sizeof(manager_xz), fd);
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dump_magiskrc(const char *path, mode_t mode) {
|
||||
int fd = creat(path, mode);
|
||||
write(fd, magiskrc, sizeof(magiskrc));
|
||||
@ -362,6 +371,8 @@ int main(int argc, char *argv[]) {
|
||||
if (argc > 1 && strcmp(argv[1], "-x") == 0) {
|
||||
if (strcmp(argv[2], "magisk") == 0)
|
||||
return dump_magisk(argv[3], 0755);
|
||||
else if (strcmp(argv[2], "manager") == 0)
|
||||
return dump_manager(argv[3], 0644);
|
||||
else if (strcmp(argv[2], "magiskrc") == 0)
|
||||
return dump_magiskrc(argv[3], 0755);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user