From 866e20ec51e8a08587a65d7527483733718f636e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 23 May 2015 16:52:36 +0000 Subject: (callback_build_formats): make our own $tmpdir on Windows, instead of using File::Temp. Report from Stephan Hennig, 21 May 2015 23:10:08. From Norbert. git-svn-id: svn://tug.org/texlive/trunk@37485 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texlive/fmtutil.pl | 31 +++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/scripts/texlive/fmtutil.pl b/Master/texmf-dist/scripts/texlive/fmtutil.pl index dbcb0fefb13..cca5f221bdc 100755 --- a/Master/texmf-dist/scripts/texlive/fmtutil.pl +++ b/Master/texmf-dist/scripts/texlive/fmtutil.pl @@ -9,7 +9,6 @@ # # History: # Original shell script (C) 2001 Thomas Esser, public domain -# my $TEXMFROOT; @@ -285,8 +284,27 @@ sub callback_build_formats { my $notavail = 0; # # set up a tmp dir - my $tmpdir = File::Temp::tempdir(CLEANUP => 1); - #my $tmpdir = File::Temp::tempdir(); + # On W32 it seems that File::Temp creates restrictive permissions (ok) + # that are copied over with the files created inside it (not ok). + # So make our own temp dir. + my $tmpdir; + if (win32()) { + my $foo; + for my $i (1..5) { + $foo = "$texmfvar/temp.$$." . int(rand(1000000)); + if (! -d $foo) { + if (mkdir($foo)) { + $tmpdir = $foo; + last; + } + } + } + if (! $tmpdir) { + die "Cannot get a temporary directory after five iterations ... sorry!"; + } + } else { + $tmpdir = File::Temp::tempdir(CLEANUP => 1); + } # set up destination directory $opts{'fmtdir'} || ( $opts{'fmtdir'} = "$texmfvar/web2c" ) ; TeXLive::TLUtils::mkdirhier($opts{'fmtdir'}) if (! -d $opts{'fmtdir'}); @@ -295,12 +313,11 @@ sub callback_build_formats { exit (1); } # since the directory does not exist, we can make it absolute with abs_path - # without andy trickery around non-existing dirs + # without any trickery around non-existing dirs $opts{'fmtdir'} = Cwd::abs_path($opts{'fmtdir'}); # for safety, check again die ("abs_path didn't succeed, that is strange: $?") if !$opts{'fmtdir'}; - # # code taken over from the original shell script for KPSE_DOT etc my $thisdir = cwd(); $ENV{'KPSE_DOT'} = $thisdir; @@ -356,6 +373,10 @@ sub callback_build_formats { print_info("Not available formats: $notavail\n") if ($notavail); print_info("Failure during builds: $err\n") if ($err); chdir($thisdir) || warn("chdir($thisdir) failed: $!"); + if (win32()) { + # try to remove the tmpdir with all files + TeXLive::TLUtils::rmtree($tmpdir); + } return 0; } -- cgit v1.2.3