|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# get threads for tasks |
| 4 | +JOBS=$(($(nproc) + 1)) |
| 5 | + |
| 6 | +# prompt for root and install necessary packages |
| 7 | +sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf |
| 8 | +> imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev |
| 9 | +> libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc |
| 10 | +> zip zlib1g-dev |
| 11 | + |
| 12 | +# rom type? |
| 13 | +read -p "Do ya want android (t) or android tv (f)? " FOSTERTYPE |
| 14 | + |
| 15 | +# check to see if git is configured, if not prompt user |
| 16 | +if ["$(git config --list)" != *"user.email"*] |
| 17 | +then |
| 18 | + read -p "Enter your git email address: " GITEMAIL |
| 19 | + read -p "Enter your name: " GITNAME |
| 20 | + git config --global user.email $GITEMAIL |
| 21 | + git config --global user.name $GITNAME |
| 22 | +fi |
| 23 | + |
| 24 | +# clean build? |
| 25 | +if [ ! -d ./android ]; |
| 26 | +then |
| 27 | + # download and unzip latest platform tools |
| 28 | + wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip |
| 29 | + unzip platform-tools-latest-linux.zip -d ~ |
| 30 | + cd ../ |
| 31 | + |
| 32 | + # check for platform tools in PATH, add if missing |
| 33 | + if ! grep -q "PATH=\"$HOME/platform-tools:$PATH\"" "~/.profile" ; |
| 34 | + then |
| 35 | + echo "if [ -d \"$HOME/platform-tools\" ] ; then" >> ~/.profile |
| 36 | + echo " PATH=\"$HOME/platform-tools:$PATH\"" >> ~/.profile |
| 37 | + echo "fi" >> ~/.profile |
| 38 | + fi |
| 39 | + |
| 40 | + # create directories and get repo |
| 41 | + mkdir -p ~/bin |
| 42 | + mkdir -p ~/android/lineage |
| 43 | + curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo |
| 44 | + chmod a+x ~/bin/repo |
| 45 | + |
| 46 | + # check for bin in PATH, add if missing |
| 47 | + if ! grep -q "PATH=\"$HOME/bin:$PATH\"" "~/.profile" ; |
| 48 | + then |
| 49 | + echo "if [ -d \"$HOME/bin\" ] ; then" >> ~/.profile |
| 50 | + echo " PATH=\"$HOME/bin:$PATH\"" >> ~/.profile |
| 51 | + echo "fi" >> ~/.profile |
| 52 | + fi |
| 53 | + |
| 54 | + # initialize repo, sync |
| 55 | + cd ~/android/lineage |
| 56 | + repo init -u https://github.com/LineageOS/android.git -b lineage-17.1 |
| 57 | + repo sync --force-sync -j${JOBS} |
| 58 | + git clone https://gitlab.com/switchroot/android/manifest.git -b lineage-17.1 .repo/local_manifests |
| 59 | +fi |
| 60 | + |
| 61 | +# update stuff (used for clean too but kinda unnecessary) |
| 62 | +cd ~/android/lineage |
| 63 | +repo forall -c 'git reset --hard' |
| 64 | +repo forall -c 'git clean -fdd' |
| 65 | +cd .repo/local_manifests |
| 66 | +git pull |
| 67 | +cd ../../ |
| 68 | +repo sync --force-sync -j${JOBS} |
| 69 | +./build/envsetup.sh |
| 70 | + |
| 71 | +# repopicks |
| 72 | +repopick -t nvidia-enhancements-q |
| 73 | +repopick -t nvidia-nvgpu-q |
| 74 | +repopick -t nvidia-shieldtech-q |
| 75 | +repopick -t icosa-bt-lineage-17.1 |
| 76 | +repopick 287339 |
| 77 | +repopick 284553 |
| 78 | + |
| 79 | +# patch bionic_intrinsics, nvcpl, oc, joycond, and foster |
| 80 | +cd bionic |
| 81 | +patch -p1 < ../.repo/local_manifests/patches/bionic_intrinsics.patch |
| 82 | +cd ../frameworks/base |
| 83 | +patch -p1 < ../../.repo/local_manifests/patches/frameworks_base_nvcpl.patch |
| 84 | +cd ../../kernel/nvidia/linux-4.9/kernel/kernel-4.9 |
| 85 | +patch -p1 < ../../../../../.repo/local_manifests/patches/oc-android10.patch |
| 86 | +cd ~/android/lineage/hardware/nintendo/joycond |
| 87 | +patch -p1 < ../../../.repo/local_manifests/patches/joycond10.patch |
| 88 | +wget -O .repo/android_device_nvidia_foster.patch https://gitlab.com/ZachyCatGames/q-tips-guide/-/raw/master/res/android_device_nvidia_foster.patch |
| 89 | +cd ~/android/lineage/device/nvidia/foster |
| 90 | +rm patch -p1 < ../../../.repo/android_device_nvidia_foster.patch |
| 91 | +patch -p1 < ../../../.repo/android_device_nvidia_foster.patch |
| 92 | +cd ../../../ |
| 93 | + |
| 94 | +# ccache |
| 95 | +export USE_CCACHE=1 |
| 96 | +export CCACHE_EXEC="/usr/bin/ccache" |
| 97 | +export WITHOUT_CHECK_API=true |
| 98 | +ccache -M 50G |
| 99 | + |
| 100 | +### Rebuild (clean) |
| 101 | +mkdir -p ./out/target/product/$OUTPUTFILE/vendor/lib/modules |
| 102 | +sh ./build/envsetup.sh |
| 103 | + |
| 104 | +# check rom type and assign gapps type and rom type |
| 105 | +if [$FOSTERTYPE == "t"]; |
| 106 | +then |
| 107 | + TYPE = "tvstock" |
| 108 | + OUTPUTFILE = "foster" |
| 109 | + lunch lineage_foster-userdebug |
| 110 | +else |
| 111 | + TYPE = "pico" |
| 112 | + OUTPUTFILE = "foster_tab" |
| 113 | + lunch lineage_foster_tab-userdebug |
| 114 | +fi |
| 115 | +make -j${JOBS} bacon |
| 116 | + |
| 117 | +## This script copies the build output to the output dir |
| 118 | +## so it can be used by hekate |
| 119 | + |
| 120 | +cd ${BUILDBASE} |
| 121 | + |
| 122 | +ZIP_FILE=$(ls -rt ~/android/lineage/out/target/product/$OUTPUTFILE/lineage-17.1-*-UNOFFICIAL-$OUTPUTFILE.zip | tail -1) |
| 123 | + |
| 124 | +## Copy to output |
| 125 | +echo "Creating switchroot install dir..." |
| 126 | +mkdir -p ./android/output/switchroot/install |
| 127 | +echo "Creating switchroot android dir..." |
| 128 | +mkdir -p ./android/output/switchroot/android |
| 129 | +echo "Downloading hekate..." |
| 130 | +LATEST_HEKATE=$(curl -sL https://github.com/CTCaer/hekate/releases/latest | grep -o '/CTCaer/hekate/releases/download/.*/hekate_ctcaer.*zip') |
| 131 | +curl -L -o ./hekate.zip https://github.com/$LATEST_HEKATE |
| 132 | +unzip -u ./hekate.zip -d ./android/output/ |
| 133 | +echo "Creating bootloader config dir..." |
| 134 | +mkdir -p ./android/output/bootloader/ini |
| 135 | +echo "Copying build zip to SD Card..." |
| 136 | +cp $ZIP_FILE ~/android/output/ |
| 137 | +echo "Copying build combined kernel and ramdisk..." |
| 138 | +cp ~/android/lineage/out/target/product/$OUTPUTFILE/boot.img ./android/output/switchroot/install/ |
| 139 | +echo "Copying build dtb..." |
| 140 | +cp ~/android/lineage/out/target/product/$OUTPUTFILE/obj/KERNEL_OBJ/arch/arm64/boot/dts/tegra210-icosa.dtb ./android/output/switchroot/install/ |
| 141 | +echo "Downloading twrp..." |
| 142 | +curl -L -o ~/android/output/switchroot/install/twrp.img https://github.com/PabloZaiden/switchroot-android-build/raw/master/external/twrp.img |
| 143 | +echo "Downloading coreboot.rom..." |
| 144 | +curl -L -o ~/android/output/switchroot/android/coreboot.rom https://github.com/PabloZaiden/switchroot-android-build/raw/master/external/coreboot.rom |
| 145 | +echo "Downloading 00-android.ini..." |
| 146 | +curl -L -o ~/android/output/bootloader/ini/00-android.ini https://gitlab.com/ZachyCatGames/shitty-pie-guide/-/raw/master/res/00-android.ini?inline=false |
| 147 | +echo "Downloading boot scripts..." |
| 148 | +curl -L -o ~/android/output/switchroot/android/common.scr https://gitlab.com/switchroot/bootstack/switch-uboot-scripts/-/jobs/artifacts/master/raw/common.scr?job=build |
| 149 | +curl -L -o ~/android/output/switchroot/android/boot.scr https://gitlab.com/switchroot/bootstack/switch-uboot-scripts/-/jobs/artifacts/master/raw/sd.scr?job=build |
| 150 | +echo "Downloading Pico Open GApps..." |
| 151 | + |
| 152 | +# get base URL for pico gapps |
| 153 | +BASE_GAPPS_URL=$(curl -L https://sourceforge.net/projects/opengapps/rss?path=/arm64 \ |
| 154 | + | grep -Po "https:\/\/.*10\.0-${TYPE}.*zip\/download" \ |
| 155 | + | head -n 1 \ |
| 156 | + | sed "s/\/download//" \ |
| 157 | + | sed "s/files\///" \ |
| 158 | + | sed "s/projects/project/" \ |
| 159 | + | sed "s/sourceforge/downloads\.sourceforge/") |
| 160 | + |
| 161 | +TIMESTAMP=$(echo $(( $(date '+%s%N') / 1000000000))) |
| 162 | +FULL_GAPPS_URL=$(echo $BASE_GAPPS_URL"?use_mirror=autoselect&ts="$TIMESTAMP) |
| 163 | +curl -L -o ./android/output/opengapps_${TYPE}.zip $FULL_GAPPS_URL |
| 164 | + |
| 165 | +## Patch zip file to accept any bootloader version |
| 166 | +OUTPUT_ZIP_FILE=$(ls -rt ~/android/output/lineage-17.1-*-UNOFFICIAL-${OUTPUTFILE}.zip | tail -1) |
| 167 | + |
| 168 | +mkdir -p ./META-INF/com/google/android/ |
| 169 | +unzip -p $OUTPUT_ZIP_FILE META-INF/com/google/android/updater-script > ./META-INF/com/google/android/updater-script.original |
| 170 | +sed -E 's/getprop\(\"ro\.bootloader\"\)/true || getprop\(\"ro\.bootloader\"\)/g' < ./META-INF/com/google/android/updater-script.original > ./META-INF/com/google/android/updater-script |
| 171 | +rm ./META-INF/com/google/android/updater-script.original |
| 172 | +zip -u $OUTPUT_ZIP_FILE META-INF/com/google/android/updater-script |
| 173 | +rm -rf ./META-INF/com/google/android/ |
| 174 | + |
0 commit comments