Files
builders_rubenslte/build.sh
T

93 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
readonly ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
readonly BUILD="$ROOT/build-lineage-16.0"
readonly MANIFEST_URL="https://github.com/LineageOS/android.git"
readonly MANIFEST_BRANCH="lineage-16.0"
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 <<EOF
usage: $0 [-hn] [bootimage|bacon|clean|prune]
flags:
-h show this help
-n don't sync
commands:
bootimage build boot.img (kernel + dt.img + ramdisk, fast gate)
twrp build TWRP recovery.img
bacon full build -> lineage_rubenslte-*.zip
clean mka clean
prune remove all of "$BUILD"
EOF
}
do_build() {
mkdir -p "$BUILD"
cd "$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.xml" .repo/local_manifests/
fi
if [ ! -v "NO_SYNC" ]; then
rlte_print "Syncing repositories"
repo sync -c -j"$(nproc)"
fi
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)"
if [ "$CMD" = "twrp" ]; then
WITH_TWRP=true mka recoveryimage
else
mka "$CMD"
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|twrp|bacon|clean) CMD="${1:-}"; do_build ;;
prune) rm -rf "$BUILD" ;;
*) usage; exit 1 ;;
esac