[system] / trunk / webwork2 / bin / ww-update-config Repository:
ViewVC logotype

Annotation of /trunk/webwork2/bin/ww-update-config

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4204 - (view) (download)

1 : sh002i 4130 #!/usr/bin/perl
2 :    
3 :     use strict;
4 :     use warnings;
5 :    
6 : sh002i 4203 my $cvs_header_line = '\$' . 'CVSHeader';
7 :    
8 : sh002i 4130 foreach my $arg (@ARGV) {
9 :     my ($conf_file, $dist_file);
10 :    
11 :     if ($arg =~ /^(.*)\.dist$/) {
12 :     $conf_file = $1;
13 :     $dist_file = $arg;
14 :     } else {
15 :     $conf_file = $arg;
16 :     $dist_file = "$arg.dist";
17 :     }
18 :    
19 :     my $conf_version = cvs_version($conf_file)
20 :     or die "couldn't find CVS version in $conf_file\n";
21 :     my $dist_version = cvs_version($dist_file)
22 :     or die "couldn't find CVS version in $dist_file\n";
23 :    
24 :     if ($conf_version eq $dist_version) {
25 :     print "$conf_file is up-to-date at version $conf_version.\n";
26 :     next;
27 :     }
28 :    
29 : sh002i 4204 #print "conf_version=$conf_version dist_version=$dist_version\n";
30 :     system "cvs diff -r '$conf_version' -r '$dist_version' '$dist_file'"
31 :     . "| patch '$conf_file'";
32 : sh002i 4130 }
33 :    
34 :     sub cvs_version {
35 :     my ($file) = @_;
36 :     open my $fh, "<", $file or die "couldn't open $file for reading: $!\n";
37 :     my $line;
38 :     while (my $line = <$fh>) {
39 : sh002i 4203 if ($line =~ /$cvs_header_line.*?(1(?:\.\d+)+)/) {
40 : sh002i 4130 return $1;
41 :     }
42 :     }
43 :     }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9