summaryrefslogtreecommitdiff
path: root/Tools/scripts/mkptools/mkpinstall
diff options
context:
space:
mode:
authorPeter Pentchev <roam@FreeBSD.org>2001-02-22 14:51:44 +0000
committerPeter Pentchev <roam@FreeBSD.org>2001-02-22 14:51:44 +0000
commitfe8a84044613ac9b4f2a6483c8446f27d8c463fc (patch)
tree15f217a096f0765160c5ce4e18a130781595ab7e /Tools/scripts/mkptools/mkpinstall
parentupdate to 0.5.13 (diff)
Do not hardcode /tmp as a temp directory base, try $TMPDIR, $TMP and
the system temp dir as given by paths.h (paths.ph) in this order. Approved by: nbm Perl-fu by: des, Tony Finch <dot@dotat.at>
Diffstat (limited to '')
-rwxr-xr-xTools/scripts/mkptools/mkpinstall23
1 files changed, 21 insertions, 2 deletions
diff --git a/Tools/scripts/mkptools/mkpinstall b/Tools/scripts/mkptools/mkpinstall
index 13f9947ac0eb..c97e5ed2ae94 100755
--- a/Tools/scripts/mkptools/mkpinstall
+++ b/Tools/scripts/mkptools/mkpinstall
@@ -26,12 +26,31 @@
#
use strict;
+my $path_tmp = "/tmp";
+eval {
+ require 'paths.ph';
+ $path_tmp = &_PATH_TMP;
+};
-my ($user, $origdir, $portname, $tmpdir, $wdpdir, $predir, $hmake);
+
+sub testdir (@) {
+ my $d; # currently tested dir
+
+ foreach $d (@_) {
+ next unless defined($d);
+ $d =~ s,/$,,;
+ return $d if ((-d $d) && (-w $d));
+ }
+ return "";
+}
+
+my ($user, $origdir, $portname, $tmpbase, $tmpdir, $wdpdir, $predir, $hmake);
chomp ($user = `logname`);
chomp ($origdir = `pwd`);
chomp ($portname = `basename $origdir`);
-$tmpdir = "/tmp/$user.$portname";
+$tmpbase = testdir($ENV{'TMPDIR'}, $ENV{'TMP'}, $path_tmp);
+($tmpbase eq "") and die("No temp dir, please define either TMPDIR or TMP\n");
+$tmpdir = "$tmpbase/$user.$portname";
$wdpdir = "$tmpdir/wdp";
$predir = "$tmpdir/prefix";