blob: edbde0e068129ca385f76ecc9de4c226f9a66ba3 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/bin/bash
# Copyright (c) 2006 Mauro Carvalho Chehab (mchehab@infradead.org)
# This code is placed under the terms of the GNU General Public License
#
#This script is capable to mass import patches on a mbox file, test for it, allow
#comment editing and applying it.
#
#This script requires:
#1) git, since it uses gitimport to break a mbox into patches;
#2) hg mailqueue. It is easier to manage patches using mq, allowing to work with
# the patches before applying to the tree.
head=v4l/scripts/hghead.pl
if [ "$1" == "" ]; then
echo "Usage: $0 <mbox>"
exit
fi
MBOX=$1
if [ "$TMPDIR" == "" ]; then
TMPDIR=/tmp
fi
DIR=$TMPDIR/mailimport$$
mkdir $DIR
if [ "$?" != "0" ]; then
echo "*** Error at mkdir $DIR"
exit;
fi
trap "rm -rf $DIR" EXIT
TMP2=$DIR/patchheader
apply_patch () {
next=$1
echo patch -s -t -p1 --dry-run -l -N -d linux -i $next
patch -s -t -p1 --dry-run -l -N -d linux -i $next
if [ "$?" != "0" ]; then
$head $next
echo "*** ERROR"
exit
fi
nano $next
unset cont
until [ "$cont" == "0" ]; do
cont=0
$head $next >$TMP2
if [ "`grep 'Bad formed author' $TMP2`" != "" ]; then
echo Patch bad formed. Please fix.
sleep 1
nano $next
cont=1
fi
done
# hg qnew doesn't support specifying a date
# date="`perl -ne '{ if ( s/^# Date: //) { print; } }' $TMP2`"
# echo "Patch date is $date"
# patch -s -t -p1 -l -N -d linux -i ../$next
# cd linux
# hg addremove `diffstat -p1 -l $next`
# cd ..
name=`cat $next | perl -ne '
if (s/Subject:\s+(.*)/$1/) {
m/\s*(.*)\s*\n/;
$_="$1";
tr/[A-Z]/[a-z]/;
s/[^a-z0-9]/_/g;
s/_+$//;
s/_+/_/g;
s/^v4l_dvb_\d+[a-z]*_//g;
printf "%s.patch",$_;
exit;
}'`
cat $next| grep -v "^#" >$TMPDIR/$name
echo hg -m "`cat $TMP2|grep -v "^#"`" qnew $name
hg qnew -m "`cat $TMP2|grep -v "^#"`" $name
patch -s -t -p1 -l -N -d linux -i $next
hg qrefresh
}
echo git-mailsplit $MBOX $DIR
echo -n "Number of patches at file: "
git-mailsplit $MBOX $DIR
echo
for i in $DIR/*; do
cat $i| git-mailinfo $DIR/msg $DIR/patch>$DIR/author
cat $DIR/msg|grep -vi ^CC: >$DIR/msg2
cat $DIR/author|perl -ne "if (m/Author[:]\\s*(.*)\\n/) { \$auth=\$1; } else \
{ if (m/Email[:]\\s*(.*)\\n/) { print \"From: \$auth \<\$1\>\n\"; } else \
{ if (m/Subject[:]\\s*(.*)\\n/) { \
\$sub=\$1; \
\$sub=~ s;^(media|dvb|v4l|video|drivers|[-_/: \\t])*(.*);\$2;; \
print \"Subject: \$sub\\n\"; \
} else \
{ print; } } \
}" >$DIR/author2
out=$DIR/patch.diff
cat $DIR/author2
echo "Signed-off-by: $CHANGE_LOG_NAME <$CHANGE_LOG_EMAIL_ADDRESS>" >>$DIR/msg2
echo "cat $DIR/author2 $DIR/msg2 $DIR/patch >$out"
cat $DIR/author2 $DIR/msg2 $DIR/patch >$out
apply_patch $out
done
|