Advertisement
Guest User

Untitled

a guest
Sep 6th, 2021
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.15 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. rom_fp="$(date +%y%m%d)"
  4. originFolder="$(dirname "$0")"
  5. mkdir -p release/$rom_fp/
  6. set -e
  7.  
  8. if [ -z "$USER" ];then
  9. export USER="$(id -un)"
  10. fi
  11. export LC_ALL=C
  12.  
  13. manifest_url="https://android.googlesource.com/platform/manifest"
  14. aosp="android-8.1.0_r65"
  15. phh="android-8.1"
  16.  
  17. build_target="$1"
  18. rebuild_release=""
  19. if [ "$1" == "android-9.0" ];then
  20. manifest_url="https://gitlab.com/aosp-security/manifest"
  21. aosp="android-9.0.0_r53-r47"
  22. phh="android-9.0"
  23. elif [ "$1" == "android-10.0" ];then
  24. manifest_url="https://android.googlesource.com/platform/manifest"
  25. aosp="android-10.0.0_r41"
  26. phh="android-10.0"
  27. elif [ "$1" == "android-11.0" ];then
  28. manifest_url="https://android.googlesource.com/platform/manifest"
  29. aosp="android-11.0.0_r40"
  30. phh="android-11.0"
  31. else
  32. # guess android version from version number
  33. rebuild_release="yes"
  34. if [ -n "$(echo $1 | grep -E '^v3..')" ];then
  35. build_target="android-11.0"
  36. elif [ -n "$(echo $1 | grep -E '^v2..')" ];then
  37. build_target="android-10.0"
  38. elif [ -n "$(echo $1 | grep -E '^v1..')" ];then
  39. build_target="android-9.0"
  40. else
  41. build_target="android-8.1"
  42. fi
  43. # download manifest with the given version number
  44. tmp_manifest_source=$(mktemp -d)
  45. wget "https://github.com/phhusson/treble_experimentations/releases/download/$1/manifest.xml" -O $tmp_manifest_source/manifest.xml
  46. sed -i 's/<remote name="aosp" fetch=".." review="https:\/\/android-review.googlesource.com\/"\/>/<remote name="aosp" fetch="https:\/\/android.googlesource.com\/" review="https:\/\/android-review.googlesource.com\/"\/>/' $tmp_manifest_source/manifest.xml
  47. (cd $tmp_manifest_source; git init; git add manifest.xml; git commit -m "$1")
  48. fi
  49.  
  50. if [ "$release" == true ];then
  51. [ -z "$version" ] && exit 1
  52. [ ! -f "$originFolder/release/config.ini" ] && exit 1
  53. fi
  54.  
  55. if [ -n "$rebuild_release" ];then
  56. repo init -u "$tmp_manifest_source" -m manifest.xml
  57. else
  58. repo init -u "$manifest_url" -b $aosp
  59. if [ -d .repo/local_manifests ] ;then
  60. ( cd .repo/local_manifests; git fetch; git reset --hard; git checkout origin/$phh)
  61. else
  62. git clone https://github.com/phhusson/treble_manifest .repo/local_manifests -b $phh
  63. fi
  64. fi
  65. repo sync -c -j 1 --force-sync
  66.  
  67. repo forall -r '.*opengapps.*' -c 'git lfs fetch && git lfs checkout'
  68. (cd device/phh/treble; git clean -fdx; bash generate.sh)
  69. (cd vendor/foss; git clean -fdx; bash update.sh)
  70. rm -f vendor/gapps/interfaces/wifi_ext/Android.bp
  71.  
  72. . build/envsetup.sh
  73.  
  74. buildVariant() {
  75. lunch $1
  76. make BUILD_NUMBER=$rom_fp installclean
  77. make BUILD_NUMBER=$rom_fp -j8 systemimage
  78. make BUILD_NUMBER=$rom_fp vndk-test-sepolicy
  79. xz -c $OUT/system.img -T0 > release/$rom_fp/system-${2}.img.xz
  80. }
  81.  
  82. repo manifest -r > release/$rom_fp/manifest.xml
  83. bash "$originFolder"/list-patches.sh
  84. cp patches.zip release/$rom_fp/patches.zip
  85.  
  86. if [ "$build_target" == "android-11.0" ];then
  87. (
  88. git clone https://github.com/phhusson/sas-creator
  89. cd sas-creator
  90.  
  91. git clone https://github.com/phhusson/vendor_vndk -b android-10.0
  92. )
  93.  
  94. # ARM64 vanilla {ab, a-only, ab vndk lite}
  95. buildVariant treble_arm64_bvS-userdebug roar-arm64-ab-vanilla
  96. ( cd sas-creator; bash run.sh 64 ; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm64-aonly-vanilla.img.xz)
  97. ( cd sas-creator; bash lite-adapter.sh 64; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm64-ab-vndklite-vanilla.img.xz )
  98.  
  99. # ARM64 floss {ab, a-only, ab vndk lite}
  100. buildVariant treble_arm64_bfS-userdebug roar-arm64-ab-floss
  101. ( cd sas-creator; bash run.sh 64 ; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm64-aonly-floss.img.xz)
  102. ( cd sas-creator; bash lite-adapter.sh 64; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm64-ab-vndklite-floss.img.xz )
  103.  
  104. # ARM32 vanilla {ab, a-only}
  105. buildVariant treble_arm_bvS-userdebug roar-arm-ab-vanilla
  106. ( cd sas-creator; bash run.sh 32; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm-aonly-vanilla.img.xz )
  107.  
  108. # ARM32 gogapps {ab, a-only}
  109. buildVariant treble_arm_boS-userdebug roar-arm-ab-gogapps
  110. ( cd sas-creator; bash run.sh 32; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm-aonly-gogapps.img.xz )
  111.  
  112. # ARM32_binder64 vanilla {ab, ab vndk lite}
  113. buildVariant treble_a64_bvS-userdebug roar-arm32_binder64-ab-vanilla
  114. ( cd sas-creator; bash lite-adapter.sh 32; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm32_binder64-ab-vndklite-vanilla.img.xz)
  115.  
  116. # ARM64 Gapps {ab, a-only, ab vndk lite}
  117. buildVariant treble_arm64_bgS-userdebug roar-arm64-ab-gapps
  118. ( cd sas-creator; bash run.sh 64 ; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm64-aonly-gapps.img.xz)
  119. ( cd sas-creator; bash lite-adapter.sh 64; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm64-ab-vndklite-gapps.img.xz )
  120.  
  121. # ARM32_binder64 go gapps {ab, ab vndk lite}
  122. buildVariant treble_a64_boS-userdebug roar-arm32_binder64-ab-gogapps
  123. ( cd sas-creator; bash lite-adapter.sh 32; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm32_binder64-ab-vndklite-gogapps.img.xz )
  124.  
  125. # ARM32_binder64 gapps {ab, ab vndk lite}
  126. buildVariant treble_a64_bgS-userdebug roar-arm32_binder64-ab-gapps
  127. ( cd sas-creator; bash lite-adapter.sh 32; xz -c s.img -T0 > ../release/$rom_fp/system-roar-arm32_binder64-ab-vndklite-gapps.img.xz )
  128. elif [ "$build_target" == "android-10.0" ];then
  129. buildVariant treble_arm64_afS-userdebug quack-arm64-aonly-floss
  130. buildVariant treble_arm64_avS-userdebug quack-arm64-aonly-vanilla
  131. buildVariant treble_arm64_agS-userdebug quack-arm64-aonly-gapps
  132. buildVariant treble_arm64_aoS-userdebug quack-arm64-aonly-go
  133. buildVariant treble_arm64_bfS-userdebug quack-arm64-ab-floss
  134. buildVariant treble_arm64_bvS-userdebug quack-arm64-ab-vanilla
  135. buildVariant treble_arm64_bgS-userdebug quack-arm64-ab-gapps
  136. buildVariant treble_arm64_boS-userdebug quack-arm64-ab-go
  137. buildVariant treble_arm_avS-userdebug quack-arm-aonly-vanilla
  138. buildVariant treble_arm_agS-userdebug quack-arm-aonly-gapps
  139. buildVariant treble_arm_aoS-userdebug quack-arm-aonly-go
  140. buildVariant treble_arm_bvS-userdebug quack-arm-ab-vanilla
  141. buildVariant treble_arm_bgS-userdebug quack-arm-ab-gapps
  142. buildVariant treble_arm_boS-userdebug quack-arm-ab-go
  143. buildVariant treble_a64_avS-userdebug quack-arm32_binder64-aonly-vanilla
  144. buildVariant treble_a64_agS-userdebug quack-arm32_binder64-aonly-gapps
  145. buildVariant treble_a64_aoS-userdebug quack-arm32_binder64-aonly-go
  146. buildVariant treble_a64_bvS-userdebug quack-arm32_binder64-ab-vanilla
  147. buildVariant treble_a64_bgS-userdebug quack-arm32_binder64-ab-gapps
  148. buildVariant treble_a64_boS-userdebug quack-arm32_binder64-ab-go
  149. else
  150. buildVariant treble_arm64_avN-userdebug arm64-aonly-vanilla-nosu
  151. buildVariant treble_arm64_agS-userdebug arm64-aonly-gapps-su
  152. #buildVariant treble_arm64_afS-userdebug arm64-aonly-floss-su
  153. rm -Rf out/target/product/phhgsi*
  154.  
  155. buildVariant treble_arm64_bvN-userdebug arm64-ab-vanilla-nosu
  156. buildVariant treble_arm64_bgS-userdebug arm64-ab-gapps-su
  157. #buildVariant treble_arm64_bfS-userdebug arm64-ab-floss-su
  158. rm -Rf out/target/product/phhgsi*
  159.  
  160. buildVariant treble_arm_avN-userdebug arm-aonly-vanilla-nosu
  161. [ "$build_target" != "android-9.0" ] && buildVariant treble_arm_aoS-userdebug arm-aonly-go-su
  162. buildVariant treble_arm_agS-userdebug arm-aonly-gapps-su
  163. rm -Rf out/target/product/phhgsi*
  164.  
  165. buildVariant treble_a64_avN-userdebug arm32_binder64-aonly-vanilla-nosu
  166. buildVariant treble_a64_agS-userdebug arm32_binder64-aonly-gapps-su
  167. rm -Rf out/target/product/phhgsi*
  168.  
  169. if [ "$build_target" == "android-9.0" ];then
  170. buildVariant treble_a64_bvN-userdebug arm32_binder64-ab-vanilla-nosu
  171. buildVariant treble_a64_bgS-userdebug arm32_binder64-ab-gapps-su
  172. fi
  173. rm -Rf out/target/product/phhgsi*
  174. fi
  175.  
  176. if [ "$release" == true ];then
  177. (
  178. rm -Rf venv
  179. pip install virtualenv
  180. export PATH=$PATH:~/.local/bin/
  181. virtualenv -p /usr/bin/python3 venv
  182. source venv/bin/activate
  183. pip install -r $originFolder/release/requirements.txt
  184.  
  185. name="AOSP 8.1"
  186. [ "$build_target" == "android-9.0" ] && name="AOSP 9.0"
  187. python $originFolder/release/push.py "$name" "$version" release/$rom_fp/
  188. rm -Rf venv
  189. )
  190. fi
  191.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement