Advertisement
Aclegg2011

Untitled

Feb 29th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.26 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. rom_fp="$(date +%y%m%d)"
  4. rompath=$(pwd)
  5. mkdir -p release/$rom_fp/
  6. # Comment out 'set -e' if your session terminates.
  7. set -e
  8.  
  9. localManifestBranch="q"
  10. rom="bliss"
  11. bliss_variant=""
  12. bliss_variant_name=""
  13. bliss_release="n"
  14. bliss_partiton=""
  15. filename=""
  16. file_size=""
  17. clean="n"
  18. sync="n"
  19. patch="n"
  20. romBranch=""
  21. ver=$(date +"%F")
  22.  
  23. if [ -z "$USER" ];then
  24. export USER="$(id -un)"
  25. fi
  26. export LC_ALL=C
  27.  
  28. if [[ $(uname -s) = "Darwin" ]];then
  29. jobs=$(sysctl -n hw.ncpu)
  30. elif [[ $(uname -s) = "Linux" ]];then
  31. jobs=$(nproc)
  32. fi
  33.  
  34.  
  35. while test $# -gt 0
  36. do
  37. case $1 in
  38.  
  39. # Normal option processing
  40. -h | --help)
  41. echo "Usage: $0 options buildVariants blissBranch"
  42. echo "options: -c | --clean : Does make clean && make clobber and resets the treble device tree"
  43. echo " -r | --release : Builds a twrp zip of the rom (only for A partition) default creates system.img"
  44. echo " -s | --sync: Repo syncs the rom (clears out patches), then reapplies patches to needed repos"
  45. echo ""
  46. echo "buildVariants: arm64_a_stock | arm64_ab_stock : Vanilla Rom"
  47. echo " arm64_a_gapps | arm64_ab_gapps : Stock Rom with Gapps Built-in"
  48. echo " arm64_a_foss | arm64_ab_foss : Stock Rom with Foss"
  49. echo " arm64_a_go | arm64_ab_go : Stock Rom with Go-Gapps"
  50. echo ""
  51. echo "blissBranch: select which bliss branch to sync, default is o8.1-los"
  52. ;;
  53. -v | --version)
  54. echo "Version: Bliss Treble Builder 0.3"
  55. echo "Updated: 7/29/2018"
  56. ;;
  57. -c | --clean)
  58. clean="y";
  59. echo "Cleaning build and device tree selected."
  60. ;;
  61. -r | --release)
  62. bliss_release="y";
  63. echo "Building as release selected."
  64. ;;
  65. -s | --sync)
  66. sync="y"
  67. echo "Repo syncing and patching selected."
  68. ;;
  69. -p | --patch)
  70. patch="y";
  71. echo "patching selected."
  72. ;;
  73. # ...
  74.  
  75. # Special cases
  76. --)
  77. break
  78. ;;
  79. --*)
  80. # error unknown (long) option $1
  81. ;;
  82. -?)
  83. # error unknown (short) option $1
  84. ;;
  85.  
  86. # FUN STUFF HERE:
  87. # Split apart combined short options
  88. -*)
  89. split=$1
  90. shift
  91. set -- $(echo "$split" | cut -c 2- | sed 's/./-& /g') "$@"
  92. continue
  93. ;;
  94.  
  95. # Done with options
  96. *)
  97. break
  98. ;;
  99. esac
  100.  
  101. # for testing purposes:
  102. shift
  103. done
  104.  
  105. if [ "$1" = "arm64_a_stock" ];then
  106. bliss_variant=treble_arm64_avN-userdebug;
  107. bliss_variant_name=arm64-a-stock;
  108. bliss_partition="a";
  109.  
  110. elif [ "$1" = "arm64_a_gapps" ];then
  111. bliss_variant=treble_arm64_agS-userdebug;
  112. bliss_variant_name=arm64-a-gapps;
  113. bliss_partition="a";
  114.  
  115. elif [ "$1" = "arm64_a_foss" ];then
  116. bliss_variant=treble_arm64_afS-userdebug;
  117. bliss_variant_name=arm64-a-foss;
  118. bliss_partition="a";
  119.  
  120. elif [ "$1" = "arm64_a_go" ];then
  121. bliss_variant=treble_arm64_aoS-userdebug;
  122. bliss_variant_name=arm64-a-go;
  123. bliss_partition="a";
  124.  
  125. elif [ "$1" = "arm64_ab_stock" ];then
  126. bliss_variant=treble_arm64_bvN-userdebug;
  127. bliss_variant_name=arm64-ab-stock;
  128. bliss_partition="ab";
  129.  
  130. elif [ "$1" = "arm64_ab_gapps" ];then
  131. bliss_variant=treble_arm64_bgS-userdebug;
  132. bliss_variant_name=arm64-ab-gapps;
  133. bliss_partition="ab";
  134.  
  135. elif [ "$1" = "arm64_ab_foss" ];then
  136. bliss_variant=treble_arm64_bfS-userdebug;
  137. bliss_variant_name=arm64-ab-foss;
  138. bliss_partition="ab";
  139.  
  140. elif [ "$1" = "arm64_ab_go" ];then
  141. bliss_variant=treble_arm64_boS-userdebug;
  142. bliss_variant_name=arm64-ab-go;
  143. bliss_partition="ab";
  144. else
  145. echo "you need to at least use '--help'"
  146. fi
  147.  
  148. if [ "$2" = "" ];then
  149. romBranch="q"
  150. echo "Using branch $romBranch for repo syncing Bliss."
  151. else
  152. romBranch="$2"
  153. echo "Using branch $romBranch for repo syning Bliss."
  154. fi
  155.  
  156. if [ $sync == "y" ];then
  157. repo init -u https://github.com/BlissRoms/platform_manifest.git -b $romBranch
  158. rm -f .repo/local_manifests/replace.xml
  159. if [ -d $rompath/.repo/local_manifests ] ;then
  160. cp -r $rompath/vendor/bliss/treble/manifests/* $rompath/.repo/local_manifests
  161. else
  162. mkdir -p $rompath/.repo/local_manifests
  163. cp -r $rompath/vendor/bliss/treble/manifests/* $rompath/.repo/local_manifests
  164. fi
  165.  
  166. repo sync -c -j$jobs --no-tags --no-clone-bundle --force-sync
  167.  
  168. else
  169. echo "Not gonna sync this round"
  170. fi
  171.  
  172. rm -f device/*/sepolicy/common/private/genfs_contexts
  173.  
  174. if [ $clean == "y" ];then
  175. (cd device/phh/treble; git clean -fdx; bash generate.sh $rom)
  176. make clean && make clobber
  177. else
  178. (cd device/phh/treble; bash generate.sh $rom)
  179. fi
  180.  
  181. sed -i -e 's/BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736/BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648/g' device/phh/treble/phhgsi_arm64_a/BoardConfig.mk
  182.  
  183. #if [ $sync == "y" ];then
  184. #if [ -z "$local_patches" ];then
  185. # if [ -d patches ];then
  186. # ( cd vendor/bliss/treble/patches/patches; git fetch; git reset --hard; git checkout origin/$localManifestBranch)
  187. # else
  188. # git clone https://github.com/aclegg2011/treble_patches vendor/bliss/treble/patches -b $localManifestBranch
  189. # fi
  190. #else
  191. # rm -Rf vendor/bliss/treble/patches/patches
  192. # mkdir vendor/bliss/treble/patches/patches
  193. # unzip "$local_patches" -d patches
  194. #fi
  195. #echo "Let the patching begin"
  196. #bash "$rompath/vendor/bliss/treble/apply-patches.sh" $rompath/vendor/bliss/treble/patches/patches
  197. #fi
  198.  
  199. #if [[ $patch == "y" ]];then
  200. echo "Let the patching begin"
  201. bash "$rompath/vendor/bliss/treble/apply-patches.sh" $rompath/vendor/bliss/treble/patches
  202. #fi
  203.  
  204. #blissRelease(){
  205. #if [[ "$1" = "y" && $bliss_partition = "a" ]];then
  206. # echo "Building twrp flashable gsi.."
  207. # if [ -d $OUT/img2sdat ] ;then
  208. # cp -r $rompath/build/make/core/treble/img2sdat/* $OUT/img2sdat
  209. # else
  210. # mkdir -p $OUT/img2sdat
  211. # cp -r $rompath/build/make/core/treble/img2sdat/* $OUT/img2sdat
  212. # fi
  213. # if [ -d $OUT/twrp_flashables ] ;then
  214. # cp -r $rompath/build/make/core/treble/twrp_flashables/* $OUT/twrp_flashables
  215. # else
  216. # mkdir -p $OUT/twrp_flashables
  217. # cp -r $rompath/build/make/core/treble/twrp_flashables/* $OUT/twrp_flashables
  218. # fi
  219. # cp $OUT/system.img $OUT/img2sdat/system.img
  220. # cd $OUT/img2sdat
  221. # ./img2sdat.py system.img -o tmp -v 4
  222. # cd $rompath
  223. # cp $OUT/img2sdat/tmp/* $OUT/twrp_flashables/arm64a
  224. # cd $OUT/twrp_flashables/arm64a
  225. # 7za a -tzip arm64a.zip *
  226. # cd $rompath
  227. # cp $OUT/twrp_flashables/arm64a/arm64a.zip $rompath/release/$rom_fp/Bliss-$ver-$bliss_variant_name.zip
  228. # rm -rf $OUT/img2sdat $OUT/twrp_flashables
  229. # filename=Bliss-$ver-$bliss_variant_name.zip
  230. # filesize=$(stat -c%s release/$rom_fp/$filename)
  231. # md5sum release/$rom_fp/Bliss-$ver-$bliss_variant_name.zip > release/$rom_fp/Bliss-$ver-$bliss_variant_name.zip.md5
  232. # md5sum_file=Bliss-$ver-$bliss_variant_name.zip.md5
  233. #else
  234. # if [[ "$1" = "n" || $bliss_partition = "ab" ]];then
  235. # echo "Twrp Building is currently not suported on a/b"
  236. # fi
  237. # echo "Compressing and Copying $OUT/system.img -> release/$rom_fp/Bliss-$ver-$bliss_variant_name.img.xz"
  238. # xz -c $OUT/system.img > release/$rom_fp/Bliss-$ver-$bliss_variant_name.img.xz
  239. # filename=Bliss-$ver-$bliss_variant_name.img.xz
  240. # filesize=$(stat -c%s release/$rom_fp/$filename)
  241. # md5sum release/$rom_fp/Bliss-$ver-$bliss_variant_name.img.xz > release/$rom_fp/Bliss-$ver-$bliss_variant_name.img.xz.md5
  242. # md5sum_file=Bliss-$ver-$bliss_variant_name.img.xz.md5
  243. #fi
  244. #}
  245.  
  246. blissHeader(){
  247. file_size=$(echo "${filesize}" | awk '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }')
  248. echo -e ""
  249. echo -e " ___ ___ ___ ___ "
  250. echo -e " /\ \ /\__\ ___ /\ \ /\ \ "
  251. echo -e " /::\ \ /:/ / /\ \ /::\ \ /::\ \ "
  252. echo -e " /:/\:\ \ /:/ / \:\ \ /:/\ \ \ /:/\ \ \ "
  253. echo -e " /::\~\:\__\ /:/ / /::\__\ _\:\~\ \ \ _\:\~\ \ \ "
  254. echo -e " /:/\:\ \:\__\ /:/__/ __/:/\/__/ /\ \:\ \ \__\ /\ \:\ \ \__\ "
  255. echo -e " \:\~\:\/:/ / \:\ \ /\/:/ / \:\ \:\ \/__/ \:\ \:\ \/__/ "
  256. echo -e " \:\ \::/ / \:\ \ \::/__/ \:\ \:\__\ \:\ \:\__\ "
  257. echo -e " \:\/:/ / \:\ \ \:\__\ \:\/:/ / \:\/:/ / "
  258. echo -e " \::/__/ \:\__\ \/__/ \::/ / \::/ / "
  259. echo -e " ~~ \/__/ \/__/ \/__/ "
  260. echo -e ""
  261. echo -e "===========-Bliss Package Complete-==========="
  262. echo -e "File: $1"
  263. echo -e "MD5: $3"
  264. echo -e "Size: $file_size"
  265. echo -e "==============================================="
  266. echo -e "Have A Truly Blissful Experience"
  267. echo -e "==============================================="
  268. echo -e ""
  269. }
  270.  
  271. if [[ "$1" = "arm64_a_stock" || "$1" = "arm64_a_gapps" || "$1" = "arm64_a_foss" || "$1" = "arm64_a_go" || "$1" = "arm64_ab_stock" || "$1" = "arm64_ab_gapps" || "$1" = "arm64_ab_foss" || "$1" = "arm64_ab_go" ]];then
  272. echo "Setting up build env for $1"
  273. . build/envsetup.sh
  274. fi
  275.  
  276. buildVariant() {
  277. ## echo "running lunch for $1"
  278. ## lunch $1
  279. echo "Running lunch for $bliss_variant"
  280. lunch $bliss_variant
  281. make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp installclean
  282. make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp -j$jobs systemimage
  283. make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp vndk-test-sepolicy
  284. blissRelease $bliss_release $bliss_partition
  285. blissHeader $filename $filesize $md5sum_file
  286. }
  287.  
  288. if [[ "$1" = "arm64_a_stock" || "$1" = "arm64_a_gapps" || "$1" = "arm64_a_foss" || "$1" = "arm64_a_go" || "$1" = "arm64_ab_stock" || "$1" = "arm64_ab_gapps" || "$1" = "arm64_ab_foss" || "$1" = "arm64_ab_go" ]];then
  289. buildVariant $bliss_variant $bliss_variant_name
  290. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement