unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] scripts: add script to export v1 inboxes to maildir
@ 2022-04-05 23:01 Evan Gates
  2022-04-11 20:36 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Evan Gates @ 2022-04-05 23:01 UTC (permalink / raw)
  To: meta

---

I'm pretty sure this is a gross misuse of the public-inbox format, and
as such will not be offended if you decide not to include this script.

I read the public-inbox README and liked the idea of the pull model.
I briefly scanned clients.txt but didn't easily figure out how I was
supposed to pull and read mail locally.  Since the v1 format already
has a bunch of uniquely named files, that are themselves emails,
it was pretty simple to symlink them into a maildir format so I can
read them in my mail client.

As a followup to this abomination, what is the correct way to pull
and read mail locally?

 scripts/v1-to-maildir | 58 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100755 scripts/v1-to-maildir

diff --git a/scripts/v1-to-maildir b/scripts/v1-to-maildir
new file mode 100755
index 00000000..1cfcd2de
--- /dev/null
+++ b/scripts/v1-to-maildir
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Script to export v1 public-inbox repos to Maildir format.  Supports
+# updates.  Creates a .Maildirs directory in the PWD and a subdirectory
+# for each public-inbox git repo passed as an argument.  The repos ARE
+# NOT bare repos.
+#
+# Usage:
+#
+#     v1-to-maildir [public-inbox-v1-repo]...
+#
+# Example:
+#
+#     mkdir ~/lists
+#     cd ~/lists
+#     git clone https://public-inbox.org/meta public-inbox-meta
+#     git clone https://public-inbox.org/test public-inbox-test
+#     v1-to-maildir */
+# 
+#     Then point mail client to ~/lists/.Maildirs
+#     Run v1-to-maildir */ again to git pull and add new messages.
+
+dir=.Maildirs
+fmt=%-10s
+
+for d do
+	printf %s\\n "-- $d"
+	printf "$fmt" git\ pull:
+	if ! git -C "$d" pull -q; then
+		continue
+	fi
+	echo OK
+
+	printf "$fmt" mkdir:
+	for md in new cur tmp; do
+		if ! mkdir -p "$dir/$d/$md"; then
+			continue 2
+		fi
+	done
+	echo OK
+
+	printf "$fmt" new:
+	declare -A cur
+	new=()
+	for f in "$dir/$d/cur/"*; do
+		f=${f##*/}
+		f=${f%%:*}
+		cur[$f]=1
+	done
+	for f in "$d/"*/*; do
+		((cur[${f##*/}])) || new+=("$f")
+	done
+	((${#new[@]})) &&
+		printf %s\\0 "${new[@]/#/..\/..\/..\/}" |
+			xargs -0 ln -sft "$dir/$d/new"
+	printf %d\\n "${#new[@]}"
+	echo
+done
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-11 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 23:01 [PATCH] scripts: add script to export v1 inboxes to maildir Evan Gates
2022-04-11 20:36 ` Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).