# toraidl/coloros_port architecture

> Architecture diagram of the GitHub repository toraidl/coloros_port, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/toraidl/coloros_port
- Repository: https://github.com/toraidl/coloros_port

## Overview

This repository is a ColorOS ROM porting and packaging project for supported OnePlus and Oppo devices. The documented user workflow supplies a base ROM and a port ROM to `port.sh`; the intended result is an automatically ported package. The tree contains image extraction and conversion tools, filesystem/configuration patchers, device-specific release and overlay assets, and OTA/flash utilities. The README does not document the script’s internal call sequence, and `port.sh` was not sampled, so those connections are shown as unverified rather than asserted.

Main entry points: [`port.sh`](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/port.sh) (Port orchestrator), [`bin/imgextractor/imgextractor.py`](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/imgextractor/imgextractor.py) (Image extraction), [`functions.sh`](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/functions.sh) (Shared functions), [`bin/lpunpack.py`](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/lpunpack.py) (Dynamic partition unpack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Port workflow"]
  node_port["Port orchestrator<br/>[port.sh]"]
  node_functions["Shared functions<br/>[functions.sh]"]
end

subgraph group_images["Image processing"]
  node_super["Dynamic partition unpack<br/>[lpunpack.py]"]
  node_extractor["Image extraction<br/>[imgextractor.py]"]
  node_ext4["Ext4 image reader<br/>[ext4.py]"]
  node_sdat["Dat image conversion<br/>[sdat2img.py]"]
end

subgraph group_adaptation["ROM adaptation"]
  node_context["SELinux context patch<br/>[contextpatch.py]"]
  node_fsconfig["Filesystem config patch<br/>[fspatch.py]"]
  node_smali["Smali method patch<br/>[patchmethod.py]"]
  node_smali_v2["Advanced Smali patch<br/>[patchmethod_v2.py]"]
  node_vbmeta["VBMeta patch<br/>[patch-vbmeta.py]"]
  node_device_assets["Device overlays"]
  node_device_op4["OP4E5D release rules<br/>[releasetools.py]"]
  node_device_9r["OnePlus9R release rules<br/>[releasetools.py]"]
end

subgraph group_delivery["Package and flash"]
  node_otatools["OTA packaging tools"]
  node_flash["Device flashing tools"]
  node_output["Ported ROM package"]
end

node_user(("ROM porter"))

node_user -->|"runs with ROMs"| node_port
node_port -.->|"may unpack"| node_super
node_port -.->|"may extract"| node_extractor
node_extractor -->|"imports"| node_ext4
node_port -.->|"may convert"| node_sdat
node_port -.->|"may patch"| node_context
node_port -.->|"may patch"| node_fsconfig
node_port -.->|"may patch"| node_smali
node_port -.->|"may patch"| node_smali_v2
node_port -.->|"may patch"| node_vbmeta
node_port -.->|"may apply"| node_device_assets
node_port -.->|"may configure"| node_device_op4
node_port -.->|"may configure"| node_device_9r
node_port -.->|"may package with"| node_otatools
node_port -.->|"produces"| node_output
node_output -.->|"may flash via"| node_flash
node_port -.->|"may use"| node_functions

click node_port "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/port.sh"
click node_functions "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/functions.sh"
click node_super "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/lpunpack.py"
click node_extractor "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/imgextractor/imgextractor.py"
click node_ext4 "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/imgextractor/ext4.py"
click node_sdat "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/Linux/x86_64/sdat2img.py"
click node_context "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/contextpatch.py"
click node_fsconfig "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/fspatch.py"
click node_smali "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/patchmethod.py"
click node_smali_v2 "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/patchmethod_v2.py"
click node_vbmeta "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/patch-vbmeta.py"
click node_device_assets "https://github.com/toraidl/coloros_port/tree/COS16/OOS16/devices/OnePlus8T/overlay"
click node_device_op4 "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/devices/OP4E5D/releasetools.py"
click node_device_9r "https://github.com/toraidl/coloros_port/blob/COS16/OOS16/devices/OnePlus9R/releasetools.py"
click node_otatools "https://github.com/toraidl/coloros_port/tree/COS16/OOS16/otatools/bin"
click node_flash "https://github.com/toraidl/coloros_port/tree/COS16/OOS16/bin/flash"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_port,node_functions toneBlue
class node_super,node_extractor,node_ext4,node_sdat toneAmber
class node_context,node_fsconfig,node_smali,node_smali_v2,node_vbmeta,node_device_assets,node_device_op4,node_device_9r toneMint
class node_otatools,node_flash,node_output toneRose
class node_user toneIndigo
```

## Components

### Port workflow

- [Port orchestrator](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/port.sh): `port.sh`
- [Shared functions](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/functions.sh): `functions.sh`

### Image processing

- [Dynamic partition unpack](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/lpunpack.py): `bin/lpunpack.py`
- [Image extraction](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/imgextractor/imgextractor.py): `bin/imgextractor/imgextractor.py`
- [Ext4 image reader](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/imgextractor/ext4.py): `bin/imgextractor/ext4.py`
- [Dat image conversion](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/Linux/x86_64/sdat2img.py): `bin/Linux/x86_64/sdat2img.py`

### ROM adaptation

- [SELinux context patch](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/contextpatch.py): `bin/contextpatch.py`
- [Filesystem config patch](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/fspatch.py): `bin/fspatch.py`
- [Smali method patch](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/patchmethod.py): `bin/patchmethod.py`
- [Advanced Smali patch](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/patchmethod_v2.py): `bin/patchmethod_v2.py`
- [VBMeta patch](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/bin/patch-vbmeta.py): `bin/patch-vbmeta.py`
- [Device overlays](https://github.com/toraidl/coloros_port/tree/COS16/OOS16/devices/OnePlus8T/overlay): `devices/OnePlus8T/overlay`
- [OP4E5D release rules](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/devices/OP4E5D/releasetools.py): `devices/OP4E5D/releasetools.py`
- [OnePlus9R release rules](https://github.com/toraidl/coloros_port/blob/COS16/OOS16/devices/OnePlus9R/releasetools.py): `devices/OnePlus9R/releasetools.py`

### Package and flash

- [OTA packaging tools](https://github.com/toraidl/coloros_port/tree/COS16/OOS16/otatools/bin): `otatools/bin`
- [Device flashing tools](https://github.com/toraidl/coloros_port/tree/COS16/OOS16/bin/flash): `bin/flash`
- **Ported ROM package**

### Other components

- **ROM porter**

## Connections

- ROM porter → Port orchestrator: runs with ROMs (evidence: `README.md`)
- Port orchestrator → Dynamic partition unpack: may unpack
- Port orchestrator → Image extraction: may extract
- Image extraction → Ext4 image reader: imports (evidence: `bin/imgextractor/imgextractor.py`)
- Port orchestrator → Dat image conversion: may convert
- Port orchestrator → SELinux context patch: may patch
- Port orchestrator → Filesystem config patch: may patch
- Port orchestrator → Smali method patch: may patch
- Port orchestrator → Advanced Smali patch: may patch
- Port orchestrator → VBMeta patch: may patch
- Port orchestrator → Device overlays: may apply
- Port orchestrator → OP4E5D release rules: may configure
- Port orchestrator → OnePlus9R release rules: may configure
- Port orchestrator → OTA packaging tools: may package with
- Port orchestrator → Ported ROM package: produces
- Ported ROM package → Device flashing tools: may flash via
- Port orchestrator → Shared functions: may use
