Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 218 lines (194 sloc) 5.648 kb
2ecc614 @gregkh char-misc stuff
authored
1 #!/bin/bash
a10f3d5 @gregkh work: fix up do.sh script
authored
2 #
3 # Take the branch we are working on, create the patches, email out that we
4 # applied them, merge to the branch, and push the branch to the servers if we
5 # are online.
6
7
4fb86a8 @gregkh work/do.sh: push the "added-to-*" logic into the main script
authored
8
9 FROM='<gregkh@linuxfoundation.org>'
10 TO=""
11 CC=""
12
13 author()
14 {
15 first_author=""
16 TXT=$2
17 if [ ! -f $TXT ]
18 then
19 echo "$TXT is missing"
20 exit 1
21 fi
22 author=""
23 while read l
24 do
25 # skip the Message-ID: line so we don't send email to the wrong place
26 #echo "$l"
27 reply=$(echo "$l" | grep -i Message-ID:)
28 if [ x"$reply" != x ]
29 then
30 continue
31 fi
32
33 # if this is the start of the diff, then it's time to stop looking
34 diff=$(echo "$l" | grep "^---")
35 if [ x"$diff" != x ]
36 then
37 #echo "diffstart!!!!!"
38 break
39 fi
40
41 for x in $l
42 do
43 a=$(echo "$x" | sed -n -e 's/.*<\(.*@[^>]*\).*/\1/p')
44 if [ x"$a" != x ]
45 then
46 if [ x"$author" == x ]
47 then
48 author=$a
49 first_author=$a
50 else
51 author="$author $a"
52 fi
53 fi
54 done
55 done < $TXT
56 author=$(echo "$author" | tr ' ' '\n' | grep -v "$first_author" |
57 sort | uniq)
58 author="$first_author $author"
59 eval $1=$(echo $author | sed -e 's/ /,/g')
60 if [ x"$3" != x ]
61 then
62 eval $3=$first_author
63 fi
64 }
65
66 reply()
67 {
68 PATCH=$1
69 echo "PATCH=$PATCH"
70 SUBJECT=`grep "Subject:" $PATCH | sed s/Subject\:\ //`
71 MESSAGE_ID=`grep -i "^Message-ID:" $PATCH | cut -f 2 -d ' ' | cut -f 2 -d '<' | cut -f 1 -d '>'`
72 author AUTHOR $1 FIRST_AUTHOR
73 # echo "author said $AUTHOR"
74 # echo "first_author said $FIRST_AUTHOR"
75 if [ x"$AUTHOR" == "x" ]
76 then
77 echo "nobody to notify"
78 exit 0
79 fi
80 to=""
81 for i in $(echo "$AUTHOR" | sed -e 's/,/ /g')
82 do
83 if ! echo "$TO" | grep "$i"
84 then
85 to=$to" -to $i"
86 fi
87 done
88 if [ x"$cc" != x ]
89 then
90 cc="-cc $cc"
91 fi
92
93 CHARSET=$(guess-charset "$PATCH")
94 if test "x$CHARSET" = "ANSI_X3.4-1968"; then
95 CHARSET=
96 else
97 CHARCMD="-charset=$CHARSET"
98 fi
99
100 ID=`make_message_id`
101
102 # echo "makemail -to $AUTHOR -from=$FROM -subject=\"patch $PATCH added to gregkh tree\" -date=\"$(date -R)\" -reply_to=$MESSAGE_ID -message=$ID $CHARCMD"
103 (
104 echo
105 echo "This is a note to let you know that I've just added the patch titled"
106 echo
107 echo " $SUBJECT"
108 echo
109 echo "to my ${TREE} git tree which can be found at"
110 echo " git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/${TREE}.git"
111 echo "in the ${TREE}-${BRANCH} branch."
112 echo
113 echo "The patch will show up in the next release of the linux-next tree"
114 echo "(usually sometime within the next 24 hours during the week.)"
115 echo
116 if [ "${BRANCH}" = "next" ] ; then
e913a95 @gregkh work/do.sh: fixed up wording
authored
117 echo "The patch will also be merged in the next major kernel release"
4fb86a8 @gregkh work/do.sh: push the "added-to-*" logic into the main script
authored
118 echo "during the merge window."
119 else
e913a95 @gregkh work/do.sh: fixed up wording
authored
120 echo "The patch will hopefully also be merged in Linus's tree for the"
4fb86a8 @gregkh work/do.sh: push the "added-to-*" logic into the main script
authored
121 echo "next -rc kernel release."
122 fi
123 echo
124 echo "If you have any questions about this process, please let me know."
125 echo
126 echo
127 cat $PATCH
128 echo
129 ) |
130 makemail -to "$AUTHOR" -from="$FROM" \
131 -subject="patch \"$SUBJECT\" added to ${TREE} tree" \
132 -date="$(date -R)" \
133 -reply_to="$MESSAGE_ID" \
134 -message_id="$ID" \
135 "$CHARCMD" | \
136 ~/bin/msmtp-enqueue.sh $to
137 }
138
139
a10f3d5 @gregkh work: fix up do.sh script
authored
140 # we need to be either on the 'work-next' branch, or the 'work-linus' branch in
141 # order to work properly, error out if we are on something else.
142 CURRENT_BRANCH=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
143 BRANCH=""
144 if [ "$CURRENT_BRANCH" = "work-next" ] ; then
145 BRANCH="next"
146 else if [ "$CURRENT_BRANCH" = "work-linus" ] ; then
147 BRANCH="linus"
148 fi
149 fi
150
151 if [ "$BRANCH" = "" ] ; then
152 echo "ERROR!!!"
153 echo "Right now you are on the \"$CURRENT_BRANCH\" branch."
154 echo "You need to be on either \"work-next\" or \"work-linus\" branch to work properly."
155 exit
156 fi
157 echo "BRANCH=$BRANCH"
158
159 # look and see if there are any patches in this dir first, error out if so, we
160 # don't want to accidentally send them out twice
161 OLD_PATCH=`ls 0*.patch 2>/dev/null | head -n 1`
162 if [ "${OLD_PATCH}" != "" ] ; then
ff1e4cc @gregkh work/do.sh: clean up patches automatically
authored
163 echo "WARNING: There are old patches still in the directory:"
164 for P in 0*.patch; do
165 echo " ${P}"
166 done
167 echo ""
168 echo "I will clean them up if you don't stop the script right now."
169 echo -n "[ret] to continue"
170 read
171 rm 0*.patch
172 #exit
a10f3d5 @gregkh work: fix up do.sh script
authored
173 fi
2ecc614 @gregkh char-misc stuff
authored
174
175 PWD=`pwd`
176 TREE=`basename ${PWD}`
177
a10f3d5 @gregkh work: fix up do.sh script
authored
178 # generate the patches
179 # 'fp' is my alias for 'format-patch -k -M -N'
180 git fp ${TREE}-${BRANCH}
181
182 # verify that we actually generated some patches
183 PATCH=`ls 0*.patch 2>/dev/null | head -n 1`
184 if [ "${PATCH}" = "" ] ; then
185 echo "ERROR!!!"
186 echo "No patches were generated, are you sure you actually committed anything here?"
187 exit
188 fi
189
190 # send out emails
4fb86a8 @gregkh work/do.sh: push the "added-to-*" logic into the main script
authored
191 #../added-to-${TREE}-${BRANCH} 0*.patch
192 for patch_file in `ls 0*.patch`
193 do
194 reply $patch_file
195 echo "acknowledged $patch_file"
196 echo "-----------------------------------------------"
197 echo
198 done
199
a10f3d5 @gregkh work: fix up do.sh script
authored
200
201 # merge the patches back to the branch
202 git checkout ${TREE}-${BRANCH} && git merge work-${BRANCH}
11e46ce @gregkh fix up do scripts to handle online/offline issues
authored
203
204 # if something goes wrong, exit
205 if [ $? -ne 0 ] ; then
206 exit
207 fi
208
cfd8e8f @gregkh work/do.sh: call gregkh_machine_online instead of hard coding it
authored
209 ONLINE=`gregkh_machine_online`
11e46ce @gregkh fix up do scripts to handle online/offline issues
authored
210 # Only push if we have a network connection
a10f3d5 @gregkh work: fix up do.sh script
authored
211 if [ "$ONLINE" = "1" ] ; then
f3d2561 @gregkh do.sh: handle newer version of git for pushes
authored
212 git push kroah.com ${TREE}-${BRANCH}
213 git push
11e46ce @gregkh fix up do scripts to handle online/offline issues
authored
214 fi
215
a10f3d5 @gregkh work: fix up do.sh script
authored
216 # now go back to the original branch so that we can continue to work
217 git checkout work-${BRANCH}
Something went wrong with that request. Please try again.