compile_script=/tmp/kernel-compile-script.sh
cover="no"
series=""
+resend="no"
+GIT_FORMAT_PATCH_SUBJECT="PATCH"
+skip_compile=0
print_usage()
{
echo "${PROG_NAME} -- Envoi de patches linux kernel"
- echo "Usage: ${PROG_NAME} [OPTIONS...] COMMIT_START COMMIT_END"
+ echo "Usage: ${PROG_NAME} [OPTIONS...]"
echo
echo "Options:"
+ echo " -d resend patch"
echo " -e end commit (string)"
echo " -f folder containing patch infos"
echo " -h display this help and exit"
+ echo " -n dot not compile patches"
echo " -r really send emails (default = dry-run)"
echo " -s start commit (string)"
echo
}
-while getopts "e:f:hrs:" flag ;do
+while getopts "de:f:hnrs:" flag ;do
case ${flag} in
+ d)
+ resend="yes"
+ ;;
e)
commit_end="${OPTARG}"
;;
print_usage
exit 0
;;
+ n)
+ skip_compile=1
+ ;;
r)
DRY_RUN=""
;;
exit 1
fi
+if [ ${skip_compile} -eq 0 ]; then
+ if [ x"${compile_branch}" = x"" ]; then
+ echo "Missing compile_branch shell variable"
+ exit 1
+ fi
+fi
+
if [ x"${base_commit}" = x"" ]; then
base_commit="auto"
fi
# If the cover letter is not between start and end commits, save a copy:
cp ${srcdir}/cover-letter.txt /tmp
-patches_branch="kernel_send_patches"
+patches_branch="hv_send_patches_$(basename ${srcdir})"
if [ x"${series}" != x"" ]; then
patches_branch="${patches_branch}_v${series}"
fi
-patches_branch="${patches_branch}_$(basename ${srcdir})"
-
orig_branch=$(git branch --show-current)
if [ x"${orig_branch}" = x"" ]; then
GIT_FORMAT_PATCH_OPTS="${GIT_FORMAT_PATCH_OPTS} --cover-letter"
fi
-if [ x"${series}" != x"" ]; then
+series_prefix=""
+if [ x"${series}" != x"" -a x"${series}" != x"1" ]; then
+ series_prefix="v${series}-"
GIT_FORMAT_PATCH_OPTS="${GIT_FORMAT_PATCH_OPTS} -v ${series}"
fi
-git format-patch ${GIT_FORMAT_PATCH_OPTS} --output-directory=${srcdir} ${base_branch}
+if [ x"${resend}" = x"yes" ]; then
+ GIT_FORMAT_PATCH_SUBJECT="RESEND ${GIT_FORMAT_PATCH_SUBJECT}"
+fi
+
+git format-patch --subject-prefix="${GIT_FORMAT_PATCH_SUBJECT}" \
+ ${GIT_FORMAT_PATCH_OPTS} --output-directory=${srcdir} ${base_branch}
if [ x"${cover}" = x"yes" ]; then
# Replace subject line in cover letter:
- sed -i -e "s/\*\*\* SUB.*/${subject}/" ${srcdir}/v${series}-0000-cover-letter.patch
+ sed -i -e "s/\*\*\* SUB.*/${subject}/" ${srcdir}/${series_prefix}0000-cover-letter.patch
# Replace blurb line in cover letter:
- sed -i -e "/.*BLURB.*/{r /tmp/cover-letter.txt" -e 'd}' ${srcdir}/v${series}-0000-cover-letter.patch
+ sed -i -e "/.*BLURB.*/{r /tmp/cover-letter.txt" -e 'd}' ${srcdir}/${series_prefix}0000-cover-letter.patch
collect_email_addresses
fi
# Check patches (except special case of cover letter patch):
for p in ${srcdir}/*.patch; do
- if [ x"$(basename ${p})" != x"v${series}-0000-cover-letter.patch" ]; then
+ if [ x"$(basename ${p})" != x"${series_prefix}0000-cover-letter.patch" ]; then
if [ x"${ignore_checkpatch_errors}" != x"" ]; then
set +e
CHECKPATCH_OPS="--ignore ${ignore_checkpatch_errors}"
fi
done
-cat > ${compile_script} << "EOF"
+if [ ${skip_compile} -eq 0 ]; then
+ cat > ${compile_script} << "EOF"
#!/bin/bash
# Do not edit, auto-generated script
echo
COMPILE_CMD
EOF
-if [ x"${init_cmd}" != x"" ]; then
- sed -i -e "s@.*INIT_CMD@${init_cmd}@" ${compile_script}
+ if [ x"${init_cmd}" != x"" ]; then
+ sed -i -e "s@.*INIT_CMD@${init_cmd}@" ${compile_script}
+ fi
+ sed -i -e "s@COMPILE_CMD@${compile_cmd}@" ${compile_script}
+ chmod u+x ${compile_script}
+
+ # Create temporary branch for compilation, based on compile_branch:
+ temp_compile_branch="${patches_branch}_compile"
+
+ if git branch | grep -q ${temp_compile_branch}; then
+ git branch -D ${temp_compile_branch}
+ fi
+
+ git checkout -b ${temp_compile_branch} ${compile_branch}
+
+ # Make sure temp_compile_branch is rebased on base_branch:
+ git rebase ${base_branch}
+
+ # Apply all of our commits to temp_compile_branch:
+ git cherry-pick ${COMMIT_START_SHA1}..${COMMIT_END_SHA1}
+
+ # Compile and test each commit:
+ git rebase --exec=${compile_script} ${compile_branch}
fi
-sed -i -e "s@COMPILE_CMD@${compile_cmd}@" ${compile_script}
-chmod u+x ${compile_script}
-# Compile each commit. Create branch to avoid "detached HEAD" state, and also to
-# keep a record of what was sent:
-git rebase --exec=${compile_script} ${base_branch}
git checkout ${orig_branch}
+if [ ${skip_compile} -eq 0 ]; then
+ # Remove temporary branch:
+ git branch -D ${temp_compile_branch}
+fi
+
# Send email(s)
git send-email ${DRY_RUN} --annotate --thread --no-chain-reply-to \
${TO_OPTS} ${CC_OPTS} \