aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/quilt-mail
blob: e0df3d935fc04412e8faf18953681ad5ab0c4344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Script to take a stable-queue, and turn it into a -rc release to be
# sent off in email.
#

# locations of some things that you might want to override if you are a
# different developer than gregkh
STABLE_QUEUE="/home/gregkh/linux/stable/stable-queue/"
TMP_DIR="/home/gregkh/linux/tmp/"

SCRIPT_NAME=`basename ${0}`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# programs that we depend on in this script
REQUIREMENTS="kv splitmbox.pl kup mbox2send filterdiff"
# todo check dependancies using hash or something


MBOX="$1"
if [ "${MBOX}" == "" ] ; then
	echo "using default 'mbox' name for the mailbox."
	MBOX="mbox"
fi

FULL_VERSION=`kv`
BASE_VERSION=${FULL_VERSION/-rc?/}
VERSION=`basename \`pwd\``
ROOT_VERSION=${VERSION/\.y/}
ROOT_VERSION=${ROOT_VERSION/linux-/}

REL_ARRAY=(${FULL_VERSION//./ })
MAJOR=${REL_ARRAY[0]}
VER="${MAJOR}.x"

RC_ARRAY=(${FULL_VERSION//-/ })
RC=${RC_ARRAY[1]}

#DATE=`date -u --date="2 days"`
DATE=`date -u --rfc-822 --date="2 days"`

if [ ${FULL_VERSION} == ${BASE_VERSION} ] ; then
	echo "Makefile says the version is ${FULL_VERSION}, did you forget to set the -rc version?"
	exit
fi


# create a directory for everything to live in
#TMP_DIR=`mktemp -d ${TMP_DIR}/stable-${ROOT_VERSION}-XXXX` || exit 1
TMP_DIR=`mktemp -d ${TMP_DIR}/stable-${FULL_VERSION}-XXX` || exit 1

# Generate the Makefile diff, with just the version number change in it
# relies on filterdiff from the wonderful patchutils package
git diff Makefile | filterdiff --hunks 1 > ${TMP_DIR}/Makefile.patch


# make a git tree to create the log file in the format that Linus likes.
echo "Creating a git tree of the commits..."
ORIGINAL_DIR=`pwd`
TMP_TREE=`mktemp -d ${TMP_DIR}/stable-${ROOT_VERSION}-XXXX` || exit 1
TMP_LOG=`mktemp ${TMP_DIR}/stable-log-XXXX` || exit 1
git clone -s . ${TMP_TREE}
cd ${TMP_TREE}
git checkout -b temp_branch
git quiltimport --patches=${STABLE_QUEUE}/queue-${ROOT_VERSION}
if [ $? -ne 0 ]; then
	echo "git quilt import failed!!!"
	exit 1
fi

# Apply the Makefile patch and commit it
patch -p1 < ${TMP_DIR}/Makefile.patch
git commit -a -m "Linux ${FULL_VERSION}"

# Generate the diffstat and patch
git diff ${VERSION}..HEAD > ${TMP_DIR}/patch-${FULL_VERSION}
git diff --stat ${VERSION}..HEAD > ${TMP_DIR}/diffstat

# sign the patch
gpg -a -b ${TMP_DIR}/patch-${FULL_VERSION}

# generate the log file
git log --abbrev=12 --format="%aN <%aE>%n    %s%n" ${VERSION}..HEAD > ${TMP_LOG}

# clean up the git tree by deleting it
cd ${ORIGINAL_DIR}
#rm -rf ${TMP_TREE}


echo "Creating the mailbox for kernel release ${FULL_VERSION}"
TMPFILE=`mktemp ${TMP_DIR}/stable_header.XXXXXX` || exit 1
NUM_PATCHES=`quilt series | wc -l`

(
echo "This is the start of the stable review cycle for the ${BASE_VERSION} release."
echo "There are ${NUM_PATCHES} patches in this series, all will be posted as a response"
echo "to this one.  If anyone has any issues with these being applied, please"
echo "let me know."
echo ""
echo "Responses should be made by ${DATE}."
echo "Anything received after that time might be too late."
echo ""
echo "The whole patch series can be found in one patch at:"
echo "	https://www.kernel.org/pub/linux/kernel/v${VER}/stable-review/patch-${FULL_VERSION}.gz"
echo "or in the git tree and branch at:"
echo "	git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-${ROOT_VERSION}.y"
echo "and the diffstat can be found below."
echo ""
echo "thanks,"
echo ""
echo "greg k-h"
echo ""
echo "-------------"
echo "Pseudo-Shortlog of commits:"
echo ""
cat ${TMP_LOG}
#stable-shortlog
echo ""
echo "-------------"
echo ""
echo "Diffstat:"
echo ""

cat ${TMP_DIR}/diffstat
) > ${TMPFILE}

FROM="Greg Kroah-Hartman <gregkh@linuxfoundation.org>"
TO="stable@vger.kernel.org"
CC="patches@lists.linux.dev"
#SUBJECT="${BASE_VERSION}-stable review"
SUBJECT="${FULL_VERSION} review"

quilt mail --mbox ${TMP_DIR}/${MBOX}	\
	-M "${TMPFILE}"		\
	--sender "${FROM}"	\
	--from "${FROM}"	\
	--to "${TO}"		\
	--cc "${CC}"		\
	--prefix "PATCH ${ROOT_VERSION}"	\
	--subject "${SUBJECT}"

rm ${TMPFILE} ${TMP_LOG}

echo "mbox is now in ${TMP_DIR}/${MBOX}"

cd ${TMP_DIR}
${STABLE_QUEUE}/scripts/mbox2send ${ROOT_VERSION} ${FULL_VERSION} ${MBOX}
#< ${MBOX}.new formail -ds sh -c 'cat > msg.$FILENO'
splitmbox.pl ${MBOX}.new .

# find the "0" email message
if [ -f "msg.0" ]; then
	MSG="msg.0"
elif [ -f "msg.00" ]; then
	MSG="msg.00"
elif [ -f "msg.000" ]; then
	MSG="msg.000"
elif [ -f "msg.0000" ]; then
	MSG="msg.0000"
else
	echo "msg.ZERO can not be found???"
	echo "Aborting!"
	exit 1
fi

# List of names to cc: on the 00/XX email message
# must escape '.' characters properly due to use of sed below
CC_NAMES=("linux-kernel@vger\.kernel\.org"
	  "torvalds@linux-foundation\.org"
	  "akpm@linux-foundation\.org"
	  "linux@roeck-us\.net"
	  "shuah@kernel\.org"
	  "patches@kernelci\.org"
	  "lkft-triage@lists\.linaro\.org"
	  "pavel@denx\.de"
	  "jonathanh@nvidia\.com"
	  "f\.fainelli@gmail\.com"
	  "sudipm\.mukherjee@gmail\.com"
	  "srw@sladewatkins\.net"
	  "rwarsow@gmx\.de"
	  "conor@kernel\.org"
	  "hargar@microsoft\.com"
	  "broonie@kernel\.org")

#CC_LIST="stable@vger\.kernel\.org"
CC_LIST="patches@lists.linux.dev"
for name in "${CC_NAMES[@]}"; do
	CC_LIST+=", ${name}"
done
echo "Adding names to ${MSG}: ${CC_LIST}"

#sed -i -e "s/Cc: stable@vger\.kernel\.org/Cc: ${CC_LIST}/" "${TMP_DIR}"/"${MSG}"
sed -i -e "s/Cc: ${CC}/Cc: ${CC_LIST}/" "${TMP_DIR}"/"${MSG}"


# Create a script to upload the patch to kernel.org and to send the patches out
echo "#!/bin/bash" > ${TMP_DIR}/send_it_off
echo "kup --host=git@gitolite.kernel.org --subcmd=kup-server put patch-${FULL_VERSION} patch-${FULL_VERSION}.asc /pub/linux/kernel/v${VER}/stable-review/patch-${FULL_VERSION}.gz" >> ${TMP_DIR}/send_it_off

if [ "${RC}" == "rc1" ] ; then
	echo "git send-email msg.*" >> ${TMP_DIR}/send_it_off
	echo "#git send-email ${MSG}" >> ${TMP_DIR}/send_it_off
else
	echo "#git send-email msg.*" >> ${TMP_DIR}/send_it_off
	echo "git send-email ${MSG}" >> ${TMP_DIR}/send_it_off
fi

chmod 755 ${TMP_DIR}/send_it_off


# Push a version of the patches out to the world in a git tree
cd ${TMP_TREE}
git checkout linux-${ROOT_VERSION}.y
git merge -q temp_branch
#echo "git push --force gitolite@ra.kernel.org:/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-${ROOT_VERSION}.y"
#git push --force gitolite@ra.kernel.org:/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-${ROOT_VERSION}.y
echo "git push --force git@gitolite.kernel.org:/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-${ROOT_VERSION}.y"
git push --force git@gitolite.kernel.org:/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-${ROOT_VERSION}.y

# clean up the git tree by deleting it
cd ${ORIGINAL_DIR}
rm -rf ${TMP_TREE}

# announce what needs to be done
echo "cd ${TMP_DIR}"
echo "./send_it_off"