#!/usr/bin/env perl # $Id$ # Copyright 2008 TeX Users Group. # This file is licensed under the GNU General Public License version 2 # or any later version. # # Check that the same set of files are wrappers on w32 and symlinks on # all others. BEGIN { $^W = 1; ($mydir = $0) =~ s,/[^/]*$,,; unshift (@INC, "$mydir/.."); } use Getopt::Long; use Pod::Usage; our $mydir; my $help = 0; GetOptions("help|?" => \$help) or pod2usage(1); pod2usage(-exitstatus => 0, -verbose => 2) if $help; exit (&main ()); sub main { my $err = 0; chomp (my $Master = `cd $mydir/../.. && pwd`); my $bindir = "$Master/bin"; chdir ($bindir) || die "chdir($bindir) failed: $!"; my %w = &unx_wrapper_entries ("i386-linux"); # add some additional wrappers which are not found # automatically since they are not .. symlinks on Unix. $w{'fmtutil-sys'} = 1; $w{'getnonfreefonts-sys'} = 1; $w{'updmap'} = 1; $w{'updmap-sys'} = 1; my $srcdir = "$Master/../Build/source/texk/texlive"; $cww = "$srcdir/tl-w32-starter.bat"; $err += &check_w32 ("win32", $cww, %w); # one more, the wrapper itself. $err += system ("cmp win32/tl-w32-wrapper.texlua" . " $srcdir/tl-w32-wrapper.texlua"); return $err; } # return all symlinks starting with ".." in DIR as a hash, with symlink # targets as the values. Check that targets are executable. # sub unx_wrapper_entries { my ($DIR) = @_; my %ret; chomp (my $olddir = `pwd`); chdir ($DIR) || die "chdir($DIR) failed: $!"; local *DIR; opendir (DIR, ".") || die "opendir($DIR) failed: $!"; while (my $ent = readdir (DIR)) { next unless -l $ent; # skip all but symlinks my $target = readlink ($ent); die "readlink($ent) failed: $!" if !defined ($target); next unless $target =~ /^\.\./; # skip all but .. symlinks # the target of the symlink should be executable. warn "$ent: target $target not executable\n" if ! -x $target; $ret{$ent} = $target; # remember name and link target } closedir (DIR) || warn "closedir($DIR) failed: $!"; chdir ($olddir) || die "chdir($olddir) failed: $!"; return %ret; } # windows is special, as usual. given the list of wrappers in UW, check # that each of those entries exists in W32DIR and is a copy of the # canonical w32 wrapper specified in W32CANONICAL. # sub check_w32 { my ($w32dir, $w32canonical, %uw) = @_; my $diff = 0; for my $k (sort keys %uw) { #print "$k -> $uw{$k}\n"; my $target = $uw{$k}; next if $k eq "context"; # has its own .cmd file next if $target =~ /dviasm|ebong/; # no .bat for python next if $target =~ /ps4pdf/; # has its own .bat next if $target =~ /simpdftex/; # shell script next if $target =~ /tex4ht/; # tex4ht has its own .bat's $diff += system ("cmp $w32dir/$k.bat $w32canonical"); } return $diff; }