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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4204 - (download) (annotate)
Sat Jul 8 14:42:47 2006 UTC (6 years, 11 months ago) by sh002i
File size: 986 byte(s)
uncomment code

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 my $cvs_header_line = '\$' . 'CVSHeader';
    7 
    8 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 	#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 }
   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 		if ($line =~ /$cvs_header_line.*?(1(?:\.\d+)+)/) {
   40 			return $1;
   41 		}
   42 	}
   43 }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9