#!/usr/local/bin/perl -w ##---------------------------------------------------------------------------## ## File: ## $Id: mk-procmailrc,v 1.9 2002/03/11 20:28:11 ehood Exp $ ## Description: ## Program to create a procmail recipe file from lists.txt. ##---------------------------------------------------------------------------## ## Copyright (C) 2001-2002 Earl Hood ## ## 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., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA ##---------------------------------------------------------------------------## package MHArc::mk_procmailrc; my $Dir; BEGIN { $Dir = `dirname $0`; chomp $Dir; } use lib "$Dir/../lib"; # Add relative lib to search path use MHArc::Config; my $config = MHArc::Config->load("$Dir/../lib/config.sh"); use Getopt::Long; use MHArc::ListDef; MAIN: { my @htaccess = (); my $basedir = $config->{'SW_ROOT'} || "$Dir/.."; my $procmail_path = $config->{'PROCMAIL_PATH'}; GetOptions( 'basedir', \$basedir, 'procmail-path=s', \$procmail_path ) || die; ## Read lists definition file my $file = shift(@ARGV) || $config->{'LISTS_DEF_FILE'} || "$Dir/../lib/lists.def"; my $listdef = MHArc::ListDef->new($file); ## Print procmailrc header print <{$name}{'address'}}; if (!scalar(@addr)) { # no addresses defined warn qq/Warning: No addresses defined for '$name'\n/; next; } # create procmail regex for list $pm_conditions = '* (^TO_'; $pm_conditions .= '(' if (scalar(@addr) > 1); $pm_conditions .= join('|', @addr); $pm_conditions .= ')' if (scalar(@addr) > 1); $pm_conditions .= '|(^(Delivered-To:|List-Post:).*'; $pm_conditions .= '(' if (scalar(@addr) > 1); $pm_conditions .= join('|', @addr); $pm_conditions .= ')' if (scalar(@addr) > 1); $pm_conditions .= '))'; if (defined($listdef->{$name}{'procmail-condition'})) { foreach $str (@{$listdef->{$name}{'procmail-condition'}}) { $pm_conditions .= "\n$str"; } } # check if doing monthly or yearly archives $period = lc($listdef->{$name}{'period'}) || 'month'; $period = 'month' if ($name eq '.catch'); if ($period eq 'year') { $folder_name = '$YEARFOLDER'; } else { $folder_name = '$MONTHFOLDER'; } # check if rule should not be final if matched if ($listdef->{$name}{'final'}) { $pm_copy = ''; } else { $pm_copy = ' c'; } # check if separating out cvs commits if ($check_cvs = $listdef->{$name}{'cvs-commits'}[0]) { $cvs_prefix = $listdef->{$name}{'cvs-subject-prefix'}[0] || 'CVS commit'; foreach $addr (@addr) { print <