--- loncom/build/filecompare.pl 2004/07/02 22:04:50 1.14 +++ loncom/build/filecompare.pl 2014/06/09 05:14:12 1.15 @@ -3,7 +3,7 @@ # The LearningOnline Network with CAPA # filecompare.pl - script used to help probe and compare file statistics # -# $Id: filecompare.pl,v 1.14 2004/07/02 22:04:50 albertel Exp $ +# $Id: filecompare.pl,v 1.15 2014/06/09 05:14:12 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -77,6 +77,8 @@ Options (before file/dir names): N=2: same as N=1 except without md5sum N=3: md5sum=same --> 1; age<0 --> 2 N=4: cvstime>0 --> 2 + N=5: md5sum=same --> 1; cvstime<0 and sha1sum from dns_checksums=different --> 2; + N=6: md5sum=same --> 1; age<0 and sha1sum from dns_checksums=different --> 2; The third way to pass arguments is set by the -s flag. filecompare.pl -s SOURCE=[source] TARGET=[target] MODE=[mode] LOC1 LOC2 @@ -103,6 +105,7 @@ unless (@ARGV) { # size similarity (bytes) # line count difference # number of different lines +# sha1sum similarity to checksum for same file in installed version # # Quantities of comparison: # existence (no,yes); other values become 'n/a' @@ -112,10 +115,11 @@ unless (@ARGV) { # size similarity (byte difference) # line count difference (integer) # number of different lines (integer) +# sha1sum ("same" or "different") # ---------------------------------------------------------------- Dependencies # implementing from unix command line (assuming bash) -# md5sum, diff, wc -l +# md5sum, diff, wc -l, sha1sum # ---------------------------------------------- Process command line arguments # Flags (before file/dir names): @@ -240,6 +244,7 @@ my %OUTPUT=( 'size'=>(sub {print 'size: '.@_[0];return;}), 'lines'=>(sub {print 'lines: '.@_[0];return;}), 'diffs'=>(sub {print 'diffs: '.@_[0];return;}), + 'sha1sum'=>(sub {print 'sha1sum: '.@_[0];return;}), ); my %MEASURE=( @@ -275,6 +280,31 @@ my %MEASURE=( my $rv2=`diff $file1 $file2 | grep '^>' | wc -l`; chop $rv2; $rv2=~s/^\s+//; $rv2=~s/\s+$//; return ($rv1,$rv2); } ), + 'sha1sum'=>( sub { my ($file1,$file2)=@_; + if (open(my $fh,"; + close($fh); + chomp($loncaparev); + $loncaparev =~ s/^\QLON-CAPA release \E//; + $loncaparev =~ s/\-\d{8}$//; + my ($rv1)=split(/ /,`sha1sum $file2`); chomp $rv1; + my $checksum; + if ($loncaparev eq 'CVS_HEAD') { + return ($rv1,$checksum); + } + elsif (open(my $fh,"<../../loncom/dns_checksums/$loncaparev.tab")) { + while (<$fh>) { + chomp(); + if (/^\Q$file2\E,[\d\.]+,(\w+)$/) { + $checksum = $1; + last; + } + } + close($fh); + return ($rv1,$checksum); + } + } + return('n/a','n/a'); }), ); FLOOP: foreach my $file (@files) { @@ -290,7 +320,7 @@ FLOOP: foreach my $file (@files) { } my ($existence1,$existence2)=&{$MEASURE{'existence'}}($file1,$file2); my $existence=$existence1.':'.$existence2; - my ($cvstime,$md5sum,$age,$size,$lines,$diffs); + my ($cvstime,$md5sum,$age,$size,$lines,$diffs,$sha1sum); if ($existence1 eq 'no' or $existence2 eq 'no') { $md5sum='n/a'; $age='n/a'; @@ -298,14 +328,28 @@ FLOOP: foreach my $file (@files) { $size='n/a'; $lines='n/a'; $diffs='n/a'; + $sha1sum='n/a'; } else { if ($buildmode) { my ($cvstime1,$cvstime2)=&{$MEASURE{'cvstime'}}($file1,$file2); $cvstime=$cvstime1-$cvstime2; - } + my ($sha1sumfile,$checksum) = &{$MEASURE{'sha1sum'}}($file1,$file2); + $sha1sum='n/a'; + unless ($checksum eq 'n/a') { + if ($sha1sumfile && $checksum) { + if ($sha1sumfile eq $checksum) { + $sha1sum='same'; + } + else { + $sha1sum='different'; + } + } + } + } else { $cvstime='n/a'; + $sha1sum='n/a'; } my ($age1,$age2)=&{$MEASURE{'age'}}($file1,$file2); $age=$age1-$age2; @@ -468,6 +512,39 @@ FLOOP: foreach my $file (@files) { exit(0); } } + elsif ($buildmode==5) { # -b5 + if ($md5sum eq 'same') { + exit(1); + } + elsif ($cvstime<0) { + if ($sha1sum eq 'same') { + exit(0); + } + else { + exit(2); + } + } + else { + exit(0); + } + } + elsif ($buildmode==6) { # -b6 + if ($md5sum eq 'same') { + exit(1); + } + elsif ($age<0) { + if ($sha1sum eq 'same') { + exit(0); + } + else { + exit(2); + } + } + else { + exit(0); + } + } + if ($showflag) { print "$file"; if ($verbose==1) { @@ -479,12 +556,15 @@ FLOOP: foreach my $file (@files) { print &{$OUTPUT{'age'}}($age); print "\t"; print &{$OUTPUT{'md5sum'}}($md5sum); + print "\t"; + print &{$OUTPUT{'sha1sum'}}($sha1sum); print "\t"; print &{$OUTPUT{'size'}}($size); print "\t"; print &{$OUTPUT{'lines'}}($lines); print "\t"; print &{$OUTPUT{'diffs'}}($diffs); + } print "\n"; } 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.