X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fkernel-send-patches.sh;fp=scripts%2Fkernel-send-patches.sh;h=6cca90dbad66097572bdd2217591e0186a93df16;hb=4bdf58b65635c9428ac7647d5c3e1cb451c08fa5;hp=d69f914848c0629392f719365d4a3a116c92469f;hpb=ccbccf5b7a602ef6ab93bb467b4d029d49e0ab68;p=hvutilities.git diff --git a/scripts/kernel-send-patches.sh b/scripts/kernel-send-patches.sh index d69f914..6cca90d 100755 --- a/scripts/kernel-send-patches.sh +++ b/scripts/kernel-send-patches.sh @@ -29,6 +29,7 @@ catch() # Cleanup for both normal exit and error: rm -f /tmp/all.patch rm -f ${compile_script} + rm -f /tmp/cover-letter.txt } # --non: do not print name for each email address @@ -43,6 +44,8 @@ orig_branch="" srcdir="" compile_cmd="make" compile_script=/tmp/kernel-compile-script.sh +cover="no" +series="" print_usage() { @@ -103,9 +106,8 @@ if [ ! -d ${srcdir} ]; then exit 1 fi -if [ ! -f ${srcdir}/cover-letter.txt ]; then - echo "Missing cover letter template" - exit 1 +if [ -f ${srcdir}/cover-letter.txt ]; then + cover="yes" fi if [ ! -f ${srcdir}/infos.sh ]; then @@ -125,23 +127,31 @@ if [ x"${commit_end}" = x"" ]; then exit 1 fi +if [ x"${cover}" = x"yes" ]; then + if [ x"${series}" = x"" ]; then + echo "Missing series shell variable" + exit 1 + fi -if [ x"${series}" = x"" ]; then - echo "Missing series shell variable" - exit 1 + if [ x"${subject}" = x"" ]; then + echo "Missing subject shell variable" + exit 1 + fi fi -if [ x"${subject}" = x"" ]; then - echo "Missing subject shell variable" +if [ x"${cc_list}" = x"" ]; then + echo "Missing cc_list shell variable" exit 1 fi -if [ x"${cc_list}" = x"" ]; then - echo "Missing cc_list shell variable" +if [ x"${base_branch}" = x"" ]; then + echo "Missing base_branch shell variable" exit 1 fi -patches_branch="kernel_send_patches_v${series}_$(basename ${srcdir})" +if [ x"${base_commit}" = x"" ]; then + base_commit="auto" +fi # First arg: commit message find_commit_by_log() @@ -156,7 +166,7 @@ find_commit_by_log() # all emails, including cover letter and actual patches. collect_email_addresses() { - cat ${srcdir}/v${series}-*.patch > /tmp/all.patch + cat ${srcdir}/*.patch > /tmp/all.patch # These variables will have one email address per line" TO_MAIL="$(${TO_CMD} /tmp/all.patch)" @@ -169,7 +179,10 @@ collect_email_addresses() while IFS= read -r line; do CC_OPTS="${CC_OPTS} --cc ${line}" done <<< "${CC_MAIL}" +} +add_cc_list_addresses() +{ for address in ${cc_list}; do CC_OPTS="${CC_OPTS} --cc ${address}" done @@ -191,15 +204,54 @@ fi rm -rf ${srcdir}/*.patch -git format-patch --base=auto -v ${series} --output-directory=${srcdir} --cover-letter ${COMMIT_START_SHA1}..${COMMIT_END_SHA1} +# 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" -# Replace subject line in cover letter: -sed -i -e "s/\*\*\* SUB.*/${subject}/" ${srcdir}/v${series}-0000-cover-letter.patch +if [ x"${series}" != x"" ]; then + patches_branch="${patches_branch}_v${series}" +fi + +patches_branch="${patches_branch}_$(basename ${srcdir})" + +orig_branch=$(git branch --show-current) -# Replace blurb line in cover letter: -sed -i -e "/.*BLURB.*/{r ${srcdir}/cover-letter.txt" -e 'd}' ${srcdir}/v${series}-0000-cover-letter.patch +if [ x"${orig_branch}" = x"" ]; then + echo "Error: unable to determine current branch" + exit 1 +fi -collect_email_addresses +if git branch | grep -q ${patches_branch}; then + git branch -D ${patches_branch} +fi + +git checkout -b ${patches_branch} ${COMMIT_END_SHA1} +git branch --set-upstream-to ${base_branch} + +GIT_FORMAT_PATCH_OPTS="--base=${base_commit}" + +if [ x"${cover}" = x"yes" ]; then + GIT_FORMAT_PATCH_OPTS="${GIT_FORMAT_PATCH_OPTS} --cover-letter" +fi + +if [ x"${series}" != x"" ]; then + GIT_FORMAT_PATCH_OPTS="${GIT_FORMAT_PATCH_OPTS} -v ${series}" +fi + +git format-patch ${GIT_FORMAT_PATCH_OPTS} --output-directory=${srcdir} ${COMMIT_START_SHA1}..${COMMIT_END_SHA1} + +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 + + # Replace blurb line in cover letter: + sed -i -e "/.*BLURB.*/{r /tmp/cover-letter.txt" -e 'd}' ${srcdir}/v${series}-0000-cover-letter.patch + + collect_email_addresses +fi + +add_cc_list_addresses # Check patches (except special case of cover letter patch): for p in ${srcdir}/*.patch; do @@ -217,13 +269,6 @@ for p in ${srcdir}/*.patch; do fi done -orig_branch=$(git branch --show-current) - -if [ x"${orig_branch}" = x"" ]; then - echo "Error: unable to determine current branch" - exit 1 -fi - cat > ${compile_script} << "EOF" #!/bin/bash # Do not edit, auto-generated script @@ -237,10 +282,6 @@ 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: -if git branch | grep -q ${patches_branch}; then - git branch -D ${patches_branch} -fi -git checkout -b ${patches_branch} ${COMMIT_END_SHA1} git rebase --exec=${compile_script} ${COMMIT_START_SHA1} git checkout ${orig_branch}