/
do.sh
executable file
·211 lines (188 loc) · 5.4 KB
/
do.sh
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
#
# Take the branch we are working on, create the patches, email out that we
# applied them, merge to the branch, and push the branch to the servers if we
# are online.
FROM='<gregkh@linuxfoundation.org>'
TO=""
CC=""
author()
{
first_author=""
TXT=$2
if [ ! -f $TXT ]
then
echo "$TXT is missing"
exit 1
fi
author=""
while read l
do
# skip the Message-ID: line so we don't send email to the wrong place
#echo "$l"
reply=$(echo "$l" | grep -i Message-ID:)
if [ x"$reply" != x ]
then
continue
fi
# if this is the start of the diff, then it's time to stop looking
diff=$(echo "$l" | grep "^---")
if [ x"$diff" != x ]
then
#echo "diffstart!!!!!"
break
fi
for x in $l
do
a=$(echo "$x" | sed -n -e 's/.*<\(.*@[^>]*\).*/\1/p')
if [ x"$a" != x ]
then
if [ x"$author" == x ]
then
author=$a
first_author=$a
else
author="$author $a"
fi
fi
done
done < $TXT
author=$(echo "$author" | tr ' ' '\n' | grep -v "$first_author" |
sort | uniq)
author="$first_author $author"
eval $1=$(echo $author | sed -e 's/ /,/g')
if [ x"$3" != x ]
then
eval $3=$first_author
fi
}
reply()
{
PATCH=$1
echo "PATCH=$PATCH"
SUBJECT=`grep "Subject:" $PATCH | sed s/Subject\:\ //`
MESSAGE_ID=`grep -i "^Message-ID:" $PATCH | cut -f 2 -d ' ' | cut -f 2 -d '<' | cut -f 1 -d '>'`
author AUTHOR $1 FIRST_AUTHOR
# echo "author said $AUTHOR"
# echo "first_author said $FIRST_AUTHOR"
if [ x"$AUTHOR" == "x" ]
then
echo "nobody to notify"
exit 0
fi
to=""
for i in $(echo "$AUTHOR" | sed -e 's/,/ /g')
do
if ! echo "$TO" | grep "$i"
then
to=$to" -to $i"
fi
done
if [ x"$cc" != x ]
then
cc="-cc $cc"
fi
CHARSET=$(guess-charset "$PATCH")
if test "x$CHARSET" = "ANSI_X3.4-1968"; then
CHARSET=
else
CHARCMD="-charset=$CHARSET"
fi
ID=`make_message_id`
# echo "makemail -to $AUTHOR -from=$FROM -subject=\"patch $PATCH added to gregkh tree\" -date=\"$(date -R)\" -reply_to=$MESSAGE_ID -message=$ID $CHARCMD"
(
echo
echo "This is a note to let you know that I've just added the patch titled"
echo
echo " $SUBJECT"
echo
echo "to my ${TREE} git tree which can be found at"
echo " git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/${TREE}.git"
echo "in the ${TREE}-${BRANCH} branch."
echo
echo "The patch will show up in the next release of the linux-next tree"
echo "(usually sometime within the next 24 hours during the week.)"
echo
if [ "${BRANCH}" = "next" ] ; then
echo "The patch will also be merged in the next major kernel release"
echo "during the merge window."
else
echo "The patch will hopefully also be merged in Linus's tree for the"
echo "next -rc kernel release."
fi
echo
echo "If you have any questions about this process, please let me know."
echo
echo
cat $PATCH
echo
) |
makemail -to "$AUTHOR" -from="$FROM" \
-subject="patch \"$SUBJECT\" added to ${TREE} tree" \
-date="$(date -R)" \
-reply_to="$MESSAGE_ID" \
-message_id="$ID" \
"$CHARCMD" | \
~/bin/msmtp-enqueue.sh $to
}
# we need to be either on the 'work-next' branch, or the 'work-linus' branch in
# order to work properly, error out if we are on something else.
CURRENT_BRANCH=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
BRANCH=""
if [ "$CURRENT_BRANCH" = "work-next" ] ; then
BRANCH="next"
else if [ "$CURRENT_BRANCH" = "work-linus" ] ; then
BRANCH="linus"
fi
fi
if [ "$BRANCH" = "" ] ; then
echo "ERROR!!!"
echo "Right now you are on the \"$CURRENT_BRANCH\" branch."
echo "You need to be on either \"work-next\" or \"work-linus\" branch to work properly."
exit
fi
echo "BRANCH=$BRANCH"
# look and see if there are any patches in this dir first, error out if so, we
# don't want to accidentally send them out twice
OLD_PATCH=`ls 0*.patch 2>/dev/null | head -n 1`
if [ "${OLD_PATCH}" != "" ] ; then
echo "ERROR!!!"
echo "There are old patches still in the directory,"
echo "clean them up before running this again."
exit
fi
PWD=`pwd`
TREE=`basename ${PWD}`
# generate the patches
# 'fp' is my alias for 'format-patch -k -M -N'
git fp ${TREE}-${BRANCH}
# verify that we actually generated some patches
PATCH=`ls 0*.patch 2>/dev/null | head -n 1`
if [ "${PATCH}" = "" ] ; then
echo "ERROR!!!"
echo "No patches were generated, are you sure you actually committed anything here?"
exit
fi
# send out emails
#../added-to-${TREE}-${BRANCH} 0*.patch
for patch_file in `ls 0*.patch`
do
reply $patch_file
echo "acknowledged $patch_file"
echo "-----------------------------------------------"
echo
done
# merge the patches back to the branch
git checkout ${TREE}-${BRANCH} && git merge work-${BRANCH}
# if something goes wrong, exit
if [ $? -ne 0 ] ; then
exit
fi
ONLINE=`gregkh_machine_online`
# Only push if we have a network connection
if [ "$ONLINE" = "1" ] ; then
git push kroah.com ${TREE}-${BRANCH}
git push
fi
# now go back to the original branch so that we can continue to work
git checkout work-${BRANCH}