]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - scripts/bad_stable
scripts/bad_stable: update it a bit
[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
af42601c 49 diff=$(echo "$l" | grep "^--- ")
9831ae87
GKH
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 138 echo
e22d6dc1
SL
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
9831ae87
GKH
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" \
1582f8c5 161 -subject="FAILED: patch \"$SUBJECT\" failed to apply to $STABLE_VERSION-stable tree" \
9831ae87
GKH
162 -date="$(date -R)" \
163 -message_id="$ID" \
164 "$CHARCMD" | \
571fc94c 165 ~/bin/msmtp-enqueue.sh $to
9831ae87
GKH
166}
167
af42601c 168git_id="$1"
1582f8c5 169shift
9831ae87 170
af42601c
GKH
171if [ "${git_id}" == "" ] ; then
172 echo "bad_stable GIT_ID KERNEL_VERSION"
571fc94c 173 echo "Must provide git id to be told is bad"
1582f8c5
GKH
174 exit;
175fi
176
af42601c 177echo "git_id = ${git_id}"
9831ae87 178
571fc94c
GKH
179if [ "$#" == "0" ] ; then
180 versions=$(/home/gregkh/linux/stable/active_kernel_versions_get.sh)
181else
182 versions="$*"
183fi
184echo "versions=${versions}"
185
186for STABLE_VERSION in ${versions}
9831ae87 187do
af42601c 188 echo "bad version = ${STABLE_VERSION}"
9831ae87
GKH
189 TMPFILE=`mktemp bad_patch.XXXXX` || exit 1
190 git show --pretty=email $git_id > $TMPFILE
191 reply $TMPFILE
192 rm $TMPFILE
193done
194
195#for patch_file in $*
196#do
197# reply $patch_file
198# echo "acknowledged $patch_file"
199# echo "-----------------------------------------------"
200# echo
201#done