Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- echo "Applying patches"
- patches_path="$build_root/device/jsr/d10f/patches/"
- pushd "$patches_path" > /dev/null
- unset repos
- find -type f -name '*.patch'|cut -d / -f 2-|sort
- for patch in `find -type f -name '*.patch'|cut -d / -f 2-|sort`; do
- # Strip patch title to get git commit title - git ignore [text] prefixes in beginning of patch title during git am
- title=$(sed -rn "s/Subject: (\[[^]]+] *)*//p" "$patch")
- absolute_patch_path="$patches_path/$patch"
- # 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)
- repo_to_patch="$(if dirname $patch|grep -q /; then dirname $patch; else dirname $patch |tr '_' '/'|tr '+' '_'; fi)"
- echo -n "Is $repo_to_patch patched for '$title' ?.. "
- pushd "$build_root/$repo_to_patch" > /dev/null
- if (git log |fgrep -q "$title" ); then
- echo Yes
- commit_hash=$(git log --oneline |grep "$title"|cut -d ' ' -f 1)
- echo -n "Checking if patch $patch matches commit $commit_hash... "
- commit_md5=$(git show --stat $commit_hash -p --pretty=format:%b|md5sum|cut -d ' ' -f 1)
- patch_md5=$(sed '0,/^$/d' $absolute_patch_path|head -n -3 |md5sum|cut -d ' ' -f 1)
- # grep -oPz -- '(?s)-- ?\n[0-9.]+\n' $absolute_patch_path
- if [ $commit_md5 = $patch_md5 ]; then
- echo 'Yes, it matches'
- else
- echo 'NO! MISMATCH!'
- sed '0,/^$/d' $absolute_patch_path|head -n -3 > /tmp/patch
- git show --stat $commit_hash -p --pretty=format:%b > /tmp/commit
- diff -u /tmp/patch /tmp/commit
- fi
- else
- echo No
- echo "Trying to apply patch $(basename "$patch") to '$repo_to_patch'"
- if ! git am $absolute_patch_path; then
- echo "Failed, aborting git am"
- git am --abort
- fi
- fi
- popd > /dev/null
- done
- popd > /dev/null
- echo "Applying patches: done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement