1 |
robbat2 08/12/03 04:23:28 |
2 |
|
3 |
Modified: checkoutlist |
4 |
Added: cvslogholder.pl |
5 |
Log: |
6 |
Add new script for better loginfo handling. |
7 |
|
8 |
Revision Changes Path |
9 |
1.13 checkoutlist |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/CVSROOT/checkoutlist?rev=1.13&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/CVSROOT/checkoutlist?rev=1.13&content-type=text/plain |
13 |
diff : http://sources.gentoo.org/viewcvs.py/CVSROOT/checkoutlist?r1=1.12&r2=1.13 |
14 |
|
15 |
Index: checkoutlist |
16 |
=================================================================== |
17 |
RCS file: /var/cvsroot/CVSROOT/checkoutlist,v |
18 |
retrieving revision 1.12 |
19 |
retrieving revision 1.13 |
20 |
diff -p -w -b -B -u -u -r1.12 -r1.13 |
21 |
--- checkoutlist 17 Sep 2008 21:30:55 -0000 1.12 |
22 |
+++ checkoutlist 3 Dec 2008 04:23:28 -0000 1.13 |
23 |
@@ -24,3 +24,4 @@ commitlog-infra.pl |
24 |
commitlog-portage.pl |
25 |
readers |
26 |
val-tags |
27 |
+cvslogholder.pl |
28 |
|
29 |
|
30 |
|
31 |
1.1 cvslogholder.pl |
32 |
|
33 |
file : http://sources.gentoo.org/viewcvs.py/CVSROOT/cvslogholder.pl?rev=1.1&view=markup |
34 |
plain: http://sources.gentoo.org/viewcvs.py/CVSROOT/cvslogholder.pl?rev=1.1&content-type=text/plain |
35 |
|
36 |
Index: cvslogholder.pl |
37 |
=================================================================== |
38 |
#!/usr/bin/perl |
39 |
# This script provides temporary capture and replay of loginfo stdin, so that |
40 |
# we can run multiple processing scripts. |
41 |
# robbat2@g.o, 2008/12/02 |
42 |
# |
43 |
# Example use: |
44 |
# ALL ( cvslogholder.pl --capture %c %r %p %{sVv} ; \ |
45 |
# cvslogholder.pl --display %c %r %p %{sVv} | script1 ; \ |
46 |
# cvslogholder.pl --display %c %r %p %{sVv} | script2 ; \ |
47 |
# cvslogholder.pl --cleanup %c %r %p %{sVv} ) |
48 |
use strict; |
49 |
use warnings; |
50 |
use Digest::SHA1 qw(sha1_hex); |
51 |
use Getopt::Long; |
52 |
|
53 |
my $LOGDIR = '/mnt/cvstmpdir/'; |
54 |
my $USER = $ENV{'USER'}; |
55 |
|
56 |
my $CMD_CAPTURE = 0; |
57 |
my $CMD_DISPLAY = 0; |
58 |
my $CMD_CLEANUP = 0; |
59 |
my $CMD_HELP = 0; |
60 |
|
61 |
my $result = GetOptions( |
62 |
"capture" => \$CMD_CAPTURE, |
63 |
"display" => \$CMD_DISPLAY, |
64 |
"cleanup" => \$CMD_CLEANUP, |
65 |
); |
66 |
|
67 |
unless($CMD_CAPTURE + $CMD_DISPLAY + $CMD_CLEANUP == 1 and @ARGV > 0) { |
68 |
print STDERR "You must specify exactly one mode and arguments.\n"; |
69 |
exit(1); |
70 |
} |
71 |
|
72 |
my $args = (join(' ', (map { sprintf( "'%s'",$_); } @ARGV))); |
73 |
#printf "args: %s\n", $args; |
74 |
my $argchecksum = sha1_hex($args); |
75 |
#printf "argchecksum: %s\n", $argchecksum; |
76 |
|
77 |
my $basename = sprintf("%s/cvslog-%s-%s",$LOGDIR, $USER, $argchecksum); |
78 |
#printf "basename: $basename"; |
79 |
|
80 |
my $argfile = $basename.".args"; |
81 |
my $logfile = $basename.".log"; |
82 |
|
83 |
if($CMD_CAPTURE == 1) { |
84 |
if(-f $argfile) { |
85 |
print STDERR "argfile $argfile already exists. Serious error!\n"; |
86 |
exit(2); |
87 |
} |
88 |
|
89 |
if(-f $logfile) { |
90 |
print STDERR "logfile $logfile already exists. Serious error!\n"; |
91 |
exit(2); |
92 |
} |
93 |
|
94 |
open ARGFILE,">", $argfile or die "Unable to create $argfile."; |
95 |
print ARGFILE join('',map { sprintf("%s\n", $_); } @ARGV); |
96 |
close ARGFILE; |
97 |
|
98 |
|
99 |
open LOGFILE,">", $logfile or die "Unable to create $logfile."; |
100 |
while(<STDIN>) { |
101 |
print LOGFILE $_; |
102 |
} |
103 |
close LOGFILE; |
104 |
} elsif($CMD_DISPLAY) { |
105 |
open LOGFILE,"<", $logfile or die "Unable to find $logfile"; |
106 |
while(<LOGFILE>) { |
107 |
print $_; |
108 |
} |
109 |
close LOGFILE; |
110 |
} elsif($CMD_CLEANUP) { |
111 |
unlink $logfile; |
112 |
unlink $argfile; |
113 |
} |