From: Greg Kroah-Hartman Date: Fri, 20 Nov 2009 19:23:39 +0000 (-0800) Subject: update the scripts the send email X-Git-Tag: v2.6.31.7~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d895cd7ddd19763ea01366c84669e00a42073d2;p=thirdparty%2Fkernel%2Fstable-queue.git update the scripts the send email This addes a message_id to the email, to keep vger.kernel.org from thinking that this is a mail loop Also adds mime type handling if we are sending out a UTF-8 message so that mail clients are happier. --- diff --git a/scripts/added-to-stable b/scripts/added-to-stable index 75ed2f7f9f7..3d2ec302954 100755 --- a/scripts/added-to-stable +++ b/scripts/added-to-stable @@ -9,7 +9,7 @@ # exit 1 #} -KERNEL_MINOR_VERSION='25' +KERNEL_MINOR_VERSION='31' KERNEL="2.6.$KERNEL_MINOR_VERSION" EMAIL_ADDRESS='' @@ -135,8 +135,17 @@ reply() SUBJECT="patch $PATCH added to $KERNEL-stable tree" - echo "makemail -to $AUTHOR -from=$FROM -subject=\"$SUBJECT\" -date=\"$(date -R)\" -reply_to=$MESSAGE_ID" - echo "smtpsend -server=$SMTP_SERVER $to -from=$FROM" + CHARSET=$(guess-charset "$PATCH") + if test "x$CHARSET" = "ANSI_X3.4-1968"; then + CHARSET= + else + CHARCMD="-charset=$CHARSET" + fi + + ID=`make_message_id` + + echo "makemail -to $AUTHOR -from=$FROM -subject=\"$SUBJECT\" -date=\"$(date -R)\" -reply_to=$MESSAGE_ID --message=$ID $CHARCMD" +# echo "smtpsend -server=$SMTP_SERVER $to -from=$FROM" ( @@ -163,10 +172,15 @@ reply() grep -lR $FIRST_AUTHOR /home/gregkh/linux/stable/stable-queue/queue-$KERNEL/ 2> /dev/null | sed -e 's/\/home\/gregkh\/linux\/stable\/stable-queue\///' ) | - makemail -to "$AUTHOR" -from="$FROM" -cc="$STABLE, $STABLE_COMMITS" \ + makemail -to "$AUTHOR" \ + -from="$FROM" \ + -cc="$STABLE, $STABLE_COMMITS" \ -subject="$SUBJECT" \ -date="$(date -R)" \ - -reply_to="$MESSAGE_ID" | \ + -reply_to="$MESSAGE_ID" \ + -message_id="$ID" \ + "$CHARCMD" \ + | \ # talk to the suse network instead of localhost (due to the way suse.de now handles email...) # smtpsend -server=$SMTP_SERVER $to -from=$FROM msmtp $to diff --git a/scripts/guess-charset b/scripts/guess-charset new file mode 100755 index 00000000000..1b0fe546349 --- /dev/null +++ b/scripts/guess-charset @@ -0,0 +1,52 @@ +#! /usr/bin/env python +# vim: set fileencoding=utf-8 +# (c) Uwe Kleine-König +# GPLv2 + +import locale +import sys + +f = file(sys.argv[1]) +data = f.read() + +def len_utf8_char(data): + def check_cont(num): + if all(map(lambda c: ord(c) >= 0x80 and ord(c) <= 0xbf, data[1:num])): + return num + else: + return -1 + + if ord(data[0]) < 128: + # ASCII char + return 1 + elif ord(data[0]) & 0xe0 == 0xc0: + return check_cont(2) + elif ord(data[0]) & 0xf0 == 0xe0: + return check_cont(3) + elif ord(data[0]) & 0xf8 == 0xf0: + return check_cont(4) + elif ord(data[0]) & 0xfc == 0xf8: + return check_cont(5) + elif ord(data[0]) & 0xfe == 0xfc: + return check_cont(6) + +i = 0 +maxl = 0 +while i < len(data): + l = len_utf8_char(data[i:]) + if l < 0: + prefenc = locale.getpreferredencoding() + if prefenc not in ('UTF-8', 'ANSI_X3.4-1968'): + print prefenc + else: + print 'ISO-8859-1' + sys.exit(0) + + if maxl < l: + maxl = l + i += l + +if maxl > 1: + print 'UTF-8' +else: + print 'ANSI_X3.4-1968' diff --git a/scripts/make_message_id b/scripts/make_message_id new file mode 100755 index 00000000000..b76f77fdf3b --- /dev/null +++ b/scripts/make_message_id @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +# we make a "fake" message id by taking the current number +# of seconds since the beginning of Unix time and tacking on +# a random number to the end, in case we are called quicker than +# 1 second since the last time we were called. + +my $date = `date "+\%s"`; +my $hostname = `hostname -d`; +chomp($date); +my $pseudo_rand = int (rand(4200)); +$message_id = "$date$pseudo_rand\@$hostname"; +print "$message_id"; diff --git a/scripts/makemail b/scripts/makemail index 2dddb36a56a..447de1ac43b 100755 --- a/scripts/makemail +++ b/scripts/makemail @@ -25,7 +25,8 @@ GetOptions(\%options, "subject=s", "date=s", "reply_to=s", - "message_id=s" + "message_id=s", + "charset=s" ); if (defined($options{"subject"})) { @@ -49,6 +50,9 @@ if (defined($options{"reply_to"})) { if (defined($options{"message_id"})) { print("Message-ID: <" . $options{"message_id"} . ">\n"); } +if (defined($options{"charset"})) { + print("MIME-Version: 1.0\nContent-Type: text/plain; charset=" . $options{"charset"} . "\nContent-Transfer-Encoding: 8bit\n"); +} print("\n");