-
Notifications
You must be signed in to change notification settings - Fork 5
/
phablet-patches-apply
executable file
·56 lines (44 loc) · 1.56 KB
/
phablet-patches-apply
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
if [ $# -lt 1 ];then
echo "Usage $0 patchdir [project]"
exit
fi
PD=`readlink -f $1`
if [ ! -d $PD ];then
echo "Patch directory $PD does not exist"
exit
fi
RD=$PD
while [ ! -d $RD/bionic ];do
RD=`dirname $RD`
done
NEWBRANCH=`repo info -o|grep merge|cut -f 2 -d:|tr -d ' '|sed 's,^.*/,,;s,^,phablet-,'`
# This will start applying patches to a project using git am and stop at the first one that fails
# Patches tried so far are written to ,applied under the project directory so a
# subsequent invocation starts from where it last failed.
# You can fix a failed patch by git apply --reject and manual editing, then remove
# the FAILED prefix from ,applied to mark a failed patch fixed.
apply_to_project() {
echo Creating branch $NEWBRANCH and applying patches on it for project $PROJECT
repo start $NEWBRANCH $PROJECT
repo forall $PROJECT -c "
for p in $RD/$PROJECT/*.patch;do
pn=\$(basename \$p)
grep -w \$pn ,applied >/dev/null 2>&1 && echo Skipping already applied patch \$pn && continue
echo Applying \$p
if git am -p1 --keep-cr \$p >/dev/null 2>&1;then
echo \$pn >>,applied
else
echo FAILED\$pn >>,applied
git am --abort && echo FAILED TO APPLY \$p
break
fi
done
"
}
#Patches in Ubuntu Touch we do not necessarily need to port to AOSP/CodeAurora as they are CM or target specific and not much use for the OEM
DROPPED="android|vendor|qemu"
find $PD -name commits |xargs -n 1 dirname | sed "s;$RD/;;" | grep -v -E "$DROPPED" | while read PROJECT
do
apply_to_project
done