CVSROOT: ciabot.pl Updated to latest version.
arekm
arekm at pld-linux.org
Tue Aug 23 19:12:16 CEST 2005
Author: arekm Date: Tue Aug 23 17:12:15 2005 GMT
Module: CVSROOT Tag: HEAD
---- Log message:
Updated to latest version.
---- Files affected:
CVSROOT:
ciabot.pl (1.9 -> 1.10)
---- Diffs:
================================================================
Index: CVSROOT/ciabot.pl
diff -u CVSROOT/ciabot.pl:1.9 CVSROOT/ciabot.pl:1.10
--- CVSROOT/ciabot.pl:1.9 Sun Jan 4 17:55:22 2004
+++ CVSROOT/ciabot.pl Tue Aug 23 19:12:10 2005
@@ -12,32 +12,45 @@
# Free Software Foundation.
#
# The master location of this file is
-# http://pasky.or.cz/~pasky/dev/cvs/ciabot.pl.
+# http://pasky.or.cz/~pasky/dev/cvs/ciabot.pl.
+#
+# This version has been modified a bit, and is available on CIA's web site:
+# http://cia.navi.cx/clients/cvs/ciabot_cvs.pl
#
# This program is designed to run from the loginfo CVS administration file. It
# takes a log message, massaging it and mailing it to the address given below.
#
# Its record in the loginfo file should look like:
#
-# ALL $CVSROOT/CVSROOT/ciabot.pl %s $USER project from_email dest_email
+# ALL /usr/bin/perl $CVSROOT/CVSROOT/ciabot_cvs.pl %{,,,s} $USER project from_email dest_email ignore_regexp
+#
+# IMPORTANT: The %{,,,s} in loginfo is new, and is required for proper operation.
#
-# Note that the last three parameters are optional, you can alternatively change
-# the defaults below in the configuration section.
+# Make sure that you add the script to 'checkoutlist' before
+# committing it. You may need to change /usr/bin/perl to point to your
+# system's perl binary.
#
-# If it does not work, try to disable $xml_rpc in the configuration section
-# below.
+# Note that the last four parameters are optional, you can alternatively
+# change the defaults below in the configuration section.
#
-# $Id$
use strict;
-use vars qw ($project $from_email $dest_email $rpc_uri @sendmail $sync_delay $xml_rpc);
-
-
+use vars qw ($project $from_email $dest_email $rpc_uri $sendmail $sync_delay
+ $xml_rpc $ignore_regexp $alt_local_message_target);
### Configuration
# Project name (as known to CIA).
+#
+# NOTE: This shouldn't be a long description of your project. Ideally
+# it is a short identifier with no spaces, punctuation, or
+# unnecessary capitalization. This will be used in URLs related
+# to your project, as an internal identifier, and in IRC messages.
+# If you want a longer name shown for your project on the web
+# interface, please use the "title" metadata key rather than
+# putting that here.
+#
$project = 'pld';
# The from address in generated mails.
@@ -49,25 +62,48 @@
# If using XML-RPC, connect to this URI.
$rpc_uri = 'http://cia.navi.cx/RPC2';
-# Path to your sendmail binary. If you have it at a different place (and
-# outside of $PATH), add your location at the start of this list. By all means
-# keep the trailing empty string in the array.
- at sendmail = ('sendmail', '/usr/lib/sendmail', '/usr/sbin/sendmail', '');
+# Path to your USCD sendmail compatible binary (your mailer daemon created this
+# program somewhere).
+$sendmail = '/usr/sbin/sendmail';
# Number of seconds to wait for possible concurrent instances. CVS calls up
# this script for each involved directory separately and this is the sync
# delay. 5s looks as a safe value, but feel free to increase if you are running
# this on a slower (or overloaded) machine or if you have really a lot of
# directories.
+# Increasing this could be a very good idea if you're on Sourceforge ;)
$sync_delay = 5;
# This script can communicate with CIA either by mail or by an XML-RPC
# interface. The XML-RPC interface is faster and more efficient, however you
# need to have RPC::XML perl module installed, and some large CVS hosting sites
# (like Savannah or Sourceforge) might not allow outgoing HTTP connections
-# while they allow outgoing mail.
+# while they allow outgoing mail. Also, this script will hang and eventually
+# not deliver the event at all if CIA server happens to be down, which is
+# unfortunately not an uncommon condition.
$xml_rpc = 0;
+# You can make this bot to totally ignore events concerning the objects
+# specified below. Each object is composed of <module>/<path>/<filename>,
+# therefore file Manifest in root directory of module gentoo will be called
+# "gentoo/Manifest", while file src/bfu/inphist.c of module elinks will be
+# called "elinks/src/bfu/inphist.c". Easy, isn't it?
+#
+# This variable should contain regexp, against which will each object be
+# checked, and if the regexp is matched, the file is ignored. Therefore ie. to
+# ignore all changes in the two files above and everything concerning module
+# 'admin', use:
+#
+# $ignore_regexp = "^(gentoo/Manifest|elinks/src/bfu/inphist.c|admin/)";
+$ignore_regexp = "";
+
+# It can be useful to also grab the generated XML message by some other
+# programs and ie. autogenerate some content based on it. Here you can specify
+# a file to which it will be appended.
+$alt_local_message_target = "";
+
+
+
### The code itself
@@ -78,6 +114,16 @@
# affected in each directory
+# A nice nonprinting character we can use as a separator relatively safely.
+# The commas in loginfo above give us 4 commas and a space between file
+# names given to us on the command line. This is the separator used internally.
+# Now we can handle filenames containing spaces, and probably anything except
+# strings of 4 commas or the ASCII bell character.
+#
+# This was inspired by the suggestion in:
+# http://mail.gnu.org/archive/html/info-cvs/2003-04/msg00267.html
+#
+$" = "\7";
### Input data loading
@@ -85,7 +131,7 @@
# These arguments are from %s; first the relative path in the repository
# and then the list of files modified.
- at files = split (' ', ($ARGV[0] or ''));
+ at files = split (' ,,,', ($ARGV[0] or ''));
$dir[0] = shift @files or die "$0: no directory specified\n";
$dirfiles[0] = "@files" or die "$0: no files specified\n";
@@ -97,6 +143,7 @@
# Figure out who is doing the update.
+# $user = $ARGV[1];
$user = $ENV{'CVS_USER'} || $ENV{'CVS_USERNAME'} || $ENV{'CVSUSER'} || getlogin || (getpwuid($<))[0] || "nobody";
@@ -105,6 +152,7 @@
$project = $ARGV[2] if $ARGV[2];
$from_email = $ARGV[3] if $ARGV[3];
$dest_email = $ARGV[4] if $ARGV[4];
+$ignore_regexp = $ARGV[5] if $ARGV[5];
# Parse stdin (what's interesting is the tag and log message)
@@ -114,11 +162,25 @@
last if /^Log Message/;
}
+$logmsg = "";
while (<STDIN>) {
next unless ($_ and $_ ne "\n" and $_ ne "\r\n");
+ s/&/&/g;
+ s/</</g;
+ s/>/>/g;
$logmsg .= $_;
}
+### Remove to-be-ignored files
+
+$dirfiles[0] = join (' ',
+ grep {
+ my $f = "$module/$dir[0]/$_";
+ $f !~ m/$ignore_regexp/;
+ } split (/\s+/, $dirfiles[0])
+) if ($ignore_regexp);
+exit unless $dirfiles[0];
+
### Sync between the multiple instances potentially being ran simultanously
@@ -126,6 +188,7 @@
my $sum; # _VERY_ simple hash of the log message. It is really weak, but I'm
# lazy and it's really sorta exceptional to even get more commits
# running simultanously anyway.
+$sum = 0;
map { $sum += ord $_ } split(//, $logmsg);
my $syncfile; # Name of the file used for syncing
@@ -173,7 +236,8 @@
### Compose the mail message
-my ($VERSION) = '$Revision$' =~ / (\d+\.\d+) /;
+my ($VERSION) = '2.3';
+my ($URL) = 'http://cia.navi.cx/clients/cvs/ciabot_cvs.pl';
my $ts = time;
$message = <<EM
@@ -181,7 +245,7 @@
<generator>
<name>CIA Perl client for CVS</name>
<version>$VERSION</version>
- <url>http://pasky.or.cz/~pasky/dev/cvs/ciabot.pl</url>
+ <url>$URL</url>
</generator>
<source>
<project>$project</project>
@@ -205,11 +269,11 @@
map {
$_ = $dir[$dirnum] . '/' . $_;
s#^.*?/##; # weed out the module name
- s/ / /g;
+ s/&/&/g;
s/</</g;
s/>/>/g;
$message .= " <file>$_</file>\n";
- } split(/ /, $dirfiles[$dirnum]);
+ } split($", $dirfiles[$dirnum]);
}
$message .= <<EM
@@ -225,6 +289,15 @@
+### Write the message to an alt-target
+
+if ($alt_local_message_target and open (ALT, ">>$alt_local_message_target")) {
+ print ALT $message;
+ close ALT;
+}
+
+
+
### Send out the XML-RPC message
@@ -254,10 +327,7 @@
# Open our mail program
-foreach my $sendmail (@sendmail) {
- die "$0: cannot fork sendmail: $!\n" unless ($sendmail);
- open (MAIL, "| $sendmail -t -oi -oem") and last;
-}
+open (MAIL, "| $sendmail -t -oi -oem") or die "Cannot execute $sendmail : " . ($?>>8);
# The mail header
@@ -276,6 +346,6 @@
# Close the mail
close MAIL;
-die "$0: sendmail exit status " . $? >> 8 . "\n" unless ($? == 0);
+die "$0: sendmail exit status " . ($? >> 8) . "\n" unless ($? == 0);
# vi: set sw=2:
================================================================
---- CVS-web:
http://cvs.pld-linux.org/CVSROOT/ciabot.pl?r1=1.9&r2=1.10&f=u
More information about the pld-cvs-commit
mailing list