Mailing List Archive

svn commit: r292369 - in /spamassassin/trunk: MANIFEST Makefile.PL build/mkrules
Author: jm
Date: Wed Sep 28 18:48:53 2005
New Revision: 292369

URL: http://svn.apache.org/viewcvs?rev=292369&view=rev
Log:
added support for a script to build rules from 'rulesrc', and output files to 'rules' as part of the build process

Added:
spamassassin/trunk/build/mkrules (with props)
Modified:
spamassassin/trunk/MANIFEST
spamassassin/trunk/Makefile.PL

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/MANIFEST?rev=292369&r1=292368&r2=292369&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Wed Sep 28 18:48:53 2005
@@ -458,3 +458,4 @@
tools/sysreport
tools/test_extract
tools/triplets.pl
+build/mkrules

Modified: spamassassin/trunk/Makefile.PL
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/Makefile.PL?rev=292369&r1=292368&r2=292369&view=diff
==============================================================================
--- spamassassin/trunk/Makefile.PL (original)
+++ spamassassin/trunk/Makefile.PL Wed Sep 28 18:48:53 2005
@@ -1029,12 +1029,14 @@
sa-learn: sa-learn.raw
$(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -i$? -o$@

-sa-update: sa-update.raw
- $(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -i$? -o$@
+sa-update: sa-update.raw build_rules
+ $(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -isa-update.raw -osa-update

spamd/spamd: spamd/spamd.raw
$(PREPROCESS) $(FIXBYTES) $(FIXVARS) $(FIXBANG) -m$(PERM_RWX) -i$? -o$@

+build_rules: rulesrc rules
+ $(PERL) build/mkrules --src rulesrc --out rules

SPAMC_MAKEFILE = spamc/Makefile
MAKE_SPAMC = $(MAKE) -f $(SPAMC_MAKEFILE)

Added: spamassassin/trunk/build/mkrules
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/mkrules?rev=292369&view=auto
==============================================================================
--- spamassassin/trunk/build/mkrules (added)
+++ spamassassin/trunk/build/mkrules Wed Sep 28 18:48:53 2005
@@ -0,0 +1,87 @@
+#!/usr/bin/perl -w
+#
+# build/mkrules -- compile the SpamAssassin rules into installable form
+#
+# <@LICENSE>
+# Copyright 2004 Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# </@LICENSE>
+
+# This is an implementation of
+# http://wiki.apache.org/spamassassin/RulesProjPromotion
+
+sub usage {
+ die "mkrules/run [--src srcdir] [--out outputdir]\n";
+}
+
+use File::Find;
+use File::Copy;
+
+use Getopt::Long;
+use vars qw($opt_src $opt_out);
+GetOptions("src=s", "out=s");
+
+die "no src" unless ($opt_src);
+die "no out" unless ($opt_out);
+die "unreadable src" unless (-d $opt_src);
+die "unreadable out" unless (-d $opt_out);
+
+File::Find::find ({
+ wanted => \&wanted,
+ no_chdir => 1
+ }, $opt_src);
+
+sub wanted {
+ return unless (-f $File::Find::name && /\d.*\.cf$/i);
+
+ my $dir = $File::Find::name;
+ $dir =~ s/^${opt_src}[\/\\\:]//s;
+ $dir =~ s/([^\/\\\:]+)$//;
+ my $file = $1;
+
+ if ($dir =~ /sandbox/) {
+ apply_sandbox_rules($dir, $file);
+ }
+ else {
+ copy_rule_file_if_newer($dir, $file);
+ }
+}
+
+
+sub copy_rule_file_if_newer {
+ my ($dir, $file) = @_;
+
+ my $f = "$opt_src/$dir/$file";
+ my $t = "$opt_out/$file";
+
+ if (!-r $t || -M $t > -M $f) {
+ print "cp $f $t\n";
+ copy($f, $t) or die "copy failed from $f to $t: $!\n";
+ }
+}
+
+sub apply_sandbox_rules {
+ my ($dir, $file) = @_;
+
+ # TODO! this section should implement the validation criteria from
+ # http://wiki.apache.org/spamassassin/RulesProjPromotion .
+ #
+ # right now, it just copies the file, raw.
+
+ my $f = "$opt_src/$dir/$file";
+ my $t = "$opt_out/$file";
+ print "grepcp?? $f $t\n";
+ copy($f, $t) or die "copy failed from $f to $t: $!\n";
+}
+

Propchange: spamassassin/trunk/build/mkrules
------------------------------------------------------------------------------
svn:executable = *