summaryrefslogtreecommitdiff
path: root/apply-patches.sh
blob: 44d416eaef24483d9d34030d8d9fa75a3a88301a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash 
# copied from github.com:phhusson/treble_experimentations 
 
set -e
 
patches="$(readlink -f -- $1)"
 
for project in $(cd $patches/patches; echo *);do
p="$(tr _ / <<<$project |sed -e 's;platform/;;g')"
"$p" == build ] && p=build/make
repo sync -l --force-sync $p
pushd $p
git clean -fdx; git reset --hard
for patch in $patches/patches/$project/*.patch;do
#Check if patch is already applied 
if patch -f -p1 --dry-run -R < $patch > /dev/null;then
continue
fi
 
if git apply --check $patch;then
git am $patch
elif patch -f -p1 --dry-run < $patch > /dev/null;then
#This will fail 
git am $patch || true
patch -f -p1 < $patch
git add -u
git am --continue
else
echo "Failed applying $patch"
fi
done
popd
done