1# Packaging Tool<a name="EN-US_TOPIC_0000001101934690"></a> 2 3- [Introduction](#section184mcpsimp) 4- [Directory Structure](#section191mcpsimp) 5- [Description](#section211mcpsimp) 6- [Repositories Involved](#section247mcpsimp) 7 8## Introduction<a name="section184mcpsimp"></a> 9 10The packaging tool is used to prepare an update package. It provides the following functions: 11 12- Creating a full update package: The update package contains only the data necessary for full image update. 13 14- Creating a differential update package: The update package contains only the data necessary for differential image update. 15 16- Creating an update package with changeable partitions: The update package contains the partition table and full image data, which are used for partition change processing and image restoration after partition change. 17 18## Directory Structure<a name="section191mcpsimp"></a> 19 20``` 21/base/update/packaging_tools 22├── lib # Dependency libraries of the packaging tool. 23├── blocks_manager.py # BlocksManager class for block management 24├── build_update.py # Access to the packaging tool for differential update packages 25├── gigraph_process.py # Stash for re-sorting the ActionList 26├── image_class.py # Full image and sparse image parsing 27├── log_exception.py # Global log system with custom exceptions 28├── patch_package_process.py # Differential image processing for obtaining patch difference through differential calculation on blocks 29├── script_generator.py # Update script generator 30├── transfers_manager.py # ActionInfo object creation 31├── update_package.py # Update package format management and update package writing 32├── utils.py # Options management and related functions 33└── vendor_script.py # Extended update scripts 34``` 35 36## Description<a name="section211mcpsimp"></a> 37 38Running environment: 39 40- Ubuntu 18.04 or later 41 42- Python 3.5 or later 43 44- Python library xmltodict, which is used to parse XML files and needs to be installed independently. 45 46- bsdiff executable program, which performs differential calculation to generate the patch package 47 48- imgdiff executable program, which performs differential calculation on the zip, gz, and lz4 files to generate the patch package 49 50- e2fsdroid executable program, which performs differential calculation to generate the map files of an image 51 52Parameter configuration: 53 54``` 55Positional arguments: 56target_package Target package file path. 57update_package Update package file path. 58Optional arguments: 59-h, --help Show this help message and exit. 60-s SOURCE_PACKAGE, --source_package SOURCE_PACKAGE Source package file path. 61-nz, --no_zip No zip mode, which means to output update package without zip. 62-pf PARTITION_FILE, --partition_file PARTITION_FILE Variable partition mode, which means to partition list file path. 63-sa {ECC,RSA}, --signing_algorithm {ECC,RSA} Signing algorithms supported by the tool, including ECC and RSA. 64-ha {sha256,sha384}, --hash_algorithm {sha256,sha384} Hash algorithms supported by the tool, including sha256 and sha384. 65-pk PRIVATE_KEY, --private_key PRIVATE_KEY Private key file path. 66``` 67 68Example code for creating a full update package: 69 70``` 71python build_update.py ./target/ ./target/package -pk ./target/updater_config/rsa_private_key2048.pem 72``` 73 74Example code for creating a differential update package: 75 76``` 77python build_update.py -s source.zip ./target/ ./target/package -pk./target/updater_config/rsa_private_key2048.pem 78``` 79 80## Repositories Involved<a name="section247mcpsimp"></a> 81 82Update subsystem 83 84**update\_packaging\_tools** 85 86