From 2a0405da32abd735687a3019c8e058435f436205 Mon Sep 17 00:00:00 2001 From: Emil Kosz Date: Sun, 13 Sep 2026 22:53:45 +0200 Subject: [PATCH] general: restructuring after branchout --- ...-cflags-suppress-stringop-truncation.patch | 0 ...002-build-core-fix-ar-absolute-paths.patch | 0 ...-add-std-gnu++11-for-nullptr-support.patch | 0 ...ore-combo-remove-icf-safe-for-BFD-ld.patch | 0 ...IG_OVERRIDE-ordering-and-passthrough.patch | 0 AGENTS.md | 130 ------------------ README.md | 45 +----- build_twrp.sh => build.sh | 14 +- build_los-14.1.sh | 99 ------------- common.sh | 15 -- local_manifests/los-14.1.xml | 35 ----- local_manifests/twrp.xml => manifest.xml | 0 patches/README.md | 16 --- ...1-art-mem-map-fix-mmap-on-kernel-518.patch | 29 ---- 14 files changed, 11 insertions(+), 372 deletions(-) rename patches/twrp/0001-host-cflags-suppress-stringop-truncation.patch => 0001-host-cflags-suppress-stringop-truncation.patch (100%) rename patches/twrp/0002-build-core-fix-ar-absolute-paths.patch => 0002-build-core-fix-ar-absolute-paths.patch (100%) rename patches/twrp/0003-recovery-add-std-gnu++11-for-nullptr-support.patch => 0003-recovery-add-std-gnu++11-for-nullptr-support.patch (100%) rename patches/twrp/0004-build-core-combo-remove-icf-safe-for-BFD-ld.patch => 0004-build-core-combo-remove-icf-safe-for-BFD-ld.patch (100%) rename patches/twrp/0005-build-core-tasks-kernel-fix-KERNEL_CONFIG_OVERRIDE-ordering-and-passthrough.patch => 0005-build-core-tasks-kernel-fix-KERNEL_CONFIG_OVERRIDE-ordering-and-passthrough.patch (100%) delete mode 100644 AGENTS.md rename build_twrp.sh => build.sh (81%) delete mode 100755 build_los-14.1.sh delete mode 100644 common.sh delete mode 100644 local_manifests/los-14.1.xml rename local_manifests/twrp.xml => manifest.xml (100%) delete mode 100644 patches/README.md delete mode 100644 patches/los/0001-art-mem-map-fix-mmap-on-kernel-518.patch diff --git a/patches/twrp/0001-host-cflags-suppress-stringop-truncation.patch b/0001-host-cflags-suppress-stringop-truncation.patch similarity index 100% rename from patches/twrp/0001-host-cflags-suppress-stringop-truncation.patch rename to 0001-host-cflags-suppress-stringop-truncation.patch diff --git a/patches/twrp/0002-build-core-fix-ar-absolute-paths.patch b/0002-build-core-fix-ar-absolute-paths.patch similarity index 100% rename from patches/twrp/0002-build-core-fix-ar-absolute-paths.patch rename to 0002-build-core-fix-ar-absolute-paths.patch diff --git a/patches/twrp/0003-recovery-add-std-gnu++11-for-nullptr-support.patch b/0003-recovery-add-std-gnu++11-for-nullptr-support.patch similarity index 100% rename from patches/twrp/0003-recovery-add-std-gnu++11-for-nullptr-support.patch rename to 0003-recovery-add-std-gnu++11-for-nullptr-support.patch diff --git a/patches/twrp/0004-build-core-combo-remove-icf-safe-for-BFD-ld.patch b/0004-build-core-combo-remove-icf-safe-for-BFD-ld.patch similarity index 100% rename from patches/twrp/0004-build-core-combo-remove-icf-safe-for-BFD-ld.patch rename to 0004-build-core-combo-remove-icf-safe-for-BFD-ld.patch diff --git a/patches/twrp/0005-build-core-tasks-kernel-fix-KERNEL_CONFIG_OVERRIDE-ordering-and-passthrough.patch b/0005-build-core-tasks-kernel-fix-KERNEL_CONFIG_OVERRIDE-ordering-and-passthrough.patch similarity index 100% rename from patches/twrp/0005-build-core-tasks-kernel-fix-KERNEL_CONFIG_OVERRIDE-ordering-and-passthrough.patch rename to 0005-build-core-tasks-kernel-fix-KERNEL_CONFIG_OVERRIDE-ordering-and-passthrough.patch diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index ca50d60..0000000 --- a/AGENTS.md +++ /dev/null @@ -1,130 +0,0 @@ -# AGENTS.md — builders_rubenslte - -Build drivers + docs for **TWRP recovery** (`recovery.img`) and a -**LineageOS 14.1 ROM** for the Samsung Tab Active SM-T365 (`rubenslte`, -Qualcomm MSM8926 / msm8226, Linux kernel 3.4). - -## Layout - -``` -build_twrp.sh TWRP -> recovery.img (omni twrp-5.1) -build_los-14.1.sh LOS -> boot.img / lineage_rubenslte-*.zip (cm-14.1, Jack) -common.sh shared: apply_patches (idempotent patch application) -shell.nix nix-shell FHS env for both builds (nixpkgs 22.11 pinned) -patches/twrp post-sync fixes -local_manifests/ los-14.1.xml + twrp.xml -twrp-build/ los-build/ .ccache/ .jack-repository/ (gitignored workspaces) -``` - -## Repos - -Everything rubenslte lives on gitea, fetched anonymously over https: -`https://git.cfpi-fpsi.eu/rubenslte`. - -- `twrp_device_samsung_rubenslte` — TWRP device tree, **self-contained** - (own BoardConfig.mk / mkbootimg.mk / dtbtool, no platform imports). -- `android_kernel_samsung_msm8226-rubenslte` — S3NEO msm8226 kernel - fork, built from source -- `android_device_samsung_rubenslte` — LOS device tree; inherits the shared - msm8226-common / qcom-common platform layers (cm-14.1) -- `android_vendor_samsung_rubenslte` — LOS proprietary blobs. - -`android_device_samsung_msm8226-common` lives on gitea too (cm-14.1) — a mirror -of the maintainer fork that produced the matisse family (LineageOS org has no -cm-14.1 for it). The two qcom-common platform layers come straight from -LineageOS (`device/samsung/qcom-common`, `device/qcom/common`, both cm-14.1). - -## Commands - -Both scripts are console-style with `getopts`; the only flag is `-h` (usage). -Every build runs a full `repo sync` first, so in-tree edits are always wiped -and re-patched — there is no skip-sync mode. - -```bash -./build_twrp.sh -h # usage -./build_twrp.sh build # full build -> recovery.img at repo root -./build_twrp.sh clean # remove twrp-build/out and recovery.img -./build_twrp.sh prune # remove all of twrp-build and recovery.img - -./build_los-14.1.sh bootimage # build boot.img (kernel + dt.img + ramdisk, fast gate) -./build_los-14.1.sh bacon # full build -> lineage_rubenslte-*.zip -./build_los-14.1.sh clean # mka clean -./build_los-14.1.sh prune # remove all of los-build -``` - -Cheap checks without nix: `bash -n common.sh build_twrp.sh build_los.sh`. -Patch check: `patch -p1 --dry-run -d < patches//`. -Flashing / boot keys: README.md. - -## How the builds work - -- **Env**: everything runs inside the nix-shell FHS env (`shell.nix`). Run - `nix-shell` first, then invoke the scripts. -- **TWRP sources**: `repo init` of omni `twrp-5.1` - (`platform_manifest_twrp_omni`) + `local_manifests/twrp.xml` copied into - `.repo/local_manifests/` before `repo sync -c -j$(nproc)`, then - `apply_patches patches/twrp`. -- **LOS sources**: `repo init` of cm-14.1 (`LineageOS/android`) + - `local_manifests/rubenslte.xml` copied in before `repo sync -c -j$(nproc)`. -- **Patches**: `common.sh::apply_patches` dry-runs each patch with `LC_ALL=C` - first. An already-applied patch makes GNU patch (2.8, from the nix env) - report `Reversed (or previously applied) patch detected` on the forward dry - run — that output, not the exit code, is what skips it. Warnings print the - patch log but don't abort the build. -- **Toolchain (TWRP)**: arm-eabi-4.8 (gcc 4.8, matches stock) is checked out - by `repo sync` — the omni twrp-5.1 manifest already declares - `prebuilts/gcc/linux-x86/arm/arm-eabi-4.8` at the default revision - `refs/tags/android-5.1.1_r28` (aosp remote). It lands at - `prebuilts/gcc/linux-x86/arm/arm-eabi-4.8` and is put on `PATH` (the sync - fetches it). LOS uses the tree's own prebuilts. -- **Compiler (LOS)**: Jack only, in-process (`JACK_SERVER=false - JACK_NO_SERVER=1`); the jack/jill jars are seeded into `.jack-repository/` - from `prebuilts/sdk/tools/jacks/` with `cp -n`. -- **Kernel**: built from source via the omni/lineage kernel build rules. -- **SEANDROIDENFORCE**: `build_los.sh` appends the trailer to the LOS boot.img - (`append_seandroidenforce`) — required by Samsung bootloaders. - -Artifacts: `recovery.img` (repo root; `build_twrp.sh` checks it against -`RECOVERY_BUDGET=10485248` and errors if it exceeds the partition) and -`los-build/out/target/product/rubenslte/lineage_rubenslte-*.zip`. - -## Invariants — do not "simplify" - -- `BoardConfig.mk`: `INSTALLED_DTIMAGE_TARGET` + `BOARD_MKBOOTIMG_ARGS` stay - *recursive* (`=`, expanded after `PRODUCT_OUT`/`KERNEL_OUT` exist) — never `:=`. -- `mkbootimg.mk`: the dt.img rule depends on `INSTALLED_KERNEL_TARGET`; the - ramdisk must stay LZMA + trimmed or the image overflows the partition. -- **SEANDROIDENFORCE** trailer + `--dt` are required for Samsung bootloaders - (`append_seandroidenforce` appends it to LOS boot.img). -- LOS is Jack-only and the ROM is **bare** (no GApps, `/data` ext4). - -## Gotchas - -- **The env deliberately has no 64-bit host gcc**: PATH `gcc` is the genuine - 32-bit `pkgsi686Linux.gcc9` from `multiPkgs`, because omni/TWRP host tools - are compiled as obj32 (`-m32`) and only work against a real 32-bit compiler. - Adding `gcc` to `targetPkgs` regresses the TWRP build with the classic - `gnu/stubs-32.h: No such file or directory` (x86_64 nixpkgs gcc has no - 32-bit multilib headers). -- **repo launcher warning**: the nix-provided `gitRepo` launcher is read-only - and warns that it can't auto-update to a newer repo version — harmless. -- Don't switch LOS off Jack or re-enable the Jack server (host TLS breaks the - server path and aborts the build). -- `repo sync` wipes in-tree edits — expected. Prefer editing the **device - repos**, not patching; patches are only for upstream 5.1/14.1 sources that - can't live in the device tree. -- Commit style: short lowercase-imperative subject, no body. Stage with - `git add -A` (images and workspaces are gitignored). - -## Why local_manifests - -`repo` auto-imports every `.xml` in `.repo/local_manifests/` on top of the -primary manifest, so both builds get their rubenslte bits without forking the -whole manifest. (`repo` reads the copy the build script drops into -`twrp-build/` / `los-build/.repo/local_manifests/` — edit the source files, -every build re-copies them.) - -# Else - -For depth: `patches/README.md`, `twrp_device_samsung_rubenslte/README.md`, -`local_manifests/rubenslte.xml`. diff --git a/README.md b/README.md index 645052a..7f1bd04 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,9 @@ # builders\_rubenslte -Build scripts and patches for TWRP and LineageOS 14.1 for the Samsung -Galaxy Tab Active SM-T365 (`rubenslte`). +Build scripts and utilities for rubenslte TWRP builds. ## Quick start Requirements: either a NixOS system (or Nix), or a set up on some other distro with all required packages. First (if on Nix), run -`nix-shell`. Then, there are two main scripts: `./build_twrp.sh` and -`./build_los.sh`. Run each one with `-h` to figure out how to use -them. - -## Flashing - -| Mode | Key combo | -|----------|---------------------| -| Recovery | Vol+ & Home & Power | -| Download | Vol- & Home & Power | - -First, flash TWRP using either Odin (Windows) or Heimdall. For the -latter, use `heimdall flash --RECOVERY recovery.img --no-reboot` while -in download mode. - -Then, you can boot into TWRP using the recovery key combination, -factory reset, then flash the ROM zip. - -## Device information - -| Basic | Spec sheet | -|-------------------|----------------------------------------| -| Name | Galaxy Tab Active | -| Model | SM-T365 | -| Codename | rubenslte | -| CPU | Quad-core 1.2 GHz Cortex A-7 | -| Chipset | Qualcomm Snapdragon 400 (MSM8926, LTE) | -| ro.board.platform | msm8226 | -| ro.product.board | MSM8926 | -| GPU | Qualcomm Adreno 305 | -| Memory | 1.5 GB | -| Shipped Android | Android 4.4 | -| Latest Android | Android 5.1.1 | -| Storage | 16 GB | -| MicroSD | 64 GB | -| Battery | 4450 mAh | -| Display | 800x1280 px | -| Rear camera | 3.1 Mpx | -| Front camera | 1.2 Mpx | -| Similar devices | milletlte, matisselte | - +nix-shell. Then, run `./build.sh -h` to figure out how to build. diff --git a/build_twrp.sh b/build.sh similarity index 81% rename from build_twrp.sh rename to build.sh index 55634ee..e273bf1 100755 --- a/build_twrp.sh +++ b/build.sh @@ -3,13 +3,13 @@ set -euo pipefail readonly ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$ROOT" -source common.sh readonly MANIFEST_URL="https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git" readonly MANIFEST_BRANCH="twrp-5.1" -readonly MANIFEST_LOCAL="local_manifests/twrp.xml" -readonly RECOVERY_BUDGET=10485248 +rlte_print() { printf '\033[34m[%s] %s\033[0m\n' "$0" "$*" ; } +rlte_error() { printf '\033[31m[%s] error: %s\033[0m\n' "$0" "$*" >&2 ; exit 1; } +rlte_ok() { printf '\033[32m[%s] ok: %s\033[0m\n' "$0" "$*" ; exit 0; } usage() { cat < lineage_rubenslte-*.zip - clean mka clean - prune remove all of los-build -EOF -} - -append_seandroidenforce() { - local img="$1" - - [ -f "$img" ] || return - tail -c 16 "$img" | grep -q "SEANDROIDNEFORCE" || \ - printf 'SEANDROIDENFORCE' >> "$img" -} - -do_build() { - mkdir -p los-build - cd los-build - - if [ ! -d .repo ]; then - rlte_print "Setting up repo" - repo init --depth 1 -u "$MANIFEST_URL" -b "$MANIFEST_BRANCH" - mkdir -p .repo/local_manifests - cp "$ROOT/$MANIFEST_LOCAL" .repo/local_manifests/ - fi - - if [ ! -v "NO_SYNC" ]; then - rlte_print "Syncing repositories" - repo sync -c -j"$(nproc)" - fi - - rlte_print "Applying patches" - apply_patches "$ROOT/patches/los" - - export LC_ALL=C LANG=C USE_CCACHE=1 CCACHE_DIR="$ROOT/.ccache" \ - JACK_SERVER=false JACK_NO_SERVER=1 \ - JACK_REPOSITORY="$ROOT/.jack-repository" TOP="$PWD" \ - ANDROID_BUILD_TOP="$PWD" - - mkdir -p "$ROOT/.jack-repository" - cp -n "$TOP"/prebuilts/sdk/tools/jacks/jack-*.jar "$ROOT/.jack-repository" - cp -n "$TOP"/prebuilts/sdk/tools/jills/jill-*.jar "$ROOT/.jack-repository" - - set +eu - source build/envsetup.sh - lunch lineage_rubenslte-userdebug - set -e - - if [ -z "${TARGET_PRODUCT:-}" ]; then - rlte_error "lunch failed - TARGET_PRODUCT not set" - exit 1 - fi - - rlte_print "Commencing build (command: $CMD)" - mka "$CMD" - - if [ "$CMD" != "clean" ]; then - rlte_print "Appending SEANDROIDENFORCE" - append_seandroidenforce "$ROOT/los-build/out/target/product/rubenslte/boot.img" - fi - - rlte_ok "Done." -} - -while getopts ":hn" opt; do - case "$opt" in - h) usage; exit 0 ;; - n) NO_SYNC=1 ;; - *) usage; exit 1 ;; - esac -done - -shift $((OPTIND - 1)) - -case "${1:-}" in - bootimage|bacon|clean) CMD="${1:-}"; do_build ;; - prune) rm -rf los-build ;; - *) usage; exit 1 ;; -esac diff --git a/common.sh b/common.sh deleted file mode 100644 index 464c021..0000000 --- a/common.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -rlte_print() { printf '\033[34m[%s] %s\033[0m\n' "$0" "$*" ; } -rlte_error() { printf '\033[31m[%s] error: %s\033[0m\n' "$0" "$*" >&2 ; exit 1; } -rlte_ok() { printf '\033[32m[%s] ok: %s\033[0m\n' "$0" "$*" ; exit 0; } - -apply_patches() { - local dir="$1" - for p in "$dir"/*.patch; do - [ -e "$p" ] || continue - patch -p1 --forward --batch --dry-run < "$p" || continue - patch -p1 --batch < "$p" - done -} - diff --git a/local_manifests/los-14.1.xml b/local_manifests/los-14.1.xml deleted file mode 100644 index 6cdd951..0000000 --- a/local_manifests/los-14.1.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/local_manifests/twrp.xml b/manifest.xml similarity index 100% rename from local_manifests/twrp.xml rename to manifest.xml diff --git a/patches/README.md b/patches/README.md deleted file mode 100644 index 201cd5d..0000000 --- a/patches/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Patches - -These patches make the 2015-era sources build on a modern host toolchain. - -## TWRP / omni 5.1 (`patches/twrp/`) - -| Patch | File(s) | Problem fixed | -|-------|---------|---------------| -| `0001-host-cflags-suppress-stringop-truncation.patch` | `build/core/combo/HOST_linux-x86*.mk` | `-Werror=stringop-truncation` errors with host GCC >= 8 | -| `0002-build-core-fix-ar-absolute-paths.patch` | `build/core/definitions.mk` | host `ar`/absolute path handling in whole-archive extraction breaks with newer binutils; extract to a temp dir instead | -| `0003-recovery-add-std-gnu++11-for-nullptr-support.patch` | `bootable/recovery/Android.mk` | adds `-std=gnu++11` for `nullptr` under the recovery Clang build | -| `0004-build-core-combo-remove-icf-safe-for-BFD-ld.patch` | `build/core/combo/TARGET_linux-arm.mk` | `-Wl,--icf=safe` is gold-only; commented out for the BFD linker supplied by the toolchain download | -| `0005-build-core-tasks-kernel-fix-KERNEL_CONFIG_OVERRIDE-ordering-and-passthrough.patch` | `build/core/tasks/kernel.mk` | applies the additional config before the override, drops the clobbering `oldconfig` after override, and passes the override on the kernel build command line | - -These target the omni `twrp-5.1` manifest sources — they only apply inside the -repo workspace, not on a host. diff --git a/patches/los/0001-art-mem-map-fix-mmap-on-kernel-518.patch b/patches/los/0001-art-mem-map-fix-mmap-on-kernel-518.patch deleted file mode 100644 index 5fed49a..0000000 --- a/patches/los/0001-art-mem-map-fix-mmap-on-kernel-518.patch +++ /dev/null @@ -1,29 +0,0 @@ -From: rubenslte-builder -Date: Sat, 13 Sep 2026 21:00:00 +0200 -Subject: [PATCH 1/1] art-mem-map-fix-mmap-on-kernel-518 - -Workaround for mmap error when building on Linux kernel 5.18+. -Adds MAP_FIXED_NOREPLACE in MapFileAtAddress (host builds only, -guarded by #if !defined(ART_TARGET)), forcing the kernel to honor -the expected address instead of mapping at a different one. - -Fixes: android-review.googlesource.com/c/platform/art/+/673bd2c638ed82bbe71cf7d645d433973a624e4f -Bug: 23318356 ---- - diff --git a/art/runtime/mem_map.cc b/art/runtime/mem_map.cc - index b9d51c1..f034a3d 100644 - --- a/art/runtime/mem_map.cc - +++ b/art/runtime/mem_map.cc - @@ -393,7 +393,12 @@ - DCHECK(ContainedWithinExistingMap(expected_ptr, byte_count, error_msg)) - << ((error_msg != nullptr) ? *error_msg : std::string()); - flags |= MAP_FIXED; -+#if !defined(ART_TARGET) -+ } else if (expected_ptr) { -+#define MAP_FIXED_NOREPLACE 0x100000 -+ flags |= MAP_FIXED_NOREPLACE; -+#endif - } else { - CHECK_EQ(0, flags & MAP_FIXED); - // Don't bother checking for an overlapping region here. We'll - // check this if required after the fact inside CheckMapRequest.