Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jan 2001 14:21:57 +0200
From:      Peter Pentchev <roam@orbitel.bg>
To:        Neil Blakey-Milner <nbm@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Cc:        cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: ports/Tools/scripts/mkptools mkpbuild mkpinstall
Message-ID:  <20010103142157.D54743@ringworld.oblivion.bg>
In-Reply-To: <20010103141000.B54743@ringworld.oblivion.bg>; from roam@orbitel.bg on Wed, Jan 03, 2001 at 02:10:01PM %2B0200
References:  <200101031116.f03BGlq39072@freefall.freebsd.org> <20010103141000.B54743@ringworld.oblivion.bg>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 03, 2001 at 02:10:01PM +0200, Peter Pentchev wrote:
> On Wed, Jan 03, 2001 at 03:16:47AM -0800, Neil Blakey-Milner wrote:
> > nbm         2001/01/03 03:16:46 PST
> > 
> >   Modified files:
> >     Tools/scripts/mkptools mkpbuild mkpinstall 
> >   Log:
> >   As a quick fix, use /tmp instead of the currently hardcoded /usr/tmp.
> 
> How about the attached patch to check for a user-specified temp dir?
> (this is one of my first attempts at style(.perl)-ish Perl code, so
>  feel free to flame or point at manpages :)

Or maybe rather this.. (smacks forehead)..

G'luck,
Peter

-- 
This sentence every third, but it still comprehensible.

Index: ports/Tools/scripts/mkptools/mkpbuild
===================================================================
RCS file: /home/ncvs/ports/Tools/scripts/mkptools/mkpbuild,v
retrieving revision 1.2
diff -u -r1.2 mkpbuild
--- ports/Tools/scripts/mkptools/mkpbuild	2001/01/03 11:16:46	1.2
+++ ports/Tools/scripts/mkptools/mkpbuild	2001/01/03 12:20:54
@@ -27,11 +27,24 @@
 
 use strict;
 
-my ($user, $origdir, $portname, $tmpdir, $wdpdir, $predir, $hmake);
+sub testdir (@) {
+	my $d;			# currently tested dir
+
+	foreach $d (@_) {
+		next unless defined($d);
+		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'},
+		'/usr/tmp', '/tmp', '/var/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";
 
Index: ports/Tools/scripts/mkptools/mkpinstall
===================================================================
RCS file: /home/ncvs/ports/Tools/scripts/mkptools/mkpinstall,v
retrieving revision 1.2
diff -u -r1.2 mkpinstall
--- ports/Tools/scripts/mkptools/mkpinstall	2001/01/03 11:16:46	1.2
+++ ports/Tools/scripts/mkptools/mkpinstall	2001/01/03 12:20:54
@@ -27,11 +27,24 @@
 
 use strict;
 
-my ($user, $origdir, $portname, $tmpdir, $wdpdir, $predir, $hmake);
+sub testdir (@) {
+	my $d;			# currently tested dir
+
+	foreach $d (@_) {
+		next unless defined($d);
+		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'},
+		'/usr/tmp', '/tmp', '/var/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";
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010103142157.D54743>