FAQ on creating a patch update.zip for firmware through the recovery
FAQ on creating a patch update.zip for firmware through the recovery
Edit Updater-script. Information, solutions, commands, signature patches.
Instructions for installing system and user applications with recovery
Editing installed firmware and removing system applications
(keywords)
CAPABILITIES
#
capabilities
- Adding multiple user / system applications "in a single click" (one patch)
- Adding / removing system applications without root rights and auxiliary programs
- Changing the firmware (replacing files, decorating, etc.)
- Updating the program or firmware
- Remapping the memory ( discussions in another topic )
- Getting root rights ( SuperUser )
INSTRUMENTS AND FILES
#
instruments
- Installed on the phone custom recovery ( CWM / TWRP )
- NotePad ++ (editor with saving Unix format)
- Zip_signer (archive subscriber)
- ZIP archiver
- file-sample.zip file (or update-binary for manual assembly)
Attached fileZip_signer.rar (13 , 28 KB)
Attached filesample.zip ( 6,67 MB)
Attached fileupdate-binary.rar (113,25 KB)
(additional versions of the binary) Attached filebinary_all.rar (649,36 KB)
Binary (archive / source)
#
binaries (sources)
The sources of the binary, the main link:
https: //android.google...ootable/recovery/+refs
choose for example "android-5.1.1_r18" (the last build for today), then look for the folder "updater", in the folder "updater" sources binaries
, for example https: //android.google...droid-5.1.1_r1/updater - you can look all the teams that can execute in android 5.1.1 Binary (in install.c file, at the bottom)
© Octanium
Subscriber for Linux: Attached filesignapk.zip ( 9,24 KB)
+ Android update-script (Post Nyashnaya # 63580419)
Attention! Patches are created only for mod.rekovery and effectively work only in them. In the stock recovery (on devices "out of the box") patches do not work.
#
Programs for creating update.zip
Programs for automatic patch creation
Program for creating update.zip - Android Script Creator
Developer: Octanium
Interface: Graphical (rus, eng)
OS: Windows \ Linux \ MAC OS \ Solaris
Recover: CWM, TWRP
Program for creating update.zip - Update Zip Creator
Developer: Shipiloff69
Interface: Command line (eng)
OS: Windows
Recover: CWM, TWRP
Autogeneration updater-script
Sh-script for self-generation updater-script with all symbolic links and rights to system files.
. . . CREATION. . .
#
creature
In order to install new apk system applications into your device, you need to perform three steps:
1) build your update.zip (from the sample.zip sample)
2) sign the update.zip utility Zip_signer
3) put it on the flash drive and install to the device via ClockWorkMod Recovery
These steps are universal, i.e. suitable for other similar operations.
STEP # 1
Assemble a new update.zip using the "sample" sample.zip
The procedure for using the sample.zip:
1) Unarchive the sample.zip archive
2) Delete the signature files META-INF / CERT.RS, CERT.SF, MANIFEST.MF ( since 2m steps we will create them for our assembly)
3) Put your user application (xxxxx.apk) in the / data / app folder.
4) If necessary, edit the updater-script file (more later)
5) Archive all (META-INF and data) ZIP without compression
STEP # 2
Sign update.zip using Zip_signer utility. Zip_signer utility usage
procedure:
1. Rename your edited (ie already with the application inside) sample.zip in update.zip
2. Place it in the folder with the program Zip_signer
3. Run the file zip_signer.bat
4. Wait until the process is completed
5. In the folder will appear the file update-finished .zip - this is the signed file
6. Rename update-finished.zip at your discretion (according to the logic of the patch)
STEP # 3
Setting up annexes
1. Pause (renamed) update-finished.zip to the flash drive and install it to the device via TWRP or CWM (install zip from sdcard -> chooze zip from internal sdcard -> Yes, install sample.zip)
2. Reboot the device
#
Creating in Linux
The actions are the same as described above, except for the signature.
Sign ZIP-archive:
- Download signapk.zip and unzip it to the folder <folder-signapk>
- Assign the rights for all content - "rwxrwxrwx" (chmod -R 777 ~ / <folder-signapk>)
- We execute the signature program (signapk <name archive with extension>)
A little manual on how to create an update script based on system.img and boot.img
Attention! Patches are created only for mod.rekovery and effectively work only in them. In the stock recovery (on devices "out of the box") patches do not work.
STRUCTURE OF THE PATCH. . . EDITING UPDATE-SCRIPT
#
structure
The root of the patch:
- the folder META-INF
- the folder where the applications are installed (system, data, sdcard, cache, sd-ext)
Required files:
- META-INF / com / google / android / update-binary - also creates a temporary working folder tmp
- META-INF / com / google / android / updater-script - the executable script for which copy operations occur, etc.
#
editing
Let's take a look at sample.zip
The patch adds a custom MyPiano application to Data.
Code :
ui_print ("=== Patching new application ===");
ui_print (""); - displays an inscription and an empty line
run_program ("/ sbin / busybox", "mount", "/ data"); - (mounts data) opens access to work with the system partition
package_extract_dir ("data", "/ data"); - copies the contents of the data folder to the appropriate folder on the device
set_perm_recursive (1000, 1000, 0771, 0644, "/ data / app"); - sets the owner, group and permissions for the contents of the folder on the device (info by the code below)
run_program ("/ sbin / busybox", "
ui_print ("=== Complete ==="); - displays a message about the completion of the process
busybox - the application for executing the command line, installed with custom recovery, is in ramdisk / sbin. in custom firmware often add it to the system / xbin
Possible fixes for their purposes
1) Change permissions
set_perm_recursive (1000, 1000, 0771, 0644, "/ data / app /");
can be replaced with:
set_perm (1000, 1000, 0644, "/data/app/mypiano.apk"); - in this case, the rights will change only for the added application
2) Adding the system application
a. the root folder of data is changed to system
b. in the code updater-script the same thing
at. rights are assigned via set_perm only for the application being added, for system code 0675 (info on codes below)
3) Removing the application / file
A line of the following kind is added to the code:
delete ("/ system / app / OldApk.apk");
4) Provided that busybox is elsewhere, a possible replacement of
run_program ("/ sbin / busybox", "mount", "/ data"); - to - run_program ("/ system / xbin / busybox", "mount", "/ data");
or
mount ("ext4", "EMMC", "/ dev / block / mmcblk0p 5 ", "/ data");
#
example-explanation
At first it is developed as a habit, and later when viewing complex code it makes it very easy to "read" the code, find the necessary information, and visualize the sections / steps of the code.
In the example, a simple script, in which the main working functions are indented. Those. all the rest simply for beauty and convenience (they can even be deleted).
It is also possible to use double and triple TABs, a good example is the writing of html site code.
show_progress (1.000000, 2);
ui_print ("");
ui_print ("========================================");
ui_print ("---------- Silent AUDIO Patch ----------");
ui_print ("========================================");
ui_print ("> Mounting system ...");
run_program ("/ sbin / busybox", "mount", "/ system");
ui_print ("> Copying files ...");
package_extract_dir ("system", "/ system");
ui_print ("> Fixing permissions ...");
set_perm_recursive (0, 0, 0755, 0644, "/ system / media /");
ui_print ("> Unmounting system ...");
run_program ("/ sbin / busybox", "umount", "/ system");
ui_print ("------- Changing AUDIO Complete --------");
ui_print ("");
DESCRIPTION OF UPDATER-SCRIPT COMMANDS. . . EXAMPLES OF USE OF COMMANDS
#
teams
• package_extract_dir
Syntax : package_extract_dir ("<src-dir>", "<dst-dir>");
Copies the contents of <src-dir> to <dst-dir>. Files in <dst-dir> that are available in <src-dir> are overwritten.
Example : package_extract_dir ("system", "/ system"); Copy files from the update.zip/system folder to / system
• package_extract_file
Syntax : package_extract_file ("<src-file>", "<dst-file>");
Copies the file <src-file> to <dst-file>. If the file <dst-file> exists, it is overwritten.
Example : package_extract_file ("test.sh", "
Syntax : format ("MTD", "<root>");
Formats the <root> section (see the appendix).
Example : format ("MTD", "system"); Completely format / system. Note: formatting removes irreversible data.
Example 2 : format ("ext4", "EMMC", "/ dev / block / mtdblock5", "0", "/ system");
Identification of the block number under the spoiler "info and materials".
• delete
Syntax : delete ("<file1>" [, "file2", ... "fileN"]);
Removes the file (s)
Example : delete ("/ system / app / Calculator.apk"); Removes the Calculator.apk from the system / app folder.
• delete_recursive
Syntax :delete_recursive ("<dir1>" [, "dir2", ... "dirN"]);
Recursively removes the folder (s) with all the contents.
Example : delete_recursive ("/ data / dalvik-cache"); Removes the / data / dalvik-cache folder with all the contents.
• run_program
Syntax : run_program ("<filetorun>" [, "opt1>", "<opt2>", "<opt3>"]);
Starts the program (script) <filetorun>.
Example : run_program ("/ tmp / install_busybox.sh"); Run the /tmp/install_busybox.sh script.
• set_perm
Syntax : set_perm (<uid>, <gid>, <mode>, <
Sets the owner, group, and permissions on a file or folder as 'chmod', 'chown', and 'chgrp' all in one.
Example : set_perm (0, 2000, 0550, "/system/etc/init.goldfish.sh") ; Set the owner, group, and permissions for the file /system/etc/init.goldfish.sh
• set_perm_recursive
Syntax : set_perm_recursive (<uid>, <gid>, <dir-mode>, <file-mode>, <path> , ... "<pathN>"])
Recursively sets the owner, group, and permissions for the contents of the folder. <dir-mode> - for folders, <file-mode> - for files.
Example : set_perm_recursive (0, 0, 0755, 0644, "/ system / app"); Set the permissions for the content / system / app,
show_progress
Syntax : show_progress (<fraction>, <duration>);
Progress progress bar for a fraction of <fraction> for <duration> seconds. <duration> can be zero to advance it by the set_progress command, not by time.
Example : show_progress (0.100000, 1); Increase progress by 0.1 part in 1 second
• set_progress
Syntax : set_progress (<fraction>);
Sets the position of the progress bar to the fraction <fraction>, for the most recent call to the show_progress command.
Example : set_progress (0.500000);
• symlink
Syntax :symlink ("<link-target>", "<link-path1" [, "<link-path2>", "<link-path3>"));
Creates a symbolic link (like 'ln-s'). <link-path> is written in the format root: path, and <link-target> in the format of the target file system (and can be relative). Wikipedia Symlink .
Example : symlink ("/ data / app_s", "/ system / app"); Creates a symbolic link to the / data / app_s folder for the / system / app
• mount directory.
Syntax : mount ("<kind>", "<what>", "<path>");
Mounts <what> into the path <path>. <what> should be the name of the section, if <kind> is "MTD",
or block of memory if <kind> is "vfat" Example : mount ("MTD", "userdata", "/ data");
• unmount
Syntax : unmount ("<path>");
Disables <path>.
Example : unmount ("/ data");
• ui_print
Syntax : ui_print ("<message>");
Displays the message <message>
Example : ui_print ("Formatting SYSTEM ...");
• sleep
Syntax : sleep (<time>);
Pause the process for <time> seconds
Example : sleep (5); - a pause of 5 seconds, after which the script code is executed further.
#
android 4.4+ commands
• set_metadata / set_metadata_recursive
Syntax : set_metadata (?????);
Sets the owner, group and permissions (new command instead of set_perm for andriod 4.4. *)
Example : Android update-script (Post # 32151495)
• set_metadata / set_metadata_recursive
Syntax :
set_metadata ("file name", "key1", "value1", " key2 "," value2 ', ...)
set_metadata_recursive ( "directory name", "key1", "value1", "key2", "value2', ...)
Keys:
* capabilities the
first three (uid, gid, mode) is the same as in chmod, the "uid", 0, "gid", 1000, "mode", 06754 is populated. There are
three "uid" keys for installing the firmware, 0, "gid", 1000, "mode", 06754.
Example : set_metadata ("/ system / xbin / shelld", "uid", 0, "gid", 1000, "mode", 06754, "capabilities", 0x0, " selabel "," u: object_r: system_file: s0 ");
set_metadata_recursive ("/ system / xbin", "uid", 0, "gid", 2000, "dmode", 0755, "fmode", 0755, "capabilities", "0x0", "selabel", "u: object_r: system_file: s0 ");
• commands for Nexus'
block_image_update ("/ dev / block / platform / msm_sdcc.1 / by-name / system", package_extract_file ("system.transfer.list"), "system.new.dat", "system.patch.dat");
Syntax: block_image_update ("Path to the section block", package_extract_file ("list of information for the patch (?)"), "image", "image patch");
I understand that so strongly compressed firmware (the system image) is stitched.
Another ifelse
Example: ifelse (is_mounted ("/ system"), unmount ("/ system")); - If the partition is mounted, the command is given to unmount it, if unmounting, then nothing happens.
• Information on the attributes set_metadata and similar commands on Android 4.4+
Android update-script (Post blackeangel # 50803606)
Description of where to get "u: object_r: uncrypt_exec: s0" and similar attributes
ps: commands for the recovery of the TWRP family
. . .
#
examples
• Sample script that can delete \ move \ backup files and conduct a log of actions
Android Script Creator (Post Octanium # 51085030)
• Temporary Busybox
#
temporary busybox
Used in the absence of busybox, or to not be attached to its location in the system.
package_extract_file ("busybox", "/ tmp / busybox");
set_perm (0, 0, 0777, "/ tmp / busybox");
run_program ("/ tmp / busybox", "mount", "/ data");
...
run_program ("/ tmp / busybox", "unmount", "/ data");
©
• Reboot Commands
#
reboot
The code for the "reboot" and "reboot in the recovery", respectively:
run_program ("/ sbin / reboot");
run_program ("/ sbin / reboot", "recovery");
• run_program
#
run_program
Installing BusyBox ©
Put the busybox file in / system / xbin
In the updater-script:
set_perm_recursive (0, 2000, 0755, 0755, "/ system / xbin");
set_perm (0, 1000, 0755, "/ system / xbin / busybox");
run_program ("/ system / xbin / busybox", "--install", "-s", "/ system / xbin");
-------------------------------------------------- ----------
...
• show_progress / set_progress
#
set_progress
Example # 1 - Android Script Creator (Post Octanium # 44840383)
------------------------------------- -----------------------
Example # 2
When the script is executed very quickly (1-4 seconds), I used the following code:
show_progress (1.000000, 3);
Those. for 3 seconds the progress bar reaches 100% (gradually).
The number "3" is selected as [script installation time] +1 sec, so that the progress bar during installation is guaranteed to move and did not reach 100% before the script is installed.
-------------------------------------------------- ----------
...
• sleep
#
sleep
Example # 1 - Android Script Creator (Post Octanium # 44840383)
------------------------------------- -----------------------
...
In development ...
• package_extract_dir
#
package_extract_dir
In developing...
• package_extract_file
#
package_extract_file
In developing...
• format
#
format
In developing...
• delete
#
delete
In developing...
• delete_recursive
#
delete_recursive
In developing...
• set_perm
#
set_perm
In developing...
• set_perm_recursive
#
set_perm_recursive
In developing...
• symlink
#
symlink
In developing...
• mount
#
mount
• unmount
#
unmount
In developing...
• ui_print
#
ui_print
In developing...
ERRORS
#
Possible errors and their solution
If you know what Recovery is, CWM, you know what custom firmware is and what they are eating, then for sure you are faced with the fact that the firmware or update is not installed while displaying the "Status #" error.
Signature verification failed. Installation aborted - Patches are created only for mod.rekovery and effectively work only in them. In the stock recovery (on devices "out of the box") patches do not work. You should replace the stock recovery with CWM or TWRP.
Status 0 - this error code occurred due to the fact that the updater-script or update-binary file is missing from the firmware or update
Status 255 - this error code was caused by the fact that the update-binary file does not match
In both cases, it treats the same, you need to take update-binary from any firmware for your device.
Status 1 - this error code was caused by the wrong way to mount the
Status 4 partitions - this error code was caused by the fact that the archive firmware or archive - Update is designed for an earlier version of CWM (there was used updater-script without the update-binary binaries).
Status 6 - a) Indicates that updater-scpript is not created in Unix format, so when you install Android does not recognize what is written there and gives an Error Status 6. In order to fix it, I advise you to download and install NotePad ++ and change the format;
b) Syntax error (missing any character, for example ";", missing the letter in the command)
Status 7- a) The firmware is not suitable for your device and the updater-script has another name for the model. Open updater-script and delete the lines containing the name of someone else's model and re-subscribe the firmware.
b) Through the recovery, first mount the system (mounts & storage - mount / system), then put the patch
in). The solution to the problem with the STATUS 7 error is: Sony Ericsson XPERIA neo - CyanogenMod 7 - FreeXperia PROJECT (OS 2.3) (
line # 11599821) line * ** col **: syntax error - Syntax error in the line of code # *** and symbol # ** (look for where you missed or put an extra character, usually commas and quotes)
Symlink: some symlinks failed - There is not enough space in the system partition. The patch installs the files in the wrong partition / block.
No space left on device - There is not enough space in the system partition. The patch installs the files in the wrong partition / block.
format () expects 4 args got 5 or format () expects 5 args got 4 - [function format () expected X argument, but got Y] - in the format content, we remove or add the name of the section, for example ("ext4", "EMMC "," / dev / block / mmcblk0p6 ", " 0 " , " / system " ) . "argument" is the data that is written inside the brackets, separated by commas.
No space left on device - there is not enough space in the partition to be stitched The
bug does not produce a bug, the patch in the MOD is working, but the necessary application is not added - see the section of the header UPDATER-SCRIPT EDITING -> p.4,
Please upgrade to latest binary or ..... binary - The update-binary file does not work, you need to take update-binary from any firmware for your device.
Subscriber Zip_signer does not work - check the java on the computer, update or reinstall.
"java" is not an internal or external command, an executable program, or a batch file. - error in Zip_signer - install Java, Android update-script (Post Vulcanus # 54856173)
ps: If there are often errors during your experiments - try the first thing to create the simplest patch (taking as a basis sample.zip), and then go to more complex.
This is done first of all in order to avoid mechanical errors during the creation of the patch, as well as to check compatibility with update-binary, compatibility with mod.rekovery and compliance with the signature.
INFO. . . RELATED TOPICS. . . SOURCES. . . OFFERS
#
info and materials
Codes of access rights
Calculator of codes for "permissions"
Wikipedia - Chmod
Calculator of rights for files
Source codes owner / group
How to remove all metadata (symlink, selabel) from the firmware (root / busybox)
Development update-binary:
Bash script as update-binary for ZIP-update
Information:
- Definition of block number
#
How to find the block number
It is possible when writing the format commands ("ext4", "EMMC", "/ dev / block / mmcblk0p5", "0", "/ system"); and the like, the question arises as to which block number exactly belongs to your device.
Methods for determining the block:
1) To determine the block numbers in the device, you can use the MTK Droid Tools program . Start the program, connect the device, click the "Block map" button in the program.
2) In the presence of rut or mod.rekare. Find / proc / dumchar_info - open it as a text file. Either the file / proc / partitions.
- Definition of the block number from shao2004 (2 more ways) - Android update-script (Post shao2004 # 56403374)
- Definition of the block number from Serega (shell) - Scripts on the shell for Android (Post Cake # 46931331)
For those who write updates with the very zero itself for specific firmware
Related topics
FAQ on ClockworkMod recovery
FAQ for TWRP recovery
Shell scripts for Android
Syntax highlighting Edify (language used in updater-script) in Notepad ++
#
Miscellaneous
OpenRecoveryScript is a scripting engine that allows applications to send recovery commands.
Debugging and checking the script on the
Update Script Generator from blackeangel
#
sources and thanks
Information on Android updater-script from skOt (old topic): Android updater-script (Post # 5936887)
Android updater-script (Post # 5936887)
Android updater-script (Post # 25586798)
Modification of software and decorations for Huawei U8186 Ascend Y101
Bash -script as an update-binary for the ZIP update
Samsung GT-S5830 Galaxy Ace - Creating a Custom Recovery
Club owners UMI X2
Club owners Samsung Galaxy Ace 2
LG Optimus One - Firmware CyanogenMod 7 (OS 2.3.7) - Archive
Samsung GT-I9000 Galaxy S - Catalog and review of firmware / mods
#
offers
If you notice any mistakes in the description or there are materials for supplementing the article - please report in the topic, or through QMS.
Also I would very much like to supplement this instruction with other examples and patch capabilities. In particular, visual examples of executing the commands ** _ progress and symlink.
I will try to do this as far as patches are being created. And if you have any worthwhile materials, also post it)
In addition to the sample.zip patch, I would like to add a number of other "standard" patches
If an error occurs, accurately formulate it (or put a log) and attach the script code under the spoiler.
But beforehand, try to figure it out yourself by doing the suggested actions from the "Errors" section of the header.
To add information to the header - in the desired post click "Complaint" (message to the moderator) and specify what and where to add.