I’ve been working on Edify scripting to create a flashable zip that allows me to patch a regular CM7 nightly build with a reverted libaudio.so and updated libcamera.so

There’s literally no documentation anywhere! There’s some very old posts about Amend scripts (update-script) on XDA but nothing about the newer Edify scripts (updater-script and update-binary) that CM7 uses.

My script is based on the script from gapps:

ui_print("Mounting /system");
run_program("/sbin/busybox", "mount", "/system");

ui_print("Extracting libraries");
show_progress(0.100000, 0);
package_extract_file("libcamera.so", "/system/lib/libcamera.so");
package_extract_file("libaudio.so", "/system/lib/libaudio.so");
show_progress(0.100000, 10);

ui_print("Setting permissions");
show_progress(0.200000, 0);
set_perm(0, 0, 0644, "/system/lib/libcamera.so");
set_perm(0, 0, 0644, "/system/lib/libaudio.so");
show_progress(0.200000, 10);

run_program("/sbin/busybox", "umount", "/system");
ui_print("Installation complete!");

There’s not a huge amount of documentation about the folder structure of a zip or apk, but essentially its this:

libaudio.so
libcamera.so
META-INF/com/google/android/
   updater-script
   update-binary

You have to take update-binary from another zip file, such as a the CM7 zip itself.

There’s also very little documentation about signing zips. I found that the command to do that is:

java -jar signapk.jar testkey.x509.pem testkey.pk8 update.zip update-signed.zip

signapk.jar can be found in the out/host/linux-x86/framework/ directory of a compiled build and the AOSP signing keys can be found in the build/target/product/security/ directory of the Android source tree.

To make a patch to revert libaudio I had to diff against the version before HEAD for that whole directory – we have to do it this way as the previous commit is different for AudioHardware to AudioPolicyManager – this is “get the previous commit, whatever that may be”, not “get this specific commit for this specific file”:

cd device/zte/blade/libaudio/
git diff HEAD^ > ~/libaudio.patch

Then I can apply the patch to HEAD (optionally check for errors first):

git apply --check ~/libaudio.patch

No we have a patch to revert to a previous version, kind of the opposite of what patches are usually for!

I’ve created a new directory on my server for all the CM7 stuff like patches and KANG builds here, which includes this signed zip patch.