From ad8939a4f6ab13b7e1c1916348969c8f4f23a532 Mon Sep 17 00:00:00 2001
From: Will Andrews <will@FreeBSD.org>
Date: Sat, 19 Aug 2000 08:08:47 +0000
Subject: Make -n work again.  Add new option -s to allow people to specify a
 $DISTDIR to put distfiles in, if they can't touch $PORTSDIR/distfiles. If
 this is freefall, default to $tmpdir, which is relatively secure since most
 users on it are trusted.  Reset FETCH_BEFORE_ARGS to "-btA" instead of
 "-btsA", so the distfile is actually fetched.  Add a method to allow the name
 of the module to be changed if -i is used.  Update to use the modulesupdate
 that's in /usr/local/bin.

Addport should now work properly on freefall, without -v option.

Submitted by:	roger (-s, $tmpdir by default on freefall)
Thanks to:	peter (copying modulesupdate to /usr/local/bin)
---
 Tools/scripts/addport | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/Tools/scripts/addport b/Tools/scripts/addport
index 1aa311873ed0..1d9f75b1f86d 100755
--- a/Tools/scripts/addport
+++ b/Tools/scripts/addport
@@ -19,12 +19,13 @@ use strict;
 
 my %opts;
 
-getopts('d:h:intu:v', \%opts);
+getopts('d:h:ins:tu:v', \%opts);
 
+my $distdir = $opts{'s'} if ($opts{'s'} ne "");
 my $dir = $opts{'d'};
 my $h = "freefall.FreeBSD.org";
 $h = $opts{'h'} if ($opts{'h'} ne "");
-my $n = $opts{'n'};
+my $n = ""; $n = "-n " if $opts{'n'};
 my $u = $ENV{USER};
 $u = $opts{'u'} if ($opts{'u'} ne "");
 my $more_testing = $opts{'t'};
@@ -53,7 +54,7 @@ if ($myhost ne lc($h)) {
 	$ssh = "";
 	$repo = "/home/ncvs";
 }
-my $cvs = "cvs -d $repo";
+my $cvs = "cvs $n-d $repo";
 
 # stuff that always happens when we start
 BEGIN {
@@ -78,7 +79,13 @@ my @commands;
 if (!$vanilla) {
 	push(@commands, "$make clean check-categories");
 	push(@commands, "$portlint");
-	push(@commands, "$make FETCH_BEFORE_ARGS='-btsA' checksum");
+	if (-d $distdir) {
+		push(@commands, "$make DISTDIR='$distdir' FETCH_BEFORE_ARGS='-btA' checksum");
+	} elsif ($myhost eq "freefall.freebsd.org") {
+		push(@commands, "$make DISTDIR='$tmpdir' FETCH_BEFORE_ARGS='-btA' checksum");
+	} else {
+		push(@commands, "$make FETCH_BEFORE_ARGS='-btA' checksum");
+	}
 	if ($more_testing) {
 		push(@commands, "$make distclean");
 		push(@commands, "$make build");
@@ -92,7 +99,7 @@ if ($dir eq "") {
 }
 
 my @dirs = split(/\,/, $dir);
-my $portname;
+my $portname; my $module;
 foreach my $thisdir (@dirs) {
 	# do some dir sanity checking first
 	errx(1, "Please specify valid directories to import new ports from.") if $thisdir eq "";
@@ -134,9 +141,18 @@ foreach my $thisdir (@dirs) {
 	chomp(my $cvs_category = $category);
 	$cvs_category =~ s/-/_/g;
  
- 	print "We're ready to commit.\n";
+ 	$module = $portname;
+	if ($opts{'i'}) {
+		if (prompt("Port will be added as module $portname.  OK? ")) {
+			do {
+				$module = query("Preferred module name for $module? ");
+			} while (prompt("Is the new module name $module OK? "));
+		}
+	}
+	print "We're ready to commit.\n";
 	print "Source directory: $thisdir\n";
 	print "Target CVS Repo directory: ports/$category/$portname\n";
+	print "Modules entry: $module --> ports/$category/$portname\n";
 	prompt("Adding port $portname to $category OK? ") && errx(1, "user abort requested");
 	chdir $tmpdir or err(1, "$tmpdir");
 
@@ -181,7 +197,7 @@ foreach my $thisdir (@dirs) {
 	# commit the actual port.
 	chdir "$tmpdir/$category" or err(1, "$tmpdir/$category");
 	system("$cvs ci Makefile $portname") && errx(1, "cvs commit failed, aborting.");
-	system("$ssh $perl ~mharo/bin/modulesupdate $portname ports/$category/$portname") && errx(1, "adding port to modules failed, aborting.");
+	system("$ssh $perl /usr/local/bin/modulesupdate $module ports/$category/$portname") && errx(1, "adding port to modules failed, aborting.");
 }
 
 print <<EOF;
@@ -233,7 +249,7 @@ print <<EOF;
 authors: <will\@FreeBSD.org>, <mharo\@FreeBSD.org>
 
 SYNOPSIS
-	$0 [-h host] [-u user] [-intv] -d directory
+	$0 [-h host] [-u user] [-s distdir] [-intv] -d directory
 
 	Where "directory" contains the comma-delimited list
 	of root directories of new ports that you wish to
@@ -243,13 +259,16 @@ SYNOPSIS
 OPTIONS
 	-h host		Use a cvshost besides freefall.FreeBSD.org
 	-i		Interactive mode; allow more control over
-			where things are placed.
+			where things are placed.  This is required in
+			order to change things like module names etc.
 	-n		Do not actually commit anything.
+	-s distdir	Use a different directory besides the default,
+			for downloading distfiles.  This defaults to the
+			temporary directory set up on freefall.
 	-u user		Use a different username (default: $u).
 	-t		Do more port testing
 	-v		Plain vanilla "add it" - no testing at all.
-			This option overrides -t.  It is currently
-			necessary in order to use this on freefall.
+			This option overrides -t in all cases.
 
 EXAMPLES
 	% addport -n -d greatgame,helpfuldev,shoot
-- 
cgit debian/1.2.3+git2.25.1-1-2-gaceb0