Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## ===============CONFIGURATION===============
- VENDOR="jsr"
- DEVICE="d10f"
- OTA_FULL_ZIPS_DIR="/home/android/ota/ota_mirror/public_http/ota/$DEVICE/full"
- ## ===============END OF CONFIGURATION===============
- # Раскраска скрипта (код не мой!)
- black='\E[30m'
- red='\E[31m'
- green='\E[32m'
- yellow='\E[33m'
- blue='\E[34m'
- magenta='\E[35m'
- cyan='\E[36m'
- white='\E[37m'
- function cecho { echo -ne "$2"
- echo "$1"
- tput sgr0 -T xterm
- }
- do_one_diff() {
- ts="$1"
- nextts="$2"
- if [ -z "$nextts" ]; then
- echo "==================================="
- echo "Since $(date -u -d @$ts)"
- echo "==================================="
- 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'
- else
- echo "==================================="
- echo "Since $(LC_ALL=C date -u -d @$ts) and before $(LC_ALL=C date -u -d @$nextts)"
- echo "==================================="
- 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'
- fi
- echo
- }
- build_changelog() {
- export CHANGESPATH=device/$VENDOR/$DEVICE/buildinfo/CHANGES.txt
- rm -f $CHANGESPATH
- files=$(echo $OTA_FULL_ZIPS_DIR/*.zip|sort)
- export nextts=""
- export ts=""
- for file in $files; do
- eval `unzip -c $file system/build.prop|fgrep ro.build.date.utc|tr . _`
- nextts="$ro_build_date_utc"
- if [ ! -z "$ts" ]; then
- echo Processing $file from `date -u -d @$ts`
- do_one_diff $ts $nextts >> $CHANGESPATH
- fi
- export ts="$nextts"
- done
- do_one_diff $nextts >> $CHANGESPATH
- }
- cecho "[0/7] Reverting patched repos to original revisions" $green
- cd device/$VENDOR/$DEVICE/patches
- unset repos
- for repo in `find -type f|xargs -n1 dirname|sort|uniq`; do
- export repos="$repos $repo"
- done
- cd - > /dev/null
- repo sync -l $repos
- cecho "[1/7] Resetting buildinfo in device tree to default" $green
- cd device/$VENDOR/$DEVICE/
- git checkout buildinfo/
- cd - > /dev/null
- cecho "[2/7] Checking repos for dirty changes" $green
- # repo forall -c 'echo [$REPO_I/$REPO_COUNT] $REPO_PROJECT; git status|egrep -v "Сейчас ни на одной из веток|нечего коммитить, нет изменений в рабочем каталоге|HEAD отделен на|занял вывод списка неотслеживаемых файлов|^$"'|tee device/$VENDOR/$DEVICE/configs/repo_state.log
- 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
- mv device/$VENDOR/$DEVICE/buildinfo/repo_stats.txt device/$VENDOR/$DEVICE/buildinfo/repo_state.txt
- cecho "[3/7] Generating manifest for current tree state" $green
- repo manifest -r -o device/$VENDOR/$DEVICE/buildinfo/build-manifest.xml
- cecho "[4/7] Generating CHANGES.txt" $green
- build_changelog
- cecho "[4/7] Sourcing envsetup.sh, reapplying patches" $green
- source build/envsetup.sh
- cecho "[5/7] Launching build system" $green
- if brunch cm_d10f-userdebug; then
- cecho "[6/7] Build successed!" $green
- cd out/target/product/$DEVICE/
- cp `cat rom_out_package` `cat rom_ota_name`
- md5sum `cat rom_ota_name` > `cat rom_ota_name`.md5sum
- cd - > /dev/null
- cecho "[7/7] out/target/product/$DEVICE/`cat out/target/product/$DEVICE/rom_ota_name` built" $green
- else
- cecho "Build failed!" $red
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement