refine apply patches script

This commit is contained in:
Ziyang Zhou
2024-05-19 17:25:32 +08:00
parent 67791923f8
commit 754cb80d35

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
usage() { usage() {
script=`basename $0` echo "USAGE: $(basename "$0") AOSP-SRC [TAG]"
echo "USAGE: $script AOSP-SRC [TAG]"
exit 1 exit 1
} }
@@ -11,24 +10,26 @@ usage() {
src=$1 src=$1
tag=$2 tag=$2
if [ -z "$tag" ]; then if [[ -z $tag ]]; then
echo "detect AOSP tag from manifest" echo "detect AOSP tag from manifest"
tag=`grep revision $src/.repo/manifests/default.xml | cut -d\" -f 2 | cut -d/ -f 3` tag=$(basename "$(xmllint --xpath "string(/manifest/default/@revision)" "$src"/.repo/manifests/default.xml)")
fi fi
echo "===== AOSP SRC: $src" echo "===== AOSP SRC: $src"
echo "===== AOSP TAG: $tag" echo "===== AOSP TAG: $tag"
patch_dir=$(dirname $(realpath $0))/$tag patch_dir=$(dirname "$(realpath "$0")")/$tag
if [ ! -d $patch_dir ];then if [[ ! -d $patch_dir ]]; then
echo "patches for $tag not exist" echo "patches for $tag not exist"
exit 1 exit 1
fi fi
cd $patch_dir cd "$patch_dir" || exit 1
for p in `find * -links 2` while read -r p
do do
[[ $(find "$patch_dir/$p" -maxdepth 1 -name '*.patch' 2> /dev/null | wc -l) -eq 0 ]] && continue
echo echo
echo "process project: $p" echo "process project: $p"
git -C $src/$p am --reject $patch_dir/$p/* || echo "*****[ERROR]***** apply failed: $p" git -C "$src/$p" am --reject "$patch_dir/$p"/* || echo "*****[ERROR]***** apply failed: $p"
done done < <(find -- * -type d)