summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/fmtutil.pl31
1 files changed, 26 insertions, 5 deletions
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;
}