Add busybox to source

This commit is contained in:
topjohnwu 2017-07-30 20:14:12 +08:00
parent 9fca7011aa
commit 24164c8580
7 changed files with 25 additions and 15 deletions

3
.gitmodules vendored
View File

@ -13,3 +13,6 @@
[submodule "MagiskManager"] [submodule "MagiskManager"]
path = MagiskManager path = MagiskManager
url = https://github.com/topjohnwu/MagiskManager.git url = https://github.com/topjohnwu/MagiskManager.git
[submodule "jni/busybox"]
path = jni/busybox
url = https://github.com/topjohnwu/ndk-busybox.git

View File

@ -58,7 +58,7 @@ def build_binary(args):
header('* Building Magisk binaries') header('* Building Magisk binaries')
ndk_build = os.path.join(os.environ['ANDROID_HOME'], 'ndk-bundle', 'ndk-build') ndk_build = os.path.join(os.environ['ANDROID_HOME'], 'ndk-bundle', 'ndk-build')
debug_flag = '' if args.release else '-DDEBUG' debug_flag = '' if args.release else '-DMAGISK_DEBUG'
proc = subprocess.run('{} APP_CFLAGS=\"-DMAGISK_VERSION=\\\"{}\\\" -DMAGISK_VER_CODE={} {}\" -j{}'.format( proc = subprocess.run('{} APP_CFLAGS=\"-DMAGISK_VERSION=\\\"{}\\\" -DMAGISK_VER_CODE={} {}\" -j{}'.format(
ndk_build, args.versionString, args.versionCode, debug_flag, multiprocessing.cpu_count()), shell=True) ndk_build, args.versionString, args.versionCode, debug_flag, multiprocessing.cpu_count()), shell=True)
if proc.returncode != 0: if proc.returncode != 0:
@ -113,8 +113,8 @@ def sign_adjust_zip(unsigned, output):
header('* Signing / Adjusting Zip') header('* Signing / Adjusting Zip')
# Unsigned->signed # Unsigned->signed
proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'signapk.jar'), proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'signapk.jar'),
os.path.join('ziptools', 'test.certificate.x509.pem'), os.path.join('ziptools', 'test.certificate.x509.pem'),
os.path.join('ziptools', 'test.key.pk8'), unsigned, 'tmp_signed.zip']) os.path.join('ziptools', 'test.key.pk8'), unsigned, 'tmp_signed.zip'])
if proc.returncode != 0: if proc.returncode != 0:
error('First sign flashable zip failed!') error('First sign flashable zip failed!')
@ -131,8 +131,8 @@ def sign_adjust_zip(unsigned, output):
error('Adjust flashable zip failed!') error('Adjust flashable zip failed!')
# Adjusted -> output # Adjusted -> output
proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'minsignapk.jar'), proc = subprocess.run(['java', '-jar', os.path.join('ziptools', 'minsignapk.jar'),
os.path.join('ziptools', 'test.certificate.x509.pem'), os.path.join('ziptools', 'test.certificate.x509.pem'),
os.path.join('ziptools', 'test.key.pk8'), 'tmp_adjusted.zip', output]) os.path.join('ziptools', 'test.key.pk8'), 'tmp_adjusted.zip', output])
if proc.returncode != 0: if proc.returncode != 0:
error('Second sign flashable zip failed!') error('Second sign flashable zip failed!')

View File

@ -39,6 +39,7 @@ LOCAL_SRC_FILES := \
su/su_socket.c su/su_socket.c
LOCAL_CFLAGS := -Wno-implicit-exception-spec-mismatch LOCAL_CFLAGS := -Wno-implicit-exception-spec-mismatch
LOCAL_CPPFLAGS := -std=c++11
LOCAL_LDLIBS := -llog LOCAL_LDLIBS := -llog
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
@ -51,3 +52,10 @@ include jni/selinux/libsepol/Android.mk
# Build magiskboot # Build magiskboot
include jni/magiskboot/Android.mk include jni/magiskboot/Android.mk
# Build busybox (32-bit only)
ifneq ($(TARGET_ARCH_ABI), x86_64)
ifneq ($(TARGET_ARCH_ABI), arm64-v8a)
include jni/busybox/Android.mk
endif
endif

View File

@ -1,4 +1,2 @@
APP_ABI := x86 x86_64 armeabi-v7a arm64-v8a APP_ABI := x86 x86_64 armeabi-v7a arm64-v8a
APP_PLATFORM := android-21 APP_PLATFORM := android-21
APP_UNIFIED_HEADERS := true
APP_CPPFLAGS += -std=c++11

1
jni/busybox Submodule

@ -0,0 +1 @@
Subproject commit 2178671c6ef5322f2695cb0ee56df4195d8218ae

View File

@ -25,7 +25,7 @@
static char *buf, *buf2; static char *buf, *buf2;
static struct vector module_list; static struct vector module_list;
#ifdef DEBUG #ifdef MAGISK_DEBUG
static int debug_log_pid, debug_log_fd; static int debug_log_pid, debug_log_fd;
#endif #endif
@ -69,7 +69,7 @@ static int merge_img(const char *source, const char *target) {
rename(source, target); rename(source, target);
return 0; return 0;
} }
// resize target to worst case // resize target to worst case
int s_used, s_total, t_used, t_total, n_total; int s_used, s_total, t_used, t_total, n_total;
get_img_size(source, &s_used, &s_total); get_img_size(source, &s_used, &s_total);
@ -261,7 +261,7 @@ static void construct_tree(const char *module, struct node_entry *parent) {
* 1. File in module is a symlink * 1. File in module is a symlink
* 2. Target file do not exist * 2. Target file do not exist
* 3. Target file is a symlink, but not /system/vendor * 3. Target file is a symlink, but not /system/vendor
*/ */
int clone = 0; int clone = 0;
if (IS_LNK(node) || access(buf, F_OK) == -1) { if (IS_LNK(node) || access(buf, F_OK) == -1) {
clone = 1; clone = 1;
@ -296,7 +296,7 @@ static void construct_tree(const char *module, struct node_entry *parent) {
construct_tree(module, node); construct_tree(module, node);
} }
} }
closedir(dir); closedir(dir);
cleanup: cleanup:
@ -484,7 +484,7 @@ void post_fs_data(int client) {
if (!check_data()) if (!check_data())
goto unblock; goto unblock;
#ifdef DEBUG #ifdef MAGISK_DEBUG
// Start debug logs in new process // Start debug logs in new process
debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644); debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644);
char *const command[] = { "logcat", "-v", "brief", NULL }; char *const command[] = { "logcat", "-v", "brief", NULL };
@ -751,7 +751,7 @@ void late_start(int client) {
if (access(MANAGERAPK, F_OK) == 0) { if (access(MANAGERAPK, F_OK) == 0) {
while (1) { while (1) {
sleep(5); sleep(5);
char *const command[] = { "sh", "-c", char *const command[] = { "sh", "-c",
"CLASSPATH=/system/framework/pm.jar " "CLASSPATH=/system/framework/pm.jar "
"/system/bin/app_process /system/bin " "/system/bin/app_process /system/bin "
"com.android.commands.pm.Pm install -r " MANAGERAPK, NULL }; "com.android.commands.pm.Pm install -r " MANAGERAPK, NULL };
@ -773,7 +773,7 @@ void late_start(int client) {
buf = buf2 = NULL; buf = buf2 = NULL;
vec_deep_destroy(&module_list); vec_deep_destroy(&module_list);
#ifdef DEBUG #ifdef MAGISK_DEBUG
// Stop recording the boot logcat after every boot task is done // Stop recording the boot logcat after every boot task is done
kill(debug_log_pid, SIGTERM); kill(debug_log_pid, SIGTERM);
waitpid(debug_log_pid, NULL, 0); waitpid(debug_log_pid, NULL, 0);

View File

@ -58,7 +58,7 @@ static inline void do_nothing() {}
// Dummy function to depress debug message // Dummy function to depress debug message
static inline void stub(const char *fmt, ...) {} static inline void stub(const char *fmt, ...) {}
#ifdef DEBUG #ifdef MAGISK_DEBUG
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#else #else
#define LOGD(...) stub(__VA_ARGS__) #define LOGD(...) stub(__VA_ARGS__)