├── README.md ├── init.kokoro.rc ├── kokoro.mk ├── magisk ├── busybox ├── copy.sh ├── loadpolicy.sh ├── magisk32 ├── magisk64 ├── magiskboot └── magiskinit └── magiskpolicy /README.md: -------------------------------------------------------------------------------- 1 | # Project Kokoro - integrate Magisk into your Android-x86 build (x86_64 only) 2 | 3 | **Current Magisk branch : stable** 4 | 5 | **Current Magisk version : 24.1** 6 | 7 | This project is aim to integrate Magisk into Android-x86 build automatically, and can even be able to use modules as well as Zygisk. It's mainly based on works like [MagiskOnWSA](https://github.com/LSPosed/MagiskOnWSA) or [MagiskOnEmu](https://github.com/HuskyDG/MagiskOnEmu) so you will see they might be pretty similar. 8 | Kokoro currently aiming to support Android-x86 builds that are Android 10+ with x86_64 only, so if you want x86 support you can contribute here, I don't have any interest to support it so far. 9 | 10 | Note that the instruction is only for building the image, if you want to manually integrate into a prebuilts image (say like PrimeOS 2.0) you have to figure it out yourself. 11 | 12 | ## How to use 13 | - Clone this repo to vendor/supremegamers/kokoro 14 | - It is recommend to clear everything related to koushSU, the old Superuser that Android-x86 usually use, you can try to remove external/koush folder (which includes [Superuser](https://git.osdn.net/view?p=android-x86/external-koush-Superuser.git;a=summary) and [Widget](https://git.osdn.net/view?p=android-x86/external-koush-Superuser.git;a=summary)) , also reverting the commit in Settings (for example, [here is my commit on ProjectSakura-x86](https://github.com/supremegamers/android_packages_apps_Settings/commit/4a4de015c8c7724bc9c222cc6c8f1a6dc4a013f1)) 15 | - Go to bootable/newinstaller and cherry-pick [this commit](https://github.com/supremegamers/bootable_newinstaller/commit/9ff32be219e65b08f3cbd2e20629e1df3dabe218) to patch sepolicy using magiskpolicy tool 16 | - It is recommend to cherry-pick [this commit](https://github.com/supremegamers/bootable_newinstaller/commit/929245d5c46aa19ddab5de8cf153bf82b6adc16b) on bootable/newinstaller too so that if you extract system.sfs out to .img Magisk is still usable, but keep in mind that you will never be able to set system as R/W. 17 | - Go to device/generic/common and cherry-pick [this commit](https://github.com/supremegamers/device_generic_common/commit/2a37e98631fff756f933222b6586258f2897999e) so that the build will copy the files and also init.*.rc can recognize init.kokoro.rc 18 | - When building, please export `ANDROID_INTEGRATE_MAGISK=true` so that the build will start copying the Magisk files in. 19 | - **WARNING** : If the build failed in the selinux test stage (to check the integrity of the file), remove the whole out/target/product/*arch* (in this case x86_64) and then try again, **do not make clean or delete the out folder** 20 | 21 | ## How does it works 22 | Well..... same as the 2 projects above, init.kokoro.rc will prepare a tmpfs folder (in this case `/dev/magisk`) and then putting all the Magisk files into it (the files are located in /system/etc/magisk), linking to the appropriate tools and then starting the Magisk boot stage like `post-fs-data`/`services`/`boot-complete` . 23 | 24 | In order to prevent the magic mount to accidentally mount the whole drive to `/data` instead of the only data folder or image, I unmount the data in magic mount (if it does mount) and then linking the mount place to /data instead. Not only does it help magic mount to not accidentally mount the drive, but also helps the Magisk modules show and working properly. 25 | 26 | After that, Magisk is completely initialized and you can use it. 27 | 28 | ## Origin of the name 29 | The name `Kokoro` comes from [Hata no Kokoro](https://en.touhouwiki.net/wiki/Hata_no_Kokoro), a character from _Touhou Project_ , usually appears on fighting games in the series. Since her power is manipulating emotions by using the masks I decided to use her name for this project. 30 | 31 | ![Kokoro](https://en.touhouwiki.net/images/8/8d/Th155Kokoro.png) 32 | 33 | _Kokoro art made by [Moe Harukawa](https://en.touhouwiki.net/wiki/Moe_Harukawa) used in the main series fighting games produced by [Tasofro](https://tasofro.net/) + [Team Shanghai Alice](https://www16.big.or.jp/~zun/)_ 34 | 35 | ## Credit 36 | 37 | The project is nothing without the work of these guys 38 | - [John Wu](https://github.com/topjohnwu) and the contributors behind [Magisk](https://github.com/topjohnwu/Magisk). 39 | - [LSPosed Team](https://github.com/LSPosed) with the work behind [MagiskOnWSA](https://github.com/LSPosed/MagiskOnWSA) 40 | - [HuskyDG](https://github.com/HuskyDG) for helping me setting up Magisk on Android-x86 so that I can complete make project. 41 | 42 | 43 | ## Good luck 44 | -------------------------------------------------------------------------------- /init.kokoro.rc: -------------------------------------------------------------------------------- 1 | on post-fs-data 2 | start logd 3 | start adbd 4 | mkdir /dev/magisk 5 | mount tmpfs tmpfs /dev/magisk mode=0755 6 | copy /system/etc/magisk/magisk64 /dev/magisk/magisk64 7 | chmod 0755 /dev/magisk/magisk64 8 | symlink /dev/magisk/magisk64 /dev/magisk/magisk 9 | symlink /dev/magisk/magisk64 /dev/magisk/su 10 | symlink /dev/magisk/magisk64 /dev/magisk/resetprop 11 | copy /system/etc/magisk/magisk32 /dev/magisk/magisk32 12 | chmod 0755 /dev/magisk/magisk32 13 | copy /system/etc/magisk/magiskinit /dev/magisk/magiskinit 14 | chmod 0755 /dev/magisk/magiskinit 15 | symlink /dev/magisk/magiskinit /dev/magisk/magiskpolicy 16 | mkdir /dev/magisk/.magisk 700 17 | mkdir /dev/magisk/.magisk/mirror 700 18 | mkdir /dev/magisk/.magisk/block 700 19 | rm /dev/.magisk_unblock 20 | start IhhslLhHYfse 21 | start FAhW7H9G5sf 22 | umount /dev/magisk/.magisk/mirror/data 23 | rm /dev/magisk/.magisk/mirror/data 24 | symlink /data /dev/magisk/.magisk/mirror/data 25 | wait /dev/.magisk_unblock 40 26 | rm /dev/.magisk_unblock 27 | 28 | service IhhslLhHYfse /system/bin/sh /system/etc/magisk/loadpolicy.sh 29 | user root 30 | seclabel u:r:magisk:s0 31 | oneshot 32 | 33 | service FAhW7H9G5sf /dev/magisk/magisk --post-fs-data 34 | user root 35 | seclabel u:r:magisk:s0 36 | oneshot 37 | 38 | service HLiFsR1HtIXVN6 /dev/magisk/magisk --service 39 | class late_start 40 | user root 41 | seclabel u:r:magisk:s0 42 | oneshot 43 | 44 | on property:sys.boot_completed=1 45 | start YqCTLTppv3ML 46 | 47 | service YqCTLTppv3ML /dev/magisk/magisk --boot-complete 48 | user root 49 | seclabel u:r:magisk:s0 50 | oneshot -------------------------------------------------------------------------------- /kokoro.mk: -------------------------------------------------------------------------------- 1 | ##Copy init.kokoro.rc and Magisk files into the system 2 | 3 | PRODUCT_COPY_FILES += \ 4 | $(LOCAL_PATH)/init.kokoro.rc:root/init.kokoro.rc \ 5 | $(foreach f,$(wildcard $(LOCAL_PATH)/magisk/*),$(f):$(subst $(LOCAL_PATH),system/etc,$(f))) \ 6 | -------------------------------------------------------------------------------- /magisk/busybox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supremegamers/kokoro/351ba55173d6bb3e175fbf2611a08a1aa5bdb2d2/magisk/busybox -------------------------------------------------------------------------------- /magisk/copy.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | if [ ! -d /data/adb/magisk/addon.d.sh ]; then 4 | cp /system/etc/magisk/addon.d.sh /data/adb/magisk/addon.d.sh 5 | fi 6 | if [ ! -d /data/adb/magisk/boot_patch.sh ]; then 7 | cp /system/etc/magisk/boot_patch.sh /data/adb/magisk/addon.d.sh 8 | fi 9 | if [ ! -d /data/adb/magisk/bootctl ]; then 10 | cp /system/etc/magisk/bootctl /data/adb/magisk/bootctl 11 | fi 12 | if [ ! -d /data/adb/magisk/main.jar ]; then 13 | cp /system/etc/magisk/main.jar /data/adb/magisk/main.jar 14 | fi 15 | if [ ! -d /data/adb/magisk/uninstaller.sh ]; then 16 | cp /system/etc/magisk/uninstaller.jar /data/adb/magisk/uninstaller.jar 17 | fi 18 | if [ ! -d /data/adb/magisk/util_functions.sh ]; then 19 | cp /system/etc/magisk/util_functions.jar /data/adb/magisk/util_functions.jar 20 | fi 21 | 22 | symlink /system/etc/magisk/magisk64 /data/adb/magisk/magisk64 23 | symlink /system/etc/magisk/magisk32 /data/adb/magisk/magisk32 24 | symlink /system/etc/magisk/busybox /data/adb/magisk/busybox 25 | symlink /system/etc/magisk/magiskboot /data/adb/magisk/magiskboot 26 | symlink /system/etc/magisk/magiskinit /data/adb/magisk/magiskinit -------------------------------------------------------------------------------- /magisk/loadpolicy.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | restorecon -R /data/adb/magisk 3 | for module in $(ls /data/adb/modules); do 4 | if ! [ -f "/data/adb/modules/$module/disable" ] && [ -f "/data/adb/modules/$module/sepolicy.rule" ]; then 5 | /dev/magisk/magiskpolicy --live --apply "/data/adb/modules/$module/sepolicy.rule" 6 | fi 7 | done 8 | -------------------------------------------------------------------------------- /magisk/magisk32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supremegamers/kokoro/351ba55173d6bb3e175fbf2611a08a1aa5bdb2d2/magisk/magisk32 -------------------------------------------------------------------------------- /magisk/magisk64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supremegamers/kokoro/351ba55173d6bb3e175fbf2611a08a1aa5bdb2d2/magisk/magisk64 -------------------------------------------------------------------------------- /magisk/magiskboot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supremegamers/kokoro/351ba55173d6bb3e175fbf2611a08a1aa5bdb2d2/magisk/magiskboot -------------------------------------------------------------------------------- /magisk/magiskinit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supremegamers/kokoro/351ba55173d6bb3e175fbf2611a08a1aa5bdb2d2/magisk/magiskinit -------------------------------------------------------------------------------- /magiskpolicy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supremegamers/kokoro/351ba55173d6bb3e175fbf2611a08a1aa5bdb2d2/magiskpolicy --------------------------------------------------------------------------------