]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - scripts/added-to-stable
first cut at a script to automate the quilt mail generation
[thirdparty/kernel/stable-queue.git] / scripts / added-to-stable
1 #!/bin/bash
2
3 KERNEL_MINOR_VERSION='34'
4 KERNEL="2.6.$KERNEL_MINOR_VERSION"
5
6 EMAIL_ADDRESS='<gregkh@linuxfoundation.org>'
7
8 STABLE='<stable@vger.kernel.org>'
9 STABLE_COMMITS='<stable-commits@vger.kernel.org>'
10
11 extract_addr()
12 {
13 read l
14 read l
15 read l
16 read l
17 a=$(echo "$l" | sed -n -e 's/.*<\(.*@[^>]*\).*/\1/p')
18 echo $a
19 }
20
21 if [ x"$SMTP_SERVER" = x ]
22 then
23 SMTP_SERVER=localhost:25
24 fi
25
26 if [ x"$EMAIL_ADDRESS" = x ]
27 then
28 echo "You must set the EMAIL_ADDRESS environment variable to your email address"
29 exit 1
30 fi
31 FROM=$EMAIL_ADDRESS
32
33 TO=""
34 CC=""
35
36 author()
37 {
38 first_author=""
39 TXT=$2
40 if [ ! -f $TXT ]
41 then
42 echo "$TXT is missing"
43 exit 1
44 fi
45 author=""
46 while read l
47 do
48 # skip the Message-ID: line so we don't send email to the wrong place
49 echo "$l"
50 reply=$(echo "$l" | grep -i Message-ID:)
51 if [ x"$reply" != x ]
52 then
53 continue
54 fi
55
56 # if this is the start of the diff, then it's time to stop looking
57 diff=$(echo "$l" | grep "^---")
58 if [ x"$diff" != x ]
59 then
60 echo "diffstart!!!!!"
61 break
62 fi
63
64 for x in $l
65 do
66 a=$(echo "$x" | sed -n -e 's/.*<\(.*@[^>]*\).*/\1/p')
67 if [ x"$a" != x ]
68 then
69 if [ x"$author" == x ]
70 then
71 author=$a
72 first_author=$a
73 else
74 author="$author $a"
75 fi
76 fi
77 done
78 done < $TXT
79 author=$(echo "$author" | tr ' ' '\n' | grep -v "$first_author" |
80 sort | uniq)
81 author="$first_author $author"
82 eval $1=$(echo $author | sed -e 's/ /,/g')
83 if [ x"$3" != x ]
84 then
85 eval $3=$first_author
86 fi
87 }
88
89
90
91 reply()
92 {
93 PATCH=$1
94 # patch_name=$(stripit $1)
95 # PATCH=$P/patches/$patch_name.patch
96 # TXT=$P/txt/$patch_name.txt
97 # if [ ! -f $TXT ]
98 # then
99 # echo $TXT is missing
100 # exit 1
101 # fi
102 echo "PATCH=$PATCH"
103 # SUBJECT=`grep "Subject:" $PATCH`
104 SUBJECT=`grep "Subject:" $PATCH | sed s/Subject\:\ //`
105 # SUBJECT=$(head -n 2 $PATCH | tail -n 1)
106 MESSAGE_ID=`grep -i "^Message-ID:" $PATCH | cut -f 2 -d ' ' | cut -f 2 -d '<' | cut -f 1 -d '>'`
107 author AUTHOR $1 FIRST_AUTHOR
108 echo "author said $AUTHOR"
109 echo "first_author said $FIRST_AUTHOR"
110 if [ x"$AUTHOR" == "x" ]
111 then
112 echo "nobody to notify"
113 exit 0
114 fi
115 to=""
116 for i in $(echo "$AUTHOR" | sed -e 's/,/ /g')
117 do
118 if ! echo "$TO" | grep "$i"
119 then
120 to=$to" -to $i"
121 fi
122 done
123 if [ x"$cc" != x ]
124 then
125 cc="-cc $cc"
126 fi
127
128 # SUBJECT="patch $PATCH added to $KERNEL-stable tree"
129
130 CHARSET=$(guess-charset "$PATCH")
131 if test "x$CHARSET" = "ANSI_X3.4-1968"; then
132 CHARSET=
133 else
134 CHARCMD="-charset=$CHARSET"
135 fi
136
137 ID=`make_message_id`
138
139 echo "makemail -to $AUTHOR -from=$FROM -subject=\"$SUBJECT\" -date=\"$(date -R)\" -reply_to=$MESSAGE_ID --message=$ID $CHARCMD"
140 # echo "smtpsend -server=$SMTP_SERVER $to -from=$FROM"
141
142
143 (
144 echo
145 echo "This is a note to let you know that I've just added the patch titled"
146 echo
147 echo " $SUBJECT"
148 echo
149 echo "to the $KERNEL-stable tree which can be found at:"
150 echo " http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary"
151 echo
152 echo "The filename of the patch is:"
153 echo " " `basename "$PATCH"`
154 echo "and it can be found in the queue-$KERNEL subdirectory."
155 echo
156 echo "If you, or anyone else, feels it should not be added to the stable tree,"
157 echo "please let <stable@vger.kernel.org> know about it."
158 echo
159 echo
160 cat $PATCH
161 echo
162 echo
163 echo -n "Patches currently in stable-queue which might be from "
164 echo "$FIRST_AUTHOR are"
165 echo
166 grep -lR $FIRST_AUTHOR /home/gregkh/linux/stable/stable-queue/queue-$KERNEL/ 2> /dev/null |
167 sed -e 's/\/home\/gregkh\/linux\/stable\/stable-queue\///'
168 ) |
169 makemail -to "$AUTHOR" \
170 -from="$FROM" \
171 -cc="$STABLE, $STABLE_COMMITS" \
172 -subject="Patch \"$SUBJECT\" has been added to the $KERNEL-stable tree" \
173 -date="$(date -R)" \
174 -reply_to="$MESSAGE_ID" \
175 -message_id="$ID" \
176 "$CHARCMD" \
177 | \
178 ~/bin/msmtp-enqueue.sh -a coco "$to"
179 #msmtp $to
180 }
181
182 for patch_file in $*
183 do
184 reply $patch_file
185 echo "acknowledged $patch_file"
186 echo "-----------------------------------------------"
187 echo
188 done