Skip to content

Commit

Permalink
m_inmail DB now located in $XDG_DATA_HOME/lbdb/m_inmail.db
Browse files Browse the repository at this point in the history
For backward compatibility an already existing
$HOME/.lbdb/m_inmail.utf-8 file is used as first preference
(https://bugs.debian.org/843917)
  • Loading branch information
RolandRosenfeld committed Jul 29, 2023
1 parent 7fea476 commit eeb0604
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

### Changed

- The m_inmail DB is now located by default in
$XDG_DATA_HOME/lbdb/m_inmail.db. For backward compatibility an
already existing $HOME/.lbdb/m_inmail.utf-8 file is used as first
preference (https://bugs.debian.org/843917)

### Added

- Add $XDG_CONFIG_HOME/lbdb/config as additional ldbdrc file location,
Expand Down
4 changes: 0 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
- Optimize munge/munge-keeporder to work case-insensitive (at least on
the domain part of the addresses).

- Add support for XDG_DATA_HOME
https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
https://bugs.debian.org/843917

- Add support for "notmuchmail".

- Add testsuite.
Expand Down
50 changes: 29 additions & 21 deletions lbdb-fetchaddr.man.in
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
.\" -*- nroff -*-
.\" Copyright (c) 1998-2018 Roland Rosenfeld <[email protected]>
.\"
.\" Copyright (c) 1998-2023 Roland Rosenfeld <[email protected]>
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
Expand All @@ -20,7 +20,7 @@
lbdb-fetchaddr \- grab addresses from mails and append them to lbdb database
.SH SYNOPSIS
.B lbdb-fetchaddr
.RB [ -d
.RB [ -d
.IR dateformat ]
.RB [ -x
.IR headerfieldlist ]
Expand All @@ -36,16 +36,20 @@ lbdb-fetchaddr \- grab addresses from mails and append them to lbdb database
.B lbdb-fetchaddr
is a shell script which reads a mail on stdin. It extracts the
contents of some header fields (default:
.RB ` From: ',
.RB ` To: ',
.RB ` Cc: ',
.RB ` Resent-From: ',
.RB ` From: ',
.RB ` To: ',
.RB ` Cc: ',
.RB ` Resent-From: ',
and
.RB ` Resent-To: ')
from the mail header (only addresses with a real name) and appends
them to the database file, which defaults to
.IR $HOME/.lbdb/m_inmail.utf-8 .
For performance issues
.I $XDG_DATA_HOME/lbdb/m_inmail.db
or
.I $HOME/.lbdb/m_inmail.utf-8
if the latter already exists (backward compatibility).
.PP
For performance issues
.B lbdb-fetchaddr
appends new addresses to this file without removing duplicates. To get
rid of duplicates, the program
Expand All @@ -54,22 +58,22 @@ exists, which is run by
.B m_inmail
if needed and removes duplicates.
.PP
To use this program, put the following lines into your
To use this program, put the following lines into your
.I $HOME/.procmailrc:
.nf
.nf
:0hc
| lbdb-fetchaddr
.fi
.fi
.PP
.B lbdb-fetchaddr
writes the actual date to the third column of the database by using
.BR strftime (3).
It uses "%Y-%m-%d %H:%M" as the default date format (e.g. "1999-04-29
14:33"). You can change this by using the
14:33"). You can change this by using the
.B -d
option to select a different date format string as parameter of
lbdb-fetchaddr command like
.nf
.nf
:0hc
| lbdb-fetchaddr \-d "%y-%m-%d"
.fi
Expand All @@ -83,7 +87,7 @@ Print version number of lbdb-fetchaddr.
Print short help of lbdb-fetchaddr.
.TP
.BI -d " dateformat"
Use the given date format using
Use the given date format using
.BR strftime (3)
syntax.
.TP
Expand All @@ -104,13 +108,17 @@ mail address as real name.
.TP
.BI -f " databasefile"
Use the given file for storing the grabbed addresses instead of using
the default
.IR $HOME/.lbdb/m_inmail.utf-8 .
.SH FILES
the
.I $XDG_DATA_HOME/lbdb/m_inmail.db
resp.
.I $HOME/.lbdb/m_inmail.utf-8
default.
.SH FILES
.I $XDG_DATA_HOME/lbdb/m_inmail.db
.br
.IR $HOME/.lbdb/m_inmail.utf-8 " (old version before using $XDG_DATA_HOME)"
.br
.IR $HOME/.lbdb/m_inmail.list " (old version used for ISO-8859-15 encoded addresses)"

.br
.I @libdir@/fetchaddr
.br
Expand Down
21 changes: 13 additions & 8 deletions lbdb-fetchaddr.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
#
# -*-sh-*-
# Copyright (C) 1998-2000 Thomas Roessler <[email protected]>
# 1999-2022 Roland Rosenfeld <[email protected]>
#
# 1999-2023 Roland Rosenfeld <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
Expand All @@ -28,7 +28,9 @@ dotlock=@DOTLOCK@
[ -n "$USE_LOCAL_LIB" ] && [ -x $USE_LOCAL_LIB/lbdb_dotlock ] && dotlock=$USE_LOCAL_LIB/lbdb_dotlock
fetchaddr=${USE_LOCAL_LIB:-@libdir@}/fetchaddr

db=$HOME/.lbdb/m_inmail.utf-8
db=${XDG_DATA_HOME:-$HOME/.local/share}/lbdb/m_inmail.db
[ -f $HOME/.lbdb/m_inmail.utf-8 ] && db=$HOME/.lbdb/m_inmail.utf-8

datefmt='%Y-%m-%d %H:%M'
additional_param=""

Expand All @@ -43,17 +45,18 @@ usage() {
echo " -c 'charset' charset for the database storage"
echo " -a also grep addresses without realname"
echo " -f 'filename' database filename defaults to"
echo " \$HOME/.lbdb/m_inmail.utf-8"
echo " \$XDG_DATA_HOME/lbdb/m_inmail.db or"
echo " \$HOME/.lbdb/m_inmail.utf-8 if already exists"
}

while [ $# -gt 0 ]
do
case "$1" in
-v)
-v)
echo "lbdb-fetchaddr version $LBDB_VERSION"
exit 0
;;
-h)
-h)
usage
exit 0
;;
Expand Down Expand Up @@ -104,6 +107,8 @@ do
shift
done



if [ ! -f "$db" ]; then
dbdir=$(dirname "$db")
if [ ! -d "$dbdir" ]; then
Expand Down
15 changes: 8 additions & 7 deletions lbdb.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# ~/.lbdb/lbdbrc
# ~/.lbdb/rc
# (evaluated with ascending priority!)
#
# (c) 1999-2022 Roland Rosenfeld <[email protected]>
#
# (c) 1999-2023 Roland Rosenfeld <[email protected]>
#

#
Expand All @@ -35,7 +35,7 @@
# - m_palm search your Palm addressbook file.
# - m_gnomecard search your GnomeCard address database files.
# - m_bbdb search your BBDB (big brother database).
# - m_ldap query an LDAP server
# - m_ldap query an LDAP server
# - m_wanderlust search your wanderlust ~/.addresses file.
# - m_osx_addressbook search the OS X addressbook (only available on OS X).
# - m_evolution search in the Ximan Evolution addressbook.
Expand All @@ -46,9 +46,10 @@ METHODS="m_inmail m_passwd m_finger"

#
# If you want to use a different database file for m_inmail, you can
# define it in INMAIL_DB (defaults to $HOME/.lbdb/m_inmail.utf-8)
# define it in INMAIL_DB (defaults to $XDG_DATA_HOME/lbdb/m_inmail.db or
# $HOME/.lbdb/m_inmail.utf-8 if the latter exists)
#
#INMAIL_DB="$HOME/.lbdb/m_inmail.utf-8"
#INMAIL_DB="${XDG_DATA_HOME:-$HOME/.local/share}/lbdb/m_inmail.db"

#
# If you want m_finger to ask other host then localhost, create a list here:
Expand Down Expand Up @@ -149,7 +150,7 @@ METHODS="m_inmail m_passwd m_finger"
# - m_abook query the abook(1) program
#
# if you have more than one abook addressbook, use the ABOOK_FILES
# variable. It contains a space separated list of all your files.
# variable. It contains a space separated list of all your files.
# Default is $HOME/.abook/addressbook $HOME/.abook.addressbook
# ABOOK_FILES="$HOME/.abook/friends $HOME/.abook/work"

Expand Down Expand Up @@ -183,7 +184,7 @@ METHODS="m_inmail m_passwd m_finger"
# address in m_inmail database is first).
# If you set this to "name", lbdbq sorts the output by real name.
# If you set this to "comment", lbdbq sorts the output by comment (column 3).
# If you set this to "reverse_comment", lbdbq sorts the output by comment
# If you set this to "reverse_comment", lbdbq sorts the output by comment
# but with reverse order (column 3).
# If you set this to "address", lbdbq sorts the output by addresses
# (that's the default).
Expand Down
7 changes: 6 additions & 1 deletion lbdbq.man.in
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ This module will look up user name fragments in a list of mail
addresses created by
.BR lbdb-fetchaddr (1).
By default this uses
.IR $XDG_DATA_HOME/lbdb/m_inmail.db ,
which is overridden, if
.I $HOME/.lbdb/m_inmail.utf-8
as its database file, but this can be changed using
exists (the old default) as its database file, but this can be changed
using
.B INMAIL_DB
variable (but do not forget to change this in the
.BR lbdb-fetchaddr (1)
Expand Down Expand Up @@ -371,6 +374,8 @@ Print short help of lbdbq.
.br
.I @libdir@/*
.br
.I $XDG_DATA_HOME/lbdb/m_inmail.db
.br
.I $HOME/.lbdb/m_inmail.utf-8
.br
.I $HOME/.lbdb/nodelist
Expand Down
11 changes: 7 additions & 4 deletions m_inmail.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#
# Copyright (C) 1998-2000 Thomas Roessler <[email protected]>
# 1999-2022 Roland Rosenfeld <[email protected]>
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
Expand All @@ -21,7 +21,10 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@

M_INMAIL_DB=${INMAIL_DB:-$HOME/.lbdb/m_inmail.utf-8}
fallbackdb=${XDG_DATA_HOME:-$HOME/.local/share}/lbdb/m_inmail.db
[ -f $HOME/.lbdb/m_inmail.utf-8 ] && fallbackdb=$HOME/.lbdb/m_inmail.utf-8

M_INMAIL_DB=${INMAIL_DB:-$fallbackdb}

m_inmail_query()
{
Expand Down

0 comments on commit eeb0604

Please sign in to comment.