Skip to main content

📦 SDAT2IMG Brotli

Original Project

PyPI

MIT

This Python script extracts and converts Android OTA update files—specifically .dat.br (Brotli compressed) and .transfer.list—into a usable .img disk image. This is especially useful for unpacking system, vendor, or product partitions from A/B OTA packages.


Changelog / Release Notes

v1.0.3 (2025-05-31)

  • Bug Fixes:
    • Add requirements.txt.

v1.0.2 (2025-05-31)

  • Bug Fixes:
    • Fixed an issue where the sdat2img-brotli command-line tool failed to correctly parse file paths (e.g., -d, -t arguments) provided by the user. This occurred because the argument parsing logic was not executed when the tool was invoked via its console entry point. The argparse logic has been moved directly into the main conversion function (convert_rom_files_function) to ensure robust argument handling across all execution methods.

v1.0.1 (2025-05-31)

  • Improved: Simplified library import. Users can now directly from sdat2img_brotli import convert_rom_files_function.

✨ Features

  • ✔️ Supports .dat.br files (Brotli compressed).
  • ✔️ Converts .dat + .transfer.list into a flashable .img.
  • ✔️ Automatic decompression of .dat.br and cleanup of temporary .dat files.
  • ✔️ Flexible input/output paths via command-line arguments (CLI).
  • ✔️ Defaults to current directory files if no arguments are provided for ease of use.
  • ✔️ User-friendly logs and error messages.

🚀 Installation

You can easily install sdat2img-brotli using pip:

pip install sdat2img-brotli

🔧 Requirements

  • Python 3.6 or higher.
  • The brotli Python module (automatically installed via pip).

📖 Usage

This script offers two convenient ways to run it:

1. Simple Run (Using Default Files)

If your system.new.dat.br and system.transfer.list files are in the same directory where you run the command, simply execute:

sdat2img-brotli

The tool will automatically:

  1. Decompress system.new.dat.br into system.new.dat.
  2. Convert system.new.dat and system.transfer.list into system.img.

2. Advanced Run (Using Command-Line Arguments)

For more flexibility, you can specify the paths for input files and the output filename using command-line arguments. This is ideal for processing files not in the current directory or for renaming the output.

sdat2img-brotli -d <path_to_dat_br_file> -t <path_to_transfer_list_file> -o <output_img_name>

Arguments:

  • -d or --datbr: Specifies the path to the .dat.br input file.
    • Example: -d "C:\roms\my_system.new.dat.br"
    • Default: system.new.dat.br
  • -t or --transferlist: Specifies the path to the .transfer.list input file.
    • Example: -t "C:\roms\my_system.transfer.list"
    • Default: system.transfer.list
  • -o or --outputimg: Specifies the name and path for the output .img file.
    • Example: -o "extracted_system.img"
    • Default: system.img

Practical Examples:

  • Convert a vendor partition located in a specific folder:
    sdat2img-brotli -d "D:\OTA\vendor.new.dat.br" -t "D:\OTA\vendor.transfer.list" -o "vendor.img"
    
  • Generate an img with a custom name in the current directory:
    sdat2img-brotli -o "my_custom_system.img"
    
  • Get help and see all available options:
    sdat2img-brotli --help
    

3. Usage as a Python Library

You can also import and use the core conversion function in your own Python projects:

from sdat2img_brotli.main import convert_rom_files_function

# Example 1: Use default files (system.new.dat.br, system.transfer.list, system.img)
print("--- Starting conversion with default files ---")
success_default = convert_rom_files_function()
if success_default:
    print("Default conversion successful! 🎉")
else:
    print("Default conversion failed! ❌")

print("\n" + "="*50 + "\n")

# Example 2: Specify custom file paths
print("--- Starting conversion with custom files ---")
my_datbr_path = "path/to/your/custom_rom.new.dat.br" # Replace with your actual path
my_transfer_list_path = "path/to/your/custom_rom.transfer.list" # Replace with your actual path
my_output_image_name = "custom_extracted_image.img"

success_custom = convert_rom_files_function(
    datbr_path=my_datbr_path,
    transferlist_path=my_transfer_list_path,
    output_img_name=my_output_image_name
)

if success_custom:
    print(f"Custom conversion successful! Output: {my_output_image_name} 🎉")
else:
    print("Custom conversion failed! ❌")

Note: When using as a library, ensure the input files (.dat.br and .transfer.list) exist at the specified paths.


📁 Output

Upon successful conversion, a .img file (e.g., system.img, vendor.img) will be generated. This is a raw disk image that can be opened and explored with various tools, such as:

  • 7-Zip
  • DiskGenius
  • Linux Reader (for Windows)
  • mount command (on Linux)
  • Other ext4 filesystem tools on Linux

🙏 Credits


📄 License

This script is open-source and released under the MIT License. Use it freely and feel free to contribute!


Metadata

Release files for sdat2img-brotli 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sdat2img-brotli 1.0.3
File Size Uploaded
sdat2img-brotli-1.0.3.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sdat2img-brotli 1.0.3
File Interpreter ABI Platform
sdat2img_brotli-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / sdat2img-brotli-1.0.3.tar.gz

Download URL sdat2img-brotli-1.0.3.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
29443d1aad588340212d6c15f2ff0af562e89b4e38fad7e1876537003a7f9fa6
BLAKE2b-256 checksum
How to use checksums
1c339ae6904df94725a6e66f4d4a57070115eced17549228b5e47f86d09c12aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.6

Release files / sdat2img_brotli-1.0.3-py3-none-any.whl

Download URL sdat2img_brotli-1.0.3-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1ab1c9cf1278f4f51a63e6545c14cd947bdf11a100cd2c180e2c464137344a5
BLAKE2b-256 checksum
How to use checksums
3c30ce4efbdfa9a453f9f9f2cc577da93ea2afbffbffcda183e744011c59806f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page