2 $ID = q(cvsprep,v 1.6 2004/06/12 02:07:09 eagle Exp );
4 # cvsprep -- Prep a multi-directory commit.
6 # Written by Russ Allbery <rra@stanford.edu>
7 # Copyright 2001, 2002, 2003, 2004
8 # Board of Trustees, Leland Stanford Jr. University
10 # This program is free software; you can redistribute it and/or modify it
11 # under the same terms as Perl itself.
13 use Getopt::Long qw(GetOptions);
16 Getopt::Long::config ('require_order');
17 GetOptions ('help|h' => \$help, 'version|v' => \$version) or exit 1;
19 print "Feeding myself to perldoc, please wait....\n";
20 exec ('perldoc', '-t', $0);
22 my @version = split (' ', $ID);
23 shift @version if $ID =~ /^\$Id/;
24 my $version = join (' ', @version[0..2]);
26 $version =~ s/(\S+)$/($1)/;
32 my $directory = shift;
33 die "$0: CVS didn't provide a directory\n" unless $directory;
34 my $tmp = $ENV{TMPDIR} || '/tmp';
35 $tmp .= '/cvs.' . $< . '.' . getpgrp;
36 if (!mkdir ($tmp, 0700)) {
37 if (-l $tmp || !-d _ || (lstat _)[4] != $<) {
38 die "$0: can't create $tmp: $!\n";
41 open (LOG, "> $tmp/directory") or die "$0: can't create $tmp/directory: $!\n";
42 print LOG "$directory\n";
49 cvsprep - Prep for a multi-directory CVS commit
57 This program is designed to run from CVS's F<commitinfo> administrative file
58 and make a note of the last directorie involved in the commit. It is used to
59 support merging of multi-directory CVS commits into a single notification by
60 B<cvslog> (B<cvslog> knows to stop merging commits when it sees the
61 notification for the final directory recorded by B<cvsprep>).
63 It should be run from F<commitinfo> with something like:
65 DEFAULT $CVSROOT/CVSROOT/cvsprep
67 If you are using CVS version 1.12.6 or later, the format strings for
68 F<commitinfo> rules have changed. This line should instead be:
70 DEFAULT $CVSROOT/CVSROOT/cvsprep -- %r/%p
72 once you've set UseNewInfoFmtStrings=yes in F<config>.
74 The directory in which the commit is occurring is saved in a file named
75 F<directory> in a directory in TMPDIR named cvs.<uid>.<group>, where <uid> is
76 the UID of the committing user and <group> is the process group of the commit
77 process. If TMPDIR is not used, F</tmp> is used as the parent directory.
79 For details on how to install this program as part of a B<cvslog>
80 installation, see cvslog(1).
86 =item B<-h>, B<--help>
88 Print out this documentation (which is done simply by feeding the script to
91 =item B<-v>, B<--version>
93 Print out the version of B<cvsprep> and exit.
97 =item can't create %s: %s
99 (Fatal) B<cvsprep> was unable to create either the directory or the file in
100 that directory needed to pass information to B<cvslog>, or the directory
101 already exists and is owned by someone other than the current user. The
102 directory for this commit won't be recorded, and B<cvslog> will therefore not
103 merge this multi-directory commit.
105 =item CVS didn't provide a directory
107 (Fatal) No directory was given on the B<cvsprep> command line. If run out of
108 F<commitinfo> as described above, CVS should pass the name of the directory in
109 which the commit is happening as the first argument to B<cvsprep>.
117 =item TMPDIR/cvs.%d.%d/directory
119 B<cvslog> expects this file to contain the name of the final directory
120 affected by a multidirectory commit. B<cvsprep> creates the parent directory
121 and stores its first argument in this file.
123 The first %d is the numeric UID of the user running B<cvslog>. The second %d
124 is the process group B<cvslog> is part of. The process group is included in
125 the directory name so that if you're running a shell that calls setpgrp() (any
126 modern shell with job control should), multiple commits won't collide with
127 each other even when done from the same shell.
129 If TMPDIR isn't set in the environment, F</tmp> is used for TMPDIR.
139 If set, specifies the temporary directory to use instead of F</tmp> for
140 storing information about multidirectory commits. Setting this to some
141 private directory is recommended if you're doing CVS commits on a multiuser
142 machine with other untrusted users due to the standard troubles with safely
143 creating files in F</tmp>. (Note that other programs besides B<cvslog> also
150 B<cvsprep> inherently creates directories in TMPDIR (F</tmp> by default) with
151 very predictable names. It creates directories rather than files because this
152 should be less risky, but this is still something of a security risk. Because
153 of this, I highly recommend that you set TMPDIR to some other directory that
154 only you have write access to, such as a subdirectory of your home directory.
156 For more warnings, see cvslog(1).
160 This process of noting the final directory of a commit so that B<cvslog> knows
161 when to stop merging is a horrible hack. There's just no better way to do it
162 given how CVS handles commit notification, which is completely undocumented
169 Current versions of this program are available from the cvslog web site at
170 L<http://www.eyrie.org/~eagle/software/cvslog/>. B<cvslog> is available from
175 Russ Allbery <rra@stanford.edu>.
177 =head1 COPYRIGHT AND LICENSE
179 Copyright 2001, 2002, 2003, 2004 Board of Trustees, Leland Stanford Jr.
182 This program is free software; you can redistribute it and/or modify it under
183 the same terms as Perl itself.