From b4bd155553e61ae082569f8d671a9f740d044634 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 16 May 2016 00:33:33 +0000 Subject: tmp file rewrite use one global tmp dir created with File::Temp and which will be auto-removed. ALl other temp files and dirs are created within this directory. git-svn-id: svn://tug.org/texlive/trunk@41175 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLPOBJ.pm | 2 +- Master/tlpkg/TeXLive/TLUtils.pm | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'Master/tlpkg/TeXLive') diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm index e569b15455c..e4c260e31d5 100644 --- a/Master/tlpkg/TeXLive/TLPOBJ.pm +++ b/Master/tlpkg/TeXLive/TLPOBJ.pm @@ -625,7 +625,7 @@ sub make_container { my $tartempfile = ""; if (win32()) { # Since we provide our own (GNU) tar on Windows, we know it has -T. - my $tmpdir = TeXLive::TLUtils::get_system_tmpdir(); + my $tmpdir = TeXLive::TLUtils::tl_tmpdir(); $tartempfile = "$tmpdir/mc$$"; open(TMP, ">$tartempfile") || die "open(>$tartempfile) failed: $!"; print TMP map { "$_\n" } @files_to_backup; diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 588536d05db..4b3ea16117d 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -32,7 +32,7 @@ C -- utilities used in TeX Live infrastructure TeXLive::TLUtils::getenv($string); TeXLive::TLUtils::which($string); - TeXLive::TLUtils::get_system_tmpdir(); + TeXLive::TLUtils::initialize_global_tmpdir(); TeXLive::TLUtils::tl_tmpdir(); TeXLive::TLUtils::tl_tmpfile(); TeXLive::TLUtils::xchdir($dir); @@ -125,7 +125,7 @@ BEGIN { &unix &getenv &which - &get_system_tmpdir + &initialize_global_tmpdir &dirname &basename &dirname_and_basename @@ -456,20 +456,17 @@ sub which { return 0; } -=item C +=item C -Evaluate the environment variables C, C, and C in -order to find the system temporary directory. +Initializes a directory for all temporary files. This uses C +and thus honors various env variables like C, C, and C. =cut -sub get_system_tmpdir { - my $systmp=0; - $systmp||=getenv 'TMPDIR'; - $systmp||=getenv 'TMP'; - $systmp||=getenv 'TEMP'; - $systmp||='/tmp'; - return "$systmp"; +sub initialize_global_tmpdir { + $::tl_tmpdir = File::Temp::tempdir(CLEANUP => 1); + debug("tl_tempdir: creating global tempdir $::tl_tmpdir\n"); + return ($::tl_tmpdir); } =item C @@ -480,7 +477,8 @@ is terminated. =cut sub tl_tmpdir { - my $tmp = File::Temp::tempdir(CLEANUP => 1); + initialize_global_tmpdir() if (!defined($::tl_tmpdir)); + my $tmp = File::Temp::tempdir(DIR => $::tl_tmpdir, CLEANUP => 1); debug("tl_tempdir: creating tempdir $tmp\n"); return ($tmp); } @@ -494,7 +492,8 @@ Arguments are passed on to C. =cut sub tl_tmpfile { - my ($fh, $fn) = File::Temp::tempfile(@_, UNLINK => 1); + initialize_global_tmpdir() if (!defined($::tl_tmpdir)); + my ($fh, $fn) = File::Temp::tempfile(@_, DIR => $::tl_tmpdir, UNLINK => 1); debug("tl_tempfile: creating tempfile $fn\n"); return ($fh, $fn); } -- cgit v1.2.3