[PATCH v4 03/16] make shared crypto code behave library-like
[notmuch-archives.git] / 6f / f76e782197820b6f8f95a91943edd7089b7b5c
1 Return-Path: <polatel@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 40932429E25\r
6         for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 14:11:50 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id TAcStKm1vfnP for <notmuch@notmuchmail.org>;\r
17         Sat, 29 Oct 2011 14:11:48 -0700 (PDT)\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
19         [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id BC206431FB6\r
22         for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 14:11:47 -0700 (PDT)\r
23 Received: by faai28 with SMTP id i28so5123476faa.26\r
24         for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 14:11:46 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=date:from:to:cc:subject:message-id:mail-followup-to:references\r
27         :mime-version:content-type:content-disposition:in-reply-to\r
28         :organization:user-agent;\r
29         bh=ocZb+P6BLIrUL+mVAnaXxLSBUCCN4fauBvlgrwcZ8Gk=;\r
30         b=WPAyF+kXOigU9W3ozqJ+a3rjoqFVm798veE0ypl2o+57OxvSTxLhM1jv1t0iaa/TNm\r
31         6kGWQZYwVq2wlJZsjI/BMe3rwifutxjd36oLO6T+uVL9WTBJ0OhFlLC1ERB596SD3hdu\r
32         yw/NPsVdCF3SgX0RISvpIcNOt83SXzXhXaoIo=\r
33 Received: by 10.223.15.13 with SMTP id i13mr16257504faa.36.1319922700455;\r
34         Sat, 29 Oct 2011 14:11:40 -0700 (PDT)\r
35 Received: from localhost ([88.236.24.25])\r
36         by mx.google.com with ESMTPS id k16sm26695430fab.8.2011.10.29.14.11.38\r
37         (version=TLSv1/SSLv3 cipher=OTHER);\r
38         Sat, 29 Oct 2011 14:11:39 -0700 (PDT)\r
39 Date: Sun, 30 Oct 2011 00:11:35 +0300\r
40 From: Ali Polatel <polatel@gmail.com>\r
41 To: David Bremner <david@tethera.net>\r
42 Subject: Re: [PATCH] contrib/nmbug: new script for sharing tags with prefix\r
43         notmuch::\r
44 Message-ID: <20111029211134.GB4228@hayalet>\r
45 Mail-Followup-To: David Bremner <david@tethera.net>,\r
46         notmuch@notmuchmail.org, David Bremner <bremner@debian.org>\r
47 References: <1319857491-12298-5-git-send-email-david@tethera.net>\r
48         <1319906707-10141-1-git-send-email-david@tethera.net>\r
49         <1319906707-10141-2-git-send-email-david@tethera.net>\r
50 MIME-Version: 1.0\r
51 Content-Type: multipart/signed; micalg=pgp-sha1;\r
52         protocol="application/pgp-signature"; boundary="0eh6TmSyL6TZE2Uz"\r
53 Content-Disposition: inline\r
54 In-Reply-To: <1319906707-10141-2-git-send-email-david@tethera.net>\r
55 Organization: Pink Floyd\r
56 User-Agent: Mutt/1.5.21 (2010-09-15)\r
57 Cc: notmuch@notmuchmail.org, David Bremner <bremner@debian.org>\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Sat, 29 Oct 2011 21:11:50 -0000\r
71 \r
72 \r
73 --0eh6TmSyL6TZE2Uz\r
74 Content-Type: text/plain; charset=us-ascii; format=flowed\r
75 Content-Disposition: inline\r
76 Content-Transfer-Encoding: quoted-printable\r
77 \r
78 On Sat, Oct 29, 2011 at 01:45:07PM -0300, David Bremner wrote:\r
79 >From: David Bremner <bremner@debian.org>\r
80 >\r
81 >In this initial version, we take care of only the base import and\r
82 >export of the appropriate tags in line oriented format amenable to\r
83 >easy merging.\r
84 >\r
85 >The current plan to use git to share tags and resolve conflicts.\r
86 >---\r
87 > contrib/nmbug |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++++=\r
88 +++++\r
89 > 1 files changed, 69 insertions(+), 0 deletions(-)\r
90 > create mode 100755 contrib/nmbug\r
91 >\r
92 >diff --git a/contrib/nmbug b/contrib/nmbug\r
93 >new file mode 100755\r
94 >index 0000000..e9d1b14\r
95 >--- /dev/null\r
96 >+++ b/contrib/nmbug\r
97 >@@ -0,0 +1,69 @@\r
98 >+#!/bin/bash\r
99 \r
100 ^^ I'd make that:\r
101 #!/usr/bin/env bash\r
102 for systems where bash is not the default shell.\r
103 \r
104 >+# Copyright (c) 2011 David Bremner\r
105 >+# License: same as notmuch\r
106 >+\r
107 >+NMHOME=3D${HOME}/.nmbug\r
108 >+\r
109 >+NMTAGS=3D($(notmuch search --output=3Dtags "*"|grep "^notmuch::"))\r
110 >+\r
111 >+function dump() {\r
112 >+    notmuch dump -- $(printf  " tag:%s" ${NMTAGS[*]}) |\\r
113 >+    while read  -r msgid rest\r
114 >+    do\r
115 >+      outfile=3D$NMHOME/tags/$(echo $msgid | sha1sum - | cut -f1 -d' ')\r
116 >+      echo $outfile\r
117 >+      printf "msg-id: %s\n" $msgid > $outfile\r
118 >+      tmp=3D${rest#\(}\r
119 >+      read -r -a tags <<<${tmp%\)};\r
120 >+      for tag in "${tags[@]}"; do\r
121 >+          case $tag in\r
122 >+              notmuch::*)\r
123 >+                  echo "tag: $tag" >> $outfile\r
124 >+                  ;;\r
125 >+              *)\r
126 >+              # nothing\r
127 >+          esac\r
128 >+      done\r
129 >+    done\r
130 >+\r
131 >+}\r
132 >+\r
133 >+function cat_file() {\r
134 >+    tags=3D""\r
135 >+    id=3D""\r
136 >+    cat $1 |\\r
137 >+    while read -r what data\r
138 >+    do\r
139 >+      case $what in\r
140 >+          msg-id:)\r
141 >+              printf "%s (" $data\r
142 >+              ;;\r
143 >+          tag:)\r
144 >+              printf "%s " $data\r
145 >+              ;;\r
146 >+          *)\r
147 >+              echo "Syntax error $what"\r
148 >+              exit 1\r
149 >+      esac\r
150 >+    done\r
151 >+    echo ")"\r
152 >+}\r
153 >+\r
154 >+function restore() {\r
155 >+    find $NMHOME/tags -type f |\\r
156 >+    while read -r filename\r
157 >+    do\r
158 >+      cat_file $filename\r
159 >+    done | notmuch restore --match=3Dnotmuch::\r
160 >+}\r
161 >+case $1 in\r
162 >+    dump)\r
163 >+      dump\r
164 >+      ;;\r
165 >+    restore)\r
166 >+      restore\r
167 >+      ;;\r
168 >+    *)\r
169 >+      echo unknown command $1;\r
170 >+esac\r
171 >+\r
172 >--=20\r
173 >1.7.6.3\r
174 >\r
175 >_______________________________________________\r
176 >notmuch mailing list\r
177 >notmuch@notmuchmail.org\r
178 >http://notmuchmail.org/mailman/listinfo/notmuch\r
179 \r
180 --0eh6TmSyL6TZE2Uz\r
181 Content-Type: application/pgp-signature\r
182 \r
183 -----BEGIN PGP SIGNATURE-----\r
184 Version: GnuPG v2.0.18 (GNU/Linux)\r
185 \r
186 iEYEARECAAYFAk6sbAYACgkQQU4yORhF8iDaqQCePu8QY1DNdjLoV0hkWDLqHGha\r
187 8LIAn0Oaj3rCct2LtwxBx9Jaf7ilfSq0\r
188 =DgyJ\r
189 -----END PGP SIGNATURE-----\r
190 \r
191 --0eh6TmSyL6TZE2Uz--\r