Advertisement
S-trace

CM-12.1 build script

Nov 4th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.27 KB | None | 0 0
  1. #!/bin/bash
  2. ## ===============CONFIGURATION===============
  3. VENDOR="jsr"
  4. DEVICE="d10f"
  5. OTA_FULL_ZIPS_DIR="/home/android/ota/ota_mirror/public_http/ota/$DEVICE/full"
  6. ## ===============END OF CONFIGURATION===============
  7.  
  8. # Раскраска скрипта (код не мой!)
  9. black='\E[30m'
  10. red='\E[31m'
  11. green='\E[32m'
  12. yellow='\E[33m'
  13. blue='\E[34m'
  14. magenta='\E[35m'
  15. cyan='\E[36m'
  16. white='\E[37m'
  17. function cecho { echo -ne "$2"
  18.                  echo "$1"
  19.                  tput sgr0 -T xterm
  20.                 }
  21. do_one_diff() {
  22.           ts="$1"
  23.           nextts="$2"
  24.               if [ -z "$nextts" ]; then
  25.                 echo "==================================="
  26.                 echo "Since $(date -u -d @$ts)"
  27.                 echo "==================================="
  28.                 repo forall -c 'L=$(git log --oneline --after $ts -n 1); if [ "n$L" != "n" ]; then echo; echo "   * $REPO_PATH"; git log --oneline --after $ts|tac; fi'
  29.               else
  30.                 echo "==================================="
  31.                 echo "Since $(LC_ALL=C date -u -d @$ts) and before $(LC_ALL=C date -u -d @$nextts)"
  32.                 echo "==================================="
  33.                 repo forall -c 'L=$(git log --oneline --after $ts --before $nextts -n 1); if [ "n$L" != "n" ]; then echo; echo "   * $REPO_PATH"; git log --oneline --after $ts --before $nextts|tac; fi'
  34.               fi
  35.               echo
  36.               }
  37.  
  38. build_changelog() {
  39.                      export CHANGESPATH=device/$VENDOR/$DEVICE/buildinfo/CHANGES.txt
  40.                      rm -f $CHANGESPATH
  41.                      files=$(echo $OTA_FULL_ZIPS_DIR/*.zip|sort)
  42.                      export nextts=""
  43.                      export ts=""
  44.                      for file in $files; do
  45.                          eval `unzip -c $file system/build.prop|fgrep ro.build.date.utc|tr . _`
  46.                          nextts="$ro_build_date_utc"
  47.                          if [ ! -z "$ts" ]; then
  48.                            echo Processing $file from `date -u -d @$ts`
  49.                            do_one_diff $ts $nextts >> $CHANGESPATH
  50.                          fi
  51.                          export ts="$nextts"
  52.                      done
  53.                      do_one_diff $nextts >> $CHANGESPATH
  54.                  }
  55.                
  56. cecho "[0/7] Reverting patched repos to original revisions" $green
  57. cd device/$VENDOR/$DEVICE/patches
  58. unset repos
  59. for repo in `find -type f|xargs -n1 dirname|sort|uniq`; do
  60.   export repos="$repos $repo"
  61. done
  62. cd - > /dev/null
  63. repo sync -l $repos
  64.  
  65. cecho "[1/7] Resetting buildinfo in device tree to default" $green
  66. cd device/$VENDOR/$DEVICE/
  67. git checkout buildinfo/
  68. cd - > /dev/null
  69.  
  70. cecho "[2/7] Checking repos for dirty changes" $green
  71. # repo forall -c 'echo [$REPO_I/$REPO_COUNT] $REPO_PROJECT; git status|egrep -v "Сейчас ни на одной из веток|нечего коммитить, нет изменений в рабочем каталоге|HEAD отделен на|занял вывод списка неотслеживаемых файлов|^$"'|tee device/$VENDOR/$DEVICE/configs/repo_state.log
  72. LANG=C repo forall -c 'echo [$REPO_I/$REPO_COUNT] $REPO_PROJECT; git status|egrep -v "Not currently on any branch|On branch|Your branch is up-to-date|Your branch is ahead|nothing to commit, working directory clean|HEAD detached|enumerate untracked files|may speed it up|new files yourself|to publish your local commits|^$"'|tee device/$VENDOR/$DEVICE/buildinfo/repo_stats.txt
  73. mv device/$VENDOR/$DEVICE/buildinfo/repo_stats.txt device/$VENDOR/$DEVICE/buildinfo/repo_state.txt
  74.  
  75. cecho "[3/7] Generating manifest for current tree state" $green
  76. repo manifest -r -o device/$VENDOR/$DEVICE/buildinfo/build-manifest.xml
  77.  
  78. cecho "[4/7] Generating CHANGES.txt" $green
  79. build_changelog
  80.  
  81. cecho "[4/7] Sourcing envsetup.sh, reapplying patches" $green
  82. source build/envsetup.sh
  83.  
  84. cecho "[5/7] Launching build system" $green
  85. if brunch cm_d10f-userdebug; then
  86.   cecho "[6/7] Build successed!" $green
  87.   cd out/target/product/$DEVICE/
  88.   cp `cat rom_out_package` `cat rom_ota_name`
  89.   md5sum `cat rom_ota_name` > `cat rom_ota_name`.md5sum
  90.   cd - > /dev/null
  91.   cecho "[7/7] out/target/product/$DEVICE/`cat out/target/product/$DEVICE/rom_ota_name` built" $green
  92. else
  93.   cecho "Build failed!" $red
  94. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement