pub/scm/linux/kernel/git/dborkman/l2md.git  about / heads / tags
lore 2 maildir exporter
$ git log --pretty=format:'%h %s (%cs)%d'
9db252b l2md: get l2md to compile and run on MacOS (2021-10-27)
	(HEAD -> master)
c986641 l2md: use XDG compliant paths for config file and work dir (2021-08-30)
9e28c81 l2md: enable -Wextra and fix compilability (2021-08-30)
f7286b4 l2md, Makefile: add PREFIX flag (2021-02-24)
2b9fae1 l2md: fix infinite loop on reading short files (2020-07-31)
8c86c39 l2md: enable proxy support (2020-02-26)
11d4a3b l2md: add per-repo config option to enable or disable syncing (2020-01-16)
ffe6b92 l2md: add oneshot option to sync once and exit (2020-01-16)
29a394f l2md: don't panic on umatched git objects during repo walk (2020-01-16)
41619ed l2md: use correct path in error msg when config cannot be opened (2019-12-05)
...

$ git cat-file blob HEAD:README
l2md - lore2maildir
-------------------

Quick and dirty hack to import lore.kernel.org list archives via git,
to export them in maildir format or through a pipe, and to keep them
periodically synced.

It can then be used in whichever mail client that supports maildir
format, for example, mutt. Alternatively, it can also pipe new mails
to external MDAs like procmail and friends which then deliver it to
your favorite mail client eventually.

Essentially, it avoids the need to subscribe to any of the lore lists
via mail since all messages are now imported through git transport.

Together with a smtp client like msmtp (which you may need anyway for
git-send-email), it allows to interact on the mailing lists the usual
way.

All pretty basic and hacky at this point, patches very welcome. Please
send them to Daniel Borkmann <daniel@iogearbox.net>.

Build
-----

Links to -lgit2 which is shipped by pretty much all major distros.

Fedora: libgit2-devel
Ubuntu: libgit2-dev
MacOS:  brew install libgit2

To build, just type:

$ make
[...]

After setting up ~/.config/l2md/config (see below), run as:

$ ./l2md

To install, just type:

# make install

The l2md.service file contains an example systemd service deployment
for letting it run in the background ...

$ service l2md status
Redirecting to /bin/systemctl status l2md.service
● l2md.service - lore2maildir
   Loaded: loaded (/usr/lib/systemd/system/l2md.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-09-19 12:07:17 CEST; 55s ago
 Main PID: 31467 (l2md)
    Tasks: 1 (limit: 4915)
   Memory: 257.9M
   CGroup: /system.slice/l2md.service
           └─31467 /usr/bin/l2md

The muttrc file contains an example mutt config for importing the generated
maildir directories.

The procmailrc file contains an example procmail config for getting started,
there are plenty of howtos online for setting up filtering rules.

For l2md, the repository here ships with two example configs, that is,
l2mdconfig.maildir and l2mdconfig.procmail. As the name says, the former
is for exporting new mails in maildir format directly, and the latter is
one example where l2md pipes new mails via stdin to an external MDA like
procmail. Copy the one of your choice either into ~/.config/l2md/config or
~/.l2mdconfig to get started.

Troubleshooting
---------------

l2md has only a single command-line parameter, which is --verbose to allow
significantly more visibility on what it is currently doing:

$ ./l2md --verbose

By default without the --verbose it will only dump the number of new mails
and commit sha's it processed to the journal and nothing else. In case l2md
is deployed through the unit file, l2md's logs can be gathered the usual way:

$ journalctl -fu l2md

Howto 1: maildir
----------------

The l2mdconfig.maildir is an example l2md config which needs to be placed
under ~/.config/l2md/config. The muttrc is an example config to get started
for reading the maildir content.

$ cat ~/.config/l2md/config
[general]
	base = ~/.local/share/l2md/
	maildir = ~/.local/share/l2md/maildir/common
	period = 30

# bpf@vger.kernel.org list
[repo bpf]
	url = https://lore.kernel.org/bpf/0
	maildir = ~/.local/share/l2md/maildir/bpf

# netdev@vger.kernel.org list
[repo netdev]
	url = https://lore.kernel.org/netdev/1
	url = https://lore.kernel.org/netdev/0
	initial_import = 1000

The general section contains a sync period in seconds where l2md refetches
all the git repos and looks for new messages to export into the configured
maildirs. The maildir under general is a path to a shared maildir where
l2md exports new mails into. This can also be specified on a per repository
basis. Specifying the maildir under general is optional. It will default
to ~/.config/l2md/maildir or <base-path>/maildir if the base deviates from
the default one. Specifying base is optional as well. This is the working
dir of l2md where it places its git repos and other meta data for record
keeping. The default is at ~/.local/share/l2md/. To not break configs based
on the previous default base: Iff the base directory is not explicitly
specified and ~/.l2md/ exists, it will be used instead.

The repo sections with subsequent name define a repository (duh!) with
one or more git urls to lore and optional maildir export path as mentioned.
If initial_import is set to >0, then it will only import first x mails upon
initial repository creation instead of the entire archive.

Howto 2: procmail
-----------------

The l2mdconfig.procmail is an example l2md config which needs to be placed
under ~/.config/l2md/config . The procmailrc is an example config to get
started with a basic config for procmail. The provided muttrc can also be
used here in order to get started for reading the maildir content preprocessed
via procmail (the folder needs to point to procmail's MAILDIR of course).
Other MDAs should work as well, but not tested at this point.

$ cat ~/.config/l2md/config
[general]
	base = ~/.local/share/l2md/
	pipe = /usr/bin/procmail
	period = 30

[repo bpf]
	url = https://lore.kernel.org/bpf/0
	initial_import = 1000

See Howto 1 for basics. Instead of maildir, the general section here has a
setting which is set to pipe. It is pointing to the /usr/bin/procmail MDA in
the example, and generally executed as the same user as l2md. Similar as with
maildir, pipe can optionally be specified on a per repository basis.

# heads (aka `branches'):
$ git for-each-ref --sort=-creatordate refs/heads \
	--format='%(HEAD) %(refname:short) %(subject) (%(creatordate:short))'
* master       l2md: get l2md to compile and run on MacOS (2021-10-27)

# tags:
$ git for-each-ref --sort=-creatordate refs/tags \
	--format='%(refname:short) %(subject) (%(creatordate:short))'
# no tags, yet...

# associated public inboxes:
# (number on the left is used for dev purposes)
          1 netdev
          1 dm-devel
          1 linux-fbdev

git clone https://80x24.org/lore/pub/scm/linux/kernel/git/dborkman/l2md.git