You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2005/12/13 01:59:31 UTC

svn commit: r356438 - in /spamassassin/trunk: build/listpromotable lib/Mail/SpamAssassin/PluginHandler.pm

Author: jm
Date: Mon Dec 12 16:59:26 2005
New Revision: 356438

URL: http://svn.apache.org/viewcvs?rev=356438&view=rev
Log:
add 'publish' tflags too, and winnow out nonexistent rules and rules from rules dir

Modified:
    spamassassin/trunk/build/listpromotable
    spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm

Modified: spamassassin/trunk/build/listpromotable
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/listpromotable?rev=356438&r1=356437&r2=356438&view=diff
==============================================================================
--- spamassassin/trunk/build/listpromotable (original)
+++ spamassassin/trunk/build/listpromotable Mon Dec 12 16:59:26 2005
@@ -69,19 +69,33 @@
 use Mail::SpamAssassin;
 
 my $mailsa = Mail::SpamAssassin->new({
-    rules_filename => join("\000", qw( rulesrc/core rulesrc/sandbox )),
-    site_rules_filename => "rules",
+    rules_filename => "rules",
+    site_rules_filename => join("\000", qw( rulesrc/core rulesrc/sandbox )),
     local_tests_only => 1,
     dont_copy_prefs => 1,
     config_tree_recurse => 1,
     # debug => 1,
 });
 
+# hack hack hack!!  we don't want to load plugin files twice,
+# and since the mkrules compiler copies from rulesrc/sandbox/*/*.pm
+# to rules/*.pm, they would otherwise appear twice.
+foreach my $fname (<rules/*.pm>) {
+  my $path = File::Spec->rel2abs($fname);
+  $INC{$path} = 1;
+  # warn "JMD $path";
+}
+
 my %rules_with_errors = ();
 
 $mailsa->{lint_callback} = sub {
   my %opts = @_;
-  warn "lint failure: $opts{rule}: $opts{msg}";
+
+  return if ($opts{msg} =~ /
+        (?:score\sset\sfor\snon-existent|description\sexists)
+    /x);
+
+  warn "demoting $opts{rule}: $opts{msg}";
   if ($opts{iserror}) {
     $rules_with_errors{$opts{rule}}++;
   }
@@ -91,14 +105,37 @@
 
 foreach my $name (sort keys %$plist) {
   my $obj = $plist->{$name};
+  my $notes = '';
+
+  next unless ($mailsa->{conf}->{descriptions}->{$name}
+        || $mailsa->{conf}->{scores}->{$name});
+
+  # ignore rules that are not marked as promotable
   next unless ($obj->{promo});
 
+  # "nopublish" tflags
   my $tfs = $mailsa->{conf}->{tflags}->{$name};
   if ($tfs) {
     next if ($tfs =~ /\bnopublish\b/);
+
+    if ($tfs =~ /\bpublish\b/) {
+      $notes = "tflags publish";
+      goto publish;
+    }
   }
 
+  # only rules from "rulesrc" dirs
+  my $src = $mailsa->{conf}->{source_file}->{$name};
+  next if (!$src || $src !~ /rulesrc/);
+
+  # rules that fail lint
   next if $rules_with_errors{$name};
+
+  $notes = "spam=$obj->{spc} ham=$obj->{hpc} so=$obj->{so}";
+
+publish:
+
+  print "\n# $notes\n$name\n";
 }
 
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm?rev=356438&r1=356437&r2=356438&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm Mon Dec 12 16:59:26 2005
@@ -84,13 +84,16 @@
               File::Spec->rel2abs($path)
 	    );
 
-    if (exists $INC{$path}) {
-      dbg("plugin: not loading $package from $path, already loaded");
-      return;
-    }
+    # if (exists $INC{$path}) {
+      # dbg("plugin: not loading $package from $path, already loaded");
+      # return;
+    # }
 
     dbg("plugin: loading $package from $path");
-    $ret = do $path;
+
+    # use require instead of "do", so we get built-in $INC{filename}
+    # smarts
+    $ret = eval { require $path; };
   }
   else {
     dbg("plugin: loading $package from \@INC");