diff options
author | Norbert Preining <preining@logic.at> | 2009-07-01 05:15:09 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2009-07-01 05:15:09 +0000 |
commit | ae9ec747ab13e48ba02b4cc23893f0acdc430505 (patch) | |
tree | 64001286f666b001a696f5d58a0300d94a938665 | |
parent | 6435f0b267d4bc786b93e0f180edc13b39d56781 (diff) |
add tlcmp from tlpkg/bin/cmp_textfiles to TLUtils, use it instead of
the call to external diff in tlmgr check runfiles, do the runfile test
if tlmgr check all is done
git-svn-id: svn://tug.org/texlive/trunk@14045 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 9 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 46 |
2 files changed, 49 insertions, 6 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 979ac2c373b..8f9b43358af 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -73,7 +73,7 @@ use TeXLive::TLPOBJ; use TeXLive::TLUtils; use TeXLive::TLWinGoo; TeXLive::TLUtils->import(qw(member info give_ctan_mirror win32 dirname - mkdirhier copy log debug)); + mkdirhier copy log debug tlcmp)); use TeXLive::TLPaper; @@ -2483,7 +2483,7 @@ sub action_check { $ret ||= check_files($tltree); $ret ||= check_depends(); $ret ||= check_executes(); - # we do NOT automatically run the runfiles check when called with "all" + $ret ||= check_runfiles(); } elsif ($what =~ m/^files/i) { my $tltree = init_tltree($svn); $ret ||= check_files($tltree); @@ -2662,8 +2662,7 @@ sub check_runfiles { # if all copies are identical, ok, else, complain my $diff = 0; for (my $i = 1; $i < scalar(@copies); $i++) { - if ($diff = system ("diff -q --strip-trailing-cr " - . "$Master/$copies[$i-1] $Master/$copies[$i] >/dev/null")) { + if ($diff = tlcmp("$Master/$copies[$i-1]", "$Master/$copies[$i]")) { print "# $f\ndiff $Master/$copies[$i-1] $Master/$copies[$i]\n"; last; } @@ -3653,8 +3652,6 @@ Live Database are present. =item B<runfiles> List those filenames that are occurring more than one time in the runfiles. -This test needs the C<diff> utility and so is not executed when C<check> -is called without or with the C<all> argument. =back diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 9b436d00175..34e9788bb88 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -48,6 +48,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure TeXLive::TLUtils::removed_dirs(@files); TeXLive::TLUtils::download_file($path, $destination [, $progs ]); TeXLive::TLUtils::setup_programs($bindir, $platform); + TeXLive::TLUtils::tlcmp($file, $file); =head2 Installer Functions @@ -123,6 +124,7 @@ BEGIN { &xsystem &run_cmd &announce_execute_actions + &tlcmp ); @EXPORT = qw(setup_programs download_file process_logging_options tldie tlwarn info log debug ddebug dddebug debug_hash @@ -1723,6 +1725,50 @@ sub untar { } +=item C<tlcmp($file, $file)> + +Compare two files considering CR, LF, and CRLF as equivalent. +Returns 1 if different, 0 if the same. + +=cut + +sub tlcmp +{ + my ($filea, $fileb) = @_; + if (!defined($fileb)) { + die <<END_USAGE; +tlcmp needs two arguments FILE1 FILE2. +Compare as text files, ignoring line endings. +Exit status is zero if the same, 1 if different, something else if trouble. +END_USAGE + } + my $file1 = &read_file_ignore_cr ($filea); + my $file2 = &read_file_ignore_cr ($fileb); + + return $file1 eq $file2 ? 0 : 1; +} + + +# Return contents of FNAME as a string, converting all of CR, LF, and +# CRLF to just LF. +# +sub read_file_ignore_cr +{ + my ($fname) = @_; + my $ret = ""; + + local *FILE; + open (FILE, $fname) || die "open($fname) failed: $!"; + while (<FILE>) { + s/\r\n?/\n/g; + #warn "line is |$_|"; + $ret .= $_; + } + close (FILE) || warn "close($fname) failed: $!"; + + return $ret; +} + =item C<setup_programs($bindir, $platform)> |