]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - scripts/bad_stable
script/c2p: allow multiple kernel versions on the command line
[thirdparty/kernel/stable-queue.git] / scripts / bad_stable
CommitLineData
9831ae87
GKH
1#!/bin/bash
2
1582f8c5
GKH
3STABLE_VERSION=""
4EMAIL_ADDRESS='<gregkh@linuxfoundation.org>'
9831ae87
GKH
5
6extract_addr()
7{
8 read l
9 read l
10 read l
11 read l
12 a=$(echo "$l" | sed -n -e 's/.*<\(.*@[^>]*\).*/\1/p')
13 echo $a
14}
15
16if [ x"$EMAIL_ADDRESS" = x ]
17then
18 echo "You must set the EMAIL_ADDRESS environment variable to your email address"
19 exit 1
20fi
21FROM=$EMAIL_ADDRESS
22
23TO=""
24CC=""
e394f899 25STABLE='<stable@vger.kernel.org>'
9831ae87
GKH
26STABLE_COMMITS='<stable-commits@vger.kernel.org>'
27
28author()
29{
30 first_author=""
31 TXT=$2
32 if [ ! -f $TXT ]
33 then
34 echo "$TXT is missing"
35 exit 1
36 fi
37 author=""
38 while read l
39 do
40 # skip the Message-ID: line so we don't send email to the wrong place
41 #echo "$l"
42 reply=$(echo "$l" | grep -i Message-ID:)
43 if [ x"$reply" != x ]
44 then
45 continue
46 fi
47
48 # if this is the start of the diff, then it's time to stop looking
49 diff=$(echo "$l" | grep "^---")
50 if [ x"$diff" != x ]
51 then
52 #echo "diffstart!!!!!"
53 break
54 fi
55
56 for x in $l
57 do
58 a=$(echo "$x" | sed -n -e 's/.*<\(.*@[^>]*\).*/\1/p')
59 if [ x"$a" != x ]
60 then
61 if [ x"$author" == x ]
62 then
63 author=$a
64 first_author=$a
65 else
66 author="$author $a"
67 fi
68 fi
69 done
70 done < $TXT
71 author=$(echo "$author" | tr ' ' '\n' | grep -v "$first_author" |
72 sort | uniq)
73 author="$first_author $author"
74 eval $1=$(echo $author | sed -e 's/ /,/g')
75 if [ x"$3" != x ]
76 then
77 eval $3=$first_author
78 fi
79}
80
81
82
83reply()
84{
85 PATCH=$1
86# patch_name=$(stripit $1)
87# PATCH=$P/patches/$patch_name.patch
88# TXT=$P/txt/$patch_name.txt
89# if [ ! -f $TXT ]
90# then
91# echo $TXT is missing
92# exit 1
93# fi
94 #echo "PATCH=$PATCH"
95# SUBJECT=`grep "Subject:" $PATCH`
96 SUBJECT=`grep "Subject:" $PATCH | sed s/Subject\:\ //`
97# SUBJECT=$(head -n 2 $PATCH | tail -n 1)
98 MESSAGE_ID=`grep -i "^Message-ID:" $PATCH | cut -f 2 -d ' ' | cut -f 2 -d '<' | cut -f 1 -d '>'`
99 author AUTHOR $1 FIRST_AUTHOR
100 #echo "author said $AUTHOR"
101 #echo "first_author said $FIRST_AUTHOR"
102 if [ x"$AUTHOR" == "x" ]
103 then
104 echo "nobody to notify"
105 exit 0
106 fi
107 to=""
108 for i in $(echo "$AUTHOR" | sed -e 's/,/ /g')
109 do
110 if ! echo "$TO" | grep "$i"
111 then
112 to=$to" -to $i"
113 fi
114 done
115 if [ x"$cc" != x ]
116 then
117 cc="-cc $cc"
118 fi
119
120 CHARSET=$(guess-charset "$PATCH")
121 if test "x$CHARSET" = "ANSI_X3.4-1968"; then
122 CHARSET=
123 else
124 CHARCMD="-charset=$CHARSET"
125 fi
126
127 ID=`make_message_id`
128
129 #echo "makemail -to $AUTHOR -from=$FROM -subject=\"patch $PATCH added to gregkh tree\" -date=\"$(date -R)\" -message=$ID $CHARCMD"
130 echo "sending to $AUTHOR"
131
132 (
133 echo
134 echo "The patch below does not apply to the $STABLE_VERSION-stable tree."
135 echo "If someone wants it applied there, or to any other stable or longterm"
136 echo "tree, then please email the backport, including the original git commit"
e394f899 137 echo "id to <stable@vger.kernel.org>."
9831ae87
GKH
138 echo
139 echo "thanks,"
140 echo
141 echo "greg k-h"
142 echo
143 echo "------------------ original commit in Linus's tree ------------------"
144 echo
145 cat $PATCH
146 echo
147# echo
148# echo -n "Patches currently in gregkh-2.6 which might be from "
149# echo "$FIRST_AUTHOR are"
150# echo
151# grep -lR $FIRST_AUTHOR /home/gregkh/linux/patches/ 2> /dev/null |
152# sed -e 's/\/home\/gregkh\/linux\/patches\///'
153 ) |
154 makemail -to "$AUTHOR" \
155 -from="$FROM" \
156 -cc="$STABLE" \
1582f8c5 157 -subject="FAILED: patch \"$SUBJECT\" failed to apply to $STABLE_VERSION-stable tree" \
9831ae87
GKH
158 -date="$(date -R)" \
159 -message_id="$ID" \
160 "$CHARCMD" | \
1582f8c5 161 ~/bin/msmtp-enqueue.sh -a coco $to
9831ae87
GKH
162}
163
1582f8c5
GKH
164STABLE_VERSION="$1"
165shift
9831ae87 166
1582f8c5
GKH
167if [ "${STABLE_VERSION}" == "" ] ; then
168 echo "Must provide kernel version to be told is bad\n"
169 exit;
170fi
171
172echo "STABLE_VERSION = ${STABLE_VERSION}"
9831ae87
GKH
173
174for git_id in $*
175do
176 TMPFILE=`mktemp bad_patch.XXXXX` || exit 1
177 git show --pretty=email $git_id > $TMPFILE
178 reply $TMPFILE
179 rm $TMPFILE
180done
181
182#for patch_file in $*
183#do
184# reply $patch_file
185# echo "acknowledged $patch_file"
186# echo "-----------------------------------------------"
187# echo
188#done