FORUMS
Remove All Ads from XDA

[GUIDE] How to make a cwm recovery flashable zip

454 posts
Thanks Meter: 833
 
By pankaj88, Senior Member on 20th June 2012, 01:17 PM
Post Reply Email Thread
REQUIREMENTS:
- any file that you want to replace or add to your phone;
- an existing cwm flashable zip file to use as a base - I've attached one below;
- 7-zip;
- Notepad++.


STEPS:

DIRECTORY STRUCTURE:

(1) Download and place the sample.zip anywhere on your desktop;
(2) 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 bootanimation and bootsound. To do so, we have to 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 "etc" (no " ") using no CAPS or space at the end;
- repeat the process to make another folder called "media";
- 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 sanim.zip file should go in '/system/media' folder and the PowerOn.wav into '/system/etc' folder.

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

/system/app - all the system apps (SystemUI.apk etc)
/system/framework/ -framework-res.apk, twframework-res.apk, android.policy.jar
/system/etc - vold.fstab, PowerOn.wav(bootsound)
/system/media - sanim.zip (bootanimation) (only for custom ROMs)
/system/lib - libraries (*.so)

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.

That's it !!
Congratulations you've done your first CWM patch !!!

NOTE: Always backup your existing system file that you are going to replace by the patch(zip).
Attached Files
File Type: zip sample.zip - [Click for QR Code] (138.5 KB, 43917 views)
The Following 174 Users Say Thank You to pankaj88 For This Useful Post: [ View ] Gift pankaj88 Ad-Free
 
 
20th June 2012, 01:51 PM |#2  
F3niX's Avatar
Senior Member
Flag Hyderabad
Thanks Meter: 326
 
More
Good Guide!!
There are many more here. Check them

EDIT: Added your Post there. As CWM Flashable Zip Guide.
Hope you are Fine with it.
The Following 8 Users Say Thank You to F3niX For This Useful Post: [ View ] Gift F3niX Ad-Free
20th June 2012, 03:05 PM |#3  
amar1548's Avatar
Senior Member
Flag hoshiarpur
Thanks Meter: 179
 
More
Thnx so much pankaj.........
26th June 2012, 10:25 PM |#4  
Member
Flag Qiryat Ono
Thanks Meter: 12
 
More
Great guide man awesome, thanks!

I've got some questions which I believe you can answer:

1. I come from another device's forum [SAMSUNG Galaxy S II I9100] so I'm not sure, will this method work with any device, or at least with mine?

2. What I'm trying to do is to take the nandroid backup I made for the ROM my device is currently running (whole ROM, along with all the MODs, themes & changes I have on it) and convert it into a CWM flashable .zip file, so:

A. Is this even possible with this method?

B. If it is, just to verify that I got it all right up until now: I decompress the 'system.ext4.tar' file from the nandroid' backup folder and then I push the decompressed system folder into the 'sample.zip' file that I've downloaded from this thread, right?

3. I know for a fact (correct me, if I'm wrong) that a nandroid backup doesn't include a backup of the modem (at least not in my device), so how do I add my currently installed modem to the .zip file?

4. What about the recovery and bootloader, how do I add them?

5. What about "cache.ext4.tar" & "data.ext4.tar", are they necessary in any way?
The Following 2 Users Say Thank You to Itzik68 For This Useful Post: [ View ] Gift Itzik68 Ad-Free
27th June 2012, 08:28 AM |#5  
pankaj88's Avatar
OP Senior Member
Flag Delhi
Thanks Meter: 833
 
More
Quote:
Originally Posted by Itzik68

Great guide man awesome, thanks!

I've got some questions which I believe you can answer:

1. I come from another device's forum [SAMSUNG Galaxy S II I9100] so I'm not sure, will this method work with any device, or at least with mine?

2. What I'm trying to do is to take the nandroid backup I made for the ROM my device is currently running (whole ROM, along with all the MODs, themes & changes I have on it) and convert it into a CWM flashable .zip file, so:

A. Is this even possible with this method?

B. If it is, just to verify that I got it all right up until now: I decompress the 'system.ext4.tar' file from the nandroid' backup folder and then I push the decompressed system folder into the 'sample.zip' file that I've downloaded from this thread, right?

3. I know for a fact (correct me, if I'm wrong) that a nandroid backup doesn't include a backup of the modem (at least not in my device), so how do I add my currently installed modem to the .zip file?

4. What about the recovery and bootloader, how do I add them?

5. What about "cache.ext4.tar" & "data.ext4.tar", are they necessary in any way?

(1) This method will work with any device as long as the device has custom recovery (CWM).

(2) a. yes, it is possible
b. decompress system.ext4.tar and push all the files/folders in the system folder to the system folder in the sample.zip

You must add the line in BOLD/italic to the META-INF/com/google/android/updater-script file

Code:
run_program("/sbin/busybox", "mount", "/system");
delete_recursive("/system");
package_extract_dir("system", "/system");
This line has to be added only when you want to replace all the system files/folders
otherwise no need to add.

drag updater-script from sample.zip (open via 7zip, do not extract) to the desktop, make modifications, save & then push it back to the same locations in sample.zip

(3) To include modem.bin :
first drag modem.bin & this file to sample.zip
now the directory structure of sample.zip is as follows
FOLDERS - system, META-INF
FILES - modem.bin, flash_image

add following lines to the META-INF/com/google/android/updater-script file
Code:
package_extract_file("flash_image", "/tmp/flash_image");
set_perm(0, 0, 0777, "/tmp/flash_image");
ui_print("Installing modem...");
assert(package_extract_file("modem.bin", "/tmp/modem.bin"),
run_program("/tmp/flash_image", "/dev/block/mmcblk0p7", "/tmp/modem.bin"),
delete("/tmp/modem.bin"));
delete("/tmp/flash_image");


(4) Don't know about bootloader, but for recovery, similar step as above:
drag recovery.img to sample.zip

add these lines to updater-script
Code:
package_extract_file("recovery.img", "/tmp/recovery.img");
run_program("/sbin/busybox", "dd", "if=/dev/zero", "of=/dev/block/mmcblk0p8");
run_program("/sbin/busybox", "dd", "if=/tmp/recovery.img", "of=/dev/block/mmcblk0p8");
run_program("/sbin/busybox", "sync");
run_program("/sbin/busybox", "rm", "-f", "/tmp/recovery.img");
(5) No these files are not needed.
The Following 5 Users Say Thank You to pankaj88 For This Useful Post: [ View ] Gift pankaj88 Ad-Free
27th June 2012, 12:06 PM |#6  
Member
Flag Qiryat Ono
Thanks Meter: 12
 
More
Thanks man, you're awesome!!!

I still have several questions though:
Quote:
Originally Posted by pankaj88

b. decompress system.ext4.tar and push all the files/folders in the system folder to the system folder in the sample.zip

You must add the line in BOLD/italic to the META-INF/com/google/android/updater-script file

Code:
run_program("/sbin/busybox", "mount", "/system");
delete_recursive("/system");
package_extract_dir("system", "/system");
This line has to be added only when you want to replace all the system files/folders
otherwise no need to add.

drag updater-script from sample.zip (open via 7zip, do not extract) to the desktop, make modifications, save & then push it back to the same locations in sample.zip

OK, puling / pushing files / folders from / to the .zip / .tar files is no problem, but I don't really get the part with this: "updater-script" file...

1. Let's say I've pulled it:

A. What is this file?

B. How can I open and edit it?

C. You say to add those code lines, but I'm guessing there are already several other code lines in it, where do I add those line? Above something else? Below it? Where?

2. Except for this: "updater-script" file, there are also:

META-INF\CERT.RSA

META-INF\CERT.SF

META-INF\MANIFEST.MF

META-INF\com\google\android\update-binary

A. What about those, what are they?

B. Don't they need to be changed as well?

I have more questions about the other parts of your answer, but for now let's live it at that.

I'm really sorry I'm bugging you, but I really like to understand what I'm doing before doing it...
27th June 2012, 02:50 PM |#7  
pankaj88's Avatar
OP Senior Member
Flag Delhi
Thanks Meter: 833
 
More
Quote:
Originally Posted by Itzik68

Thanks man, you're awesome!!!

I still have several questions though:eek:K, puling / pushing files / folders from / to the .zip / .tar files is no problem, but I don't really get the part with this: "updater-script" file...

1. Let's say I've pulled it:

A. What is this file?

B. How can I open and edit it?

C. You say to add those code lines, but I'm guessing there are already several other code lines in it, where do I add those line? Above something else? Below it? Where?

2. Except for this: "updater-script" file, there are also:

META-INF\CERT.RSA

META-INF\CERT.SF

META-INF\MANIFEST.MF

META-INF\com\google\android\update-binary

A. What about those, what are they?

B. Don't they need to be changed as well?

I have more questions about the other parts of your answer, but for now let's live it at that.

I'm really sorry I'm bugging you, but I really like to understand what I'm doing before doing it...

(1) It is updater-script file.
CWM flashes the zip file according to the steps mentioned in this file.

lets say
updater-script contains following lines:

Code:
ui_print("|             Writing System                  |");
run_program("/sbin/busybox", "mount", "/system");
delete_recursive("/system");
package_extract_dir("system", "/system");
Explanation of all the lines:
first line just print "Writing System"
next, mounts system partition so that files can be copied to it
deletes system folder
extract the system folder in the sample.zip to the device system partition

I hope now you have understand what updater-script is all about

You can use notepad++ to edit this file

(2) All the other files should be left as they are. No need to edit those files.
But their presence is necessary in the sample.zip
(these files serve as signature of the zip file)

Download this updater-script file to study more code.
The Following 6 Users Say Thank You to pankaj88 For This Useful Post: [ View ] Gift pankaj88 Ad-Free
27th June 2012, 08:44 PM |#8  
Member
Flag Qiryat Ono
Thanks Meter: 12
 
More
OK, so now my "updater-script" file is looking like that:

Code:
ui_print("SAMPLE CWM FLASHABLE PACKAGE");
run_program("/sbin/busybox", "mount", "/system");
delete_recursive("/system");
package_extract_dir("system", "/system");
run_program("/sbin/busybox", "umount", "/system");
package_extract_file("flash_image", "/tmp/flash_image");
set_perm(0, 0, 0777, "/tmp/flash_image");
ui_print("Installing modem...");
assert(package_extract_file("modem.bin", "/tmp/modem.bin"),
run_program("/tmp/flash_image", "/dev/block/mmcblk0p7", "/tmp/modem.bin"),
delete("/tmp/modem.bin"));
delete("/tmp/flash_image");
Is that right so far?
28th June 2012, 05:17 AM |#9  
pankaj88's Avatar
OP Senior Member
Flag Delhi
Thanks Meter: 833
 
More
Quote:
Originally Posted by Itzik68

OK, so now my "updater-script" file is looking like that:

Code:
ui_print("SAMPLE CWM FLASHABLE PACKAGE");
run_program("/sbin/busybox", "mount", "/system");
delete_recursive("/system");
package_extract_dir("system", "/system");
run_program("/sbin/busybox", "umount", "/system");
package_extract_file("flash_image", "/tmp/flash_image");
set_perm(0, 0, 0777, "/tmp/flash_image");
ui_print("Installing modem...");
assert(package_extract_file("modem.bin", "/tmp/modem.bin"),
run_program("/tmp/flash_image", "/dev/block/mmcblk0p7", "/tmp/modem.bin"),
delete("/tmp/modem.bin"));
delete("/tmp/flash_image");
Is that right so far?

you should study the updater-script file, the link for which I provided in the last reply.

Code:
run_program("/sbin/busybox", "umount", "/system");
this line should come at the last when all the copying & flashing has been done.
It unmount the system partition.

Also you need to set permissions & create symbolic links.
I suggest you to study the updater script file first.

If you found any problem, post here.
The Following 2 Users Say Thank You to pankaj88 For This Useful Post: [ View ] Gift pankaj88 Ad-Free
4th July 2012, 05:36 AM |#10  
draiyan's Avatar
Senior Member
Flag Cebu City
Thanks Meter: 39
 
More
Quote:
Originally Posted by pankaj88

you should study the updater-script file, the link for which I provided in the last reply.

Code:
run_program("/sbin/busybox", "umount", "/system");
this line should come at the last when all the copying & flashing has been done.
It unmount the system partition.

Also you need to set permissions & create symbolic links.
I suggest you to study the updater script file first.

If you found any problem, post here.

what are symbolic links for? i have studied the updater script you posted.. and did some on my custom rom, both have many symbolic links, what it is for? is it necessary? or just for custom roms?
4th July 2012, 07:29 AM |#11  
pankaj88's Avatar
OP Senior Member
Flag Delhi
Thanks Meter: 833
 
More
Quote:
Originally Posted by draiyan

what are symbolic links for? i have studied the updater script you posted.. and did some on my custom rom, both have many symbolic links, what it is for? is it necessary? or just for custom roms?

for understanding what symbolic links are:
http://en.m.wikipedia.org/wiki/Symbolic_link

it is necessary to have symbolic links for every ROM that you are going to flash via CWM.

Sent from my GT-I9103 using xda app-developers app
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes