commit 72c7134ae6a136dab9e555a7195b27258caa5870
parent 4f645a0e9d67f822a7a4d53af239fe2043613536
Author: Jaromil <jaromil@dyne.org>
Date:   Thu,  5 Dec 2013 20:55:33 +0100
fixes for write-only workdir on gnu/linux
Diffstat:
4 files changed, 54 insertions(+), 52 deletions(-)
diff --git a/install.sh b/install.sh
@@ -49,10 +49,10 @@ ${=mkdir} ${WORKDIR}/bin
 cp -f src/jaro ${WORKDIR}/bin
 
 # make sure we have a temp and cache dir
-${=mkdir} $WORKDIR/tmp $WORKDIR/cache
+${=mkdir} $MAILDIRS/tmp $MAILDIRS/cache
 
-if ! [ -r $WORKDIR/Filters.txt ]; then
-    cat <<EOF > $WORKDIR/Filters.txt
+if ! [ -r $MAILDIRS/Filters.txt ]; then
+    cat <<EOF > $MAILDIRS/Filters.txt
 # Example filter configuration for Jaro Mail
 
 # mailinglist filters are in order of importance
@@ -86,11 +86,11 @@ if ! [ -r $WORKDIR/Filters.txt ]; then
 EOF
     act "Default filters created"
 else
-    error "Existing configuration $WORKDIR/Filters.txt skipped"
+    error "Existing configuration $MAILDIRS/Filters.txt skipped"
 fi
 
-if ! [ -r $WORKDIR/Applications.txt ]; then
-    cat <<EOF > $WORKDIR/Applications.txt
+if ! [ -r $MAILDIRS/Applications.txt ]; then
+    cat <<EOF > $MAILDIRS/Applications.txt
 # Example configuration to match mime/type to applications
 # each line should start with a mime/type and then indicate an executable
 
@@ -100,12 +100,12 @@ if ! [ -r $WORKDIR/Applications.txt ]; then
 EOF
     act "Default helper applications settings created"
 else
-    error "Existing configuration $WORKDIR/Applications.txt skipped"
+    error "Existing configuration $MAILDIRS/Applications.txt skipped"
 fi
 
 
-if ! [ -r $WORKDIR/Mutt.txt ]; then
-    cat <<EOF > $WORKDIR/Mutt.txt
+if ! [ -r $MAILDIRS/Mutt.txt ]; then
+    cat <<EOF > $MAILDIRS/Mutt.txt
 # Mutt specific customizations
 # uncomment and fill in with your settings
 
@@ -139,12 +139,12 @@ if ! [ -r $WORKDIR/Mutt.txt ]; then
 EOF
     act "Default Mutt configuration template created"
 else
-    error "Existing configuration $WORKDIR/Mutt.txt skipped"
+    error "Existing configuration $MAILDIRS/Mutt.txt skipped"
 fi
 
-if ! [ -r $WORKDIR/Accounts ]; then
-    ${=mkdir} $WORKDIR/Accounts
-    cat <<EOF > $WORKDIR/Accounts/README.txt
+if ! [ -r $MAILDIRS/Accounts ]; then
+    ${=mkdir} $MAILDIRS/Accounts
+    cat <<EOF > $MAILDIRS/Accounts/README.txt
 Directory containing account information
 
 Each file contains a different account: imap, pop or gmail
@@ -154,7 +154,7 @@ Examples are: imap.default.txt and smtp.default.txt
 
 One can have multiple accounts named otherwise than default
 EOF
-    cat <<EOF > $WORKDIR/Accounts/imap.default.txt
+    cat <<EOF > $MAILDIRS/Accounts/imap.default.txt
 # Name and values are separated by spaces or tabs
 # comments start the line with a hash
 
@@ -205,7 +205,7 @@ options keep
 # The password field will be filled in automatically
 #
 EOF
-    cat <<EOF > $WORKDIR/Accounts/smtp.default.txt
+    cat <<EOF > $MAILDIRS/Accounts/smtp.default.txt
 # Name and values are separated by spaces or tabs
 # comments start the line with a hash
 
@@ -227,7 +227,7 @@ port 25
 EOF
     act "Default accounts directory created"
 else
-    error "Existing configuration $WORKDIR/Accounts skipped"
+    error "Existing configuration $MAILDIRS/Accounts skipped"
 fi
 
 # our own libraries
@@ -242,12 +242,12 @@ done
 # procmail is entirely generated
 # so overwriting it won't hurt
 act "Installing procmail scripts"
-${=mkdir} $PROCMAILDIR
-cp -a src/procmail/* $PROCMAILDIR
+${=mkdir} $WORKDIR/.procmail
+cp -a src/procmail/* $WORKDIR/.procmail
 
 # also mutt is safe to override
-${=mkdir} $MUTTDIR
-cp -a src/mutt/* $MUTTDIR
+${=mkdir} $WORKDIR/.mutt
+cp -a src/mutt/* $WORKDIR/.mutt
 
 # all statistics
 ${=mkdir} $WORKDIR/.stats
@@ -277,7 +277,7 @@ cp -a src/stats/* $WORKDIR/.stats
 
 # generate initial configuration
 act "Refresh configuration"
-MAILDIRS=$MAILDIRS WORKDIR=$WORKDIR src/jaro update -q
+JAROMAILDIR=$MAILDIRS JAROWORKDIR=$WORKDIR src/jaro update -q
 
 touch $HOME/.profile
 cat $HOME/.profile | grep '^# Jaro Mail' > /dev/null
@@ -291,12 +291,13 @@ fi
 
 # update the manual
 { test -r doc/jaromail-manual.pdf } && {
-    cp -f doc/jaromail-manual.pdf $WORKDIR/Manual.pdf }
+    cp -f doc/jaromail-manual.pdf $MAILDIRS/Manual.pdf }
 
 notice "Done! now configure your personal settings, accounts and filters in:"
-act "    $WORKDIR"
-act "To read the commandline help, with a list of commands: jaro -h"
-act "Make sure jaro is in your PATH! it was just added to your ~/.profile"
+act "    $MAILDIRS"
+act "Make sure jaro is in your PATH! binaries are found in:"
 act "    $WORKDIR/bin"
+act "For a brief list of commands: jaro -h"
+act "For a complete introduction read the manual in $MAILDIRS/Manual.pdf"
 
 
diff --git a/src/zlibs/accounts b/src/zlibs/accounts
@@ -212,7 +212,7 @@ ask_password() {
 		    password=`print "protocol=${type}\npath=jaromail/${type}/${email}\nusername=${login}\nhost=${host}\n\n" | $WORKDIR/bin/jaro-gnome-keyring get`
 		fi
 		return 0
-	    elif [ -r $WORKDIR/keyring ]; then
+	    elif [ -r $KEYRING ]; then
                 func "Looking for password in local keyring for $email on $host over $type"
 		_hash=`print "$type:$email:$host" | shasum | awk '{print $1}'`
 		lookup="`lookup_secret ${_hash}`"
diff --git a/src/zlibs/addressbook b/src/zlibs/addressbook
@@ -21,16 +21,17 @@
 # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 
+ADDRESSBOOK=$MAILDIRS/Addressbook
 
 ###################
 # Jaro Brother DB
 create_addressbook() {
     func "create addressbook"
-    { test -r "$WORKDIR/addressbook" } && {
-	error "Addressbook already exists: $WORKDIR/addressbook"
+    { test -r "$ADDRESSBOOK" } && {
+	error "Addressbook already exists: $ADDRESSBOOK"
 	return 1
     }
-    cat <<EOF | ${SQL} -batch $WORKDIR/addressbook
+    cat <<EOF | ${SQL} -batch $ADDRESSBOOK
 CREATE TABLE whitelist
 (
   email   text collate nocase unique,
@@ -46,8 +47,8 @@ EOF
 	error "Error creating addressbook database."
 	return 1 }
     # make sure is private
-    chmod 600 $WORKDIR/addressbook
-    chown $_uid:$_gid $WORKDIR/addressbook
+    chmod 600 $ADDRESSBOOK
+    chown $_uid:$_gid $ADDRESSBOOK
 
     return 0
 }
@@ -55,7 +56,7 @@ EOF
 insert_address() {
     _email="${(Q)1}"; _name="${(Q)2}";
     func "insert address: $_name <$_email>"
-    cat <<EOF | ${SQL} -batch $WORKDIR/addressbook 2> /dev/null
+    cat <<EOF | ${SQL} -batch $ADDRESSBOOK 2> /dev/null
 INSERT INTO $list (email, name)
 VALUES ("${_email}", "${_name}");
 EOF
@@ -68,7 +69,7 @@ EOF
 
 # update_name() {
 #     func "update address: $1, $2"
-#     cat <<EOF | ${SQL} -batch $WORKDIR/addressbook 2> /dev/null
+#     cat <<EOF | ${SQL} -batch $ADDRESSBOOK 2> /dev/null
 # UPDATE $list SET name="${2}" WHERE email LIKE "${1}";
 # EOF
 #     { test $? != 0 } && {
@@ -77,7 +78,7 @@ EOF
 
 remove_address() {
     func "remove address <$1> from $list"
-    cat <<EOF | ${SQL} -batch $WORKDIR/addressbook
+    cat <<EOF | ${SQL} -batch $ADDRESSBOOK
 DELETE FROM $list
 WHERE email IS "${1}";
 EOF
@@ -87,7 +88,7 @@ EOF
 
 search_name() {
     func "search_name from $list like $1"
-	cat <<EOF | ${SQL} -column -batch $WORKDIR/addressbook
+	cat <<EOF | ${SQL} -column -batch $ADDRESSBOOK
 .width 64 128
 SELECT * FROM $list
 WHERE name LIKE "%${1}%";
@@ -96,7 +97,7 @@ EOF
 
 search_email() {
     func "search addressbook $list for $1"
-    cat <<EOF | ${SQL} -column -batch $WORKDIR/addressbook
+    cat <<EOF | ${SQL} -column -batch $ADDRESSBOOK
 .width 64 128
 SELECT * FROM $list
 WHERE email LIKE "%${1}%";
@@ -105,7 +106,7 @@ EOF
 
 lookup_email() {
     func "lookup email id from $list where $1"
-    cat <<EOF | ${SQL} -column -batch $WORKDIR/addressbook
+    cat <<EOF | ${SQL} -column -batch $ADDRESSBOOK
 SELECT rowid FROM $list
 WHERE email IS "${1}";
 EOF
@@ -205,7 +206,7 @@ list_addresses() {
     { test ${PARAM[1]} } && { list=${PARAM[1]} }
 
     act "Listing all contents for $list"
-    cat <<EOF | ${SQL} -column -header -batch $WORKDIR/addressbook
+    cat <<EOF | ${SQL} -column -header -batch $ADDRESSBOOK
 .width 32 40
 SELECT * FROM $list;
 EOF
@@ -242,7 +243,7 @@ import_macosx() {
     addresses=`cat $tmp`
     unlink $tmp
 
-    lock $WORKDIR/addressbook
+    lock $ADDRESSBOOK
     new=0; dupes=0;
     for a in ${(f)addresses}; do
 	_email="${a[(ws:|:)1]}"
@@ -254,7 +255,7 @@ import_macosx() {
 	else dupes=$(( $dupes + 1 )); fi
     done
 
-    unlock $WORKDIR/addressbook
+    unlock $ADDRESSBOOK
     notice "Operation completed"
     act "$new new addresses imported"
     act "$dupes duplicate addresses skipped"
@@ -309,7 +310,7 @@ BEGIN { newcard=0; c=0; name=""; email=""; }
     addresses=`cat $tmp`
     ${=rm} $tmp
 
-    lock $WORKDIR/addressbook
+    lock $ADDRESSBOOK
 
     newa=1; _name=""; _email=""
     for a in ${(f)addresses}; do
@@ -329,7 +330,7 @@ BEGIN { newcard=0; c=0; name=""; email=""; }
 	{ test $newa -eq 0 } && { _email=`echo ${(V)a} | cut -d^ -f1` }
     done
 
-    unlock $WORKDIR/addressbook
+    unlock $ADDRESSBOOK
 
     notice "Done importing addresses"
 }
@@ -337,12 +338,12 @@ BEGIN { newcard=0; c=0; name=""; email=""; }
 # export addressbook to vcard
 export_vcard() {
 
-    act "Export addressbook into vCard $WORKDIR/addressbook.vcf"
+    act "Export addressbook into vCard $ADDRESSBOOK.vcf"
     tmp=$TMPDIR/export.$datestamp.$RANDOM
 
-    lock $WORKDIR/addressbook
+    lock $ADDRESSBOOK
 
-    cat <<EOF | ${SQL} -column -header -batch $WORKDIR/addressbook \
+    cat <<EOF | ${SQL} -column -header -batch $ADDRESSBOOK \
 	| grep -v '^email' > $tmp
 .width 40 100
 .mode list
@@ -350,20 +351,20 @@ export_vcard() {
 SELECT email, name FROM $list;
 EOF
 
-    unlock $WORKDIR/addressbook
+    unlock $ADDRESSBOOK
 
     addresses=`cat $tmp`
     ${=rm} $tmp
 
-    rm -f $WORKDIR/addressbook.vcf
-    touch $WORKDIR/addressbook.vcf
+    rm -f $ADDRESSBOOK.vcf
+    touch $ADDRESSBOOK.vcf
     for a in ${(f)addresses}; do
 	_email="${a[(ws:|:)1]}"
 	# remove from name all what is an email between brackets
 	# crop (trim) all beginning and ending whitespaces from name
 	_name=`print ${a[(ws:|:)2]} | sed 's/<.*>//;s/^[ \t]*//;s/[ \t]*$//'`
 	{ test "${_email}" != "" } && {
-	    cat <<EOF >> $WORKDIR/addressbook.vcf
+	    cat <<EOF >> $ADDRESSBOOK.vcf
 BEGIN:VCARD
 VERSION:3.0
 FN:${_name}
@@ -385,7 +386,7 @@ edit_abook() {
 	return 1
     }
 
-    lock $WORKDIR/addressbook
+    lock $ADDRESSBOOK
 
     act "Editing addressbook $list"
     tmp=$TMPDIR/abook.$datestamp.$RANDOM
@@ -505,7 +506,7 @@ EOF
     func "Inserting the updated addressbook"
     cat $tmp | ${SQL} -batch $addressbook 2> /dev/null
     unlink $tmp
-    unlock $WORKDIR/addressbook
+    unlock $ADDRESSBOOK
     notice "Addressbook updated"
 }
 ###################
diff --git a/src/zlibs/filters b/src/zlibs/filters
@@ -144,7 +144,7 @@ EOF
     # SIEVE
     act "generating sieve filters"
     id=$datestamp.$RANDOM
-    sieve=$MAILDIRS/Sieve.txt
+    sieve=$MAILDIRS/Filters.sieve
     lock $sieve
     rm -f $sieve
     touch $sieve