]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - scripts/bad_stable
c2b3ed46bc02d6c4771291e186bb165c4497520d
[thirdparty/kernel/stable-queue.git] / scripts / bad_stable
1 #!/bin/bash
2
3 STABLE_VERSION=""
4 EMAIL_ADDRESS='<gregkh@linuxfoundation.org>'
5
6 extract_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
16 if [ x"$EMAIL_ADDRESS" = x ]
17 then
18 echo "You must set the EMAIL_ADDRESS environment variable to your email address"
19 exit 1
20 fi
21 FROM=$EMAIL_ADDRESS
22
23 TO=""
24 CC=""
25 STABLE='<stable@vger.kernel.org>'
26 STABLE_COMMITS='<stable-commits@vger.kernel.org>'
27
28 author()
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
83 reply()
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"
137 echo "id to <stable@vger.kernel.org>."
138 echo
139 echo "Possible dependencies:"
140 echo
141 echo "$(curl -s https://git.kernel.org/pub/scm/linux/kernel/git/sashal/deps.git/plain/v$STABLE_VERSION/$git_id)"
142 echo
143 echo "thanks,"
144 echo
145 echo "greg k-h"
146 echo
147 echo "------------------ original commit in Linus's tree ------------------"
148 echo
149 cat $PATCH
150 echo
151 # echo
152 # echo -n "Patches currently in gregkh-2.6 which might be from "
153 # echo "$FIRST_AUTHOR are"
154 # echo
155 # grep -lR $FIRST_AUTHOR /home/gregkh/linux/patches/ 2> /dev/null |
156 # sed -e 's/\/home\/gregkh\/linux\/patches\///'
157 ) |
158 makemail -to "$AUTHOR" \
159 -from="$FROM" \
160 -cc="$STABLE" \
161 -subject="FAILED: patch \"$SUBJECT\" failed to apply to $STABLE_VERSION-stable tree" \
162 -date="$(date -R)" \
163 -message_id="$ID" \
164 "$CHARCMD" | \
165 ~/bin/msmtp-enqueue.sh $to
166 }
167
168 git_id="$1"
169 shift
170
171 if [ "${git_id}" == "" ] ; then
172 echo "bad_stable GIT_ID KERNEL_VERSION"
173 echo "Must provide git id to be told is bad"
174 exit;
175 fi
176
177 echo "git_id = ${git_id}"
178
179 if [ "$#" == "0" ] ; then
180 versions=$(/home/gregkh/linux/stable/active_kernel_versions_get.sh)
181 else
182 versions="$*"
183 fi
184 echo "versions=${versions}"
185
186 for STABLE_VERSION in ${versions}
187 do
188 echo "bad version = ${STABLE_VERSION}"
189 TMPFILE=`mktemp bad_patch.XXXXX` || exit 1
190 git show --pretty=email $git_id > $TMPFILE
191 reply $TMPFILE
192 rm $TMPFILE
193 done
194
195 #for patch_file in $*
196 #do
197 # reply $patch_file
198 # echo "acknowledged $patch_file"
199 # echo "-----------------------------------------------"
200 # echo
201 #done