89 lines
2.0 KiB
Bash
Executable File
89 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
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
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
usage: $0 [-hn] [build|clean|prune]
|
|
|
|
flags:
|
|
-h show this help
|
|
-n don't sync
|
|
|
|
commands:
|
|
build build recovery.img (must be explicit)
|
|
clean remove twrp-build/out and recovery.img
|
|
prune remove all of twrp-build and recovery.img
|
|
EOF
|
|
}
|
|
|
|
do_build() {
|
|
mkdir -p twrp-build
|
|
cd twrp-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/twrp"
|
|
|
|
export LC_ALL=C LANG=C LC_CTYPE=C TOP="$PWD"
|
|
|
|
set +u
|
|
source build/envsetup.sh
|
|
lunch omni_rubenslte-userdebug
|
|
set -u
|
|
|
|
rlte_print "Commencing TWRP build"
|
|
mka recoveryimage
|
|
|
|
if [ ! -f out/target/product/rubenslte/recovery.img ]; then
|
|
rlte_error "Build did not produce recovery.img"
|
|
exit 1
|
|
fi
|
|
|
|
cp out/target/product/rubenslte/recovery.img "$ROOT/recovery.img"
|
|
|
|
if [ "$(stat -c%s "$ROOT/recovery.img")" -gt "$RECOVERY_BUDGET" ]; then
|
|
rlte_error "$ROOT/recovery.img exceeds the recovery partition budget"
|
|
exit 1
|
|
fi
|
|
|
|
rlte_ok "Image at: $ROOT/recovery.img"
|
|
}
|
|
|
|
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
|
|
build) do_build ;;
|
|
clean) rm -rf twrp-build/out recovery.img ;;
|
|
prune) rm -rf twrp-build recovery.img ;;
|
|
*) usage; exit 1 ;;
|
|
esac
|