[GUIDE] How to make a cwm recovery flashable zip

Search This thread

pankaj88

Senior Member
Jan 21, 2012
454
825
35
Delhi
www.pankajsharmaonline.blogspot.com
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).
 

Attachments

  • sample.zip
    138.5 KB · Views: 44,538
Last edited:

Itzik68

Senior Member
Dec 15, 2010
69
12
Qiryat Ono
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?
 

pankaj88

Senior Member
Jan 21, 2012
454
825
35
Delhi
www.pankajsharmaonline.blogspot.com
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");
[B][I]delete_recursive("/system");[/I][/B]
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.
 
Last edited:

Itzik68

Senior Member
Dec 15, 2010
69
12
Qiryat Ono
Thanks man, you're awesome!!!

I still have several questions though:
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");
[B][I]delete_recursive("/system");[/I][/B]
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...
 

pankaj88

Senior Member
Jan 21, 2012
454
825
35
Delhi
www.pankajsharmaonline.blogspot.com
Thanks man, you're awesome!!!

I still have several questions though: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...

(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.
 

Itzik68

Senior Member
Dec 15, 2010
69
12
Qiryat Ono
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?
 

pankaj88

Senior Member
Jan 21, 2012
454
825
35
Delhi
www.pankajsharmaonline.blogspot.com
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.
 

draiyan

Senior Member
Dec 5, 2011
429
44
Cebu City
Redmi Note 10 Pro
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?
 

pankaj88

Senior Member
Jan 21, 2012
454
825
35
Delhi
www.pankajsharmaonline.blogspot.com
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
 

baldypal

Senior Member
Dec 10, 2010
55
16
Midland
- 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)

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.
So i followed these steps with Phone.apk. Made an "app" folder inside the already existing "system" folder. moved my modified "Phone.apk" inside that folder. put on SD card, reboot recovery, choose to install from zip, choose correct zip, and get...

Error: in /sample.zip
(Status 0)
Installation aborted


Any idea. those are my exact steps, i left nothing out.
 
Last edited:

selva.simple

Senior Member
Feb 1, 2012
744
1,138
Chennai
So i followed these steps with Phone.apk. Made an "app" folder inside the already existing "system" folder. moved my modified "Phone.apk" inside that folder. put on SD card, reboot recovery, choose to install from zip, choose correct zip, and get...

Error: in /sample.zip
(Status 0)
Installation aborted


Any idea. those are my exact steps, i left nothing out.

Try do Mount/System and then flash it. Still if u get some prob, please attach ur cwm zip. Will try to help u buddy.:)
 

pankaj88

Senior Member
Jan 21, 2012
454
825
35
Delhi
www.pankajsharmaonline.blogspot.com
So i followed these steps with Phone.apk. Made an "app" folder inside the already existing "system" folder. moved my modified "Phone.apk" inside that folder. put on SD card, reboot recovery, choose to install from zip, choose correct zip, and get...

Error: in /sample.zip
(Status 0)
Installation aborted


Any idea. those are my exact steps, i left nothing out.

Do not extract the zip file.
Use "7zip" to open it & make a new folder named as "app" inside the system directory.
Also mount /system in CWM recovery.
 

baldypal

Senior Member
Dec 10, 2010
55
16
Midland
OK the "mount /system in CWM recovery" is did not do. I did not extract the files. I did use 7zip.

Sent from my Galaxy Nexus
 

baldypal

Senior Member
Dec 10, 2010
55
16
Midland
Had the chance to try this last night. Mount /system in CWM didn't allow it either. Same error.

Sent from my Galaxy Nexus using xda app-developers app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 174
    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).
    8
    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.
    6
    Thanks man, you're awesome!!!

    I still have several questions though: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...

    (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.
    5
    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");
    [B][I]delete_recursive("/system");[/I][/B]
    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.
    5
    Looks like Data/app contains apk's for the apps downloaded from the market. I want Apex to be a system app. Usually what I do after I update my rom (which wipes the /system/app folder) I open up root explorer, copy apexlauncher.apk to /system/app, set the proper permissions and reboot.

    I want to create a .zip that will do that for me (add apexlauncher.apk into /system/app).

    here i had written a small script that will do that for you...
    open the zip-folder, don't extract the zip-folder, only open and put your apexlauncher.apk to system/app!
    now you can flash the zip with cwm-recovery.. but note, the application-name must be the same for the called app and the written name in the update-script! you can also look at the update-script in META-INF folder to learn what is going on..

    apex-to-system.zip
    updater-script