Package the system. new. dat file in the update package of Android5.0, system. new. dat

Source: Internet
Author: User

Package the system. new. dat file in the update package of Android5.0, system. new. dat

Since Android 5.0, the ota package adopts a new system. img compression method. For this method, if it is a complete upgrade, the ota zip package is basically an ext4 image, but it is not a complete ext4 image, instead, it is a package that deducts a lot of zero information. You can also use this method to describe the difference package of a basic image in Sparse Mode.

This section describes how to generate the final ota zip package from the system source directory. For more information about how to obtain files from the ota package, see the unpackage of the system. new. dat file in the update package of Android5.0. Http://blog.csdn.net/howellzhu/article/details/41967523

If you want to generate a full ota package, boot, system, and other images are usually placed. the following images are generally related to devices, such as radio and slb. The generation of Boot is also related to devices, such as dt (device tree) or something. This article mainly introduces how to package system: how to generate system. new. dat and other files.

 

1. Step 1: Use the system directory and file_contexts to generate system. img

In fact, it is very simple to create system. img. Refer to another blog post: The packaging process of system. img in android.

Http://blog.csdn.net/howellzhu/article/details/42804191

 

2. Use system. img to obtain the system. new. dat, system. patch. dat, and system. transfer. list Files.

This is the focus of this article.

The main purpose of this process is to reduce the size of ota.zip and convert system. img to a sparse array description.

Let's first look at how the android source code tool works.

In the blockimgdiff. py file, the blockimgdiff. py: BlockImageDiff: WriteTransfers () function writes all xf in self. transfers to the transfer. list file.

See the following call Stack:

[call stack]build/tootls/releasetools/blockimgdiff.py:BlockImageDiff::ComputePatches&BlockImageDiff::WriteTransfersbuild/tootls/releasetools/blockimgdiff.py:BlockImageDiff::Computebuild/tootls/releasetools/common.py:BlockDifference::__init__build/tootls/releasetools/ota_from_target_files:WriteFullOTAPackagebuild/tootls/releasetools/ota_from_target_files:main()/build/core/Makefile:$(INTERNAL_OTA_PACKAGE_TARGET):$(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)

In fact, BlockImageDiff is a sparse_img.SparseImage object and a None object.

Use the following img2sdat. py script to generate the system. new. dat, system. transfer. list, and empty system. patch. dat files in the current directory:

</pre><pre name="code" class="python">#!/usr/bin/env pythonimport sysimport blockimgdiffimport sparse_imgfrom rangelib import *def main(argv):  tgt = sparse_img.SparseImage("system.img");  bif = blockimgdiff.BlockImageDiff(tgt, None)  bif.Compute("system")if __name__ == '__main__':  main(sys.argv[1:])


To simplify the work, I packed some of the above python scripts to form a python package file: img2sdat.zip, which is provided in the mkotazip toolkit mentioned at the end of the article. Using this package to process system. img is very simple, that is, the following command:

$ python img2sdat.zip

The system. new. dat, system. patch. dat, and system. transfer. list Files are generated in the current directory.

 

3. Prepare the upgrade script file and the upgrade execution file.

The upgrade execution file is provided by Android and named update-binary and needs to be placed in the following directory in the compressed package: META-INF/com/google/android

For convenience, I have packed the file in the compressed file mentioned last.

Another file is the updater-script file you want to write and modify. It also needs to be placed in the compressed package and the update-binary directory. Here is a reference for hammerhead:

show_progress(0.05, 0);getprop("ro.product.device") =="hammerhead" || abort("This package is for\"hammerhead\" devices; this is a \"" +getprop("ro.product.device") + "\".");show_progress(0.75, 10);block_image_update("/dev/block/platform/msm_sdcc.1/by-name/system",package_extract_file("system.transfer.list"),"system.new.dat", "system.patch.dat");show_progress(0.20, 2);package_extract_file("boot.img","/dev/block/platform/msm_sdcc.1/by-name/boot");

4. Pack the prepared file to generate a zip file.

This step is very simple and can be implemented using tools such as zip, minizip, and 7zip. For convenience, an install. sh script is provided in the mkotazip tool to put the previously generated files in the appropriate directory and package them. The script accepts a parameter, that is, the destination directory of the ota package. If this parameter is not specified, create an otazip directory in the current directory and use it as the target directory.

 

5. Sign the zip file [Optional]

This part of content will not be mentioned. There are many similar articles on the Internet.

 

Summarize the above steps.

1. Download the tool package mkotazip.zip (see the end of the article) in the blog to decompress the package;

2. Use the mkext4_fs tool to generate system. img;

3. Use the command python img2sdat.zip to obtain files such as system. new. dat;

4. Modify the updater-script file;

5. Run the install.shscript to generate the ota.zip file.

OK

 

Appendix: mkotazip.zip file:

Files contained in the mkotazip tool:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.