Set of scripts to build Android for LG G6 (h870) leveraging OVH Public Cloud

build_android.sh 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash
  2. # Ubuntu 20.04 base
  3. set -e
  4. set -x
  5. # Install dependencies
  6. sudo apt-get update
  7. sudo apt-get upgrade -y
  8. sudo apt-get install -y bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev
  9. sudo apt-get install -y default-jdk
  10. sudo apt-get install -y python2
  11. sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 # Android git repo hooks are python2-only
  12. # Install repo
  13. mkdir -p ~/bin
  14. cat >> ~/.profile <<EOF
  15. # set PATH so it includes user's private bin if it exists
  16. if [ -d "$HOME/bin" ] ; then
  17. PATH="$HOME/bin:$PATH"
  18. fi
  19. EOF
  20. source ~/.profile
  21. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  22. chmod a+x ~/bin/repo
  23. # Git config
  24. git config --global user.email "phyks@phyks.me"
  25. git config --global user.name "Phyks (Lucas Verney)"
  26. # Use ccache
  27. cat >> ~/.bashrc <<EOF
  28. export USE_CCACHE=1
  29. export CCACHE_EXEC=/usr/bin/ccache
  30. EOF
  31. source ~/.bashrc
  32. ccache -M 50G
  33. ccache -o compression=true
  34. # Prevent repo prompt about using colors
  35. git config --global color.ui false
  36. # Clone Lineage 17.1 or /e/ codebase (takes roughly 1h!)
  37. mkdir -p ~/android/lineage
  38. cd ~/android/lineage
  39. if [[ "${BUILD_FLAVOR}" == "lineage" ]]; then
  40. repo init -q -u https://github.com/LineageOS/android.git -b lineage-17.1
  41. elif [[ "$BUILD_FLAVOR" == "e" ]]; then
  42. repo init -q -u https://gitlab.e.foundation/e/os/android.git -b v1-q
  43. else
  44. echo "Unknown build flavor! Exiting."
  45. exit 1
  46. fi
  47. repo sync
  48. source build/envsetup.sh
  49. # Get h870-specific repos
  50. mkdir -p ~/android/lineage/.repo/local_manifests/
  51. cat > ~/android/lineage/.repo/local_manifests/roomservice.xml <<EOF
  52. <?xml version="1.0" encoding="UTF-8"?>
  53. <manifest>
  54. <project name="LG-G6-DEV/android_device_lge_h870" path="device/lge/h870" remote="github" revision="lineage-17.0" />
  55. <project name="LG-G6-DEV/android_device_lge_msm8996-common" path="device/lge/msm8996-common" remote="github" revision="stagingAU" />
  56. <project name="LG-G6-DEV/android_kernel_lge_msm8996" path="kernel/lge/msm8996" remote="github" revision="Optimizing" />
  57. <project name="LG-G6-DEV/proprietary_vendor_lge" path="vendor/lge" remote="github" revision="new_audio" />
  58. </manifest>
  59. EOF
  60. repo sync
  61. # Some h870 cherry picks
  62. croot
  63. cd frameworks/base/
  64. git remote add fixes https://github.com/BernardoBas/android_frameworks_base.git
  65. git fetch fixes
  66. # Phantom camera fixes
  67. git cherry-pick a904a84ad485d8768c7a523ec380696d573c9a9e 5a02ae0abfb2a341055aecbb46fb6ce3b24070cf
  68. # Sunrise/Sunset hardoded if location is not available
  69. git cherry-pick 2c9baf509fef40586cc07a8b3aed91bb3cc741b3
  70. croot
  71. cd device/lge/msm8996-common/
  72. git remote add brightness https://github.com/BernardoBas/android_device_lge_msm8996-common.git
  73. git fetch brightness
  74. # MIC LEVEL -- TODO
  75. git cherry-pick 9123565f56262e73dc6d613a0efc4bfb5867f5e6
  76. # ROUNDED CORNERS -- TODO
  77. git cherry-pick 5c490db56b5d2431bc21a35f865511a3ea86ca4a
  78. # If you want micro-g on Lineage, uncomment this part
  79. # Note: micro-g is already built-in with /e/
  80. # if [[ "${BUILD_FLAVOR}" == "lineage" ]]; then
  81. # croot
  82. # cd frameworks/base
  83. # curl https://raw.githubusercontent.com/lineageos4microg/docker-lineage-cicd/master/src/signature_spoofing_patches/android_frameworks_base-Q.patch > android_frameworks_base-Q.patch
  84. # patch -p1 -i android_frameworks_base-Q.patch
  85. # fi
  86. if [[ "${BUILD_FLAVOR}" == "e" ]]; then
  87. # Remove some apps built with /e/, comment if you want to keep them
  88. croot
  89. # Remove MagicEarth (non-free)
  90. rm -r prebuilts/prebuiltapks/MagicEarth
  91. # Remove DemoApp
  92. rm -r prebuilts/prebuiltapks/DemoApp
  93. # Remove DroidGuard
  94. rm -r prebuilts/prebuiltapks/DroidGuard
  95. # Remove eDrive
  96. rm -r prebuilts/prebuiltapks/eDrive
  97. # Remove ESmsSync
  98. rm -r prebuilts/prebuiltapks/ESmsSync
  99. # Remove Notes
  100. rm -r prebuilts/prebuiltapks/Notes
  101. # Remove Camera
  102. rm -r prebuilts/prebuiltapks/Camera
  103. # Remove Browser
  104. rm -r prebuilts/prebuiltapks/Browser
  105. # Remove Weather
  106. rm -r prebuilts/prebuiltapks/Weather
  107. # Remove Tasks
  108. rm -r prebuilts/prebuiltapks/Tasks
  109. # Remove PdfViewer
  110. rm -r prebuilts/prebuiltapks/PdfViewer
  111. # Remove BrowserWebView
  112. rm -r prebuilts/prebuiltapks/BrowserWebView
  113. # Remove eSpeakTTS
  114. rm -r prebuilts/prebuiltapks/eSpeakTTS
  115. # Remove LibreOfficeViewer
  116. rm -r prebuilts/prebuiltapks/LibreOfficeViewer
  117. # Remove OpenWeatherMapWeatherProvider
  118. rm -r prebuilts/prebuiltapks/OpenWeatherMapWeatherProvider
  119. # TODO
  120. fi
  121. # Build Lineage or /e/ (takes 2 to 3 hours!)
  122. croot
  123. make clean
  124. date | tee -a build.log && brunch h870 | tee -a build.log && date | tee -a build.log && touch ~/BUILD_DONE