aboutsummaryrefslogtreecommitdiff
path: root/Tools
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
parent743a0d7a5b9a30c1290de1e1a43b4934b74262b4 (diff)
downloadports-fe8a84044613ac9b4f2a6483c8446f27d8c463fc.tar.gz
ports-fe8a84044613ac9b4f2a6483c8446f27d8c463fc.zip
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>
Notes
Notes: svn path=/head/; revision=38611
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/mkptools/mkpbuild22
-rwxr-xr-xTools/scripts/mkptools/mkpinstall23
2 files changed, 41 insertions, 4 deletions
diff --git a/Tools/scripts/mkptools/mkpbuild b/Tools/scripts/mkptools/mkpbuild
index 846578d455ba..996d527547f6 100755
--- a/Tools/scripts/mkptools/mkpbuild
+++ b/Tools/scripts/mkptools/mkpbuild
@@ -26,12 +26,30 @@
#
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";
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";