[Desire HD General] sashank:
[TUT] Edify Scripts (Creating flashable zips)

Here's some stuff about edify (updater-script) codes to make your own flashable zips. Thanks to Teichopsia for the suggestion. I thought of writing a tutorial for this, but I searched around and there are a few well written ones. So I'm just going link to those.

[TUT] creating simple update.zip

In this guide, there's a change to be made in one command for our device.

mount("yaffs2", "MTD", "system", "/system");
#command is used to mount system without mounting nothing can be copied to system

For mounting the DHD /system (ext4) partition, this would be -

mount("ext4", "EMMC", "/dev/block/mmcblk0p25", "/system");

For mounting other partitions, the respective partitions are listed below. You can see them on your own device by opening Terminal Emulator and typing 'cat /proc/emmc' minus the quotes, or by connecting your phone to the computer and typing 'adb shell' followed by the previous command.

This is a list of the DHD partitions -

u0_a70@android:/ $ cat /proc/emmc
dev: size erasesize name
mmcblk0p17: 00040000 00000200 "misc"
mmcblk0p21: 0087f400 00000200 "recovery"
mmcblk0p22: 00400000 00000200 "boot"
mmcblk0p25: 22dffe00 00000200 "system"
mmcblk0p27: 12bffe00 00000200 "cache"
mmcblk0p26: 496ffe00 00000200 "userdata"
mmcblk0p28: 014bfe00 00000200 "devlog"
mmcblk0p29: 00040000 00000200 "pdata"

An alternative, easier way to mount partitions in the updater-script is by using busybox. The command for that is -

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

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

A more detailed description of the various edify commands and their syntaxes can be found here -

An introduction to the Edify (Updater-Script) language

[GUIDE] introduction to edify updater script (installer zip)

Documenting Edify for Android Updater-Scripts based off of recovery source code

------------------------------------------------

A flashable zip, for most purposes, is made to format partitions, copy files and folders into partitions, and set permissions. However, quite a few times you'll run into flashable zips which don't have any files in them. These zips just have the META-INF folder and its sub-folders, and are meant to change certain system settings, edit sqlite databases and change parts of build.prop. I have never used these myself yet, but here's a guide for those who are interested - [HOWTO] Change system settings via updater-script

------------------------------------------------

Now this is a lot to read, and it might be overwhelming for someone who just wants to quickly learn how to make a flashable zip for a bunch of files. This guide and the guides posted in it are meant to give a good understanding of the various edify commands so that you can learn to write your own updater-script from scratch. If you are not too interested in that, and just want to quickly make a flashable zip, read on.

Flashable zips are mainly used to copy files into the system and data partitions. I've attached to this post a base flashable zip which does just that. All you have to do is open the zip with any archiving program, add the files you want into their respective folders and flash away. :good:

You can also use this base script and modify the updater-script for your purposes using the edify commands. You only have to change the updater-script and add in your files, nothing else. All the other files in META-INF are standard and remain the same for any flashable zip.

The updater-script for this base flashable zip is -

ui_print("<name of zip or whatever you want to write>");

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

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

ui_print("Extracting files to /system");
package_extract_dir("system", "/system");

ui_print("Extracting files to /data");
package_extract_dir("data", "/data");

ui_print("Unmounting /data");
unmount("/data");

ui_print("Unmounting /system");
unmount("/system");

ui_print("Installation complete!");

Note: There are delete and delete_recursive functions to delete files and folders respectively, but if your intention is to replace a file in the same path, then you don't need to use those to delete the existing file prior to replacing. The file will be overwritten with the new one. Use those if you want to exclusively delete some files/folders. The set_perm_recursive function is not always necessary too, that's why I've not included it. Files copied to /system/app and /data/app are automatically set to rw-r--r--.

TIP: Sometimes I've tried flashing zips I made for my phone onto other phones. The files weren't any phone specific stuff, so there was no problem if I flashed them. But I got an 'installation aborted' error whenever I tried to flash the zips. If you run into this problem when you try to flash your zips onto other phones, just download any flashable zip for that phone that you see lying around in its forum threads. Anything - a ROM zip, theme, whatever. Extract the update-binary from it and replace the one in your zip with that. That's it. It will flash fine after that. You don't need to change the updater-script or anything else to match that phone if you've used the generic updater-script that I provided above. It works for all phones. If you've used a script in which the mount command syntax contains the exact partition codes of DHD/I4G, then you'll have to change those to match the new phone.

Happy flashing!