[Galaxy S II General] TeamRainless:
<<<TeamRainless>>> The DEFINITIVE Guide to Making Update.zip Files for The Galaxy SII

YOU NEED TO KNOW HOW TO DO THIS.

It's like changing a flat tire... a skill you never really need until it's far too late for you to learn how to do it because now you're stuck in Compton on a Saturday night... Better to learn NOW.

June 11th, 2012 (If you're reading much later you might want to check and see if Google has changed everything again.)

For starters: I'm writing this guide because ALL of the other guides for making an update.zip suck. Most of them follow the pattern of "Create a file called 'updater-script', write some stuff in it... and you're done!"

I happily nuked my Galaxy S II 20 times... including accidentally erasing my internal SD trying to figure out which "some stuff" I was supposed to write.

That said... creating an update.zip isn't as easy as all the smart-asses would have you believe it is... but it isn't as hard as YOU think it is either. I'm going to show you how to do it in three steps:

1. update-binary - a file that I'm giving you.

2. updater-script - a text file so simple to write you can do it in notepad in under 60 seconds

3. signing tool - I provide the link for one below but you can use whatever you want. Takes less than a second. (Note: Only standard bootloader Update.zips need to be signed. CWM zips don't. Still it's a good practice and... like I said it takes less than a second to do.)

WARNING: Screwing up an Update.zip can, at the very least, force you to do a factory reset and a clean wipe. And... at worst brick your phone.

Now... that said, if you follow these instructions CAREFULLY... there is very little chance of that.

Now the very first thing you're going to need is the correct update-binary for your phone. I have included the one for the GS2.

If you use a different one... it probably won't work. At least this has been my experience. So if you get an "Installation Aborted" error... this is probably why.

Next we need to write an updater-script in your favorite txt editor. (Forget about the old, BS, "update-script" that was written in Amend. New scripts for new phones have to be written in Edify. I have no idea what Edify is... but Wikipedia does... and at the very least I know how to use it.)

We are going to make a simple update.zip that mounts /system, says some stuff, and then unmounts system. Beyond that it doesn't do a thing. So if you get cute and decide to "format" instead of "mount" system... or something crazy... then good luck to you, Sir.

[B]ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ********************************* ");
ui_print(" * - XDA TeamRainless is AWESOME - * ");
ui_print(" * * ");
ui_print(" * * ");
ui_print(" ********************************* ");
ui_print(" ");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");

ui_print("Testing...");

ui_print("You might lose that girl's number now...");

ui_print("I'm DEAD serious... I'm erasing ONE number...");

ui_print("THAT girl's...");

ui_print("Ok. I'm not REALLY serious...");

run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");

ui_print("Done...");

[/B]

As I said before, this code will do absolutely nothing but mount /system, print some text, and then unmount it. There's no file extraction, or deleting, or permission stuff going on.

Update.zip files have a standardized structure. I'm simply going to copy and paste from this guy http://fokke.org/site/content/howto-create-android-updatezip-package because it's the only part of his damned tutorial that worked.

[B]update
+-
META-INF/
+- com/
+- google/
+- android/

+- update-binary
+- updater-script
system/
+- your files
[/B]

Here you've got two folders in your root folder (which I have called update): a "META-INF" folder and a "system" folder. The "META-INF" folder MUST be written exactly like that and MUST have all of the subdirectories above. (Note: Windows Users. Do not use "Send to Zip" because you will have "update.zip->Update->META-INF,system" But what you want is "update.zip->META-INF, system.") The "system" folder can be whatever you want. You don't even need a subfolder. You can have a folder called "shoes" and just have all the files you want to extract in "shoes" and make sure your updater-script says that.

[B]ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ********************************* ");
ui_print(" * -Team Rainless - * ");
ui_print(" * * ");
ui_print(" * * ");
ui_print(" ********************************* ");
ui_print(" ");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");

ui_print("Writing. Hope this doesn't screw anything up...");

package_extract_dir("shoes", "/system/fonts");

run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");

ui_print("Done...");
[/B]

(Hmm... ADB'ed into the phone after running this script in Siyah 3.3.1's recovery and it said the "system" directory was erased... BAH that can't possibly be true!... it wasn't. EDIT: figured out what was going on. The last command in the zip unmounts /system... which "unmounts system" which is why I wasn't seeing it in recovery. So I simply went into "mount /system" in recovery then adb saw it just fine. I've been smarter...)

Throwing that command into the middle of updater-script will copy whatever is in the "shoes" directory to the "/system/font" directory on your phone.

Did that screw something up? Maybe wrong permission and you want to delete it but can't get back to root explorer? We'll make another update.zip that can delete it from CWM recovery.

[B]ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ");
ui_print(" ********************************* ");
ui_print(" * -Team Rainless - * ");
ui_print(" * * ");
ui_print(" * * ");
ui_print(" ********************************* ");
ui_print(" ");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");

ui_print("Deleting. Who told you to put that there in the first place?...");

delete("/system/fonts/Clockopia2.ttf");

run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");

ui_print("Done...");[/B]

Mind you... if you copy something to the system/apps directory, for example, that doesn't have the right permissions... you will get a thousand errors and you won't be able to run ANY applications on your phone. But if you know what you copied (kids... you should ALWAYS look inside of a zip file before blindly copying it to your phone) you can just use the delete command to get rid of it.

Now about permissions...

[B]set_perm(0,0,0644,"/system/whateveritis");[/B]

Nine times out of ten that will do it.

And 9/10 Update.zip tutorials would tell you to have a nice day at this point... but the last and most important thing is that the update.zip file must be SIGNED.

That JERK included a java script that would sign at the command prompt (I don't really hate this guy btw... I'm just from the Midwest. Have you ever seen a Bob Dylan interview? This is just how we talk...). I don't really know if it works or not... because his binary didn't work.

But my preferred method for signing is D4's Update Zip maker. http://xdaforums.com/showthread.php?t=1207492

You go to:

1. File

2. Select Working Directory

3. Choose the directory of your update

And it will actually show the updater-script you just wrote and you can make any changes you need to make.

Hit "Build" and it will give you your signed zip.

It's for PC only... so if you have mac or linux you can try the Java file from the Jerk's page. (I *like* the guy! We're roommates!)

You can also use the program to generate scripts from scratch... but I didn't like HIS tutorial either. (Great program though chief!)

In the end I don't know if this was educational at all. I hope it was at least entertaining. I'd hate to think all this alcohol went to waste.