• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[TUTORIAL] Create your own UPDATE.ZIP

Search This thread
M

mackief

Guest
Hi all! This is a guide from PIRATEPARTY about the creation of a simple UPDATE.ZIP to flash on your Android phone, in recovery mode.

I've created a repository on GITHUB where you can download the "update.zip" that we'll use and modify.

So, this is the repository: update.zip--for-Android-Devices-
You can download it as ZIP archive and rename it as update.zip .

So, we have now the most important file, that we're going to modify:
All the apps that you want to insert in the archive and install on the phone, must have the .apk estension and you have to put them in /data/app . Then, if you want also the app data files, you have to take these files from your phone, going with a rooted file manager (i suggest Root_Explorer) to /data/data , copying the app folder and pasting it in /data/data of the UPDATE.ZIP.
So we have all the apps and datas that we want. Now, we have to write the script.
Let's go to META-INF/com/google/android/ and open 'updater-script' with a simple text editor.
The only lines that you have to modify are:
Code:
set_perm(1000, 1000, 0644, "/data/app/[PACKAGE].apk");
set_perm_recursive(1000, 1000, 0777, 0777, "/data/data/PACKAGE_DATA_FOLDER");
delete("/data/dalvik-cache/[email protected]@[PACKAGE][email protected]");

For each app you have to write these lines. This is an example if you want to put ROOT_EXPLORER.APK in the UPDATE.ZIP:

Code:
set_perm(1000, 1000, 0644, "/data/app/ROOT_EXPLORER.APK");
set_perm_recursive(1000, 1000, 0777, 0777, "/data/data/ROOT_EXPLORER_DATA_FOLDER");
delete("/data/dalvik-cache/[email protected]@ROOT [email protected]");


That' all. But if you want to delete some apps from your phone, you have to write between
Code:
ui_print("| 80%  Installing Applications |");
and
Code:
package_extract_dir("data", "/data");
this line:
Code:
delete("/APK_DIR/APP.APK");

IT'S IMPORTANT TO LEAVE AN EMPTY LINE AT THE END OF THE SCRIPT, OTHERWISE THE ZIP WON'T WORK!

You can easily find the name of the app going with Root Explorer to /system/app and searching the same app.

If you also want to add your modified Apps, you've to sign them with a simple app: Auto-Sign, putting them in /auto-sign/update/app and renaming it to Launcher.apk .
You can download AUTO-SIGN from the attachements!

With it you can sign your apks or your zip. So, finally, when you'll finish your zip, you'll have to put it in Auto-Sign folder ("/auto-sign").
Then, open Auto-Sign, choose your zip or apk, and click AUTO-SIGN. It will create a new apk or zip, name as SIGNED-apk/zip.

Now, you only have to put the update.zip on your sd-card and flash it! Have fun guys!
 

Attachments

  • Auto-Sign.zip
    80.3 KB · Views: 54,824
Last edited:

The_Steph

Senior Member
Mar 20, 2007
885
361
Paris
mackief,

Thanks for your tutorial. I wrote a removal script for GB that deletes everything i don't use in my ROM. I recently moved to ICS and that very script is still working but, each time, during restart, I lose root rights.

Any idea where it could come from?
 
  • Like
Reactions: tim687
M

mackief

Guest
What rom are u using?? What device??
I think that the problem is about the rom, cause you said that u didnt have problem in previous rom and you used the same script...
So, to find the problem, i have to know the rom, the device, and the script.
Can you post the script here?
 

The_Steph

Senior Member
Mar 20, 2007
885
361
Paris
mackief,

Sorry for having been so long to answer, I was not monitoring the thread :eek:

I use nightly CM9 roms for my Note (N7000). You'll find attached my latest script that still bothers me.

If you can have a look at it, it would be nice.
 

Attachments

  • updater-script.zip
    1.9 KB · Views: 8,789
Last edited:
M

mackief

Guest
good lession for tweaking my one x
I'm glad do help you! ;)

mackief,

Sorry for having been so long to answer, I was not monitoring the thread :eek:

I use nightly CM9 roms for my Note (N7000). You'll find attached my latest script that still bothers me.

If you can have a look at it, it would be nice.
I read your script, but i think that the only problem is about the root app: Superuser and his components. So, check out if some elements that you want to delete are associated to Superuser, and dont delete superuser.apk .

However, usually, in CM9 there are some apps that you CANT and HAVE NOT to delete. I suggest to you to read this file: REMOVABLE APPS

So, Superuser gives you root rights, so dont delete it.
Dont delete the list of apps that is on the link above.
The last suggestion is that you have to check if you're deleting something else that can create bugs with superuser and his working.
Write me if you want to know something else or also if these solutions arent useful: i'll help you! Bye! :D
 

Волк

Senior Member
Jan 7, 2012
1,156
546
San Diego
Interesting guide. I am curious though, you have it setting permissions but have you tried it without doing so? I ask because I made a script for CWM which copies my apk's to data/app/ and I don't set permissions and have no issues. In theory you shouldn't need to, the apk should retain the proper permissions even when copied. As well, why not set the permissions for the entire contents of the folder, ie, set the permission recursively like you do for data/data and have it run at the end of the script once everything is copied?

Lastly, one thing to note with this method of installing apps is that your first boot will take awhile, the ROM has to create the Dalvik for all the apps you just flashed, I hadn't considered that when i first ran my script and thought something was wrong.
 
M

mackief

Guest
Interesting guide. I am curious though, you have it setting permissions but have you tried it without doing so? I ask because I made a script for CWM which copies my apk's to data/app/ and I don't set permissions and have no issues. In theory you shouldn't need to, the apk should retain the proper permissions even when copied. As well, why not set the permissions for the entire contents of the folder, ie, set the permission recursively like you do for data/data and have it run at the end of the script once everything is copied?

Lastly, one thing to note with this method of installing apps is that your first boot will take awhile, the ROM has to create the Dalvik for all the apps you just flashed, I hadn't considered that when i first ran my script and thought something was wrong.

At first, i have to say to u that permissions can be not specified: i think that all the files that u put in a folder have the same permission of the folder. I set permissions only for safety.

Then, about the first boot duration, there's nothing wrong.
The system only take a while to put into effects the changes, creating the Dalvik for example.. Don't worry: it's normal! ;)
 

Волк

Senior Member
Jan 7, 2012
1,156
546
San Diego
I know it's building dalvik, it simply hadn't occurred to me initially that that was the reason for it not booting. A file can have a different permission than the folder, but I think it's only that you can have the folder r/w and a file r/o. Then, on your script you can just set permissions recursively and save yourself setting permission for each app/file individually.

Sent from my LG-P999 using xda premium
 

hermeticist

Senior Member
Jul 21, 2008
1,649
356
Before CWM 5, I used to have a script that would let me add lots of files without individual lines for each.
It worked similar to gapps, where files are separated by commas.
Any ideas?
I will be adding sound files to system/media/audio/alarm.
 
M

mackief

Guest
Before CWM 5, I used to have a script that would let me add lots of files without individual lines for each.
It worked similar to gapps, where files are separated by commas.
Any ideas?
I will be adding sound files to system/media/audio/alarm.

U can easily write the package_extract command:
Code:
package_extract_dir("???", "/???");
You write the folder, and then the android folder when you want to extract the script package.
Then you set the permission of the folder and all is done! ;)

What are symlinks?

Sent from my MB525 using Tapatalk 2
Symlinks are Simbolic Links, so they link a folder to another folder, for example, a linked folder...
In Windows, you can create a link on the desktop and you can change the name of the linked icon, but it is anyway connect to the same file, with different name.
So, the symlinks are files that connect with other files. When the os see this symlinks, it read the element info to which it is connected??
It's not difficult to understand. I suggest to you to read this: SymLinks

Hope i've helped u all! If it doesnt, ask me again! :D
 

hermeticist

Senior Member
Jul 21, 2008
1,649
356
U can easily write the package_extract command:
Code:
package_extract_dir("???", "/???");
You write the folder, and then the android folder when you want to extract the script package.
Then you set the permission of the folder and all is done!

Thanks.
I'm a little unclear about setting permissions though. Would you mind explaining?
 
M

mackief

Guest
Thanks.
I'm a little unclear about setting permissions though. Would you mind explaining?
So, if u want to set folder permissions, this is the code:
Code:
set_perm_recursive(1000, 1000, 0777, 0777, "/data/data/PACKAGE_DATA_FOLDER");
And these permissions are for a 'read-only' folder.

If u want to set file permissions, this is the code:
Code:
set_perm(1000, 1000, 0644, "/data/app/[PACKAGE].apk");
Also these permissions are for a 'read-only' file.

So do u need something else??
Hope u understood! ;)
 
Last edited:

Волк

Senior Member
Jan 7, 2012
1,156
546
San Diego
OK, here's one I can't seem to figure out, I want to copy data/app to my SD card. I tried(with /data mounted):

run_program("/sbin/busybox", "mkdir", "/sdcard/app/");
run_program("/sbin/busybox", "cp", "r", "/data/app/", "/sdcard/app/");

it fails with status 6, and log shows syntax error. I'm at a loss.
 

ramzidjoudi

Senior Member
Jun 12, 2011
286
85
nice tuto thank you very much for it
please i am noobe here
i have a unpadte to make but i don't know how here the structure of it





how to do the script please
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    mackief,

    Thanks for your tutorial. I wrote a removal script for GB that deletes everything i don't use in my ROM. I recently moved to ICS and that very script is still working but, each time, during restart, I lose root rights.

    Any idea where it could come from?
    1
    thanks for reply,

    my tablet is nonbrand so easy ways are not working, I've tried everything, I can't flash anything because I don't have access to adb shell in recovery mode.

    I also tried flashable zip files of both cwm and twrp, but after transferring them with "adb sideload" command, it verifies the package and it says installation aborted.

    besides that whatever I push in it with adb push command, after restart it deletes pushed files.
    now system directory is empty and I can't push anything inside it because they'll be removed after restart.

    so the only way for me is fooling the system with this method and copy all system files through update.zip

    how can I do that?

    thanks for help.

    So your system partition automatically is wiped when you turn the device on?

    Sent from my C6603 using XDA Premium 4 mobile app
    1
    Wow, so there's no way to restore stock firmware?
    So strange.

    You could try to pull boot.img and system partitions from your working tablet, and then repushing them to the not-working one. Obviously to do it, you need to have adb and the other android tools working on your computer...!

    well I can send zip files to it with adb sideload command.

    but where is boot.img? there is no img file in any directory at all.

    I just need a simple script to put in update.zip so it will run and do the job for me automatically.

    here is the idea:
    I need two scripts, in first one I need a script that copies the whole system and all partitions of the working one and put them in a zip file in mnt/sdcard directory.
    then I will copy all those files to a new update.zip,
    then I need a script to copy all those files to the not-working one partitions forcefully so it can't wipe them again.
    done.


    I think there is a mount command that I can use in it to mount the partitions for r/w.
    now can you please tell me what should I write in the script file?
    1
    Yep some zip tools are not working correctly, but I really don't know which ones, as I'm on Linux since 2-and-half years.
    Then, retry with another zip manager, and also I suggest to delete every assert line to not end in an error! Let me know! ;)

    Hello,
    finally i found the tool that signs correctly all the zips i create
    and also the tool that helps to create the zip and the updater script, putting in it all the stuff i want (kernel.img, boot.img, and so on) to make a complete zip to be flashed via recovery menu from SD card, without the need of connection with pc, rkbatchtool, rkandroidtool and so on
    It is an XDA thread:

    http://forum.xda-developers.com/showthread.php?t=717437

    My device find the zips created with these tools valid, so i can do any update i want
    I already tried a simple updater scripts that only prints some informations on the screen with ui_print

    Now i have only to learn the sintax of the updater script language, and to build the zip with all parts i need to recover my system...

    Thanks
    1
    HemanthJabalpuri, rezipped and have new log
    Code:
    E:Error executing updater binary in zip '/data/media/0/update.zip-6.0.6.zip'
    try this...