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

next in thread | previous in thread | raw e-mail | index | archive | help
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 :)

G'luck,
Peter

-- 
When you are not looking at it, this sentence is in Spanish.

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:08:06
@@ -27,11 +27,26 @@
 
 use strict;
 
-my ($user, $origdir, $portname, $tmpdir, $wdpdir, $predir, $hmake);
+sub testdir (@) {
+	my @dirlist = @_;	# list of dirs to test for "tempness"
+
+	my $d;			# currently tested dir
+
+	foreach $d (@dirlist) {
+		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:08:06
@@ -27,11 +27,26 @@
 
 use strict;
 
-my ($user, $origdir, $portname, $tmpdir, $wdpdir, $predir, $hmake);
+sub testdir (@) {
+	my @dirlist = @_;	# list of dirs to test for "tempness"
+
+	my $d;			# currently tested dir
+
+	foreach $d (@dirlist) {
+		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?20010103141000.B54743>