]> git.wh0rd.org Git - home.git/commitdiff
mail: add dovecot filtering
authorMike Frysinger <vapier@gentoo.org>
Thu, 29 Dec 2016 23:20:56 +0000 (18:20 -0500)
committerMike Frysinger <vapier@gentoo.org>
Thu, 29 Dec 2016 23:21:07 +0000 (18:21 -0500)
.config/mail/.gitignore [new file with mode: 0644]
.config/mail/dovecot-lda.conf [new file with mode: 0644]
.config/mail/dovecot-namespaces.conf [new file with mode: 0644]
.config/mail/filters.siv [new file with mode: 0644]
.config/mail/filters.test [new file with mode: 0755]
.config/mail/setup-symlinks [new file with mode: 0755]
.gitignore

diff --git a/.config/mail/.gitignore b/.config/mail/.gitignore
new file mode 100644 (file)
index 0000000..c1060fe
--- /dev/null
@@ -0,0 +1 @@
+/*.svbin
diff --git a/.config/mail/dovecot-lda.conf b/.config/mail/dovecot-lda.conf
new file mode 100644 (file)
index 0000000..3774a62
--- /dev/null
@@ -0,0 +1,16 @@
+postmaster_address = vapier@localhost
+
+mail_location = maildir:~/.mail:LAYOUT=fs
+
+protocol lda {
+       mail_plugins = sieve
+}
+
+plugin {
+       # http://wiki2.dovecot.org/Pigeonhole/Sieve
+       # http://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration
+       sieve = ~/.config/mail/filters.siv
+#      sieve_extensions = vnd.dovecot.debug
+}
+
+!include dovecot-namespaces.conf
diff --git a/.config/mail/dovecot-namespaces.conf b/.config/mail/dovecot-namespaces.conf
new file mode 100644 (file)
index 0000000..3d90010
--- /dev/null
@@ -0,0 +1,109 @@
+namespace "misc projects" {
+       separator = /
+       prefix = "misc projects/"
+       location = "maildir:~/.mail/misc projects"
+}
+
+namespace "misc projects/busybox" {
+       separator = /
+       prefix = "misc projects/busybox/"
+       location = "maildir:~/.mail/.misc projects.directory/busybox"
+}
+
+namespace "misc projects/toolchain" {
+       separator = /
+       prefix = "misc projects/toolchain/"
+       location = "maildir:~/.mail/.misc projects.directory/toolchain"
+}
+
+namespace "misc projects/u-boot" {
+       separator = /
+       prefix = "misc projects/u-boot/"
+       location = "maildir:~/.mail/.misc projects.directory/u-boot"
+}
+
+namespace "misc projects/uclibc" {
+       separator = /
+       prefix = "misc projects/uclibc/"
+       location = "maildir:~/.mail/.misc projects.directory/uclibc"
+}
+
+namespace "misc projects/linux" {
+       separator = /
+       prefix = "misc projects/linux/"
+       location = "maildir:~/.mail/.misc projects.directory/linux"
+}
+
+namespace "inbox" {
+       inbox = yes
+       separator = /
+       prefix = "inbox/"
+       location = "maildir:~/.mail/inbox"
+}
+
+namespace "inbox/WPI" {
+       separator = /
+       prefix = "inbox/WPI/"
+       location = "maildir:~/.mail/.inbox.directory/WPI"
+}
+
+namespace "inbox/WPI/classes" {
+       separator = /
+       prefix = "inbox/WPI/classes/"
+       location = "maildir:~/.mail/.inbox.directory/.WPI.directory/classes"
+}
+
+namespace "gentoo.org" {
+       separator = /
+       prefix = "gentoo.org/"
+       location = "maildir:~/.mail/gentoo.org"
+}
+
+namespace "gentoo.org/0 TODO" {
+       separator = /
+       prefix = "gentoo.org/0 TODO/"
+       location = "maildir:~/.mail/.gentoo.org.directory/0 TODO"
+}
+
+namespace "gentoo.org/bugs" {
+       separator = /
+       prefix = "gentoo.org/bugs/"
+       location = "maildir:~/.mail/.gentoo.org.directory/bugs"
+}
+
+namespace "gentoo.org/bugs/arches" {
+       separator = /
+       prefix = "gentoo.org/bugs/arches/"
+       location = "maildir:~/.mail/.gentoo.org.directory/.bugs.directory/arches"
+}
+
+namespace "gentoo.org/bugs/toolchain" {
+       separator = /
+       prefix = "gentoo.org/bugs/toolchain/"
+       location = "maildir:~/.mail/.gentoo.org.directory/.bugs.directory/toolchain"
+}
+
+namespace "gentoo.org/bugs/base-system" {
+       separator = /
+       prefix = "gentoo.org/bugs/base-system/"
+       location = "maildir:~/.mail/.gentoo.org.directory/.bugs.directory/base-system"
+}
+
+namespace "gentoo.org/dev" {
+       separator = /
+       prefix = "gentoo.org/dev/"
+       location = "maildir:~/.mail/.gentoo.org.directory/dev"
+}
+
+namespace "trash" {
+       separator = /
+       prefix = "trash/"
+       location = "maildir:~/.mail/trash"
+}
+
+namespace "sent-mail" {
+       separator = /
+       prefix = "sent-mail/"
+       location = "maildir:~/.mail/sent-mail"
+}
+
diff --git a/.config/mail/filters.siv b/.config/mail/filters.siv
new file mode 100644 (file)
index 0000000..6791fee
--- /dev/null
@@ -0,0 +1,676 @@
+# http://thsmi.github.com/sieve-reference/en/
+
+require "fileinto";
+require "imap4flags";
+require "body";
+require "regex";
+# require "vnd.dovecot.debug";
+
+
+# To: Me
+if anyof (header :contains "CC" "vapier@gentoo.org")
+{
+       setflag "G";
+}
+
+
+#
+# Spam
+#
+if anyof (
+       header :regex "Subject" "(Buy OEM|0EM) Software",
+       header :is "Subject" "cheap oem soft shipping //orldwide",
+       header :is "Subject" "Corel Draw",
+       header :regex "Subject" "Last chance (for lower rates|to supercharge)"
+)
+{
+       fileinto "trash";
+       stop;
+}
+if anyof (
+       header :contains "Content-Type" "text/html;",
+       body :raw :contains ["<html>", "<tbody>"]
+)
+{
+       fileinto "trash/spam";
+       stop;
+}
+#if anyof (body :raw :regex ["filename=.*\.exe", "filename=.*\.pif", "filename=.*\.scr", "filename=.*\.zip"])
+#{
+#      fileinto "trash/spam";
+#      stop;
+#}
+
+
+# SFC
+if anyof (
+       header :contains "List-Id" "<busybox-compliance.sfconservancy.org>",
+       header :contains "To" "busybox-compliance@sfconservancy.org",
+       header :contains "List-Id" "<linux-compliance.sfconservancy.org>"
+)
+{
+       fileinto "misc projects/sfc";
+       stop;
+}
+
+
+# From: @chromium.org
+#if anyof (header :contains "From" "@chromium.org")
+#{
+#      setflag "G";
+#}
+
+
+# Linux
+if anyof (
+       header :contains "List-Id" "<users.linux.kernel.org>",
+       header :contains "List-id" "<linux-arch.vger.kernel.org>"
+)
+{
+       fileinto "misc projects/linux";
+       stop;
+}
+
+
+# Linux: device-tree
+if anyof (
+       header :contains "List-Id" "<devicetree.vger.kernel.org>",
+       header :contains "List-Id" "<devicetree-compiler.vger.kernel.org>"
+)
+{
+       fileinto "misc projects/linux/embedded";
+       stop;
+}
+
+
+#
+# Misc projects
+#
+if anyof (
+       # acl
+       header :contains "List-Id" "<acl-devel.nongnu.org>",
+       header :contains "To" "acl-devel@nongnu.org",
+       header :contains "Cc" "acl-devel@nongnu.org",
+       # alsa
+       header :contains "List-Id" "<alsa-devel.alsa-project.org>",
+       # apcupsd
+       header :contains "List-Id" "<apcupsd-users.lists.sourceforge.net>",
+       # autotools
+       header :contains "List-Id" "<libtool.gnu.org>",
+       header :contains "List-Id" "<bug-automake.gnu.org>",
+       header :contains "List-Id" "<bug-libtool.gnu.org>",
+       header :contains "List-Id" "<bug-autoconf.gnu.org>",
+       header :contains "List-Id" "<autoconf.gnu.org>",
+       header :contains "List-Id" "<bug-m4.gnu.org>",
+       # bash
+       header :contains "List-Id" "<bug-bash.gnu.org>",
+       # bitpim
+       header :contains "List-Id" "<bitpim-devel.lists.sourceforge.net>",
+       # chrome
+       header :contains "List-Id" "<chrome-notebook-pilot-users.googlegroups.com>",
+       # cldr
+       header :contains "List-Id" "<cldr-users.unicode.org>",
+       # coLinux
+       header :contains "List-Id" "<colinux-users.lists.sourceforge.net>",
+       # coreutils
+       header :contains "List-Id" "<bug-coreutils.gnu.org>",
+       header :contains "List-Id" "<coreutils.gnu.org>",
+       header :contains "List-Id" "<bug-coreutils.nongnu.org>",
+       # cpio
+       header :contains "List-Id" "<bug-cpio.gnu.org>",
+       # cracklib
+       header :contains "List-Id" "<cracklib-devel.lists.sourceforge.net>",
+       # dietlibc
+       header :contains "To" "dietlibc@fefe.de",
+       header :contains "Cc" "dietlibc@fefe.de",
+       # DirectFB
+       header :contains "List-Id" "<directfb-users.directfb.org>",
+       header :contains "List-Id" "<directfb-dev.directfb.org>",
+       # dokuwiki
+       header :contains "List-Id" "<dokuwiki.list-id.freelists.org>",
+       # dropbear
+       header :contains "List-Id" "<dropbear.ucc.asn.au>",
+       # dxr2
+       header :contains "Subject" "[Dxr2-devel]",
+       # ed
+       header :contains "List-Id" "<bug-ed.gnu.org>",
+       # file
+       header :contains "List-Id" "<file.mx.gw.com>",
+       # fontforge/fontconfig
+       header :contains "List-Id" "<fontforge-devel.lists.sourceforge.net>",
+       header :contains "List-Id" "<fontconfig.lists.freedesktop.org>",
+       # gd
+       header :contains "List-Post" "<mailto:gd-devel@lists.php.net>",
+       header :contains "To" "security@libgd.org",
+       header :contains "Cc" "security@libgd.org",
+       # genext2fs
+       header :contains "List-Id" "<genext2fs-devel.lists.sourceforge.net>",
+       # gnulib
+       header :contains "List-Id" "<bug-gnulib.gnu.org>",
+       # gpm
+       header :contains "List-Id" "<gpm.lists.linux.it>",
+       # gpsd
+       header :contains "List-Id" "<gpsd-dev.nongnu.org>",
+       # grep
+       header :contains "List-Id" "<bug-grep.gnu.org>",
+       # gzip
+       header :contains "List-Id" "<bug-gzip.gnu.org>",
+       # hal
+       header :contains "List-Id" "<hal.lists.freedesktop.org>",
+       # insight
+       header :contains "List-Id" "<insight.sourceware.org>",
+       # gmp
+       header :contains "List-Id" "<gmp-discuss.gmplib.org>",
+       header :contains "List-Id" "<gmp-bugs.gmplib.org>",
+       header :contains "List-Id" "<gmp-devel.gmplib.org>",
+       # k3b
+       header :contains "List-Id" "<k3b-user.lists.sourceforge.net>",
+       # kbd
+       header :contains "List-Id" "<kbd.lists.altlinux.org>",
+       # libquicktime
+       header :contains "List-Id" "<libquicktime-devel.lists.sourceforge.net>",
+       # libtirpc
+       header :contains "List-Id" "<libtirpc-devel.lists.sourceforge.net>",
+       # Linux API
+       header :contains "List-Id" "<linux-api.vger.kernel.org>",
+       # linux-man
+       header :contains "List-Id" "<linux-man.vger.kernel.org>",
+       # lirc
+       header :contains "List-Id" "<lirc-list.lists.sourceforge.net>",
+       # LTP
+       header :contains "List-Id" "<ltp-list.lists.sourceforge.net>",
+       header :contains "List-Id" "<ltp.lists.linux.it>",
+       # m3
+       header :contains "To" "wagner@pint.elegosoft.com",
+       header :contains "Cc" "wagner@pint.elegosoft.com",
+       header :contains "To" "m3devel@elegosoft.com",
+       header :contains "Cc" "m3devel@elegosoft.com",
+       header :contains "To" "m3devel@birch.elego.de",
+       header :contains "Cc" "m3devel@birch.elego.de",
+       # metalog
+       header :contains "List-Id" "<metalog-users.lists.sourceforge.net>",
+       # mplayer
+       header :contains "To" "dvdnav-discuss@mplayerhq.hu",
+       header :contains "Cc" "dvdnav-discuss@mplayerhq.hu",
+       # module-init-tools
+       header :contains "List-Id" "<linux-modules.vger.kernel.org>",
+       # mpfr
+       header :contains "List-Id" "<mpfr.loria.fr>",
+       # mtools
+       header :contains "List-Id" "<info-mtools.gnu.org>",
+       # nano
+       header :contains "List-Id" "<nano-devel.gnu.org>",
+       # nasm
+       header :contains "List-Id" "<nasm-devel.lists.sourceforge.net>",
+       # nbd
+       header :contains "List-Id" "<nbd-general.lists.sourceforge.net>",
+       # ncurses
+       header :contains "List-Id" "<bug-ncurses.gnu.org>",
+       # net-tools
+       header :contains "List-Id" "<net-tools-devel.lists.sourceforge.net>",
+       # NFS
+       header :contains "List-Id" "<nfs.lists.sourceforge.net>",
+       header :contains "List-Id" "<linux-nfs.vger.kernel.org>",
+       # ode
+       header :contains "List-Id" "<ode.ode.org>",
+       header :contains "List-Id" "<ode.q12.org>",
+       # Open Group
+       header :contains "X-Loop" "austin-group-l@opengroup.org",
+       # powertop
+       header :contains "List-Id" "<discuss.lesswatts.org>",
+       # procps
+       header :contains "List-Id" "<procps.freelists.org>",
+       # patch
+       header :contains "List-Id" "<bug-patch.gnu.org>",
+       # readline
+       header :contains "List-Id" "<bug-readline.gnu.org>",
+       # reiserfs
+       header :contains "List-Id" "<reiserfs-devel.vger.kernel.org>",
+       # rsync
+       header :contains "List-Id" "<rsync.lists.samba.org>",
+       # SDL
+       header :contains "List-Id" "<sdl.libsdl.org>",
+       header :contains "List-Id" "<sdl-libsdl.org>",
+       # shadow
+       header :contains "List-Id" "<shadow.pld.org.pl>",
+       header :contains "List-Id" "<pkg-shadow-devel.lists.alioth.debian.org>",
+       # sigrok
+       header :contains "List-Id" "<sigrok-devel.lists.sourceforge.net>",
+       # speex
+       header :contains "List-Id" "<speex-dev.xiph.org>",
+       # sqlite
+       header :contains "List-Id" "<sqlite-users.sqlite.org>",
+       # ssl
+       header :contains "Sender" "owner-openssl-dev@openssl.org",
+       # strace
+       header :contains "List-Id" "<strace-devel.lists.sourceforge.net>",
+       header :contains "To" "strace-devel@lists.sourceforge.net",
+       header :contains "Cc" "strace-devel@lists.sourceforge.net",
+       # sudo
+       header :contains "List-Id" "<sudo-workers.sudo.ws>",
+       # syslinux
+       header :contains "List-Id" "<syslinux.zytor.com>",
+       # sysvinit-devel
+       header :contains "List-Id" "<sysvinit-devel.nongnu.org>",
+       # tar
+       header :contains "List-Id" "<bug-tar.gnu.org>",
+       # timezone
+       header :contains "List-Id" "<tz.iana.org>",
+       # uClinux
+       header :contains "List-Id" "<uclinux-dev.uclinux.org>",
+       # udev
+       header :contains "List-Id" "<linux-hotplug-devel.lists.sourceforge.net>",
+       # urjtag
+       header :contains "List-Id" "<urjtag-development.lists.sourceforge.net>",
+       # util-linux
+       header :contains "X-Mailing-List" "util-linux@vger.kernel.org",
+       # wget
+       header :contains "List-Id" "<bug-wget.gnu.org>",
+       # yasm
+       header :contains "List-Id" "<yasm-devel.tortall.net>",
+       # zlib
+       header :contains "List-Id" "<zlib-devel_madler.net.madler.net>",
+       header :contains "To" "zlib-devel@madler.net",
+       header :contains "Cc" "zlib-devel@madler.net"
+)
+{
+       fileinto "misc projects";
+       stop;
+}
+
+# Project: uclibc
+if anyof (
+       header :contains "List-Id" "<uclibc.uclibc.org>",
+       header :contains "List-Id" "<uclibc-cvs.uclibc.org>",
+       header :contains "List-Id" "<uclibc-admins.lists.busybox.net>",
+       header :contains "To" "uclibc@uclibc.org",
+       header :contains "Cc" "uclibc@uclibc.org",
+       header :contains "To" "uclibc-cvs@uclibc.org",
+       header :contains "Cc" "uclibc-cvs@uclibc.org"
+)
+{
+       fileinto "misc projects/uclibc";
+       stop;
+}
+
+# Project: busybox (after uClibc)
+if anyof (
+       header :contains "List-Id" "<busybox.mail.busybox.net>",
+       header :contains "List-Id" "<busybox-cvs.busybox.net>",
+       header :contains "List-Id" "<busybox.busybox.net>",
+       header :contains "To" "busybox@busybox.net",
+       header :contains "Cc" "busybox@busybox.net"
+)
+{
+       fileinto "misc projects/busybox";
+       stop;
+}
+
+# buildroot (after uClibc)
+if anyof (
+       header :contains "List-Id" "<buildroot.busybox.net>",
+       header :contains "To" "buildroot@buildroot.org",
+       header :contains "Cc" "buildroot@buildroot.org"
+)
+{
+       fileinto "misc projects/buildroot";
+       stop;
+}
+
+
+#
+# Toolchain
+#
+if anyof (
+       header :contains "List-Id" "<gdb-patches.sourceware.org>",
+       header :contains "List-Id" "<gdb.sourceware.org>",
+       header :contains "To" "gdb@sourceware.org",
+       header :contains "Cc" "gdb@sourceware.org",
+       header :contains "To" "gdb-patches@sourceware.org",
+       header :contains "Cc" "gdb-patches@sourceware.org"
+)
+{
+       fileinto "misc projects/toolchain";
+
+       if anyof(body :text :contains "sim/")
+       {
+               setflag "G";
+       }
+       stop;
+}
+
+if anyof (
+       # binutils
+       header :contains "List-Id" "<bug-binutils.gnu.org>",
+       header :contains "List-Post" "<mailto:binutils@sourceware.org>",
+       # ccache
+       header :contains "List-Id" "<ccache.lists.samba.org>",
+       # elfutils
+       header :contains "List-Id" "<elfutils-devel.lists.fedorahosted.org>",
+       header :contains "To" "elfutils-devel@lists.fedorahosted.org",
+       header :contains "Cc" "elfutils-devel@lists.fedorahosted.org",
+       # gcc
+       header :contains "List-Post" "<mailto:gcc-patches@gcc.gnu.org>",
+       # glibc
+       header :regex "List-Post" "<mailto:libc-(alpha|help|locales|ports|stable)@sourceware\.org>",
+       header :regex "To" "libc-(alpha|help|locales|ports|stable)@sourceware\.org",
+       header :regex "Cc" "libc-(alpha|help|locales|ports|stable)@sourceware\.org",
+       # gnuconfig
+       header :contains "List-Id" "<config-patches.gnu.org>",
+       # newlib
+       header :contains "List-Post" "<mailto:newlib@sourceware.org>",
+       # qemu
+       header :contains "List-Post" "<mailto:qemu-devel@nongnu.org>",
+       header :contains "To" "qemu-devel@nongnu.org",
+       header :contains "Cc" "qemu-devel@nongnu.org",
+       # sourceware
+       header :contains "List-Post" "<mailto:cgen@sourceware.org>",
+       header :contains "List-Post" "<mailto:crossgcc@sourceware.org>",
+       header :contains "From" "sourceware-bugzilla@sourceware.org",
+       # misc
+       header :contains "To" "libunwind-devel@nongnu.org",
+       header :contains "Cc" "libunwind-devel@nongnu.org"
+)
+{
+       fileinto "misc projects/toolchain";
+       stop;
+}
+
+
+# Project: E
+if anyof (
+       header :contains "List-Id" "<enlightenment-cvs.lists.sourceforge.net>",
+       header :contains "List-Id" "<enlightenment-devel.lists.sourceforge.net>",
+       header :contains "List-Id" "<evidence-cvs.lists.sourceforge.net>"
+)
+{
+       fileinto "misc projects/e";
+       stop;
+}
+
+
+# Project: u-boot
+if anyof (
+       header :contains "List-Id" "<u-boot-users.lists.sourceforge.net>",
+       header :contains "List-Id" "<u-boot.lists.denx.de>",
+       header :contains "To" "u-boot@lists.denx.de",
+       header :contains "Cc" "u-boot@lists.denx.de"
+)
+{
+       fileinto "misc projects/u-boot";
+       stop;
+}
+
+
+#
+# Arches
+#
+if anyof (
+       # Alpha
+       header :contains "List-Id" "<linux-alpha.vger.kernel.org>",
+       # ARM
+       header :contains "List-Id" "<boot-architecture.lists.linaro.org>",
+       header :contains "List-Id" "<cross-distro.lists.linaro.org>",
+       header :contains "List-Id" "<armedslack.lists.armedslack.org>",
+       header :contains "List-Id" "<iyonix-support.freelists.org>",
+       # Blackfin
+       header :contains "List-Id" "<uclinux-dist-devel.blackfin.uclinux.org>",
+       # s390
+       header :contains "X-Mailing-List" "linux-s390@vger.kernel.org",
+       header :contains "List-Id" "<hercules-390.yahoogroups.com>",
+       header :contains "To" "linux-390@vm.marist.edu",
+       header :contains "Cc" "linux-390@vm.marist.edu",
+       # m68k
+       header :contains "List-Id" "linux-mac68k.lists.purplehat.net",
+       # parisc
+       header :contains "List-Id" "<parisc-linux.lists.parisc-linux.org>",
+       header :contains "List-Id" "<linux-parisc.vger.kernel.org>",
+       # SuperH
+       header :contains "List-Id" "<linuxsh-dev.lists.sourceforge.net>",
+       header :contains "List-Id" "<linuxsh-cvs.lists.sourceforge.net>",
+       header :contains "List-Id" "<linuxdc-dev.lists.sourceforge.net>",
+       header :contains "List-Id" "<linux-sh.vger.kernel.org>"
+)
+{
+       fileinto "misc projects/archs";
+       stop;
+}
+
+
+#
+# Gentoo
+#
+
+# Gentoo: graphics
+if anyof (
+       header :contains "To" "graphics@gentoo.org",
+       header :contains "Cc" "graphics@gentoo.org"
+)
+{
+       fileinto "gentoo.org/bugs/graphics";
+       stop;
+}
+
+# Gentoo: openrc
+if anyof (
+       header :contains "To" "openrc@gentoo.org",
+       header :contains "Cc" "openrc@gentoo.org"
+)
+{
+       fileinto "gentoo.org/bugs/base-system/openrc";
+       stop;
+}
+
+# Gentoo: base-system
+if anyof (
+       header :contains "To" "base-system@gentoo.org",
+       header :contains "Cc" "base-system@gentoo.org"
+)
+{
+       fileinto "gentoo.org/bugs/base-system";
+       stop;
+}
+
+# Gentoo: portage
+if anyof (
+       header :regex "To" "(dev|tools)-portage@gentoo\\.org",
+       header :regex "Cc" "(dev|tools)-portage@gentoo\\.org",
+       header :contains "List-Id" "<gentoo-portage-dev.gentoo.org>"
+)
+{
+       fileinto "gentoo.org/bugs/portage";
+       stop;
+}
+
+# Gentoo: portage utils
+if anyof (
+       header :contains "To" "portage-utils@gentoo.org",
+       header :contains "Cc" "portage-utils@gentoo.org"
+)
+{
+       fileinto "gentoo.org/bugs/portage-utils";
+       stop;
+}
+
+# Gentoo: docs team
+if anyof (
+       header :contains "To" "docs-team@gentoo.org",
+       header :contains "Cc" "docs-team@gentoo.org",
+       header :contains "To" "gentoo-doc@lists.gentoo.org",
+       header :contains "Cc" "gentoo-doc@lists.gentoo.org"
+)
+{
+       fileinto "gentoo.org/docs";
+       stop;
+}
+
+if allof (header :contains "From" "bugzilla-daemon@gentoo.org")
+{
+       # Bugzilla
+
+       # Gentoo: toolchain/gcc-porting
+       if allof (header :regex "To" "(toolchain|gcc-porting)@gentoo\\.org")
+       {
+               fileinto "gentoo.org/bugs/toolchain";
+               stop;
+       }
+
+       # Gentoo: games
+       elsif allof (header :contains "To" "games@gentoo.org")
+       {
+               fileinto "gentoo.org/bugs/games";
+               stop;
+       }
+
+       # Gentoo: security bugzilla
+       elsif allof (header :contains "To" "security@gentoo.org")
+       {
+               fileinto "gentoo.org/bugs/hardened";
+               stop;
+       }
+
+       # Gentoo: bugzilla me
+       elsif allof (header :contains "To" "vapier@gentoo.org")
+       {
+               fileinto "gentoo.org/bugs/mine";
+               stop;
+       }
+
+       # Gentoo: arches
+       elsif allof (header :regex "To" "(alpha|amd64|arm|arm64|ia64|hppa|m68k|mips|ppc|ppc64|s390|sh|sparc|x86)@gentoo.org")
+       {
+               # stable/keyword req
+               if anyof(header :regex "X-Bugzilla-Keywords" "((KEYWORD|STABLE)REQ|TESTFAILURE)")
+               {
+                       setflag "\\Seen";
+                       fileinto "gentoo.org/bugs/arches/noise";
+                       stop;
+               }
+
+               # Gentoo: my herds
+               elsif anyof (header :regex "X-Bugzilla-Assigned-To" "(toolchain|security|base-system|games|sandbox)@gentoo.org")
+               {
+                       setflag "\\Seen";
+                       fileinto "trash";
+                       stop;
+               }
+       }
+
+       fileinto "gentoo.org/bugs";
+       stop;
+}
+
+# Gentoo: arches
+if anyof (
+       header :regex "To" "(alpha|amd64|arm|arm64|ia64|hppa|m68k|mips|ppc|ppc64|s390|sh|sparc|x86)@gentoo.org",
+       header :regex "Cc" "(alpha|amd64|arm|arm64|ia64|hppa|m68k|mips|ppc|ppc64|s390|sh|sparc|x86)@gentoo.org"
+)
+{
+       fileinto "gentoo.org/bugs/arches";
+       stop;
+}
+
+# Gentoo: embedded
+if anyof (
+       header :contains "List-Id" "<gentoo-embedded.gentoo.org>",
+       header :contains "To" "dev-embedded@gentoo.org",
+       header :contains "Cc" "dev-embedded@gentoo.org",
+       header :contains "To" "gentoo-mips@lists.gentoo.org",
+       header :contains "Cc" "gentoo-mips@lists.gentoo.org"
+)
+{
+       fileinto "gentoo.org/embedded";
+       stop;
+}
+
+# Gentoo: -commits
+if anyof (header :contains "List-Id" "<gentoo-commits.gentoo.org>")
+{
+       fileinto "gentoo.org/commits";
+       stop;
+}
+
+if anyof (
+       # -project
+       header :contains "List-Id" "<gentoo-project.gentoo.org>",
+       header :contains "List-Id" "<gentoo-soc.gentoo.org>",
+       header :contains "List-Id" "<gentoo-scm.gentoo.org>",
+       header :contains "To" "soc-mentors@gentoo.org",
+       header :contains "Cc" "soc-mentors@gentoo.org",
+       # gentoo-dev
+       header :contains "List-Id" "<gentoo-dev.gentoo.org>",
+       header :contains "List-Id" "<gentoo-dev-announce.gentoo.org>",
+       header :contains "List-Id" "<gentoo-devhelp.gentoo.org>",
+       header :contains "From" "no-reply@socghop.appspotmail.com",
+       # gentoo-licenses
+       header :contains "List-Id" "<gentoo-licenses.gentoo.org>",
+       # gentoo-qa
+       header :contains "List-Id" "<gentoo-qa.gentoo.org>"
+)
+{
+       fileinto "gentoo.org/dev";
+       stop;
+}
+
+# Gentoo: github
+if anyof (header :contains "List-ID" "<gentoo.gentoo.github.com>")
+{
+       fileinto "gentoo.org/github";
+       stop;
+}
+
+# Gentoo: NFP
+if anyof (header :contains "List-Id" "<gentoo-nfp.gentoo.org>")
+{
+       fileinto "gentoo.org/nfp";
+       stop;
+}
+
+# Gentoo: -core
+if anyof (header :contains "List-Id" "<gentoo-core.gentoo.org>")
+{
+       fileinto "gentoo.org/core";
+       stop;
+}
+
+# Gentoo: toolchain [not bugs]
+if allof (header :regex "To" "(toolchain|gcc-porting)@gentoo\\.org")
+{
+       fileinto "gentoo.org/bugs/toolchain/list";
+       stop;
+}
+
+# Gentoo: catalyst
+if anyof (header :contains "List-Id" "<gentoo-catalyst.gentoo.org>")
+{
+       fileinto "gentoo.org";
+       stop;
+}
+
+# Gentoo: security
+if anyof (
+       header :contains "To" "security@gentoo.org",
+       header :contains "Cc" "security@gentoo.org",
+       header :contains "To" "gentoo-hardened@lists.gentoo.org",
+       header :contains "Cc" "gentoo-hardened@lists.gentoo.org",
+       header :contains "To" "gentoo-security@lists.gentoo.org",
+       header :contains "Cc" "gentoo-security@lists.gentoo.org"
+)
+{
+       fileinto "gentoo.org/hardened";
+       stop;
+}
+
+# Gentoo: catchall
+if anyof (
+       header :contains "To" "vapier@gentoo.org",
+       header :contains "Cc" "vapier@gentoo.org",
+       header :contains "From" "vapier@gentoo.org",
+       # Moderator!
+       header :contains "To" "gentoo-dev-announce+moderators@lists.gentoo.org",
+       header :contains "Cc" "gentoo-dev-announce+moderators@lists.gentoo.org"
+)
+{
+       fileinto "gentoo.org";
+       stop;
+}
diff --git a/.config/mail/filters.test b/.config/mail/filters.test
new file mode 100755 (executable)
index 0000000..9d1b436
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+set -e
+cd ~/.config/mail
+if [ $# -eq 0 ] ; then
+       echo "ERROR: specify a message"
+       exit 1
+fi
+
+writable=false
+args=()
+case $1 in
+-e)
+       args+=( -e )
+       writable=true
+       shift
+       ;;
+esac
+
+for f in "$@" ; do
+       echo "${f}"
+       grep ^Subject: "${f}"
+       sieve-test \
+               -c dovecot-lda.conf \
+               -x 'fileinto body regex imap4flags' \
+               "${args[@]}" \
+               filters.siv "${f}"
+       if [ $? -eq 0 ] && ${writable} ; then
+               rm "${f}"
+       fi
+       echo
+done
diff --git a/.config/mail/setup-symlinks b/.config/mail/setup-symlinks
new file mode 100755 (executable)
index 0000000..d947632
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+
+"""Glue Maildir++/dovecot to kmail"""
+
+from __future__ import print_function
+
+import os
+import sys
+
+
+def main(argv):
+    mail = os.path.expanduser('~/.mail')
+    for root, dirs, files in os.walk(mail):
+        try:
+            dirs.remove('cur')
+            dirs.remove('new')
+            dirs.remove('tmp')
+        except ValueError:
+            pass
+
+        if not root.endswith('.directory'):
+            continue
+
+        print(root, file=sys.stderr)
+        for d in dirs:
+            # We will start with:
+            #  root = ~/.mail/.gentoo.org.directory/
+            #  d    = buildroot
+            # So create symlinks:
+            #  ~/.mail/gentoo.org/.buildroot -> ../.gentoo.org.directory/buildroot
+
+            # ~/.mail/
+            parent = os.path.dirname(root)
+
+            # .gentoo.org.directory
+            maildir = os.path.basename(root)
+            if maildir[0] == '.':
+                continue
+            # ../.gentoo.org.directory/buildroot
+            target = os.path.join('..', maildir, d)
+            # gentoo.org
+            maildir = maildir[1:-10]
+            # ~/.mail/gentoo.org/.buildroot
+            source = os.path.join(parent, maildir, '.' + d)
+
+            print('%s -> %s' % (source, target), file=sys.stderr)
+            if not os.path.islink(source):
+                os.symlink(target, source)
+
+        fsdir = root[len(mail) + 1:]
+        parts = fsdir.split('/')
+        fsdir = '/'.join(parts[0:-1] + [parts[-1][1:-10]])
+        ns_parts = [x[1:-10] for x in parts]
+        ns = '/'.join(ns_parts)
+
+        extra = ''
+        if ns == 'inbox':
+            extra = '\n\tinbox = yes'
+
+        print("""\
+namespace "%(ns)s" {%(extra)s
+       separator = /
+       prefix = "%(ns)s/"
+       location = "maildir:~/.mail/%(fsdir)s"
+}
+""" % {'ns': ns, 'fsdir': fsdir, 'extra': extra})
+
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv[1:]))
index 7ca8ba50ee5e8f5d24377060bef1b5a8935a655f..4a3fffd5fefecddb0817a6cf96b38277b8541235 100644 (file)
@@ -364,7 +364,6 @@ lock
 /.google_authenticator
 /.mail
 /.maildir
-/.config/mail
 /.npm/
 /.netrc
 .nfs*