Advertisement
S-trace

Untitled

Nov 11th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.30 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. find -type f -name '*.patch'|cut -d / -f 2-|sort
  7. for patch in `find -type f -name '*.patch'|cut -d / -f 2-|sort`; do
  8.     # Strip patch title to get git commit title - git ignore [text] prefixes in beginning of patch title during git am
  9.     title=$(sed -rn "s/Subject: (\[[^]]+] *)*//p" "$patch")
  10.     absolute_patch_path="$patches_path/$patch"
  11.     # 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)
  12.     repo_to_patch="$(if dirname $patch|grep -q /; then dirname $patch; else dirname $patch |tr '_' '/'|tr '+' '_'; fi)"
  13.  
  14.     echo -n "Is $repo_to_patch patched for '$title' ?.. "
  15.     pushd "$build_root/$repo_to_patch" > /dev/null
  16.     if (git log |fgrep -q "$title" ); then
  17.         echo Yes
  18.     else
  19.         echo No
  20.         echo "Trying to apply patch $(basename "$patch") to '$repo_to_patch'"
  21.         if ! git am $absolute_patch_path; then
  22.             echo "Failed, aborting git am"
  23.             git am --abort
  24.         fi
  25.     fi
  26.     popd > /dev/null
  27. done
  28. popd > /dev/null
  29. echo "Applying patches: done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement