diff options
author | Karl Berry <karl@freefriends.org> | 2012-05-21 23:58:58 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-05-21 23:58:58 +0000 |
commit | a7b8fe1003c960fbd27086146bb341a6ddae788a (patch) | |
tree | ed903293e66d4470669962e1d77abfb05dc561e2 /Master/texmf-dist/doc/latex/mycv/checksum.pl | |
parent | eec1bcc6efce237f93a0615bee7089ba973beedc (diff) |
mycv (21may12)
git-svn-id: svn://tug.org/texlive/trunk@26558 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/mycv/checksum.pl')
-rw-r--r-- | Master/texmf-dist/doc/latex/mycv/checksum.pl | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/mycv/checksum.pl b/Master/texmf-dist/doc/latex/mycv/checksum.pl new file mode 100644 index 00000000000..ffd87e310e6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/mycv/checksum.pl @@ -0,0 +1,78 @@ +#!/usr/bin/perl + +# $Id: checksum.pl 91 2012-05-20 19:28:13Z ghangenit $ + +use Term::ANSIColor; +use warnings; +use strict; + +## +## Variables +## + +my $checksumregex = "[a-fA-F0-9]{32}"; +my %checksums = ( + SRCCHECKSUM => "mycv.dtx 8AACA8304D7F1F21480FDD12D7F53EC1", + EXPCHECKSUM => "Examples/mycv-examples.dtx A745EADAE2358B66C6BFC3F55F3EA793", + DOCCHECKSUM => "Doc/mycv.tex 83ECEA99562FE163FDF735FFC582AE3B" +); + +my @externalcmds = ( 'pdftex', 'latexmk' ); + +## +## Functions +## + +sub exitWithError($$) +{ + my $stasus=shift; + my $cmd=shift; + + printf STDERR ("Error: command <%s> exited with value %d.\n", $cmd, $stasus >> 8); + exit $stasus; +} + +sub checksum() +{ + # 'keys' returns the list of keys in an apparently random order + for my $key ( keys %checksums ) + { + my ($filename, $expectedmd5) = split " ", $checksums{$key}; + + print "\n------------------------------------------------------------\n"; + print "<$filename>:\n<$expectedmd5> is the expected checksum.\n"; + + # gets some info among which the checksum of the file '$filename' + my @result = `$externalcmds[0] "\\message{\\pdfmdfivesum file{$filename}}\\end"`; + exitWithError( $?, $externalcmds[0] ) if ( $? != 0 ); + + foreach my $info (@result) + { + if ( $info =~ /($checksumregex)/ ) # the checksum info + { + chomp($info); + print "<$info> is the found checksum."; + if ( $info eq $expectedmd5 ) + { + print color 'bold green'; + print "\n[OK, they match!]\n"; print color 'reset'; + } + else + { + print color 'bold red'; + print "\n[OOPS, they do not match!]\n"; print color 'reset'; + } + } + } + print "------------------------------------------------------------\n"; + } + + `$externalcmds[1] -c texput.log 2>&1`; # removes the log file produced by 'pdftex' + exitWithError( $?, $externalcmds[1] ) if ( $? != 0 ); +} + +## +## Main +## + +checksum();
\ No newline at end of file |