#!/usr/bin/perl -w # # $FreeBSD$ # # # Perl filter to handle pre-commit checking of files. This program # records the last directory where commits will be taking place for # use by the log_accumulate script. For new file, it forcing the # existence of a RCS "Id" keyword in the first ten lines of the file. # For existing files, it checks version number in the "Id" line to # prevent losing changes because an old version of a file was copied # into the direcory. # # Possible future enhancements: # # # Check for cruft left by unresolved conflicts. Search for # "^<<<<<<<$", "^-------$", and "^>>>>>>>$". # # Look for a copyright and automagically update it to the # current year. # # Contributed by David Hampton # require 5.003; # to be sure. log_accum needs perl5 use strict; use lib $ENV{CVSROOT}; use CVSROOT::cfg; ############################################################ # # Configurable options # ############################################################ # # Check each file (except dot files) for our RCS header keyword. # (defined in the constants section.) # my $check_id = 0; ############################################################ # # Constants # ############################################################ my $ENTRIES = "CVS/Entries"; # The "Id" header to check for. my $HEADER = $cfg::IDHEADER; my $cvsroot= $ENV{'CVSROOT'} || "/home/ncvs"; ############################################################ # # Error messages # ############################################################ my $NoId = " %s - Does not contain a line with the keyword \"\$$HEADER:\".\n"; # Protect string from substitution by RCS. my $NoName = " %s - The ID line should contain only \$$HEADER\$ for a newly created file.\n"; #$DelPath = " #%s - The old path and version has been deleted from \$$HEADER\$.\n"; my $BadId = " %s - The \$$HEADER\$ is mangled.\n"; my $BadName = " %s - The pathname '%s' in the \$$HEADER\$ line does not match the actual filename.\n"; my $BadVersion = " %s - GRRR!! You spammed your copy of the file which was based upon version %s, with a different version based upon %s. Please move your '%s' out of the way, perform an update to get the current version, and then CAREFULLY merge your changes into that file.\n"; ############################################################ # # Subroutines # ############################################################ # Write a single line to a file. sub write_line { my $filename = shift; # File to write to. my $line = shift; # Line to write to the file. open FILE, ">$filename" or die "Cannot open $filename, stopped\n"; print FILE "$line\n"; close FILE; } sub check_version { my $filename = shift; my $directory = shift; my $hastag = shift; my $lastversion = shift; my $found_rcsid; # True if our rcsid was found in the file. my $rcsid; # The rcsid that was in the file. my $rcsid_info; # The expanded values of the rcsid. my $rname; # The file pathname, parsed from the rcsid. my $version; # The file version, parsed from the rcsid. # not present - either removed or let cvs deal with it. return 0 unless -f $filename; # Only check this file if it doesn't match an exclusion. my $exclude = $cvsroot . "/CVSROOT/exclude"; my $path = $directory . "/" . $filename; open(EX, "<$exclude") || die("cannot open $exclude: $!"); while () { chomp; my $ex_entry = $_; next if $ex_entry =~ /^#/; if ($path =~ /$ex_entry/) { close(EX); return(0); } } close(EX); # Search the file for our rcsid. # NOTE: We stop after finding the first potential match. open FILE, $filename or die "Cannot open $filename, stopped\n"; $found_rcsid = 0; while () { next unless /^.*(\$$HEADER.*)/; $rcsid = $1; $found_rcsid = 1; last; } close FILE; # The file should have had an rcsid in it! unless ($found_rcsid) { printf($NoId, $filename); return(1); } # Is the rcsid corrupt? unless ($rcsid =~ /\$$HEADER(: ([^\$]* )?)?\$/) { printf($BadId, $filename); return(1); } $rcsid_info = $2 || ""; ($rname, $version) = split /\s/, $rcsid_info; # Ignore version mismatches (MFC spamming etc) on branches. if ($hastag) { return (0); } # A new file should have an unexpanded rcsid. if ($lastversion eq '0') { unless ($rcsid_info eq "") { printf($NoName, $filename); return(1); } return(0); } # It's ok for the rcsid to be not expanded. if ($rcsid_info eq "") { return (0); # if ($directory =~ /^ports\//) { # return (0); # ok for ports # } # # Don't know whether to allow or trap this. It means # # one could bypass the version spam checks by simply # # using a bare tag. # printf($DelPath, $filename); # return(1); } # Check that the file name in the rcsid matches reality. if ($rname ne "$directory/$filename,v") { # If ports and the pathname is just the basename # (eg: somebody sent in a port with $Id$ and the # committer changed Id -> $HEADER and the version # numbers otherwise match. if (!($directory =~ /^ports\// && $rname eq "$filename,v")) { printf($BadName, "$directory/$filename,v", $rname); return(1); } } # Check that the version in the rcsid matches reality. if ($lastversion ne $version) { printf($BadVersion, $filename, $lastversion, $version, $filename); return(1); } return(0); } ############################################################# # # Main Body # ############################################################ #print("ARGV - ", join(":", @ARGV), "\n"); #print("id - ", $cfg::PID, "\n"); # # Suck in the Entries file # my %cvsversion; my %cvstag; open ENTRIES, $ENTRIES or die "Cannot open $ENTRIES.\n"; while () { chomp; next if /^D/; my ($filename, $ver, $stamp, $opt, $tag) = split '/', substr($_, 1); $cvsversion{$filename} = $ver; $cvstag{$filename} = $tag; $stamp = $opt; #silence -w } close ENTRIES; my $directory = $ARGV[0]; shift @ARGV; $directory =~ s,^$cvsroot[/]+,,; if ($directory =~ /^src/) { $check_id = 1; } if ($directory =~ /^ports/) { $check_id = 2; } if ($directory =~ /^src\/contrib/) { $check_id = 3; } if ($directory =~ /^src\/crypto/) { $check_id = 3; } if ($directory =~ /^src\/release/) { $check_id = 0; } if ($directory =~ /^src\/etc/) { $check_id = 0; } # # Now check each file name passed in, except for dot files. Dot files # are considered to be administrative files by this script. # if ($check_id != 0) { my $failed = 0; foreach my $arg (@ARGV) { my $hastag = ($cvstag{$arg} ne ''); next if (index($arg, ".") == 0); next if ($check_id == 2 && $arg ne "Makefile"); next if ($check_id == 3 && $hastag); $failed += &check_version($arg, $directory, $hastag, $cvsversion{$arg}); } if ($failed) { print "\n"; unlink($cfg::LAST_FILE); exit(1); } } # # Record this directory as the last one checked. This will be used # by the log_accumulate script to determine when it is processing # the final directory of a multi-directory commit. # &write_line($cfg::LAST_FILE, $directory); exit(0); over'>Commit message (Expand)AuthorAgeFilesLines * - Update to 2.4.7mnag2008-02-292-10/+10 * - Update to 2.4.6mnag2007-10-233-14/+14 * Remove leftover ifedwin2007-10-051-1/+0 * Remove support for OSVERSION < 5edwin2007-10-041-24/+11 * Allow dovecot and cyrus SASL to work together.delphij2007-08-301-6/+0 * - Update to 2.4.5mnag2007-08-012-8/+8 * - Update VDA patch to 2.4.3-vda-ngmnag2007-06-152-5/+5 * - Update to 2.4.3mnag2007-06-012-4/+4 * - Update to 2.4.1mnag2007-04-302-4/+4 * - Remove SASL1 support. security/cyrus-sasl will be removed soon.mnag2007-04-151-24/+3 * - Update VDA patch to 2.4.0mnag2007-04-062-6/+5 * * mail/postfixmnag2007-04-053-17/+19 * - Update to 2.3.8mnag2007-03-072-9/+8 * - Add mail to PROVIDE line. This fixes other scripts that require mailrafan2007-02-212-1/+2 * Addition of postfix_flags variable to rc.subr startup script.koitsu2007-02-211-2/+5 * - Update to 2.3.7rafan2007-02-012-4/+4 * - Update to 2.3.5mnag2006-12-132-4/+4 * - Remove SPF compatible options. Patch are removed in 20060719.mnag2006-11-291-1/+1 * - Update VDA patch to 2.3.4mnag2006-11-092-5/+5 * - Update to 2.3.4mnag2006-11-022-8/+8 * - Update to 2.3.3mnag2006-08-272-5/+4 * - Update VDA patch to 2.3.2mnag2006-08-132-4/+4 * Fix "typo" in previous commit.itetcu2006-08-021-1/+1 * Make rc.d start postfix later, like sendmail does.itetcu2006-08-021-1/+2 * - Update to 2.3.2mnag2006-07-312-8/+8 * - Update to 2.3.1mnag2006-07-252-4/+4 * - Spell fixes [1]mnag2006-07-202-4/+4 * * UPDATINGmnag2006-07-1910-332/+284 * - Update to use USE_BDB flagmnag2006-04-222-66/+8 * - VDA patch are rerolled. Minor changes in patch.mnag2006-04-191-3/+3 * - Update VDA patch to 2.2.10mnag2006-04-183-5/+6 * - Update to 2.2.10mnag2006-04-074-11/+20 * - Update to 2.2.9mnag2006-02-223-10/+9 * - Linker fix when use OPENSSL from portsmnag2006-01-253-5/+4 * Replace ugly "@unexec rmdir %D... 2>/dev/null || true" with @dirrmtryedwin2006-01-221-1/+1 * Modify rc.d script like example in Porters Handbook.mnag2006-01-171-11/+15 * Fix rc.d/postfix.sh restart adding pidfile and procnamemnag2006-01-132-1/+7 * Add rcNG script to start postfixmnag2006-01-134-27/+53 * Update to 2.2.8mnag2006-01-053-11/+9 * Update to 2.2.7mnag2005-12-132-4/+4 * Add MIT kerberos 5 optionmnag2005-12-011-1/+6 * Update to 2.2.6mnag2005-12-015-16/+22 * Add WITH_OPENLDAP_VER to reflect options menumnag2005-10-141-1/+4 * Proper link when use OPENSSL from ports.mnag2005-10-042-5/+5 * VDA bugfixmnag2005-09-291-2/+2 * Update PORTREVISION because libspf2 is movedvsevolod2005-09-126-164/+144 * - Add cdb map lookupsgarga2005-08-311-2/+9 * Fix outdated information regarding sendmail rc.conf variableslawrance2005-08-021-1/+4 * - Allow Marcus Grando to bypass maintainerpav2005-07-251-0/+1 * - Update to 2.2.5pav2005-07-232-4/+3 * - Update comment to match existing optionspav2005-07-221-1/+1 * - Fix build on FreeBSD 7pav2005-07-141-3/+5 * - Fix manpage links [1] [2]jylefort2005-07-073-15/+21 * - Update to 2.2.4.flz2005-06-232-4/+4 * - Add instructions for /etc/rc.conf that makebarner2005-05-201-3/+6 * Update the VDA patch to 2.2.3jylefort2005-05-113-4/+5 * Update to 2.2.3jylefort2005-05-032-3/+3 * - Update postfix to 2.2.2pav2005-04-064-8/+8 * - Update to 2.2.1pav2005-03-2012-569/+463 * - Update VDA patch to 2.1.5pav2005-02-182-4/+4 * postfix's optional postgres support doesn't work with the new Postgres portleeym2005-02-081-20/+3 * [PATCH] mail/postfix: Update to libspf2-2.1.5-5edwin2004-11-274-26/+6 * - Support SPF and TLS at the same timepav2004-11-152-1/+22 * - Fix build with SASLKRB5 optionpav2004-10-261-2/+2 * update mail/postfix to latestedwin2004-10-133-12/+12 * Make sure this patch applies correctly when PATCH_STRIP=-p1, as is thedes2004-09-041-2/+2 * Fix build on 6.0.des2004-08-312-0/+22 * - Add VDA (Virtual Delivery Agent) patchpav2004-08-222-1/+9 * Add a patch to optionnaly add libspf2mat2004-08-183-2/+21 * - Update to 2.1.4pav2004-07-143-4/+8 * - Update IPv6 patches to 2.1.3pav2004-06-252-11/+11 * - Update to 2.1.3pav2004-06-233-10/+10 * - Wordsmithing in commentpav2004-06-111-1/+1 * - Update IPv6 patches to 1.24pav2004-05-222-7/+7 * update mail/postfix to latest releaseedwin2004-05-142-3/+3 * - Update to 2.1.0pav2004-05-1214-283/+288 * - Update to 2.0.20pav2004-05-032-4/+5 * Use /usr/sbin/nologin instead of /sbin/nologin if it exists and isdes2004-04-131-4/+13 * - Kill trailing whitespacepav2004-04-021-2/+2 * - Add support for db42pav2004-03-301-10/+23 * - Update 2.0.19clement2004-03-232-3/+5 * s/USE_OPENLDAP_VER/WANT_OPENLDAP_VER/g in comments.ale2004-03-111-2/+2 * Use USE_MYSQL and USE_OPENLDAP.ale2004-03-111-21/+9 * Fix build with LDAP.osa2004-02-201-3/+3 * Update to latest released version. Update TLS/IPv6 patches to match.eik2004-01-313-9/+20 * Respect ${CC} flag.osa2003-12-311-1/+1 * Add the rc.conf pid-file specification line for startup.petef2003-12-211-0/+1 * - add CONFLICTSdinoex2003-10-141-0/+1 * Update to 2.0.16osa2003-10-023-10/+13 * Update postfix to latest release (mainly a Solaris bug workaround).osa2003-09-092-2/+2 * Update to 2.0.14 [1]osa2003-08-284-99/+99 * Fix plist at optional IPv6 configuration.kuriyama2003-08-172-1/+7 * Fix non-default dependency on openldap2[012] which is broken by splitting.kuriyama2003-08-151-3/+3 * One of the patch files for postfix was not PREFIX-clean. This makes iterwin2003-07-231-7/+7 * Included in this email is a patch to postfix which I need applied forerwin2003-07-101-1/+13 * Fix building with SASL2 case.osa2003-07-071-4/+1 * update mail/postfix: 2.0.12 --> 2.0.13daichi2003-07-023-17/+12 * Upgrade to 2.0.12.obraun2003-06-283-12/+12 * - Update postfix to 2.0.10 releasenaddy2003-06-023-4/+15 * * Upgrade to 2.0.9.obraun2003-05-133-21/+17 * update postfix to 2.0.7leeym2003-04-153-18/+34 * update postfix to 2.0.6leeym2003-03-113-4/+3 * Batch building of packages for postfix is failing due to PCRE issues.leeym2003-03-042-12/+19 * Spell `-ldes' as `-lcrypto'.nectar2003-03-031-3/+3 * Point dependencies on net/openldap to net/openldap12edwin2003-02-241-2/+2 * add PORTEPOCH=1, which was removed by maintainer in rev 1.67leeym2003-02-231-0/+1 * Add missing manpage.demon2003-02-231-2/+2 * update postfix to 2.0.4leeym2003-02-233-10/+9 * De-pkg-comment.knu2003-02-212-1/+1 * upgrade to version 2.0.2sada2003-01-195-19/+67 * Update to 2.0.0.2.petef2003-01-0917-115/+208 * Missed configure scripts in libpq version bump: chase lib version.seanc2003-01-051-2/+3 * upgrade to 1.1.12ijliao2003-01-0258-1074/+42 * Add hooks to preselect postfix optionsdwcjr2002-08-273-31/+47 * moving saslv1 includes files to make it easier to add saslv2ume2002-07-293-6/+6 * Update to 1.1.11dwcjr2002-06-205-10/+25 * Update to latestdwcjr2002-05-172-2/+2 * Update to 1.1.9dwcjr2002-05-153-12/+12 * Add PGSQL supportdwcjr2002-05-092-2/+13 * Add missing pkg-messagedwcjr2002-05-071-0/+24 * Update to 1.1.8dwcjr2002-05-074-26/+24 * handle batch buildsdwcjr2002-04-212-4/+4 * Update postfix to 1.1.7dwcjr2002-04-024-9/+20 * Add USE_SUBMAKE, where it might be necessary.sobomax2002-03-251-0/+2 * Update to 1.1.5dwcjr2002-03-194-6/+8 * Update postfix to 1.1.4dwcjr2002-02-273-6/+6 * Update to 1.1.3dwcjr2002-02-125-28/+40 * Add missing files to pkg-plistdwcjr2002-02-013-2/+18 * Update to 1.1.2 (yes they are finally using versions)dwcjr2002-01-3122-486/+411 * Use ${ECHO_CMD} instead of ${ECHO} where you mean the echo command;knu2002-01-291-9/+9 * Set context of diff for patch-aa to 2 lines to allow tls patchingdwcjr2002-01-181-51/+24 * Disable debugger by defaultnectar2002-01-151-19/+91 * Add header/body_check warnings commanddwcjr2001-11-272-0/+25 * Update to pl08 and tls to go with it.dwcjr2001-11-163-6/+6 * Update to pl07dwcjr2001-11-152-2/+2 * Update postfix to 20010228-pl06 and update tls to go with it.dwcjr2001-11-063-7/+6 * Fix path in patchdwcjr2001-10-111-1/+1 * Erase extra parts of install.cfdwcjr2001-09-241-4/+0 * Remove version tags from files that don't need it.dwcjr2001-09-242-2/+0 * Install install.cf to ensure spool is created with correct permissionsdwcjr2001-09-243-1/+18 * Update to pl05dwcjr2001-09-233-10/+9 * Fix path on main.cf in reference to prefixdwcjr2001-09-142-2/+2 * Correct the size of the dialog box so dialog(1) doesn't bug out and trashkris2001-08-201-2/+2 * Back out the db3 port update because some of these dependent ports hadknu2001-08-012-3/+3 * Reflect databases/db3's shlib version bump from 2 to 3.knu2001-07-252-2/+3 * Update to pl3 of postfixdwcjr2001-06-183-9/+9 * I'm taking over this port for Blaz since he can't dedicate time to itdwcjr2001-06-181-1/+1 * Update port to 20010228 pl02.kuriyama2001-05-214-30/+24 * update postfix to 20010228-pl01mharo2001-04-022-4/+3 * Revert previous commit.kuriyama2001-03-261-3/+3 * Link shared library for MySQL.kuriyama2001-03-241-3/+3 * Make spool directory at pkg-install.kuriyama2001-03-141-0/+1 * fix build options.sf2001-03-131-2/+2 * Disable IPv6 on Alpha, since this breaks it.alex2001-03-121-5/+20 * remove BROKEN for alpha, the unaligned access errors are a red herring.billf2001-03-111-4/+0 * Mark BROKEN for alpha: Unaligned access problems in postsuper and postlogalex2001-03-111-0/+4 * Fix the DB3 support. DB3's shlib version is now at 2.knu2001-03-061-2/+2 * use DIST_SUBDIR=postfix due to both release and snapshot don't havesf2001-03-052-3/+4 * update to NON BETA release, 20010228.sf2001-03-0549-354/+820 * Add -lz to be compiled with MySQL.kuriyama2001-02-171-1/+1 * add MASTER_SITE_RINGSERVER to MASTER_SITES.sf2001-02-061-1/+2 * Spaces->tabs in the mail category.olgeni2001-02-051-1/+1 * Switch from mysql322-{client,server} to mysql323-{client,server}.dirk2001-01-211-1/+1 * Unbreak use with rmail and bump PORTREVISION.dannyboy2000-12-233-40/+60 * Update to 19991231-pl13.dannyboy2000-12-234-4/+5 * Update to postfix 19991231-pl10. Install LDAP_README and MYSQL_README alongwill2000-11-1457-435/+1061 * Hand MAINTAINER to Blaz Zupan <blaz@amis.net>.will2000-11-081-1/+1 * Remove Torsten Blum by due effect of not being a maintainer - many reportswill2000-11-081-1/+1 * Change PKGDIR from pkg/ to . Also fix places where ${PKGDIR} isasami2000-10-081-2/+2 * Upgrade to 19991231pl8.vanilla2000-06-042-3/+3 * Upgrade the 19991231 release to patchlevel 07.obrien2000-06-022-3/+3 * If a user didn't have /usr/sbin in their path, this would have failed.billf2000-05-281-6/+6 * Standardize all user defined options to the booleans WITH_FOO andreg2000-04-171-2/+2 * Update to use PORTNAME/PORTVERSIONcpiazza2000-04-14