From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id EF18B1F4CE for ; Tue, 5 Apr 2022 23:02:14 +0000 (UTC) Received: by mail-io1-xd34.google.com with SMTP id p22so1014407iod.2 for ; Tue, 05 Apr 2022 16:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=l+5Dd1pBaf2BWqOzvnOtJeoOnh0h3UROiHJ4ZFZ6wqo=; b=hYNZOFXTsp3TAcxRDZb9MblRJyoRstQNZ1Ay8Bvd9XNDXvrDoXDpKsq1/4fuOrG3dv aRPXCh0RfW2DflcvnLyeswH6RyU6MlWWfWqo483DXAzu7RFOmQkxdYQMOx6ClCnNxrgZ p6zkDvg5gLU4W3zTQV+T38A40ZnPlGDKnndarDCNjnwx9hySQLw9j74wQkaOlQBw5wyD URhUSJo2nLwk2+497reZSu1FK/Jw625NPdcqHbnIoKKkLwC2ieHz99g6lryTqEbWpmM2 AEx4DBno2RWiWRXE0KDoPEisHhbq8OdhfVwcY7UzUNLNTl8uhX7nvX99jUvCVSfzmhLm 39iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=l+5Dd1pBaf2BWqOzvnOtJeoOnh0h3UROiHJ4ZFZ6wqo=; b=GH164RJ2JFP+H+lhl7hBbrU7kUwXUK64ZDx5dxNaLTGUI6ieYP4MCzaynEY5dWYwDW HaC+iPULWCCBbY0k+wIh8UC0nWPxA1L8ReT1WIP6fDGDPhoiw5vPxGzhMGBHEKlhKfSV Xi7d6vJArdJhPzrb5WP8VH+AweJt2YLN54hmMcbB1U0m5SGZN5vhxBTU6xBjRwfp8wgH c3iqBDiJdQDfZljfAQvIP6wZxMB1JiT3gULH7ub/tTLxWTW36ItZy9p4lOtR0tLozkpd jyw0jkKCu0mIfOzhoFsSBSDyThp+ONOAu3VwTyDAfqd/mAiCr8+rs6/ZxBYLxDRujZ/u hn8A== X-Gm-Message-State: AOAM530JZW9PbHJ9uPQZqAUlr15z11BGwlg2I2eJIInMbnY4YjZ7U8Sg +zUzW33pc6C9GiBuaUL3vunDXo6m2Ts= X-Google-Smtp-Source: ABdhPJxTYb6wd7UHXbpaqgNfKBZ/Nat6pwJQUV+uc4v7O+yXbWkDsaap7De7geXT6jvp9Z2ROHg92A== X-Received: by 2002:a6b:be03:0:b0:64c:edbb:6b95 with SMTP id o3-20020a6bbe03000000b0064cedbb6b95mr2828556iof.46.1649199733772; Tue, 05 Apr 2022 16:02:13 -0700 (PDT) Received: from uranus2.cardinalpeak.com ([2001:470:403c:0:625d:3a78:f3d5:cd9c]) by smtp.gmail.com with ESMTPSA id t11-20020a922c0b000000b002c85834eb06sm8348304ile.47.2022.04.05.16.02.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:02:13 -0700 (PDT) From: Evan Gates To: meta@public-inbox.org Subject: [PATCH] scripts: add script to export v1 inboxes to maildir Date: Tue, 5 Apr 2022 17:01:56 -0600 Message-Id: <20220405230156.25449-1-evan.gates@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: --- 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