This post was synchronized from Wing’s local tavern

I’ve been a fan of installing systems since Windows 98. On average, it took three days to reload, reload, reload on the home desktop. Never tired, then to the XP era, with GHOST, installed more crazy. Now to Android, is still brush brush, always have an idea is to make a ROM to play, so these days the SU and Xposed embedded. Thanks to Tule for your advice and discussion.

Ota packages are selected because ota packages can modify updater-script to perform operations in recovery.

Is the official ROM download address: developers.google.com/android/ota

Unzip it and you’ll see some boot.img images and stuff like that, and here we care about the meta-INF folder,

Simplified & pre-installed system APP

Here, we want to simplify the system APP. In fact, we only need to mount system and delete the folder under /system/ APP. And if you want to add system APP, you only need to create the corresponding file. Add the following code at the end of scripet


ui_print("mounting system");
mount("ext4"."EMMC"."/dev/block/platform/msm_sdcc.1/by-name/system"."/system");

ui_print("remove apps");
run_program("/sbin/busybox"."rm"."-rf"."/system/app/YouTube");

Copy the code

The above code shows the process of removing the pre-installed APP. What about the pre-installed app?

Create the same system folder in the zip package directory, put the app folder inside, and use the script to extract system to /system:

ui_print("set system apps");
package_extract_dir("system"."/system");
Copy the code

Embedded in the su

Unzipping su. Zip is almost the same as brushing the package, and the process of brushing su is actually using the script to unzip boot.img, modify the file value, and then merge boot.img again. So we can just brush su.zip in the script:

ui_print("====================>now start root");
package_extract_dir("ext/su"."/tmp/supersu");
run_program("/sbin/busybox"."unzip"."/tmp/supersu/su.zip"."META-INF/com/google/android/*"."-d"."/tmp/supersu");
run_program("/sbin/busybox"."sh"."/tmp/supersu/META-INF/com/google/android/update-binary"."dummy"."1"."/tmp/supersu/su.zip");

Copy the code

Of course, the zip directory should have a corresponding ZIP package.

Embedded xposed

This is where I got stuck for a long time, because I didn’t know the PWD of run_program, so I later used the absolute path and used another script around it:

run_program("/sbin/busybox"."chmod"."777"."/system/flash-script.sh");
run_program("/sbin/busybox"."chmod"."777"."/system/install_xposed.sh");

ui_print("run install_xposed.sh");
run_program("/system/install_xposed.sh");
Copy the code

In fact, xposed brush, is to replace some of the system files through flash-script.sh link operation, so we just put the Xposed package system folder for the position, and then execute flash-script.sh can:

install_xopsed.sh:

#! /sbin/sh
cd /system/ && /system/flash-script.sh

Copy the code

The only thing to notice here is the comment above, which baffled me for hours because the missing comment made it impossible to run with the run_program() method.

After the modification is complete, pack the ZIP package

zip -r rom.zip ./
Copy the code

One thing worth noting here is that it had to be packaged inside the directory, and there was an extra layer of directories outside, making it impossible to find the updater-script, which also messed me up for over an hour.

Resources bbs.gfan.com/android-832…