]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
update the scripts the send email
authorGreg Kroah-Hartman <gregkh@suse.de>
Fri, 20 Nov 2009 19:23:39 +0000 (11:23 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 20 Nov 2009 19:23:39 +0000 (11:23 -0800)
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.

scripts/added-to-stable
scripts/guess-charset [new file with mode: 0755]
scripts/make_message_id [new file with mode: 0755]
scripts/makemail

index 75ed2f7f9f7c1684322e2f7f0e36027a511befba..3d2ec302954bb052c04037b8b2ddf65f981fa635 100755 (executable)
@@ -9,7 +9,7 @@
 #      exit 1
 #}
 
-KERNEL_MINOR_VERSION='25'
+KERNEL_MINOR_VERSION='31'
 KERNEL="2.6.$KERNEL_MINOR_VERSION"
 
 EMAIL_ADDRESS='<gregkh@suse.de>'
@@ -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 (executable)
index 0000000..1b0fe54
--- /dev/null
@@ -0,0 +1,52 @@
+#! /usr/bin/env python
+# vim: set fileencoding=utf-8
+# (c) Uwe Kleine-König <ukleine@strlen.de>
+# 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 (executable)
index 0000000..b76f77f
--- /dev/null
@@ -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";
index 2dddb36a56af530e01ee4fe6e3ab2d46ec775c45..447de1ac43b282d38332828f4e41c38ed11a9462 100755 (executable)
@@ -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");