Advertisement
Guest User

Untitled

a guest
Dec 4th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.98 KB | None | 0 0
  1. #!/bin/bash
  2. # Install build dependencies
  3. ############################
  4. apt -qq update
  5. apt -qqy upgrade
  6. apt install -y imagemagick libwxgtk3.0-dev openjdk-8-jdk
  7. apt install -y openjdk-7-jdk
  8. apt 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-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev python git
  9.  
  10. #install google repo
  11. mkdir ~/bin 2>/dev/null
  12. PATH="$HOME/bin:$PATH"
  13. curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
  14. chmod a+x ~/bin/repo
  15.  
  16. # Environment variables
  17. #######################
  18.  
  19. export MIRROR_DIR=/srv/mirror
  20. export SRC_DIR=/srv/src
  21. export TMP_DIR=/srv/tmp
  22. export CCACHE_DIR=/srv/ccache
  23. export ZIP_DIR=/srv/zips
  24. export LMANIFEST_DIR=/srv/local_manifests
  25. export DELTA_DIR=/srv/delta
  26. export KEYS_DIR=/srv/keys
  27. export LOGS_DIR=/srv/logs
  28. export USERSCRIPTS_DIR=/srv/userscripts
  29.  
  30. export DEBIAN_FRONTEND=noninteractive
  31. export USER=root
  32.  
  33. # Configurable environment variables
  34. ####################################
  35.  
  36. # By default we want to use CCACHE, you can disable this
  37. # WARNING: disabling this may slow down a lot your builds!
  38. export USE_CCACHE=1
  39.  
  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. export CCACHE_SIZE=50G
  44.  
  45. # Environment for the LineageOS branches name
  46. # See https://github.com/LineageOS/android_vendor_cm/branches for possible options
  47. export BRANCH_NAME='v1-oreo'
  48.  
  49. # Environment for the device list (separate by comma if more than one)
  50. # eg. DEVICE_LIST=hammerhead,bullhead,angler
  51. export DEVICE_LIST='s2'
  52.  
  53. # Release type string
  54. export RELEASE_TYPE='UNOFFICIAL'
  55.  
  56. # Repo use for build
  57. export REPO='https://gitlab.e.foundation/e/os/android.git'
  58.  
  59. # Repo use for build
  60. export MIRROR=''
  61.  
  62. # OTA URL that will be used inside CMUpdater
  63. # Use this in combination with LineageOTA to make sure your device can auto-update itself from this buildbot
  64. export OTA_URL=''
  65.  
  66. # User identity
  67. export USER_NAME='user'
  68. export USER_MAIL='user@email.edu'
  69.  
  70. # Include proprietary files, downloaded automatically from github.com/TheMuppets/
  71. # Only some branches are supported
  72. export INCLUDE_PROPRIETARY=true
  73.  
  74. # Mount an overlay filesystem over the source dir to do each build on a clean source
  75. export BUILD_OVERLAY=false
  76.  
  77. # Clone the full LineageOS mirror (> 200 GB)
  78. export LOCAL_MIRROR=false
  79.  
  80. # If you want to preserve old ZIPs set this to 'false'
  81. export CLEAN_OUTDIR=false
  82.  
  83. # Change this cron rule to what fits best for you
  84. # Use 'now' to start the build immediately
  85. # For example, '0 10 * * *' means 'Every day at 10:00 UTC'
  86. export CRONTAB_TIME='now'
  87.  
  88. # Clean artifacts output after each build
  89. export CLEAN_AFTER_BUILD=true
  90.  
  91. # Provide root capabilities builtin inside the ROM (see http://lineageos.org/Update-and-Build-Prep/)
  92. export WITH_SU=false
  93.  
  94. # Provide a default JACK configuration in order to avoid out-of-memory issues
  95. export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
  96.  
  97. # Custom packages to be installed
  98. export CUSTOM_PACKAGES='MuPDF GmsCore GsfProxy FakeStore com.google.android.maps.jar Telegram Signal Mail BlissLauncher BlissIconPack MozillaNlpBackend OpenWeatherMapWeatherProvider AccountManager MagicEarth OpenCamera eDrive Weather Notes Tasks NominatimNlpBackend Light DroidGuard OpenKeychain Message Browser BrowserWebView Apps LibreOfficeViewer'
  99.  
  100. # Sign the builds with the keys in $KEYS_DIR
  101. export SIGN_BUILDS=false
  102.  
  103. # When SIGN_BUILDS = true but no keys have been provided, generate a new set with this subject
  104. export KEYS_SUBJECT='/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
  105.  
  106. # Move the resulting zips to $ZIP_DIR/$codename instead of $ZIP_DIR/
  107. export ZIP_SUBDIR=true
  108.  
  109. # Write the verbose logs to $LOGS_DIR/$codename instead of $LOGS_DIR/
  110. export LOGS_SUBDIR=true
  111.  
  112. # Apply the MicroG's signature spoofing patch
  113. # Valid values are "no", "yes" (for the original MicroG's patch) and
  114. # "restricted" (to grant the permission only to the system privileged apps).
  115. #
  116. # The original ("yes") patch allows user apps to gain the ability to spoof
  117. # themselves as other apps, which can be a major security threat. Using the
  118. # restricted patch and embedding the apps that requires it as system privileged
  119. # apps is a much secure option. See the README.md ("Custom mode") for an
  120. # example.
  121. export SIGNATURE_SPOOFING="restricted"
  122.  
  123. # Generate delta files
  124. export BUILD_DELTA=false
  125.  
  126. # Delete old zips in $ZIP_DIR, keep only the N latest one (0 to disable)
  127. export DELETE_OLD_ZIPS=0
  128.  
  129. # Delete old deltas in $DELTA_DIR, keep only the N latest one (0 to disable)
  130. export DELETE_OLD_DELTAS=0
  131.  
  132. # Delete old logs in $LOGS_DIR, keep only the N latest one (0 to disable)
  133. export DELETE_OLD_LOGS=0
  134.  
  135. # Create a JSON file that indexes the build zips at the end of the build process
  136. # (for the updates in OpenDelta). The file will be created in $ZIP_DIR with the
  137. # specified name; leave empty to skip it.
  138. # Requires ZIP_SUBDIR.
  139. export OPENDELTA_BUILDS_JSON=''
  140.  
  141. # You can optionally specify a USERSCRIPTS_DIR volume containing these scripts:
  142. #  * begin.sh, run at the very beginning
  143. #  * before.sh, run after the syncing and patching, before starting the builds
  144. #  * pre-build.sh, run before the build of every device
  145. #  * post-build.sh, run after the build of every device
  146. #  * end.sh, run at the very end
  147. # Each script will be run in $SRC_DIR and must be owned and writeable only by
  148. # root
  149.  
  150. # Create Volume entry points
  151. ############################
  152. # VOLUME $MIRROR_DIR
  153. # VOLUME $SRC_DIR
  154. # VOLUME $TMP_DIR
  155. # VOLUME $CCACHE_DIR
  156. # VOLUME $ZIP_DIR
  157. # VOLUME $LMANIFEST_DIR
  158. # VOLUME $DELTA_DIR
  159. # VOLUME $KEYS_DIR
  160. # VOLUME $LOGS_DIR
  161. # VOLUME $USERSCRIPTS_DIR
  162. # VOLUME /root/.ssh
  163.  
  164. # Create missing directories
  165. ############################
  166. mkdir -p $MIRROR_DIR
  167. mkdir -p $SRC_DIR
  168. mkdir -p $TMP_DIR
  169. mkdir -p $CCACHE_DIR
  170. mkdir -p $ZIP_DIR
  171. mkdir -p $LMANIFEST_DIR
  172. mkdir -p $DELTA_DIR
  173. mkdir -p $KEYS_DIR
  174. mkdir -p $LOGS_DIR
  175. mkdir -p $USERSCRIPTS_DIR
  176.  
  177. # Copy build files to  /root/
  178. ############################
  179. rm -rf $TMP_DIR/buildscripts
  180. if [[ $BRANCH_NAME =~ pie$ ]]; then
  181.    git clone --branch dev https://gitlab.e.foundation/e/os/docker-lineage-cicd.git $TMP_DIR/buildscripts
  182. else
  183.    git clone https://gitlab.e.foundation/e/os/docker-lineage-cicd.git $TMP_DIR/buildscripts
  184. fi
  185.  
  186. cp -rf $TMP_DIR/buildscripts/src/* /root/
  187. cp $TMP_DIR/buildscripts/apt_preferences /etc/apt/preferences
  188.  
  189. # Download and build delta tools
  190. ################################
  191. cd /root/ && \
  192.         mkdir delta && \
  193.         echo "cloning"
  194.         git clone --depth=1 https://github.com/omnirom/android_packages_apps_OpenDelta.git OpenDelta && \
  195.         gcc -o delta/zipadjust OpenDelta/jni/zipadjust.c OpenDelta/jni/zipadjust_run.c -lz && \
  196.         cp OpenDelta/server/minsignapk.jar OpenDelta/server/opendelta.sh delta/ && \
  197.         chmod +x delta/opendelta.sh && \
  198.         rm -rf OpenDelta/ && \
  199.         sed -i -e "s|^\s*HOME=.*|HOME=/root|; \
  200.                   s|^\s*BIN_XDELTA=.*|BIN_XDELTA=xdelta3|; \
  201.                   s|^\s*FILE_MATCH=.*|FILE_MATCH=lineage-\*.zip|; \
  202.                   s|^\s*PATH_CURRENT=.*|PATH_CURRENT=$SRC_DIR/out/target/product/$DEVICE|; \
  203.                   s|^\s*PATH_LAST=.*|PATH_LAST=$SRC_DIR/delta_last/$DEVICE|; \
  204.                   s|^\s*KEY_X509=.*|KEY_X509=$KEYS_DIR/releasekey.x509.pem|; \
  205.                   s|^\s*KEY_PK8=.*|KEY_PK8=$KEYS_DIR/releasekey.pk8|; \
  206.                   s|publish|$DELTA_DIR|g" /root/delta/opendelta.sh
  207.  
  208. # Set the work directory
  209. ########################
  210. cd $SRC_DIR
  211.  
  212. # Allow redirection of stdout to docker logs
  213. ############################################
  214. ln -sf /proc/1/fd/1 /var/log/docker.log
  215.  
  216. # Set the entry point to init.sh
  217. ################################
  218. /root/init.sh
  219. #end script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement