From 5ffb5664d9a7ce8185a231b56fe9088bd4c80f8d Mon Sep 17 00:00:00 2001
From: Russ Fish <fish@flux.utah.edu>
Date: Fri, 8 Dec 2006 01:39:50 +0000
Subject: [PATCH] Update setup{,-ops}.txt for FreeBSD-6.1 .

The packagedir is now passed to {ops,boss}-install with a -p argument instead of
as a PKG_PATH envar.  If the old way is done, PKG_PATH is ignored and packages are
all built from sources.  This failed in many ways (due to sync problems between the
6.1 packages and ports tarballs?)  In any case, to prevent others falling down the
same rabbit-hole, building from sources is now off by default, requiring a -s
argument to be given to do it.  Libinstall now shows PhaseSkip reasons, to make
it more clear what's going on.

Also tweak dhcpd_makeconf to handle a null DHCPD_DYNRANGE in the defs file,
to prevent a bogus dhcpd response from an inner emulab, half set-up for testing.
---
 db/dhcpd_makeconf.in    |  6 +++++-
 doc/setup-ops.txt       | 31 ++++++++++++++---------------
 doc/setup.txt           | 16 +++++++++------
 install/boss-install.in | 43 +++++++++++++++++++++++++++--------------
 install/libinstall.pm   | 10 +++++-----
 install/ops-install.in  | 25 +++++++++++++++++++-----
 6 files changed, 83 insertions(+), 48 deletions(-)

diff --git a/db/dhcpd_makeconf.in b/db/dhcpd_makeconf.in
index d97b857715..e023a3964c 100755
--- a/db/dhcpd_makeconf.in
+++ b/db/dhcpd_makeconf.in
@@ -158,7 +158,11 @@ while (my %row = $query_result->fetchhash()) {
 open(IF,"<$template") or
     fatal("Unable to open $template for reading");
 while (<IF>) {
-	if (/^(\s*)\%\%nodetype=(\w+)/) {
+	if (/^(\s*)range\s*;/) {
+		# Comment out a null DHCPD_DYNRANGE line.
+		my $spaces = $1;
+		print $OUT "${spaces}#range ... ...;\n";
+	} elsif (/^(\s*)\%\%nodetype=(\w+)/) {
 		my $spaces = $1;
 		my $nodetype = $2;
 
diff --git a/doc/setup-ops.txt b/doc/setup-ops.txt
index fb968ecb34..88db0a96f8 100644
--- a/doc/setup-ops.txt
+++ b/doc/setup-ops.txt
@@ -6,7 +6,7 @@
 
 #####
 ##### Setting up the Utah Network Testbed software
-##### Most recently tested on FreeBSD 4.11.
+##### Most recently tested on FreeBSD 6.1 .
 #####
 
 ##### Step 1 - OS installation and setup
@@ -97,37 +97,36 @@ collection that are known to work with our software, and to save you hours
 of compile time, we provide pre-built binary packages of the ports required
 by Emulab. 
 
-(Do not let the names of the following tar files bother you, e.g.
-"FreeBSD-4.10" or the apparent 20041102 date stamp.  These are indeed
-the correct files to use with FreeBSD 4.11 and with the current (May 2005)
-Emulab distribution.)
-
 Download the packages tarball from:
 
-	http://www.emulab.net/downloads/FreeBSD-4.10-20041102.tar.gz
+	http://www.emulab.net/downloads/FreeBSD-6.1-20060921.tar.gz
 
 (You can use the FreeBSD 'fetch' command to download the file.)
 
-Now, untar this someplace (you need about 70MB of space, so don't use /tmp).
+Now, untar this someplace (you need about 140MB of space, so don't use /tmp).
 Let's say you untarred it into /usr/tmp. You would then run:
 
-	env PKG_PATH=/usr/tmp/FreeBSD-4.10-20041102 pkg_add emulab-ops-1.4
+	env PKG_PATH=/usr/tmp/FreeBSD-6.1-20060921 pkg_add emulab-ops-2.0
 
 Of course, if you untarred it somewhere else, put in the correct path.
 
-Now you need to download a ports tree that corresponds to the above
-packages.  We have run into many, many problems with versions of the
+We provide all of the binary packages necessary to build ops/fs/boss in our
+packages tarball, making setup of an Emulab-in-Emulab very quick.  You may
+want to install more packages built from ports tree makefiles with downloaded
+sources, but if not there is no need to install a /usr/ports tree.
+
+We have run into many, many problems with clashes between versions of the
 FreeBSD ports.  So, rather than using the /usr/ports tree that comes on the
 FreeBSD installation media, we use one that we've tested against. You can
 grab our 'approved' copy of the ports tree from:
 
-	http://www.emulab.net/downloads/ports-20041102.tar.gz
+	http://www.emulab.net/downloads/ports-20060921.tar.gz
 	
+The tarball is about 40 meg; it unpacks to 175 meg.
+
 Untar it, move it into place as /usr/ports (rename the old directory to
 ports.old, or just remove it), and install whatever ports you want to make
-ops feel like 'home' (like emacs, jove, or whatever). NOTE: You must
-download and copy the ports tree into place, even if you do not intend to
-install any packages yourself.
+ops feel like 'home' (like emacs, jove, or whatever)
 
 ##### Step 3 - Unpacking and running configure
 
@@ -159,7 +158,7 @@ an 'install' subdirectory, with a script called 'ops-install'. Just run this
 script as root (note the same package directory argument as above).
 
 	cd install
-	env PKG_PATH=/usr/tmp/FreeBSD-4.10-20041102 perl ops-install
+	perl ops-install -p /usr/tmp/packages
 
 It will take care of installing any additional ports, and doing various
 other configuration of FreeBSD required to make it into an ops node. The
diff --git a/doc/setup.txt b/doc/setup.txt
index f4067ab3a7..485e7eea1a 100644
--- a/doc/setup.txt
+++ b/doc/setup.txt
@@ -1,6 +1,6 @@
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2001-2005 University of Utah and the Flux Group.
+# Copyright (c) 2001-2006 University of Utah and the Flux Group.
 # All rights reserved.
 #
 
@@ -144,9 +144,9 @@ and make sure the home directories for them are removed as well!
 
 Again, almost the same as on ops. Download the same tarball, and follow
 the same pkg_add procedure, except this time, you're going to install
-the emulab-boss-1.8 package instead of emulab-ops:
+the emulab-boss package instead of emulab-ops:
 
-	env PKG_PATH=/usr/tmp/FreeBSD-4.10-20041102 pkg_add emulab-boss-1.8
+	env PKG_PATH=/usr/tmp/FreeBSD-6.1-20060921 pkg_add emulab-boss-2.0
 
 Also grab a copy of our approved ports tree and install it, the same as
 described in setup-ops.txt.
@@ -184,13 +184,16 @@ boss-install in the object tree, instead of ops-install. Just run this
 script as root (note the same package directory argument as above).
 
 	cd install
-	env PKG_PATH=/usr/tmp/FreeBSD-4.10-20041102 perl boss-install
+	perl boss-install -p /usr/tmp/packages
 
 Like the ops-install script, boss-install sets up passwordless sudo for
 anyone in the wheel group.
 
 ##### Step 7 - Installing from source.
 
+This step is now done as part of boss-install.  You can check it or fix up
+problems by doing the makes yourself, as follows:
+
 In your object directory, do a 'gmake && gmake boss-install'. Then, as root, do
 a 'gmake post-install'. The post-install target needs to run as root, so that
 it can make certain scripts setuid, etc.
@@ -311,8 +314,9 @@ Utah for some.
 
 locate database - It can be useful to update the 'locate' database to help you
 find files as you're learning the system. This normally happens nightly, but
-you can force it to happen now by running 'locate.updatedb' as root. This will
-take several minutes. You can then find foo.conf by running 'locate foo.conf'.
+you can force it to happen now by running '/usr/libexec/locate.updatedb' as
+root. This will take several minutes. You can then find foo.conf by running
+'locate foo.conf'.
 
 ##### Step 11 - Reboot boss
 
diff --git a/install/boss-install.in b/install/boss-install.in
index 20205402bf..0335c71555 100644
--- a/install/boss-install.in
+++ b/install/boss-install.in
@@ -246,16 +246,18 @@ use Getopt::Std;
 # Handle command-line options
 #
 sub usage {
-    print "Usage: boss-install [-p packagedir] [-P portname]\n";
+    print "Usage: boss-install [-b] [-p packagedir] [-s] [-P portname]\n";
+    print "  Required: -p (for binary packages) or -s (for source makes.)\n";
     exit(1);
 }
 
 my $packagedir = "";
 my $batchmode  = 0;
+my $domakes  = 0;
 my $password;
 my %opts;
 
-if (! getopts("P:p:bw:", \%opts)) {
+if (! getopts("P:p:bsw:", \%opts)) {
     usage();
 }
 if (defined($opts{p})) {
@@ -264,13 +266,24 @@ if (defined($opts{p})) {
 if (defined($opts{b})) {
     $batchmode = 1;
 }
+if (defined($opts{s})) {
+    $domakes = 1;
+}
 if (defined($opts{w})) {
     $password = $opts{w};
 }
 if (defined($opts{P})) {
     $BOSS_PORT = $opts{P};
 }
-
+# Don't just charge into making ports from source by default.
+if ($packagedir eq "" and $domakes eq 0) {
+    print "At least one of -p and -s must be given.\n";
+    usage();
+}
+if ($packagedir ne "" and $domakes eq 1) {
+    print "Only one of -p and -s can be given.\n";
+    usage();
+}
 if (@ARGV) {
     usage();
 }
@@ -296,26 +309,26 @@ if ($UID != 0) {
 Phase "usersgroups", "Creating users and groups", sub {
     Phase "tbadmin", "Creating tbadmin group", sub {
 	if (getgrnam("tbadmin")) {
-	    PhaseSkip("tbadmin group already exists");
+	    PhaseSkip("Group already exists");
 	}
 	ExecQuietFatal("$PW groupadd tbadmin -g 101");
     };
     Phase "root", "Creating root group", sub {
 	if (getgrnam("root")) {
-	    PhaseSkip("root group already exists");
+	    PhaseSkip("Group already exists");
 	}
 	ExecQuietFatal("$PW groupadd root -g 103");
     };
     # Added next two cause the mysql package does not do this (port does).
     Phase "mysqlgroup", "Creating mysql group", sub {
 	if (getgrnam("mysql")) {
-	    PhaseSkip("mysql group already exists");
+	    PhaseSkip("Group already exists");
 	}
 	ExecQuietFatal("$PW groupadd mysql -g 88");
     };
     Phase "mysqluser", "Creating mysql user", sub {
 	if (getpwnam("mysql")) {
-	    PhaseSkip("mysql user already exists");
+	    PhaseSkip("User already exists");
 	}
 	ExecQuietFatal("$PW useradd mysql -g 88 -g 88 -h - ".
 		       "-d $MYSQLDBDIR -s /sbin/nologin -c 'MySQL Daemon'");
@@ -344,8 +357,8 @@ Phase "dirs", "Setting directory permissions", sub {
 
 Phase "tftp", "Setting up directories for tftp", sub {
     Phase "tftpoff", "Disabling BSD tftpd", sub {
-	PhaseSkip("no inetd.conf!?") unless (-e $INETD_CONF);
-	PhaseSkip("already disabled") unless `grep '^tftp' $INETD_CONF`;
+	PhaseSkip("No inetd.conf!?") unless (-e $INETD_CONF);
+	PhaseSkip("Already disabled") unless `grep '^tftp' $INETD_CONF`;
 	ExecQuietFatal("sed -i .orig -e '/^tftp/s/^/#/' $INETD_CONF");
 	HUPDaemon("inetd");
     };
@@ -391,7 +404,7 @@ Phase "ports", "Installing ports", sub {
 	    };
 	}
     };
-    PhaseSkip("Package directory provided; not installing from source")
+    PhaseSkip("Package directory provided; not installing from sources")
 	if ($packagedir);
 
     Phase "pcopy", "Copying ports into place", sub {
@@ -403,7 +416,7 @@ Phase "ports", "Installing ports", sub {
 	# it - hopefully it'll get fixed someday, and we remove this
 	Phase "php4patch", "Patching php4 port", sub {
 	    if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $PHP4_PATCH")) {
-		PhaseSkip("$PHP4_PATCH already applied");
+		PhaseSkip("Patch already applied");
 	    }
 	    ExecQuietFatal("$PATCH -f -l -p0 -i $PHP4_PATCH");
 	};
@@ -458,7 +471,7 @@ Phase "patches", "Applying patches", sub {
     if ($FBSD_VERSION == 4) {
 	Phase "g++patch", "Patching g++'s STL", sub {
 	    if (!ExecQuiet("$PATCH -C -f -R -p0 -i $STL_PATCH")) {
-		PhaseSkip("$STL_PATCH already applied");
+		PhaseSkip("Patch already applied");
 	    }
 	    ExecQuietFatal("$PATCH -f -p0 -i $STL_PATCH");
 	};
@@ -470,13 +483,13 @@ Phase "patches", "Applying patches", sub {
 	    $patchfile = "${patchfile}-0.13";
 	}
 	if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $patchfile")) {
-	    PhaseSkip("$patchfile already applied");
+	    PhaseSkip("Patch already applied");
 	}
 	ExecQuietFatal("$PATCH -f -l -p0 -i $patchfile");
     };
     Phase "Mysql.pm.patch", "Patching Mysql.pm", sub {
 	my $patchfile = $MYSQL_PM_PATCH;
-	my $patchfile = `realpath $patchfile`;
+	$patchfile = `realpath $patchfile`;
 	chomp $patchfile;
 
 	my $dir;
@@ -491,7 +504,7 @@ Phase "patches", "Applying patches", sub {
 	}
 
 	if (!ExecQuiet("$PATCH -d $dir -C -f -l -R -i $patchfile")) {
-	    PhaseSkip("$patchfile already applied");
+	    PhaseSkip("Patch already applied");
 	}
 	ExecQuietFatal("$PATCH -d $dir -f -l -i $patchfile");
     };
diff --git a/install/libinstall.pm b/install/libinstall.pm
index 0cd191469c..2d8f47f205 100644
--- a/install/libinstall.pm
+++ b/install/libinstall.pm
@@ -104,7 +104,7 @@ sub Phase($$$) {
     #
     SWITCH: for ($@) {
 	(/^skip$/) && do {
-	    print "[ Skipped   ]\n";
+	    print "[ Skipped ($libinstall::reason) ]\n";
 	    $$parentSkipped++;
 	    $libinstall::phaseResults{$name} = $_;
 	    last SWITCH;
@@ -224,7 +224,7 @@ sub DoneIfExists($) {
     my ($filename) = @_;
     if (!$filename) { PhaseFail("Bad filename passed to DoneIfExists"); }
     if (-e $filename) {
-	PhaseSkip("File $filename already exists");
+	PhaseSkip("File already exists");
     }
 }
 
@@ -235,7 +235,7 @@ sub DoneIfDoesntExist($) {
     my ($filename) = @_;
     if (!$filename) { PhaseFail("Bad filename passed to DoneIfExists"); }
     if (!-e $filename) {
-	PhaseSkip("File $filename does not exist");
+	PhaseSkip("File does not exist");
     }
 }
 
@@ -249,7 +249,7 @@ sub DoneIfEdited($) {
     open(FH,$filename) or return;
     if (grep /$MAGIC_STRING/, <FH>) {
         close(FH);
-	PhaseSkip("File $filename has already been edited\n");
+	PhaseSkip("File has already been edited");
     }
     close(FH);
 }
@@ -291,7 +291,7 @@ sub DoneIfMounted($)
 		if ($opt eq "nfs") {
 		    if ($dir eq $2) {
 			close(MOUNT);
-			PhaseSkip("NFS dir $dir already mounted");
+			PhaseSkip("NFS dir already mounted");
 		    }
 		}
 	    }
diff --git a/install/ops-install.in b/install/ops-install.in
index 62a8d489bd..0aaff2531d 100644
--- a/install/ops-install.in
+++ b/install/ops-install.in
@@ -79,7 +79,9 @@ use Getopt::Std;
 # Handle command-line options
 #
 sub usage {
-    print "Usage: ops-install [-b] [-p packagedir] [-P portname]\n";
+    print "Usage: ops-install [-b] [-p packagedir] [-s] " .
+	"[-P ops-portname] [-F fs-portname]\n";
+    print "  Required: -p (for binary packages) or -s (for source makes.)\n";
     exit(1);
 }
 
@@ -102,9 +104,10 @@ my $PHP4_PORT = "php4-extensions-1.0";
 
 my $packagedir = "";
 my $batchmode  = 0;
+my $domakes  = 0;
 my $password;
 my %opts;
-if (! getopts("P:p:bw:F:", \%opts)) {
+if (! getopts("P:p:bsw:F:", \%opts)) {
     usage();
 }
 if (defined($opts{p})) {
@@ -113,6 +116,9 @@ if (defined($opts{p})) {
 if (defined($opts{b})) {
     $batchmode = 1;
 }
+if (defined($opts{s})) {
+    $domakes = 1;
+}
 if (defined($opts{P})) {
     $OPS_PORT = $opts{P};
 }
@@ -122,6 +128,15 @@ if (defined($opts{F})) {
 if (defined($opts{w})) {
     $password = $opts{w};
 }
+# Don't just charge into making ports from source by default.
+if ($packagedir eq "" and $domakes eq 0) {
+    print "At least one of -p and -s must be given.\n";
+    usage();
+}
+if ($packagedir ne "" and $domakes eq 1) {
+    print "Only one of -p and -s can be given.\n";
+    usage();
+}
 if (@ARGV) {
     usage();
 }
@@ -381,7 +396,7 @@ Phase "ports", "Installing ports", sub {
 	    ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $pname");
 	};
     }
-    PhaseSkip("Package directory provided; not installing from source")
+    PhaseSkip("Package directory provided; not installing from sources")
 	if ($packagedir);
     
     Phase "pcopy", "Copying ports into place", sub {
@@ -474,7 +489,7 @@ Phase "patches", "Applying patches", sub {
 	    $patchfile = "${patchfile}-0.13";
 	}
 	if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $patchfile")) {
-	    PhaseSkip("$patchfile already applied");
+	    PhaseSkip("Patch already applied");
 	}
 	ExecQuietFatal("$PATCH -f -l -p0 -i $patchfile");
     };
@@ -483,7 +498,7 @@ Phase "patches", "Applying patches", sub {
 	    my $patchfile = $MAILMAN_PATCH;
 	
 	    if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $patchfile")) {
-		PhaseSkip("$patchfile already applied");
+		PhaseSkip("Patch already applied");
 	    }
 	    ExecQuietFatal("$PATCH -f -l -p0 -i $patchfile");
 	};
-- 
GitLab