62 lines
2.0 KiB
Bash
Executable File
62 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build a TWRP recovery image for Samsung Galaxy Tab Active (SM-T365, rubenslte).
|
|
# Must run inside the nix-shell FHS environment (shell.nix): if invoked from the
|
|
# host, it re-executes itself inside that environment via its stdin pipe.
|
|
set -euo pipefail
|
|
|
|
SCRIPT="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
|
|
|
if [ -z "${RUBENSLTE_BUILD_IN_ENV:-}" ]; then
|
|
echo "[*] Entering nix-shell FHS build environment ..."
|
|
cd "$SCRIPT"
|
|
printf '\nexport RUBENSLTE_BUILD_IN_ENV=1\nbash "%s/build_twrp.sh"\n' "$SCRIPT" \
|
|
| nix-shell shell.nix
|
|
exit $?
|
|
fi
|
|
|
|
export LC_ALL=C LANG=C LC_CTYPE=C
|
|
|
|
cd "$SCRIPT"
|
|
mkdir -p twrp-build
|
|
cd twrp-build
|
|
|
|
if [ ! -d .repo ]; then
|
|
repo init --depth 1 -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git -b twrp-5.1
|
|
fi
|
|
|
|
repo sync -c -j$(nproc)
|
|
|
|
# Device tree (gitea mirror of this repo)
|
|
if [ ! -d device/samsung/rubenslte ]; then
|
|
git clone --depth 1 https://git.cfpi-fpsi.eu/rubenslte/twrp_device_samsung_rubenslte device/samsung/rubenslte
|
|
fi
|
|
|
|
# Kernel built from source (gitea mirror of Samsung msm8226 stock tree)
|
|
if [ ! -d kernel/samsung/rubenslte ]; then
|
|
git clone --depth 1 https://git.cfpi-fpsi.eu/rubenslte/android_kernel_samsung_rubenslte kernel/samsung/rubenslte
|
|
fi
|
|
|
|
for p in "$SCRIPT"/patches/*.patch; do
|
|
patch -p1 -s < "$p" 2>/dev/null || true
|
|
done
|
|
|
|
# arm-eabi-4.8 cross toolchain (AOSP prebuilt, plain gcc host binary)
|
|
ARM_EABI_DIR="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8"
|
|
if [ ! -x "$ARM_EABI_DIR/bin/arm-eabi-gcc" ]; then
|
|
echo "[*] Downloading arm-eabi-4.8 prebuilt toolchain ..."
|
|
mkdir -p "$ARM_EABI_DIR"
|
|
curl -L --fail \
|
|
"https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/+archive/refs/tags/android-5.1.1_r38.tar.gz" \
|
|
| tar -xz -C "$ARM_EABI_DIR"
|
|
fi
|
|
export PATH="$PWD/$ARM_EABI_DIR/bin:$PATH"
|
|
|
|
export TOP="$PWD"
|
|
set +u
|
|
source build/envsetup.sh
|
|
lunch omni_rubenslte-userdebug
|
|
set -u
|
|
mka recoveryimage
|
|
|
|
cp out/target/product/rubenslte/recovery.img "$SCRIPT/"
|
|
echo "Done: $SCRIPT/recovery.img" |