|
| 1 | +# OCI images |
| 2 | + |
| 3 | +uDroid can install official operating-system container images as ordinary |
| 4 | +PRoot root filesystems. This path does not run Docker, containerd, a privileged |
| 5 | +daemon, namespaces, or a nested container runtime. The app implements the |
| 6 | +small OCI distribution and layer-processing surface needed to produce a |
| 7 | +verified rootfs in app-private storage. |
| 8 | + |
| 9 | +The first release of this path deliberately limits discovery to active |
| 10 | +operating-system images in Docker Hub's official `library` namespace. A |
| 11 | +repository appearing in search is not enough to start a download: the user |
| 12 | +must select a tag that has a compatible image for the phone architecture and |
| 13 | +review its size and source first. |
| 14 | + |
| 15 | +## Installation path |
| 16 | + |
| 17 | +```mermaid |
| 18 | +flowchart TD |
| 19 | + A["Docker Hub official OS catalogue"] --> B["Compatible repository and tag"] |
| 20 | + B --> C["Tag plus immutable SHA-256 digest"] |
| 21 | + C --> D["OCI registry manifest resolution"] |
| 22 | + D --> E["Architecture-specific manifest"] |
| 23 | + E --> F["Resumable config and layer downloads"] |
| 24 | + F --> G["SHA-256 verification"] |
| 25 | + G --> H["Ordered layer and whiteout application"] |
| 26 | + H --> I["Android and PRoot compatibility files"] |
| 27 | + I --> J["First-boot health probe"] |
| 28 | + J --> K["Atomic rootfs activation"] |
| 29 | +``` |
| 30 | + |
| 31 | +The UI stores both the human-facing tag and its platform digest. Installation |
| 32 | +therefore resolves a reference such as: |
| 33 | + |
| 34 | +```text |
| 35 | +docker.io/library/almalinux:latest@sha256:<digest> |
| 36 | +``` |
| 37 | + |
| 38 | +The tag remains useful to the user, while the digest prevents a mutable tag |
| 39 | +from silently selecting different content between review and installation. |
| 40 | + |
| 41 | +## Discovery and caching |
| 42 | + |
| 43 | +Repository discovery accepts only entries that: |
| 44 | + |
| 45 | +- belong to Docker Hub's official `library` namespace; |
| 46 | +- are active image repositories in the operating-systems category; |
| 47 | +- use a validated repository name; |
| 48 | +- are not described as deprecated. |
| 49 | + |
| 50 | +Tag discovery filters the returned platform descriptors against Android's |
| 51 | +supported ABI. `arm64-v8a`, for example, maps to OCI `linux/arm64/v8`. |
| 52 | +Repository metadata is cached for six hours and tag metadata for two hours. |
| 53 | +When refresh fails, an existing validated cache can be shown as stale data |
| 54 | +instead of removing the catalogue. Activity recreation also retains the |
| 55 | +selected repository and reloads its tag state. |
| 56 | + |
| 57 | +The catalogue is intentionally not a general Docker Hub search. Community |
| 58 | +images, arbitrary registries, private credentials, and user-provided image |
| 59 | +references need a separate trust and UX design. |
| 60 | + |
| 61 | +## Registry and download boundaries |
| 62 | + |
| 63 | +The registry client supports OCI and Docker v2 image indexes and manifests. It |
| 64 | +selects the requested OS, architecture, and variant, limits metadata response |
| 65 | +sizes, and verifies manifest digests supplied by both the selected descriptor |
| 66 | +and the registry response. |
| 67 | + |
| 68 | +Anonymous Bearer challenges are supported over HTTPS. The returned token is |
| 69 | +used only for requests to the original blob origin. The shared resumable |
| 70 | +artifact pipeline rejects unsafe header names and values, controls Range |
| 71 | +requests itself, and does not forward authorization headers across a |
| 72 | +cross-origin redirect. |
| 73 | + |
| 74 | +Each config or filesystem blob is written to a partial file, resumed when |
| 75 | +possible, checked against its descriptor's SHA-256 digest, and atomically |
| 76 | +promoted to the verified blob cache. Interrupted verified data can be reused |
| 77 | +by a later attempt. Verified blobs are removed after a rootfs is activated. |
| 78 | + |
| 79 | +## Layers, whiteouts, and activation |
| 80 | + |
| 81 | +OCI filesystem layers are applied in manifest order. Before extracting a |
| 82 | +layer, uDroid scans its tar entry names and applies: |
| 83 | + |
| 84 | +- `.wh.<name>` as deletion of the lower-layer path; |
| 85 | +- `.wh..wh..opq` as removal of lower-layer children in that directory. |
| 86 | + |
| 87 | +Whiteout marker files are excluded from normal tar extraction. Every planned |
| 88 | +path is confined to the staging rootfs, so a malformed layer cannot use |
| 89 | +whiteouts to delete app data outside that directory. |
| 90 | + |
| 91 | +Tar entry-name scanning supports ustar prefixes, POSIX PAX paths, GNU long |
| 92 | +names, checksum validation, octal sizes, and positive base-256 sizes. PAX |
| 93 | +records may also contain binary extended attributes. The scanner decodes the |
| 94 | +record key first and decodes a value as UTF-8 only when the key is `path`. |
| 95 | +This matters for AlmaLinux, whose official layer contains binary |
| 96 | +`SCHILY.xattr.security.capability` data that is valid tar metadata but is not |
| 97 | +UTF-8 text. |
| 98 | + |
| 99 | +Extraction occurs in an operation-owned staging directory. On success uDroid: |
| 100 | + |
| 101 | +1. writes Android DNS, identity, mount, and PRoot compatibility files; |
| 102 | +2. executes the same mounted first-boot health probe used by archive installs; |
| 103 | +3. writes the ready marker; |
| 104 | +4. atomically renames staging storage to the final installation name. |
| 105 | + |
| 106 | +Failed staging data is removed only when its ownership marker matches the |
| 107 | +current OCI installation. An unrelated or unrecognized directory is left |
| 108 | +untouched. |
| 109 | + |
| 110 | +## State and progress |
| 111 | + |
| 112 | +Archive and OCI installations share one persisted `InstallerWorkRequest` |
| 113 | +contract and the same foreground installer service. The state snapshot records |
| 114 | +the immutable image reference, target platform, installation name, operation |
| 115 | +identifier, progress stage, byte totals, terminal transcript, and whether the |
| 116 | +operation can be cancelled. |
| 117 | + |
| 118 | +Older archive-only snapshots are migrated when read. OCI progress survives |
| 119 | +Activity recreation and process interruption, and the UI reattaches to the |
| 120 | +same saved operation rather than creating another installation implicitly. |
| 121 | + |
| 122 | +## Validation |
| 123 | + |
| 124 | +The implementation has unit coverage for: |
| 125 | + |
| 126 | +- image-reference parsing and normalization; |
| 127 | +- manifest-list platform selection and digest verification; |
| 128 | +- Bearer authentication and origin-confined request headers; |
| 129 | +- resumable aggregate progress; |
| 130 | +- Docker Hub catalogue and tag parsing, caching, and stale fallback; |
| 131 | +- whiteout planning and path confinement; |
| 132 | +- tar checksums, PAX paths, GNU long names, and binary PAX attributes; |
| 133 | +- transactional activation, failure cleanup, persisted progress, and legacy |
| 134 | + state migration. |
| 135 | + |
| 136 | +Android probe tests use the separate |
| 137 | +`org.randomcoder.udroid.ociprobe` application ID so destructive rootfs tests |
| 138 | +cannot uninstall or overwrite the normal uDroid package. The real-device |
| 139 | +checkpoint installed the official arm64 AlmaLinux `latest` layer end to end, |
| 140 | +including compatibility configuration and the first-boot health probe. |
| 141 | + |
| 142 | +## Current limitations |
| 143 | + |
| 144 | +- Discovery is restricted to anonymous official Docker Hub operating-system |
| 145 | + images. |
| 146 | +- Only OCI/Docker image indexes, manifests, gzip tar layers, and uncompressed |
| 147 | + tar layers are accepted. |
| 148 | +- Signatures, attestations, SBOM policy, private registries, and registry |
| 149 | + credentials are not implemented. |
| 150 | +- A container image is a minimal rootfs, not a complete machine boot. Services |
| 151 | + that require a real kernel, systemd/logind, privileged mounts, or namespaces |
| 152 | + still need PRoot-specific handling. |
| 153 | +- An official image can still contain userspace assumptions that do not work |
| 154 | + under Android. Digest verification proves content identity, while the |
| 155 | + first-boot probe establishes only the baseline execution contract. |
0 commit comments