Advertisement
S-trace

Untitled

Nov 29th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.26 KB | None | 0 0
  1. build_root=$(pwd) # vendorsetup.sh is sourced by build/envsetup.sh in root of android build tree. Hope that nobody can correctly source it not from root of android tree.
  2. echo "Applying patches"
  3. patches_path="$build_root/device/jsr/d10f/patches/"
  4. pushd "$patches_path" > /dev/null
  5. unset repos
  6. for patch in `find -type f -name '*.patch'|cut -d / -f 2-|sort`; do
  7.     # Strip patch title to get git commit title - git ignore [text] prefixes in beginning of patch title during git am
  8.     title=$(sed -rn "s/Subject: (\[[^]]+] *)*//p" "$patch")
  9.     absolute_patch_path="$patches_path/$patch"
  10.     # Supported both path/to/repo_with_underlines/file.patch and path_to_repo+with+underlines/file.patch (both leads to path/to/repo_with_underlines)
  11.     repo_to_patch="$(if dirname $patch|grep -q /; then dirname $patch; else dirname $patch |tr '_' '/'|tr '+' '_'; fi)"
  12.  
  13.     echo -n "Is $repo_to_patch patched for '$title' ?.. "
  14.     pushd "$build_root/$repo_to_patch" > /dev/null
  15.     if (git log |fgrep -qm1 "$title" ); then
  16.         echo -n Yes
  17.       commit_hash=$(git log --oneline |fgrep -m1 "$title"|cut -d ' ' -f 1)
  18.       if [ q"$commit_hash" != "q" ]; then
  19.           commit_id=$(git format-patch -1 --stdout $commit_hash |git patch-id|cut -d ' ' -f 1)
  20.           patch_id=$(git patch-id < $absolute_patch_path|cut -d ' ' -f 1)
  21.           if [ "$commit_id" = "$patch_id" ]; then
  22.               echo ', patch matches'
  23.           else
  24.               echo -n ', PATCH MISMATCH!'
  25.               sed '0,/^$/d' $absolute_patch_path|head -n -3  > /tmp/patch
  26.               git show --stat $commit_hash -p --pretty=format:%b > /tmp/commit
  27.               diff -u /tmp/patch /tmp/commit
  28.               rm /tmp/patch /tmp/commit
  29.               echo ' Resetting branch!'
  30.               git checkout $commit_hash~1
  31.               git am $absolute_patch_path || git am --abort
  32.           fi
  33.     else
  34.         echo "Unable to get commit hash for '$title'! Something went wrong!"
  35.         sleep 20
  36.     fi
  37.     else
  38.         echo No
  39.         echo "Trying to apply patch $(basename "$patch") to '$repo_to_patch'"
  40.         if ! git am $absolute_patch_path; then
  41.             echo "Failed, aborting git am"
  42.             git am --abort
  43.         fi
  44.     fi
  45.     popd > /dev/null
  46. done
  47. popd > /dev/null
  48. echo "Applying patches: done"
  49.  
  50. echo "Updating overlay"
  51.  
  52. sh device/jsr/d10f/update-overlay.sh
  53. rm -f out/target/product/d10f/system/build.prop
  54.  
  55. add_lunch_combo cm_d10f-eng
  56. add_lunch_combo cm_d10f-user
  57. add_lunch_combo cm_d10f-userdebug
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement