[Defy General] [] AL []:
* * * * * * * * * * * * * * * * * * * * * * *

Important update (Oct 19, 2012):

Two important things to add here:

1-) it seems that my updater-script mounting script was wrong and it is surprising that it worked for me all that time.

--> mount() expects 4 args, had 3.

So this should be changed --> from: mount("MTD", "system", "/system") to:

mount("ext3", "EMMC", "/dev/block/mmcblk1p21", "/system");

So I attached an UPDATED empty patch for that.

If your phone uses another ext or dev/block #, you can also try this mounting script:

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

2-) Somewhere in September 2012, CM7 team added support for TLS (will add commit details later if I find it), without explaining what it is, this brought changes in the update-binary file and if it is the rom you're using, you might need to use a recent update-binary within your patch. So I also attached an updated empty patch for CM7 recent builds.

That's it! have fun with cwm recovery patches.

Cheers,

/AL

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

I've been asked about this a few times, so finally here it is: a simple guide on how to make a flashable zip - usable on CWM recovery version 3 and higher (Edify script).

Disclaimer

:

Before you go on and follow my directives, I remind you that from here on, you step into the "make this at your own risks and perils" land. I don't pretend to be a guru on this and I might even be wrong on something here; so make a nandroid backup of your current system and apps and copy of any important system file or data you do not want to lose.

Please also understand that there are many different files of various functions on your phone and that the method I've chosen to share below might not apply to all files or situations; this is a basic quick guide for a basic system file replacement.

Ok, now that the things are set straight, let's do this!

Here's what you'll need:

[] a file (or more) that you want to replace or add on your phone;

[] an existing patch.zip file to use as a base - I've attached one below;

[] a good archive manager - I recommend 7-Zip;

[] a good text editor software for your computer - I recommend Notepad++ ;

[] a signing tool - I use apkmanager from here on xda

-> Download it and extract the files into a folder [c:\apkmanager for example]

--> perequisite: java libs installed on your computer.

[] a couple fingers with a normally developped brain attached to them.

All set up?, now let's do this!

- Place the patch.zip on your desktop and rename it to something more indicative of what it will be used for;

- Right-click on it and choose: "7-Zip / Open archive" [*DO NOT extract; just *Open archive*];

Now you should see two folders: one called "system" and one called "META-INF".

I - FILES AND FOLDERS:

Let's start with the "system" one, so double-click on it:

In there, will go all files that what you want to add or replace to the system. So let's say for example that you want to replace the camera and one of its related library. To do so, we first have to create the directory arborescence and create sub-directories in the /system/ folder by following this easy method:

- On your desktop, right-click on an empty spot and select "New / Folder" then edit the name to "app" (no " ") using no CAPS or space at the end;

- repeat the process to make another folder called "lib";

- drag those two new empty folders into the /system/ folder of the 7-zip opened archive [just click yes on the popup dialogs];

- now simply drop the two files in their respective place: the Camera.apk file should go in '/system/app' folder and the library file into '/system/lib' folder.

.. If you have more files to add, just follow the logic above; I'm sure you get the idea by now..

II - UDATER-SCRIPT

The other folder included in the opened archive is named "META-INF" and all the file in it should be

left unchanged

except for

one file: "updater-script" located in the "\META-INF\com\google\android\" folder.

- So navigate to it and drag the file to your desktop and open it with Notepad++ (you can use another text editor but I would not recommend the Windows' default Notepad for that).

That file is just a text file in which all the update instructions/commands are set.

The demo patch.zip that I've attached includes a very standard and basic script which does the bear minimum: it only mounts the system, then adds / overwrites the system files and then unmount the system. That is probably what most endusers need for the vast majority of cases. No need to worry about setting files permissions; your rom/bootmenu should set that for the whole system on boot. But there are tons of other uses and commands we can use in there; things like deleting files or entire folders, setting ownership and permissions, etc., etc. If you're interested in reading more or want to go a little more 'hard-core' on this, you can go read here and here.

So, what to change in the updater-script anyway?

Well, for this example, not much! You can edit the text on the lines starting with "ui_print": those will be displayed on the CWM screen during the update process. A good coding ethic would be to include a patch description and to add in any useful comments like if the patch is for a specific build only, say hello to your mom... or whatever!

2 important notes here though in order to avoid problems

:

* Each line of the updater-script MUST end with a ";" (no " ") ;

* There HAS TO BE at least

one blank line

after the last ( ; ) line of code.

Done with updater-script? -> Save the file and drop it over the old one in the opened archive and close it.

Almost done here... one last step:

III- SIGNING THE PATCH

This is simply done by:

- placing the patch in the apkmanger folder called "place-apk-here-for-signing"

[which should be in C:\~your location~\apkmanager\];

- executing the script (double-click on Script.bat file inside the apkmanager folder) and then selecting option 16* (*this option # might have change in latest version tbd)

Edit: as ktmbikerman has kindly confirmed, the latest version of apkmanager is now called APK multitool and that (signing) option is now # 19;

- Then (type 24?) exit, grab the now signed patch from the same folder and move it to safe place and on the phone's sdcard.

Congratulations you've done your first CWM patch !!!

One last warning:

Sometimes you don't know what a new system file or apk will do to your system. Applying a new patch can be risky and might even prevent your phone from booting up altogether; it happened to me before.. But luckily, I was kind of expecting it and I had been clever enough to first make myself a second patch with the original files and place it along with the other patch on the sdcard before testing the patch. So the no-boot was no big deal afterall because I've then just re-accessed CWM recovery and installed my undo/revert patch.

So all this to say, that it's better be safe than sorry and you can do this by

preparing a fallback patch sometimes..

That's it on this for today; hope it is of any help to some of you guys.

This is a first draft version and I will add more to it soon.

Comment/suggestions are always welcomed, but

PLEASE do not full-quote

this (or any) long post.

Cheers.

/A