Advertisement
petefoth

buildl.sh

May 31st, 2022
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.85 KB | None | 0 0
  1. #!/bin/bash
  2. clear
  3. while true; do
  4.     read -p "When you flash the ROM be aware that lock screen and fingerprint can be removed easily, to prevent this encrypt your phone. Check community.e.foundation if your model supports encryption. I understand this message and want to coninue:(y/n)" yn
  5.     case $yn in
  6.           [Yy]* ) break;;
  7.       [Nn]* ) exit;;
  8.         * ) echo "Please answer yes or no.";;
  9.     esac
  10. done
  11. << COMMENTBLOCK
  12. # Install build dependencies
  13. ############################
  14. apt -qq update
  15. apt -qqy upgrade
  16. apt install -y imagemagick libwxgtk3.0-dev openjdk-8-jdk
  17. apt install -y openjdk-7-jdk
  18. apt install -y bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick libncurses5 lib32ncurses5-dev lib32readline-dev lib32z1-dev libtinfo5 liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev python python3 software-properties-common git
  19. #install google repo
  20. ####################
  21. apt install -y repo
  22.  
  23. COMMENTBLOCK
  24.  
  25. # Environment variables
  26. #######################
  27.  
  28. # User identity
  29. export USER_NAME='Pete Fotheringham'
  30. export USER_MAIL='[email protected]'
  31.  
  32. # Defaults
  33. export USE_CCACHE=1
  34. export MINIMAL_APPS=false
  35. export CLEAN_AFTER_BUILD=false
  36. export CLEAN_OUTDIR=false
  37.  
  38.  
  39. # My variables
  40. # ccache maximum size. It should be a number followed by an optional suffix: k,
  41. # M, G, T (decimal), Ki, Mi, Gi or Ti (binary). The default suffix is G. Use 0
  42. # for no limit.
  43.  
  44. export CCACHE_SIZE=300G
  45. #export BRANCH_NAME='lineage-18.1'
  46. export BRANCH_NAME='lineage-17.1'
  47. #export DEVICE_LIST='suzuran'
  48. export DEVICE_LIST='lilac,suzuran'
  49. export INCLUDE_PROPRIETARY=false
  50. export LOCAL_MIRROR=false
  51. export WITH_GMS=true
  52.  
  53. ## Sony nougat devices
  54. #export BRANCH_NAME='v0.14.1-nougat'
  55. #export DEVICE_LIST='taoshan,nicki,ivy,karin,karin-windy'
  56.  
  57. # Fixed
  58. export TMP_DIR=/home/pete/srv/los/tmp
  59. export SRC_DIR=/home/pete/srv/los/src
  60. export CCACHE_DIR=/home/pete/srv/los/ccache
  61. export ZIP_DIR=/home/pete/srv/los/zips
  62. export LMANIFEST_DIR=/home/pete/srv/los/local_manifests
  63. export DELTA_DIR=/home/pete/srv/los/delta
  64. export KEYS_DIR=/home/pete/srv/los/keys
  65. export LOGS_DIR=/home/pete/srv/los/logs
  66. export USERSCRIPTS_DIR=/home/pete/srv/userscripts
  67. export DEBIAN_FRONTEND=noninteractive
  68. export USER=root
  69. export RELEASE_TYPE='UNOFFICIAL'
  70. export SIGNATURE_SPOOFING=restricted
  71. export CUSTOM_PACKAGES=''
  72.  
  73. # Repo use for build
  74. export MIRROR=''
  75.  
  76. # OTA URL that will be used inside CMUpdater
  77. # Use this in combination with LineageOTA to make sure your device can auto-update itself from this buildbot
  78. export OTA_URL=''
  79.  
  80. # Change this cron rule to what fits best for you
  81. # Use 'now' to start the build immediately
  82. # For example, '0 10 * * *' means 'Every day at 10:00 UTC'
  83. export CRONTAB_TIME='now'
  84.  
  85. # Provide a default JACK configuration in order to avoid out-of-memory issues
  86. export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
  87.  
  88. # Sign the builds with the keys in $KEYS_DIR
  89. export SIGN_BUILDS=true
  90.  
  91. # When SIGN_BUILDS = true but no keys have been provided, generate a new set with this subject
  92. export KEYS_SUBJECT='/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'
  93.  
  94. # Move the resulting zips to $ZIP_DIR/$codename instead of $ZIP_DIR/
  95. export ZIP_SUBDIR=true
  96.  
  97. # Write the verbose logs to $LOGS_DIR/$codename instead of $LOGS_DIR/
  98. export LOGS_SUBDIR=true
  99.  
  100. # Generate delta files
  101. export BUILD_DELTA=false
  102.  
  103. # Backup the .img in addition to zips
  104. export BACKUP_IMG=true
  105.  
  106. # Delete old zips in $ZIP_DIR, keep only the N latest one (0 to disable)
  107. export DELETE_OLD_ZIPS=0
  108.  
  109. # Delete old deltas in $DELTA_DIR, keep only the N latest one (0 to disable)
  110. export DELETE_OLD_DELTAS=0
  111.  
  112. # Delete old logs in $LOGS_DIR, keep only the N latest one (0 to disable)
  113. export DELETE_OLD_LOGS=0
  114.  
  115. # Create a JSON file that indexes the build zips at the end of the build process
  116. # (for the updates in OpenDelta). The file will be created in $ZIP_DIR with the
  117. # specified name; leave empty to skip it.
  118. # Requires ZIP_SUBDIR.
  119. export OPENDELTA_BUILDS_JSON=''
  120.  
  121. export BUILD_OVERLAY=false
  122.  
  123. # You can optionally specify a USERSCRIPTS_DIR volume containing these scripts:
  124. #  * begin.sh, run at the very beginning
  125. #  * before.sh, run after the syncing and patching, before starting the builds
  126. #  * pre-build.sh, run before the build of every device
  127. #  * post-build.sh, run after the build of every device
  128. #  * end.sh, run at the very end
  129. # Each script will be run in $SRC_DIR and must be owned and writeable only by
  130. # root
  131.  
  132. # Create missing directories
  133. ############################
  134. mkdir -p $TMP_DIR
  135.  
  136. mkdir -p $SRC_DIR
  137. mkdir -p $CCACHE_DIR
  138. mkdir -p $ZIP_DIR
  139. mkdir -p $LMANIFEST_DIR
  140. mkdir -p $DELTA_DIR
  141. mkdir -p $KEYS_DIR
  142. mkdir -p $LOGS_DIR
  143. mkdir -p $USERSCRIPTS_DIR
  144.  
  145. # Copy build files to  /root/
  146. ############################
  147. rm -rf $TMP_DIR/buildscripts
  148.  
  149. git clone https://github.com/lineageos4microg/docker-lineage-cicd.git $TMP_DIR/buildscripts
  150. # Use my fork for now, until the pythin2 2/3 fix gets into lineageos4microg
  151. # git clone https://github.com/petefoth/docker-lineage-cicd.git -b work-with-python-3 $TMP_DIR/buildscripts
  152.  
  153. rm -rf /root/*
  154. cp -rf $TMP_DIR/buildscripts/src/* /root/
  155. # cp -rf $TMP_DIR/buildscripts/build-community.sh /root/build.sh
  156.  
  157. # Install build dependencies
  158. ############################
  159. #cp $TMP_DIR/buildscripts/apt_preferences /etc/apt/preferences
  160.  
  161.  
  162. << COMMENTBLOCK
  163.  
  164. # Download and build delta tools
  165. ################################
  166. cd /root/ && \
  167.         mkdir delta && \
  168.         echo "cloning"
  169.         git clone --depth=1 https://gitlab.e.foundation/e/os/android_packages_apps_OpenDelta.git OpenDelta && \
  170.         gcc -o delta/zipadjust OpenDelta/jni/zipadjust.c OpenDelta/jni/zipadjust_run.c -lz && \
  171.         cp OpenDelta/server/minsignapk.jar OpenDelta/server/opendelta.sh delta/ && \
  172.         chmod +x delta/opendelta.sh && \
  173.         rm -rf OpenDelta/ && \
  174.         sed -i -e "s|^\s*HOME=.*|HOME=/root|; \
  175.                    s|^\s*BIN_XDELTA=.*|BIN_XDELTA=xdelta3|; \
  176.                    s|^\s*FILE_MATCH=.*|FILE_MATCH=lineage-\*.zip|; \
  177.                    s|^\s*PATH_CURRENT=.*|PATH_CURRENT=$SRC_DIR/out/target/product/$DEVICE|; \
  178.                    s|^\s*PATH_LAST=.*|PATH_LAST=$SRC_DIR/delta_last/$DEVICE|; \
  179.                    s|^\s*KEY_X509=.*|KEY_X509=$KEYS_DIR/releasekey.x509.pem|; \
  180.                    s|^\s*KEY_PK8=.*|KEY_PK8=$KEYS_DIR/releasekey.pk8|; \
  181.                    s|publish|$DELTA_DIR|g" /root/delta/opendelta.sh
  182.  
  183. COMMENTBLOCK
  184.  
  185. # Set the work directory
  186. ########################
  187. cd $SRC_DIR
  188.  
  189. # Allow redirection of stdout to docker logs
  190. ############################################
  191. #ln -sf /proc/1/fd/1 /var/log/docker.log
  192.  
  193. # Set the entry point to init.sh
  194. ################################
  195. /root/init.sh
  196.  
  197. #end script
  198.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement