[Midnightbsd-cvs] src [11304] U trunk/usr.sbin/bsdinstall: add improvements from freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Wed Jul 4 10:03:26 EDT 2018


Revision: 11304
          http://svnweb.midnightbsd.org/src/?rev=11304
Author:   laffer1
Date:     2018-07-04 10:03:25 -0400 (Wed, 04 Jul 2018)
Log Message:
-----------
add improvements from freebsd

Modified Paths:
--------------
    trunk/usr.sbin/bsdinstall/bsdinstall
    trunk/usr.sbin/bsdinstall/bsdinstall.8

Property Changed:
----------------
    trunk/usr.sbin/bsdinstall/bsdinstall
    trunk/usr.sbin/bsdinstall/bsdinstall.8

Modified: trunk/usr.sbin/bsdinstall/bsdinstall
===================================================================
--- trunk/usr.sbin/bsdinstall/bsdinstall	2018-07-04 14:00:49 UTC (rev 11303)
+++ trunk/usr.sbin/bsdinstall/bsdinstall	2018-07-04 14:03:25 UTC (rev 11304)
@@ -1,6 +1,7 @@
 #!/bin/sh
 #-
 # Copyright (c) 2011 Nathan Whitehorn
+# Copyright (c) 2013 Devin Teske
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -24,17 +25,65 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
+# $FreeBSD: stable/10/usr.sbin/bsdinstall/bsdinstall 259396 2013-12-14 20:55:53Z gjb $
 # $MidnightBSD$
-# $FreeBSD: src/usr.sbin/bsdinstall/bsdinstall,v 1.3 2011/04/05 03:09:44 nwhitehorn Exp $
+#
+############################################################ INCLUDES
 
-: ${BSDINSTALL_LOG="/tmp/bsdinstall_log"}; export BSDINSTALL_LOG
+# Delay processing of debug flags as the parent until MAIN. export'd to disable
+# re-processing of flags (all children log to the parent's log file).
+#
+export DEBUG_SELF_INITIALIZE=
+export DEBUG_INITIALIZE_FILE=
+
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+
+############################################################ GLOBALS
+
 : ${BSDINSTALL_TMPETC="/tmp/bsdinstall_etc"}; export BSDINSTALL_TMPETC
+: ${BSDINSTALL_TMPBOOT="/tmp/bsdinstall_boot"}; export BSDINSTALL_TMPBOOT
 : ${PATH_FSTAB="$BSDINSTALL_TMPETC/fstab"}; export PATH_FSTAB
 : ${BSDINSTALL_DISTDIR="/usr/midnightbsd-dist"}; export BSDINSTALL_DISTDIR
 : ${BSDINSTALL_CHROOT="/mnt"}; export BSDINSTALL_CHROOT
 
-VERB=${1:-auto}; shift
+export debugFile="${debugFile-${BSDINSTALL_LOG-/tmp/bsdinstall_log}}"
 
+############################################################ MAIN
+
+#
+# Process command-line arguments
+#
+while getopts $GETOPTS_STDARGS ignored; do
+	: just skipping known flags
+done
+shift $(( $OPTIND - 1 ))
+
+# What are we here to do?
+VERB="${1:-auto}"; shift
+
 [ -d "$BSDINSTALL_TMPETC" ] || mkdir -p "$BSDINSTALL_TMPETC"
-echo "Running installation step: $VERB $@" >> "$BSDINSTALL_LOG"
-exec "/usr/libexec/bsdinstall/$VERB" "$@" 2>> "$BSDINSTALL_LOG"
+[ -d "$BSDINSTALL_TMPBOOT" ] || mkdir -p "$BSDINSTALL_TMPBOOT"
+
+# Only enable debugging if debugFile is non-NULL and can be initialized
+f_quietly f_debug_init
+f_isset debugFile || debug=
+
+f_dprintf "Running installation step: %s %s" "$VERB" "$*"
+if [ "$debug" ]; then
+	case "$debugFile" in
+	# If NULL, send errors to the bit-bucket
+	"") exec "/usr/libexec/bsdinstall/$VERB" "$@" 2> /dev/null ;;
+	# If begins with `+', send errors to both terminal and file (no `+')
+	+*) exec "/usr/libexec/bsdinstall/$VERB" "$@" \
+		2>&1 >&$TERMINAL_STDOUT_PASSTHRU | tee "${debugFile#+}" ;;
+	# Otherwise, just send errors to the file specified
+	*) exec "/usr/libexec/bsdinstall/$VERB" "$@" 2>> "$debugFile"
+	esac
+else
+	exec "/usr/libexec/bsdinstall/$VERB" "$@" 2> /dev/null
+fi
+
+################################################################################
+# END
+################################################################################


Property changes on: trunk/usr.sbin/bsdinstall/bsdinstall
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/bsdinstall/bsdinstall.8
===================================================================
--- trunk/usr.sbin/bsdinstall/bsdinstall.8	2018-07-04 14:00:49 UTC (rev 11303)
+++ trunk/usr.sbin/bsdinstall/bsdinstall.8	2018-07-04 14:03:25 UTC (rev 11304)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"-
 .\" Copyright (c) 2011-2013 Nathan Whitehorn <nwhitehorn at FreeBSD.org>
 .\" All rights reserved.
@@ -23,10 +24,9 @@
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $MidnightBSD: src/usr.sbin/bsdinstall/bsdinstall.8,v 1.2 2013/01/19 23:43:37 laffer1 Exp $
-.\" $FreeBSD: src/usr.sbin/bsdinstall/bsdinstall.8,v 1.2 2011/06/12 15:19:38 nwhitehorn Exp $
+.\" $FreeBSD: stable/10/usr.sbin/bsdinstall/bsdinstall.8 321181 2017-07-19 02:50:06Z ngie $
 .\"
-.Dd January 21, 2013
+.Dd May 23, 2017
 .Dt BSDINSTALL 8
 .Os
 .Sh NAME
@@ -34,22 +34,36 @@
 .Nd system installer
 .Sh SYNOPSIS
 .Nm
+.Op Ar options
 .Op Ar target
 .Op Ar ...
 .Sh DESCRIPTION
 .Nm
 is used for installation of new systems, both for system setup from
-installation media (e.g. CD-ROMs) and for use on live systems to prepare
+installation media, e.g., CD-ROMs, and for use on live systems to prepare
 VM images and jails.
 .Pp
 Much like
 .Xr make 1 , Nm
-takes a target and possible parameters of the target as arguments. If
-invoked with no arguments, it will invoke the
+takes a target and possible parameters of the target as arguments.
+If invoked with no arguments, it will invoke the
 .Cm auto
 target, which provides a standard interactive installation, invoking the
-others in sequence. To perform a scripted installation, these subtargets
-can be invoked separately by an installation script.
+others in sequence.
+To perform a scripted installation,
+these subtargets can be invoked separately by an installation script.
+.Sh OPTIONS
+.Nm
+supports the following options, global to all targets:
+.Bl -tag -width indent+
+.It Fl D Ar file
+Provide a path for the installation log file
+.Pq overrides Ev BSDINSTALL_LOG .
+See
+.Sx ENVIRONMENT VARIABLES
+for more information on
+.Ev BSDINSTALL_LOG .
+.El
 .Sh TARGETS
 Most of the following targets are only useful for scripting the installer.
 For interactive use, most users will be interested only in the
@@ -79,6 +93,8 @@
 .It Cm keymap
 If the current controlling TTY is a
 .Xr syscons 4
+or
+.Xr vt 4
 console, asks the user to set the current keymap, and saves the result to the
 new system's
 .Pa rc.conf .
@@ -101,17 +117,29 @@
 is set, also configures the network interfaces of the current system to match.
 .It Cm autopart
 Provides the installer's interactive guided disk partitioner for single-disk
-installations. Partitions disks, runs
-.Xr newfs 8 ,
-and writes the new system's
-.Pa fstab .
+installations.
+Defaults to UFS.
+.It Cm zfsboot
+Provides an alternative ZFS-only automatic interactive disk partitioner.
+Creates a single
+.Ic zpool
+with separate datasets for
+.Pa /tmp ,
+.Pa /usr ,
+.Pa /usr/home ,
+.Pa /usr/ports ,
+.Pa /usr/src ,
+and
+.Pa /var .
+Optionally can set up
+.Xr geli 8 
+to encrypt the disk.
 .It Cm partedit
-Provides the installer's interactive manual disk partitioner, with support
-for multi disk setups, non-UFS file systems, and manual selection of
-partition schemes. Partitions disks, runs
-.Xr newfs 8 ,
-and writes the new system's
-.Pa fstab .
+Provides the installer's interactive manual disk partitioner with an interface
+identical to
+.Xr sade 8 .
+Supports multiple disks as well as UFS, ZFS, and FAT file systems.
+ZFS is set up with one pool and dataset per partition.
 .It Cm scriptedpart Ar parameters
 Sets up disks like
 .Cm autopart
@@ -125,7 +153,8 @@
 .Op Ar scheme
 .Op Ar {partitions}
 .Pp
-Multiple disk setups are separated by semicolons. The
+Multiple disk setups are separated by semicolons.
+The
 .Ar disk
 argument specifies the disk on which to operate (which will be erased),
 while the
@@ -132,7 +161,8 @@
 .Ar scheme
 argument specifies the
 .Xr gpart 8
-partition scheme to apply to the disk. If
+partition scheme to apply to the disk.
+If
 .Ar scheme
 is unspecified,
 .Cm scriptedpart
@@ -142,7 +172,8 @@
 argument is also optional and specifies how to partition
 .Ar disk .
 It consists of a comma-separated list of partitions to create enclosed in
-curly braces. Each partition declaration takes the form
+curly braces.
+Each partition declaration takes the form
 .Pp
 .Ar size
 .Ar type
@@ -153,17 +184,25 @@
 can be appended to specify kilobytes, megabytes, and gigabytes respectively),
 while the
 .Em auto
-keyword causes the partition to take all the remaining space on the disk. The
+keyword causes the partition to take all the remaining space on the disk.
+The
 .Ar type
 option chooses the
 .Xr gpart 8
-filesystem type (e.g. freebsd-ufs or freebsd-swap).
+filesystem type, e.g., freebsd-ufs, freebsd-zfs, or freebsd-swap.
 The optional
 .Ar mount point
 argument sets where the created partition is to be mounted in the installed
-system. As an example, a typical invocation looks like:
+system.
+As an example, a typical invocation looks like:
 .Pp
 bsdinstall scriptedpart ada0 { 20G freebsd-ufs /, 4G freebsd-swap, 20G freebsd-ufs /var, auto freebsd-ufs /usr }
+.Pp
+A shorter invocation to use the default partitioning (as
+.Cm autopart
+would have used) on the same disk:
+.Pp
+bsdinstall scriptedpart ada0
 .It Cm mount
 Mounts the file systems previously configured by
 .Cm autopart ,
@@ -202,8 +241,13 @@
 Queries the user for the system daemons to begin at system startup,
 writing the result into the new system's
 .Pa rc.conf .
+.It Cm entropy
+Reads a small amount of data from
+.Pa /dev/random
+and stores it in a file in the new system's root directory.
 .It Cm config
-Installs the configuration files destined for the new system (e.g. rc.conf
+Installs the configuration files destined for the new system, e.g.,
+.Xr rc.conf 5
 fragments generated by
 .Cm netconfig ,
 etc.) onto the new system.
@@ -210,31 +254,36 @@
 .El
 .Sh ENVIRONMENT VARIABLES
 The following environment variables control various aspects of the installation
-process. Many are used internally during installation and have reasonable
-default values for most installation scenarios. Others are set by various
-interactive user prompts, and can be usefully overridden when making scripted
-or customized installers.
+process.
+Many are used internally during installation and have reasonable default values
+for most installation scenarios.
+Others are set by various interactive user prompts, and can be usefully
+overridden when making scripted or customized installers.
 .Bl -tag -width ".Ev BSDINSTALL_DISTSITE"
 .It Ev DISTRIBUTIONS
-The set of distributions to install (e.g. "base kernel ports"). Default: none
+The set of distributions to install, e.g., "base kernel ports".
+Default: none
 .It Ev BSDINSTALL_DISTDIR
 The directory in which the distribution files can be found (or to which they
-should be downloaded). Default:
-.Pa /usr/midnightbsd-dist
+should be downloaded).
+Default:
+.Pa /usr/freebsd-dist
 .It Ev BSDINSTALL_DISTSITE
 URL from which the distribution files should be downloaded if they are not
 already present in the directory defined by
 .Ev BSDINSTALL_DISTDIR .
 This should be a full path to the files, including architecture and release
-names. Most targets (e.g.
+names.
+Most targets, e.g.,
 .Cm auto
 and
-.Cm jail )
+.Cm jail ,
 that prompt for a
 .Mx
 mirror will skip that step if this variable is already defined in the
-environment. Example:
-.Pa ftp://ftp.midnightbsd.org/pub/MidnightBSD/releases/i386/0.8-RELEASE
+environment.
+Example:
+.Pa ftp://ftp.midnightbsd.org/pub/MidnightBSD/releases/powerpc/powerpc64/9.1-RELEASE
 .It Ev BSDINSTALL_CHROOT
 The directory into which the distribution files should be unpacked and the
 directory at which the root file system of the new system should be mounted.
@@ -241,7 +290,8 @@
 Default:
 .Pa /mnt
 .It Ev BSDINSTALL_LOG
-Path to a log file for the installation. Default:
+Path to a log file for the installation.
+Default:
 .Pa /tmp/bsdinstall_log
 .It Ev BSDINSTALL_TMPETC
 Directory where files destined for the new system's
@@ -248,9 +298,19 @@
 .Pa /etc
 will be stored until the
 .Cm config
-target is executed. If this directory does not already exist, it will be
-created. Default:
+target is executed.
+If this directory does not already exist, it will be created.
+Default:
 .Pa /tmp/bsdinstall_etc
+.It Ev BSDINSTALL_TMPBOOT
+Directory where files destined for the new system's
+.Pa /boot
+will be stored until the
+.Cm config
+target is executed.
+If this directory does not already exist, it will be created.
+Default:
+.Pa /tmp/bsdinstall_boot
 .El
 .Sh SCRIPTING
 .Nm
@@ -264,8 +324,9 @@
 .Xr chroot 8
 in the newly installed system before
 .Nm
-exits. The two parts are separated by the usual script header (#!), which
-also sets the interpreter for the setup script.
+exits.
+The two parts are separated by the usual script header (#!), which also sets
+the interpreter for the setup script.
 .Pp
 A typical bsdinstall script looks like this:
 .Bd -literal -offset indent
@@ -279,23 +340,25 @@
 .Ed
 .Pp
 On
-.Fx
+.Mx
 release media, such a script placed at
 .Pa /etc/installerconfig
 will be run at boot time and the system will be rebooted automatically after
-the installation has completed. This can be used for unattended network
-installation of new systems; see
+the installation has completed.
+This can be used for unattended network installation of new systems; see
 .Xr diskless 8
 for details.
 .Ss PREAMBLE
-The preamble consists of installer settings. These control global installation
-parameters (see
+The preamble consists of installer settings.
+These control global installation parameters (see
 .Sx ENVIRONMENT VARIABLES )
-as well as disk partitioning. The preamble is interpreted as a
+as well as disk partitioning.
+The preamble is interpreted as a
 .Xr sh 1
-script run at the very beginning of the install. If more complicated behavior
-than setting these variables is desired, arbitrary commands can be run here
-to extend the installer. In addition to the variables in
+script run at the very beginning of the install.
+If more complicated behavior than setting these variables is desired,
+arbitrary commands can be run here to extend the installer.
+In addition to the variables in
 .Sx ENVIRONMENT VARIABLES ,
 in particular
 .Ev DISTRIBUTIONS ,
@@ -304,15 +367,25 @@
 which is passed to the
 .Cm scriptedpart
 target to control disk setup.
+Alternatively,
+to use
+.Cm zfsboot
+instead of
+.Cm partedit ,
+the preamble can contain the variable
+.Ev ZFSBOOT_DATASETS
+instead of 
+.Ev PARTITIONS .
 .Ss SETUP SCRIPT
 Following the preamble is an optional shell script, beginning with a #!
-declaration. This script will be run at the end of the installation process
-inside a
+declaration.
+This script will be run at the end of the installation process inside a
 .Xr chroot 8
 environment in the newly installed system and can be used to set up
-configuration files, install packages, etc. Note that newly configured
-system services (e.g. networking) have not been started in the installed
-system at this time and only installation host services are available.
+configuration files, install packages, etc.
+Note that newly configured system services, e.g., networking have not
+been started in the installed system at this time and only installation
+host services are available.
 .Sh HISTORY
 This version of
 .Nm


Property changes on: trunk/usr.sbin/bsdinstall/bsdinstall.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list