diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-05 21:27:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-05 21:27:39 +0000 |
commit | 59436c90b065edbbd368ed8679d5be33153d4fcc (patch) | |
tree | 2b6543cda0aa334b4d05e91f21b85211da5ffde5 /distrib/miniroot | |
parent | ff0f2a750cbaf08bb2ec918bdabe6ad55177f066 (diff) |
sync to netbsd
Diffstat (limited to 'distrib/miniroot')
-rw-r--r-- | distrib/miniroot/Makefile | 36 | ||||
-rw-r--r-- | distrib/miniroot/install.sh | 181 | ||||
-rw-r--r-- | distrib/miniroot/install.sub | 692 | ||||
-rw-r--r-- | distrib/miniroot/list | 59 | ||||
-rw-r--r-- | distrib/miniroot/list2sh.awk | 26 | ||||
-rw-r--r-- | distrib/miniroot/makeconf.awk | 82 | ||||
-rw-r--r-- | distrib/miniroot/mtree.conf | 14 | ||||
-rw-r--r-- | distrib/miniroot/upgrade.sh | 114 |
8 files changed, 759 insertions, 445 deletions
diff --git a/distrib/miniroot/Makefile b/distrib/miniroot/Makefile index d92379b4b89..4daa0566758 100644 --- a/distrib/miniroot/Makefile +++ b/distrib/miniroot/Makefile @@ -1,29 +1,40 @@ -# $NetBSD: Makefile,v 1.2 1996/01/06 22:40:58 pk Exp $ +# $NetBSD: Makefile,v 1.2.4.3 1996/07/04 07:05:32 leo Exp $ -# Revision is 1.1A -REV= 11A +# Revision is 1.2 +REV= 12 CBIN= instbin ARCHDIR= ${.CURDIR}/../${MACHINE}/miniroot +.if exists(${ARCHDIR}/Makefile.inc) +.include "${ARCHDIR}/Makefile.inc" +.endif + MOUNT_POINT?= /mnt -VND?= vnd0 -VND_DEV= /dev/${VND}a -VND_RDEV= /dev/r${VND}a -IMAGE?= xxx-${REV}.fs -MDEC= ${DESTDIR}/usr/mdec +VND?= vnd0a +VND_DEV= /dev/${VND} +VND_RDEV= /dev/r${VND} +IMAGE?= miniroot-${REV}.fs +IMAGESIZE?= 10240 # 5Mb in 512 byte blocks +NEWFSOPTS?= -LISTS= ${ARCHDIR}/list ${.CURDIR}/list +LISTS= ${.CURDIR}/list ${ARCHDIR}/list CRUNCHCONF= ${CBIN}.conf MTREE= ${.CURDIR}/mtree.conf +.ifndef DESTDIR +all: + @echo setenv DESTDIR before makeing a miniroot! + @false +.else + all: ${CBIN} - dd if=/dev/zero of=${IMAGE} bs=512k count=10 + dd if=/dev/zero of=${IMAGE} count=${IMAGESIZE} vnconfig -v -c ${VND_DEV} ${IMAGE} - newfs -m 0 -o space ${VND_RDEV} miniroot + newfs -m 0 -o space ${NEWFSOPTS} ${VND_RDEV} miniroot mount ${VND_DEV} ${MOUNT_POINT} mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u - CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} ARCHDIR=${ARCHDIR} \ + REV=${REV} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} ARCHDIR=${ARCHDIR} \ TARGDIR=${MOUNT_POINT} sh ${.CURDIR}/runlist.sh ${LISTS} @echo "" @df -i ${MOUNT_POINT} @@ -50,5 +61,6 @@ clean cleandir: /bin/rm -f core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}.cache \ ${CBIN}.conf *.o *.lo *.c +.endif # DESTDIR check .include <bsd.obj.mk> .include <bsd.subdir.mk> diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh index 7ecfe0e64c8..9cf64b5ae08 100644 --- a/distrib/miniroot/install.sh +++ b/distrib/miniroot/install.sh @@ -1,6 +1,5 @@ #!/bin/sh -# $OpenBSD: install.sh,v 1.2 1996/03/28 21:48:18 niklas Exp $ -# $NetBSD: install.sh,v 1.2 1996/02/28 00:47:42 thorpej Exp $ +# $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $ # # Copyright (c) 1996 The NetBSD Foundation, Inc. # All rights reserved. @@ -37,7 +36,7 @@ # POSSIBILITY OF SUCH DAMAGE. # -# OpenBSD installation script. +# NetBSD installation script. # In a perfect world, this would be a nice C program, with a reasonable # user interface. @@ -50,20 +49,29 @@ MODE="install" # include machine-dependent functions # The following functions must be provided: +# md_copy_kernel() - copy a kernel to the installed disk # md_get_diskdevs() - return available disk devices # md_get_cddevs() - return available CD-ROM devices # md_get_ifdevs() - return available network interfaces +# md_get_partition_range() - return range of valid partition letters # md_installboot() - install boot-blocks on disk -# md_checkfordisklabel() - check for valid disklabel # md_labeldisk() - put label on a disk +# md_prep_disklabel() - label the root disk # md_welcome_banner() - display friendly message # md_not_going_to_install() - display friendly message # md_congrats() - display friendly message +# md_native_fstype() - native filesystem type for disk installs +# md_native_fsopts() - native filesystem options for disk installs +# md_makerootwritable() - make root writable (at least /tmp) + +# include machine dependent subroutines . install.md # include common subroutines . install.sub +# which sets? +THESETS="$ALLSETS" # Good {morning,afternoon,evening,night}. md_welcome_banner @@ -88,8 +96,10 @@ md_set_term # Get timezone info get_timezone -# We don't like it, but it sure makes a few things a lot easier. -do_mfs_mount "/tmp" "2048" +# Make sure we can write files (at least in /tmp) +# This might make an MFS mount on /tmp, or it may +# just re-mount the root with read-write enabled. +md_makerootwritable # Install the shadowed disktab file; lets us write to it for temporary # purposes without mounting the miniroot read-write. @@ -99,68 +109,10 @@ while [ "X${ROOTDISK}" = "X" ]; do getrootdisk done -# Make sure there's a disklabel there. If there isn't, puke after -# disklabel prints the error message. -md_checkfordisklabel ${ROOTDISK} -case "$resp" in - 1) - cat << \__disklabel_not_present_1 - -FATAL ERROR: There is no disklabel present on the root disk! You must -label the disk with SYS_INST before continuing. - -__disklabel_not_present_1 - exit - ;; - - 2) - cat << \__disklabel_corrupted_1 - -FATAL ERROR: The disklabel on the root disk is corrupted! You must -re-label the disk with SYS_INST before continuing. - -__disklabel_corrupted_1 - exit - ;; - - *) - ;; -esac - -# Give the user the opportinuty to edit the root disklabel. -cat << \__disklabel_notice_1 - -You have already placed a disklabel onto the target root disk. -However, due to the limitations of the standalone program used -you may want to edit that label to change partition type information. -You will be given the opporunity to do that now. Note that you may -not change the size or location of any presently open partition. - -__disklabel_notice_1 -echo -n "Do you wish to edit the root disklabel? [y] " -getresp "y" -case "$resp" in - y*|Y*) - md_prep_disklabel - disklabel -W ${ROOTDISK} - disklabel -e ${ROOTDISK} - ;; - - *) - ;; -esac - -cat << \__disklabel_notice_2 - -You will now be given the opportunity to place disklabels on any additional -disks on your system. -__disklabel_notice_2 - -_DKDEVS=`rmel ${ROOTDISK} ${_DKDEVS}` -resp="X" # force at least one iteration -while [ "X$resp" != X"done" ]; do - labelmoredisks -done +# Deal with disklabels, including editing the root disklabel +# and labeling additional disks. This is machine-dependent since +# some platforms may not be able to provide this functionality. +md_prep_disklabel ${ROOTDISK} # Assume partition 'a' of $ROOTDISK is for the root filesystem. Loop and # get the rest. @@ -205,12 +157,10 @@ while [ "X$resp" != X"done" ]; do # Invalid response; no multiple roots _first_char="X" else - _first_char=`echo ${_mount_point} | \ - cut -c 1` + _first_char=`firstchar ${_mount_point}` fi done - echo "${_device_name} ${_mount_point}" >> \ - ${FILESYSTEMS} + echo "${_device_name} ${_mount_point}" >> ${FILESYSTEMS} resp="X" # force loop to repeat ;; esac @@ -226,7 +176,7 @@ echo -n "mistakes, you may edit this now. Edit? [n] " getresp "n" case "$resp" in y*|Y*) - vi ${FILESYSTEMS} + ${EDITOR} ${FILESYSTEMS} ;; *) ;; @@ -235,8 +185,7 @@ esac # Loop though the file, place filesystems on each device. echo "Creating filesystems..." ( - while read line; do - _device_name=`echo $line | awk '{print $1}'` + while read _device_name _junk; do newfs /dev/r${_device_name} echo "" done @@ -258,10 +207,13 @@ echo -n "Configure the network? [y] " getresp "y" case "$resp" in y*|Y*) - echo -n "Enter system hostname: " resp="" # force at least one iteration + if [ -f /etc/myname ]; then + resp=`cat /etc/myname` + fi + echo -n "Enter system hostname: [$resp] " while [ "X${resp}" = X"" ]; do - getresp "" + getresp "$resp" done hostname $resp echo $resp > /tmp/myname @@ -315,7 +267,7 @@ case "$resp" in getresp "n" case "$resp" in y*|Y*) - vi /tmp/hosts + ${EDITOR} /tmp/hosts ;; *) @@ -355,12 +307,15 @@ esac # Now that the network has been configured, it is safe to configure the # fstab. -awk '{ - if ($2 == "/") - printf("/dev/%s %s ffs rw 1 1\n", $1, $2) - else - printf("/dev/%s %s ffs rw 1 2\n", $1, $2) -}' < ${FILESYSTEMS} > /tmp/fstab +( + while read _dev _mp; do + if [ "$mp" = "/" ]; then + echo /dev/$_dev $_mp ffs rw 1 1 + else + echo /dev/$_dev $_mp ffs rw 1 2 + fi + done +) < ${FILESYSTEMS} > /tmp/fstab echo "The fstab is configured as follows:" echo "" @@ -378,7 +333,7 @@ echo -n "Edit the fstab? [n] " getresp "n" case "$resp" in y*|Y*) - vi /tmp/fstab + ${EDITOR} /tmp/fstab ;; *) @@ -389,7 +344,23 @@ echo "" munge_fstab /tmp/fstab /tmp/fstab.shadow mount_fs /tmp/fstab.shadow -install_sets $ALLSETS +mount | while read line; do + set -- $line + if [ "$2" = "/" -a "$3" = "nfs" ]; then + echo "You appear to be running diskless." + echo -n "Are the install sets on one of your currently mounted filesystems? [n] " + getresp "n" + case "$resp" in + y*|Y*) + get_localdir + ;; + *) + ;; + esac + fi +done + +install_sets $ALLSETS $MDSETS # Copy in configuration information and make devices in target root. ( @@ -402,21 +373,29 @@ install_sets $ALLSETS fi done - echo -n "Installing timezone link..." - rm -f /mnt/etc/localtime - ln -s /usr/share/zoneinfo/$TZ /mnt/etc/localtime - echo "done." - - echo -n "Making devices..." - pid=`twiddle` - cd /mnt/dev - sh MAKEDEV all - kill $pid - echo "done." - - echo -n "Copying kernel..." - cp -p /bsd /mnt/bsd - echo "done." + # If no zoneinfo on the installfs, give them a second chance + if [ ! -e /usr/share/zoneinfo ]; then + get_timezone + fi + if [ ! -e /mnt/usr/share/zoneinfo ]; then + echo "Cannot install timezone link..." + else + echo -n "Installing timezone link..." + rm -f /mnt/etc/localtime + ln -s /usr/share/zoneinfo/$TZ /mnt/etc/localtime + echo "done." + fi + if [ ! -x /mnt/dev/MAKEDEV ]; then + echo "No /dev/MAKEDEV installed, something is wrong here..." + else + echo -n "Making devices..." + pid=`twiddle` + cd /mnt/dev + sh MAKEDEV all + kill $pid + echo "done." + fi + md_copy_kernel md_installboot ${ROOTDISK} ) diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index a48d9a7155c..7ccea68a553 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,6 +1,5 @@ #!/bin/sh -# $OpenBSD: install.sub,v 1.3 1996/06/29 05:54:16 tholo Exp $ -# $NetBSD: install.sub,v 1.2 1996/02/28 00:47:43 thorpej Exp $ +# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1996 The NetBSD Foundation, Inc. # All rights reserved. @@ -37,14 +36,27 @@ # POSSIBILITY OF SUCH DAMAGE. # -# OpenBSD installation/upgrade script - common subroutines. +# NetBSD installation/upgrade script - common subroutines. -VERSION=1.1A -export VERSION # XXX needed in subshell ROOTDISK="" # filled in below +VERSION= # filled in automatically (see list) +export VERSION ALLSETS="base comp etc games man misc text" # default install sets UPGRSETS="base comp games man misc text" # default upgrade sets +THESETS= # one of the above + +local_sets_dir="" # Path searched for sets by install_sets + # on the local filesystems + +# decide upon an editor +if [ X$EDITOR = X ]; then + if [ -x /usr/bin/vi ]; then + EDITOR=vi + else + EDITOR=ed + fi +fi getresp() { read resp @@ -65,6 +77,8 @@ isin() { rmel() { # remove first argument from list formed by the remaining arguments + local _a + _a=$1; shift while [ $# != 0 ]; do if [ "$_a" != "$1" ]; then @@ -74,6 +88,83 @@ rmel() { done } +cutword () { +# read a line of data, return Nth element. + local _a + local _n + local _oifs + + # optional field separator + _oifs="$IFS" + case "$1" in + -t?*) IFS=${1#-t}; shift;; + esac + + _n=$1 + read _a; set -- $_a + IFS="$_oifs" + if [ "$1" = "" ]; then return; fi + eval echo \$$_n +} + +cutlast () { +# read a line of data, return last element. Equiv. of awk '{print $NF}'. + local _a + local _oifs + + # optional field separator + _oifs="$IFS" + case "$1" in + -t?*) IFS=${1#-t}; shift;; + esac + + read _a; set -- $_a + IFS="$_oifs" + if [ "$1" = "" ]; then return; fi + while [ "$#" -gt 10 ]; do shift 10; done + eval echo \$$# +} + +firstchar () { +# return first character of argument + local _a + _a=$1 + while [ ${#_a} != 1 ]; do + _a=${_a%?} + done + echo $_a +} + +basename () { + local _oifs + if [ "$1" = "" ]; then return; fi + _oifs="$IFS" + IFS="/" + set -- $1 + IFS="$_oifs" + while [ "$#" -gt 10 ]; do shift 10; done + eval echo \$$# +} + +dir_has_sets() { + # return true when the directory $1 contains a set for $2...$n + local _dir + local _file + + _dir=$1; shift + for _file in $* + do + if [ -f $_dir/${_file}.tar.gz ]; then + return 0 + fi + # Try for stupid msdos convention + if [ -f $_dir/${_file}.tgz ]; then + return 0 + fi + done + return 1 +} + twiddle() { # spin the propeller so we don't get bored while : ; do @@ -84,24 +175,53 @@ twiddle() { done > /dev/tty & echo $! } -. install.md - -do_mfs_mount() { - # $1 is the mount point - # $2 is the size in DEV_BIZE blocks - - umount $1 > /dev/null 2>&1 - if ! mount_mfs -s $2 swap $1 ; then - cat << \__mfs_failed_1 +get_localdir() { + # $1 is relative mountpoint + local _mp + local _dir -FATAL ERROR: Can't mount the memory filesystem. - -__mfs_failed_1 - exit - fi - - # Bleh. Give mount_mfs a chance to DTRT. - sleep 2 + _mp=$1 + _dir= + while : ; do + echo -n "Enter the pathname where the sets are stored [$_dir] " + getresp "$_dir" + _dir=$resp + + # Allow break-out with empty response + if [ -z "$_dir" ]; then + echo -n "Are you sure you don't want to set the pathname? [n] " + getresp "n" + case "$resp" in + y*|Y*) + break + ;; + *) + continue + ;; + esac + fi + + if dir_has_sets "$_mp/$_dir" $THESETS + then + local_sets_dir="$_mp/$_dir" + break + else + cat << __get_reldir_1 +The directory \"$local_sets_dir\" does not exist, or does not hold any of the +upgrade sets. +__get_reldir_1 + echo -n "Re-enter pathname? [y] " + getresp "y" + case "$resp" in + y*|Y*) + ;; + *) + local_sets_dir="" + break + ;; + esac + fi + done } getrootdisk() { @@ -144,7 +264,7 @@ __labelmoredisks_1 ;; *) - if echo "$_DKDEVS" | grep "^$resp" > /dev/null ; then + if isin $resp $_DKDEVS ; then md_labeldisk $resp else echo "" @@ -165,10 +285,8 @@ addhostent() { echo "127.0.0.1 localhost" > /tmp/hosts fi - if grep "^$1 " /tmp/hosts > /dev/null; then - grep -v "^$1 " /tmp/hosts > /tmp/hosts.new - mv /tmp/hosts.new /tmp/hosts - fi + sed "/^$1 /d" < /tmp/hosts > /tmp/hosts.new + mv /tmp/hosts.new /tmp/hosts echo "$1 $2 $2.$FQDN" >> /tmp/hosts } @@ -178,9 +296,10 @@ addifconfig() { # $2 - interface symbolic name # $3 - interface IP address # $4 - interface netmask + # $5 - (optional) interface link-layer directives # Create a hostname.* file for the interface. - echo "inet $2 $4" > /tmp/hostname.$1 + echo "inet $2 $4 NONE $5" > /tmp/hostname.$1 addhostent $3 $2 } @@ -230,13 +349,33 @@ __configurenetwork_1 configure_ifs() { + local _up + local _interface_name + local _interface_ip + local _interface_mask + local _interface_symname + local _interface_extra + _interface_name=$1 + set -- `ifconfig $_interface_name | sed -n ' + 1s/.*<UP,.*$/UP/p + 1s/.*<.*>*$/DOWN/p + 2s/inet// + 2s/--> [0-9.][0-9.]*// + 2s/netmask// + 2s/broadcast// + 2p'` + + _up=$1 + _interface_ip=$2 + _interface_mask=$3 + # Get IP address resp="" # force one iteration while [ "X${resp}" = X"" ]; do - echo -n "IP address? " - getresp "" + echo -n "IP address? [$_interface_ip] " + getresp "$_interface_ip" _interface_ip=$resp done @@ -251,24 +390,44 @@ configure_ifs() { # Get netmask resp="" # force one iteration while [ "X${resp}" = X"" ]; do - echo -n "Netmask? " - getresp "" + echo -n "Netmask? [$_interface_mask] " + getresp "$_interface_mask" _interface_mask=$resp done + echo "Your network interface might require additional link-layer" + echo "directives (like \`link0'). If this is the case you can enter" + echo "these at the next prompt." + echo "" + echo -n "Additional link-layer arguments? [$_interface_extra] " + getresp "$_interface_extra" + if [ "X${resp}" != X"" ]; then + _interface_extra=$resp + fi + # Configure the interface. If it # succeeds, add it to the permanent # network configuration info. - ifconfig ${_interface_name} down - if ifconfig ${_interface_name} inet \ - ${_interface_ip} \ - netmask ${_interface_mask} up ; then + if [ $_up != "UP" ]; then + ifconfig ${_interface_name} down + if ifconfig ${_interface_name} inet \ + ${_interface_ip} \ + netmask ${_interface_mask} ${_interface_extra} up ; then + addifconfig \ + ${_interface_name} \ + ${_interface_symname} \ + ${_interface_ip} \ + ${_interface_mask} ${_interface_extra} + return 0 + fi + else + echo "Interface ${_interface_name} is already active." + echo "Just saving configuration on new root filesystem." addifconfig \ ${_interface_name} \ ${_interface_symname} \ ${_interface_ip} \ - ${_interface_mask} - return 0 + ${_interface_mask} ${_interface_extra} fi return 1 } @@ -422,8 +581,8 @@ __install_ftp_2 break fi - _ftp_file=`echo ${resp} | awk '{print $1}'` - echo "get ${_ftp_file} |\"tar -xzvpf -\"" >> \ + _ftp_file=`echo ${resp} | cutword 1'` + echo "get ${_ftp_file} |\"tar --unlink -zxvpf -\"" >> \ /tmp/ftp-script.sh done @@ -435,49 +594,57 @@ __install_ftp_2 echo "Extraction complete." } -install_common_nfs_cdrom() { - # $1 - directory containing file +install_from_mounted_fs() { + # $1 - directory containing installation sets local _filename - local _setsdone - local _prev + local _sets + local _next local _f - _sets=`(cd /mnt2/$1; ls *.tar.gz)` - if [ -z "$_sets" ]; then - echo "There are no OpenBSD install sets available in \"$1\"" + _sets="" + if dir_has_sets $1 $THESETS; then + for _f in $THESETS ; do + if [ -f $1/${_f}.tar.gz ]; then + _sets="$_sets ${_f}.tar.gz" + elif [ -f $1/${_f}.tgz ]; then + _sets="$_sets ${_f}.tgz" + fi + done + else + echo "There are no NetBSD install sets available in \"$1\"" return fi - _setsdone="" while : ; do echo "The following sets are available for extraction:" echo "(marked sets have already been extracted)" echo "" - _prev="" + _next="" for _f in $_sets ; do if isin $_f $_setsdone; then echo -n "[X] " + _next="" else echo -n " " - if [ -z "$_prev" ]; then _prev=$_f; fi + if [ -z "$_next" ]; then _next=$_f; fi fi echo $_f done echo "" # Get the name of the file. - if [ "X$_prev" = "X" ]; then resp=n; else resp=y; fi + if [ "X$_next" = "X" ]; then resp=n; else resp=y; fi echo -n "Continue extraction [$resp]?" getresp "$resp" if [ "$resp" = "n" ]; then break fi - echo -n "File name [$_prev]? " - getresp "$_prev" + echo -n "File name [$_next]? " + getresp "$_next" _f=$resp - _filename="/mnt2/$1/$_f" + _filename="/$1/$_f" # Ensure file exists if [ ! -f $_filename ]; then @@ -487,7 +654,7 @@ install_common_nfs_cdrom() { fi # Extract file - cat $_filename | (cd /mnt; tar -xzvpf -) + cat $_filename | (cd /mnt; tar --unlink -zxvpf -) echo "Extraction complete." _setsdone="$_f $_setsdone" @@ -495,11 +662,17 @@ install_common_nfs_cdrom() { } install_cdrom() { + local _drive + local _partition_range + local _partition + local _fstype + local _directory + # Get the cdrom device info cat << \__install_cdrom_1 The following CD-ROM devices are installed on your system; please select -the CD-ROM device containing the installation media: +the CD-ROM device containing the partition with the installation sets: __install_cdrom_1 _CDDEVS=`md_get_cddevs` @@ -515,7 +688,7 @@ __install_cdrom_1 *) if isin $resp $_CDDEVS ; then - _cdrom_drive=$resp + _drive=$resp else echo "" echo "The CD-ROM $resp does not exist." @@ -526,13 +699,14 @@ __install_cdrom_1 esac # Get partition + _partition_range=`md_get_partition_range` resp="" # force one iteration while [ "X${resp}" = X"" ]; do echo -n "Partition? [c] " getresp "c" case "$resp" in - [a-h]) - _cdrom_partition=$resp + $_partition_range) + _partition=$resp ;; *) @@ -556,7 +730,7 @@ __install_cdrom_2 getresp "cd9660" case "$resp" in cd9660|ffs) - _cdrom_filesystem=$resp + _fstype=$resp ;; *) @@ -567,8 +741,8 @@ __install_cdrom_2 done # Mount the CD-ROM - if ! mount -t ${_cdrom_filesystem} -o ro \ - /dev/${_cdrom_drive}${_cdrom_partition} /mnt2 ; then + if ! mount -t ${_filesystem} -o ro \ + /dev/${_drive}${_partition} /mnt2 ; then echo "Cannot mount CD-ROM drive. Aborting." return fi @@ -577,12 +751,136 @@ __install_cdrom_2 resp="" # force one iteration while [ "X${resp}" = X"" ]; do echo "Enter the directory relative to the mount point that" - echo -n "contains the file. [${_cdrom_directory}] " - getresp "${_cdrom_directory}" + echo -n "contains the file. [${_directory}] " + getresp "${_directory}" + done + _directory=$resp + + install_from_mounted_fs /mnt2/${_directory} + umount -f /mnt2 > /dev/null 2>&1 +} + +mount_a_disk() { + # Mount a disk on /mnt2. The set of disk devices to choose from + # is $_DKDEVS. + # returns 0 on failure. + + local _drive + local _partition_range + local _partition + local _fstype + local _fsopts + local _directory + local _md_fstype + local _md_fsopts + + getresp "abort" + case "$resp" in + abort) + echo "Aborting." + return 0 + ;; + + *) + if isin $resp $_DKDEVS ; then + _drive=$resp + else + echo "" + echo "The disk $resp does not exist." + echo "Aborting." + return 0 + fi + ;; + esac + + # Get partition + _partition_range=`md_get_partition_range` + resp="" # force one iteration + while [ "X${resp}" = X"" ]; do + echo -n "Partition? [d] " + getresp "d" + case "$resp" in + $_partition_range) + _partition=$resp + ;; + + *) + echo "Invalid response: $resp" + resp="" # force loop to repeat + ;; + esac + done + + # Ask for filesystem type + cat << \__mount_a_disk_2 + +The following filesystem types are supported: + 1) ffs +__mount_a_disk_2 + _md_fstype=`md_native_fstype` + _md_fsopts=`md_native_fsopts` + if [ ! -z "$_md_fstype" ]; then + echo " 2) $_md_fstype" + else + _md_fstype="_undefined_" + fi + resp="" # force one iteration + while [ "X${resp}" = X"" ]; do + echo -n "Which filesystem type? [ffs] " + getresp "ffs" + case "$resp" in + ffs) + _fstype=$resp + _fsopts="ro" + ;; + $_md_fstype) + _fstype=$resp + _fsopts=$_md_fsopts + ;; + *) + echo "Invalid response: $resp" + resp="" # force loop to repeat + ;; + esac + done + + # Mount the disk + if ! mount -t ${_fstype} -o $_fsopts \ + /dev/${_drive}${_partition} /mnt2 ; then + echo "Cannot mount disk. Aborting." + return 0 + fi + return 1 +} + +install_disk() { + local _directory + + cat << \__install_disk_1 + +The following disk devices are installed on your system; please select +the disk device containing the partition with the installation sets: + +__install_disk_1 + _DKDEVS=`md_get_diskdevs` + echo "$_DKDEVS" + echo "" + echo -n "Which is the disk with the installation sets? [abort] " + + if mount_a_disk ; then + return + fi + + # Get the directory where the file lives + resp="" # force one iteration + while [ "X${resp}" = X"" ]; do + echo "Enter the directory relative to the mount point that" + echo -n "contains the file. [${_directory}] " + getresp "${_directory}" done - _cdrom_directory=$resp + _directory=$resp - install_common_nfs_cdrom ${_cdrom_directory} + install_from_mounted_fs /mnt2/${_directory} umount -f /mnt2 > /dev/null 2>&1 } @@ -633,11 +931,13 @@ install_nfs() { done _nfs_directory=$resp - install_common_nfs_cdrom ${_nfs_directory} + install_from_mounted_fs /mnt2/${_nfs_directory} umount -f /mnt2 > /dev/null 2>&1 } install_tape() { + local _xcmd + # Get the name of the tape from the user. cat << \__install_tape_1 @@ -709,31 +1009,42 @@ __install_tape_2 echo -n "Which way is it? [1] " getresp "1" case "$resp" in - 1) - ( - cd /mnt - dd if=$TAPE | tar -xzvpf - - ) - ;; + 1) + _xcmd="tar --unlink -zxvpf -" + ;; - 2) - ( - cd /mnt - dd if=$TAPE | tar -xzvpf - - ) - ;; + 2) + _xcmd="tar --unlink -xvpf -" + ;; - *) - echo "Invalid response: $resp." - resp="" # force loop to repeat - ;; + *) + echo "Invalid response: $resp." + resp="" # force loop to repeat + ;; esac + ( cd /mnt; dd if=$TAPE | $_xcmd ) done echo "Extraction complete." } get_timezone() { local _a + local _zonepath + + # + # If the zoneinfo is not on the installation medium or on the + # installed filesystem, set TZ to GMT and return immediatly. + # + if [ ! -e /usr/share/zoneinfo -a ! -e /mnt/usr/share/zoneinfo ]; then + TZ=GMT + return + fi + if [ ! -d /usr/share/zoneinfo ]; then + _zonepath=/mnt + else + _zonepath="" + fi + cat << \__get_timezone_1 Select a time zone for your location. Timezones are represented on the @@ -747,8 +1058,8 @@ at the prompts below. __get_timezone_1 if [ X$TZ = X ]; then - TZ=`ls -l /etc/timezone 2>/dev/null | awk '{print $NF}' | - sed -e 's?/usr/share/zoneinfo/??'` + TZ=`ls -l /mnt/etc/localtime 2>/dev/null | cutlast` + TZ=${TZ#/usr/share/zoneinfo/} fi while :; do echo -n "What timezone are you in [\`?' for list] [$TZ]? " @@ -760,25 +1071,25 @@ __get_timezone_1 break; ;; "?") - ls /usr/share/zoneinfo + ls ${_zonepath}/usr/share/zoneinfo ;; *) _a=$resp - while [ -d /usr/share/zoneinfo/$_a ]; do + while [ -d ${_zonepath}/usr/share/zoneinfo/$_a ]; do echo -n "There are several timezones available" echo " within zone '$_a'" echo -n "Select a sub-timezone [\`?' for list]: " getresp "" case "$resp" in - "?") ls /usr/share/zoneinfo/$_a ;; + "?") ls ${_zonepath}/usr/share/zoneinfo/$_a ;; *) _a=${_a}/${resp} - if [ -f /usr/share/zoneinfo/$_a ]; then + if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then break; fi ;; esac done - if [ -f /usr/share/zoneinfo/$_a ]; then + if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then TZ="$_a" echo "You have selected timezone \"$_a\"". break 2 @@ -791,113 +1102,107 @@ __get_timezone_1 install_sets() { -# arguments: the base names of the distribution sets to consider -# Ask the user which media to load the distribution from. -cat << \__install_sets_1 + local _yup + _yup="FALSE" + + # Ask the user which media to load the distribution from. + cat << \__install_sets_1 It is now time to extract the installation sets onto the hard disk. -Make sure The sets are either on a local device (i.e. tape, CD-ROM) or on a +Make sure the sets are either on a local device (i.e. tape, CD-ROM) or on a network server. __install_sets_1 -if [ -f $RELDIR/$1.tar.gz ]; then - echo -n "Install from sets in the current root filesystem? [y] " - getresp "y" - case "$resp" in - y*|Y*) - for _f do - if [ ! -f $RELDIR/${_f}.tar.gz ]; then - continue - fi - echo -n "Install \"$_f\" ? [y]" - getresp "y" + + if [ "X$local_sets_dir" != "X" ]; then + install_from_mounted_fs ${local_sets_dir} + if [ X"$_setsdone" != X ]; then + _yup="TRUE" + fi + fi + + # Go on prodding for alternate locations + resp="" # force at least one iteration + while [ X"${resp}" = X ]; do + # If _yup is not FALSE, it means that we extracted sets above. + # If that's the case, bypass the menu the first time. + if [ X"$_yup" = X"FALSE" ]; then + echo -n "Install from (f)tp, (t)ape, (C)D-ROM, (N)FS" + echo -n " or local (d)isk? " + getresp "" case "$resp" in - y*|Y*) - cat $RELDIR/${_f}.tar.gz | - (cd /mnt; tar -xzvpf -) - _yup="TRUE" - echo "Extraction complete." + d*|D*) + install_disk + ;; + f*|F*) + install_ftp + ;; + t*|T*) + install_tape + ;; + c*|C*) + install_cdrom + ;; + n*|N*) + install_nfs ;; *) - echo "Skipping \"$_f\"." + echo "Invalid response: $resp" + resp="" ;; esac - done - ;; - *) - _yup="FALSE" - ;; - esac -else - _yup="FALSE" -fi + else + _yup="FALSE" # So we'll ask next time + fi -# Go on prodding for alternate locations -resp="" # force at least one iteration -while [ "X${resp}" = X"" ]; do - # If _yup is not FALSE, it means that we extracted sets above. - # If that's the case, bypass the menu the first time. - if [ X"$_yup" = X"FALSE" ]; then - echo -n "Install from (f)tp, (t)ape, (C)D-ROM, or (N)FS? [f] " - getresp "f" + # Give the user the opportunity to extract more sets. They + # don't necessarily have to come from the same media. + echo "" + echo -n "Extract more sets? [n] " + getresp "n" case "$resp" in - f*|F*) - install_ftp - ;; - - t*|T*) - install_tape - ;; - - c*|C*) - install_cdrom - ;; - - n*|N*) - install_nfs + y*|Y*) + # Force loop to repeat + resp="" ;; *) - echo "Invalid response: $resp" - resp="" ;; esac - else - _yup="FALSE" # So we'll ask next time - fi - - # Give the user the opportunity to extract more sets. They don't - # necessarily have to come from the same media. - echo "" - echo -n "Extract more sets? [n] " - getresp "n" - case "$resp" in - y*|Y*) - # Force loop to repeat - resp="" - ;; - - *) - ;; - esac -done + done } munge_fstab() { local _fstab local _fstab_shadow + local _dev + local _mp + local _fstype + local _rest + # Now that the 'real' fstab is configured, we munge it into a 'shadow' # fstab which we'll use for mounting and unmounting all of the target # filesystems relative to /mnt. Mount all filesystems. _fstab=$1 _fstab_shadow=$2 - awk '{ - if ($2 == "/") - printf("%s /mnt %s %s %s %s\n", $1, $3, $4, $5, $6) + ( while read _dev _mp _fstype _rest; do + # Skip comment lines + case "$_dev" in + \#*) continue;; + *) ;; + esac + # and some filesystem types (like there are swap,kernfs,...) + case "$_fstype" in + ffs|ufs|nfs) ;; + *) continue;; + esac + if [ "$_mp" = "/" ]; then + echo $_dev /mnt $_fstype $_rest else - printf("%s /mnt%s %s %s %s %s\n", $1, $2, $3, $4, $5, $6) - }' < $_fstab > $_fstab_shadow + echo $_dev /mnt$_mp $_fstype $_rest + fi + done ) < $_fstab > $_fstab_shadow } mount_fs() @@ -910,10 +1215,11 @@ mount_fs() _fstab=$1 ( while read line; do - _dev=`echo $line | awk '{print $1}'` - _mp=`echo $line | awk '{print $2}'` - _fstype=`echo $line | awk '{print $3}'` - _opt=`echo $line | awk '{print $4}'` + set -- $line + _dev=$1 + _mp=$2 + _fstype=$3 + _opt=$4 # If not the root filesystem, make sure the mount # point is present. @@ -943,24 +1249,40 @@ __mount_filesystems_1 unmount_fs() { # Unmount all filesystems and check their integrity. - # $1 is a file in fstab format + # Usage: [-fast] <fstab file> + local _fast local _fstab + local _pid - _fstab=$1 + if [ "$1" = "-fast" ]; then + _fast=1 + _fstab=$2 + else + _fast=0 + _fstab=$1 + fi + + if [ ! \( -f $_fstab -a -s $_fstab \) ]; then + echo "fstab empty" > /dev/tty + return + fi - echo -n "Syncing disks..." - pid=`twiddle` - sync; sleep 4; sync; sleep 2; sync; sleep 2 - kill $pid - echo "done." + if [ $_fast = 0 ]; then + echo -n "Syncing disks..." + _pid=`twiddle` + sync; sleep 4; sync; sleep 2; sync; sleep 2 + kill $_pid + echo "done." + fi ( _devs="" _mps="" # maintain reverse order while read line; do - _devs="`echo $line | awk '{print $1}'` ${_devs}" - _mps="`echo $line | awk '{print $2}'` ${_mps}" + set -- $line + _devs="$1 ${_devs}" + _mps="$2 ${_mps}" done echo -n "Umounting filesystems... " for _mp in ${_mps}; do @@ -969,6 +1291,9 @@ unmount_fs() done echo "Done." + if [ $_fast = 0 ]; then + exit + fi echo "Checking filesystem integrity..." for _dev in ${_devs}; do echo "${_dev}" @@ -990,8 +1315,9 @@ check_fs() _devs="" _mps="" while read line; do - _devs="`echo $line | awk '{print $1}'` ${_devs}" - _mps="`echo $line | awk '{print $2}'` ${_mps}" + set -- $line + _devs="$1 ${_devs}" + _mps="$2 ${_mps}" done echo "Checking filesystem integrity..." diff --git a/distrib/miniroot/list b/distrib/miniroot/list index 44f3fd33a32..2da91c76d13 100644 --- a/distrib/miniroot/list +++ b/distrib/miniroot/list @@ -1,4 +1,6 @@ -# $NetBSD: list,v 1.3 1996/01/06 22:45:14 pk Exp $ +# $NetBSD: list,v 1.4.4.1 1996/06/20 20:30:26 pk Exp $ + +SRCDIRS usr.bin bin sbin usr.sbin gnu/usr.bin # copy the crunched binary, link to it, and kill it COPY ${OBJDIR}/instbin instbin @@ -22,13 +24,9 @@ LINK instbin bin/sh LINK instbin bin/stty LINK instbin bin/sleep LINK instbin bin/sync -LINK instbin bin/tar -LINK instbin bin/test -LINK instbin bin/[ -LINK instbin sbin/disklabel -LINK instbin sbin/dmesg -LINK instbin sbin/fsck -LINK instbin sbin/halt +LINK instbin bin/test bin/[ +LINK instbin sbin/fsck_ffs sbin/fsck +LINK instbin sbin/reboot sbin/halt LINK instbin sbin/ifconfig LINK instbin sbin/init LINK instbin sbin/mknod @@ -36,46 +34,28 @@ LINK instbin sbin/mount LINK instbin sbin/mount_cd9660 LINK instbin sbin/mount_ffs LINK instbin sbin/mount_nfs -LINK instbin sbin/newfs +LINK instbin sbin/newfs sbin/mount_mfs LINK instbin sbin/ping -LINK instbin sbin/reboot LINK instbin sbin/route LINK instbin sbin/shutdown LINK instbin sbin/slattach LINK instbin sbin/umount -SYMLINK ../../instbin usr/bin/awk -SYMLINK ../../instbin usr/bin/basename SYMLINK ../../instbin usr/bin/chflags -SYMLINK ../../instbin usr/bin/chgrp -SYMLINK ../../instbin usr/bin/cut -SYMLINK ../../instbin usr/bin/egrep -SYMLINK ../../instbin usr/bin/fgrep +SYMLINK ../../instbin usr/sbin/chown usr/bin/chgrp +SYMLINK ../../instbin usr/sbin/chroot SYMLINK ../../instbin usr/bin/ftp -SYMLINK ../../instbin usr/bin/grep -SYMLINK ../../instbin usr/bin/gunzip -SYMLINK ../../instbin usr/bin/gzcat -SYMLINK ../../instbin usr/bin/gzip -SYMLINK ../../instbin usr/bin/more -SYMLINK ../../instbin usr/bin/netstat -SYMLINK ../../instbin usr/bin/rsh +SYMLINK ../../instbin usr/bin/gzip usr/bin/gunzip usr/bin/gzcat SYMLINK ../../instbin usr/bin/sed -SYMLINK ../../instbin usr/bin/strings SYMLINK ../../instbin usr/bin/sort +SYMLINK ../../instbin usr/bin/tar SYMLINK ../../instbin usr/bin/tip -SYMLINK ../../instbin usr/bin/tset -SYMLINK ../../instbin usr/bin/vi -SYMLINK ../../instbin usr/sbin/chown -SYMLINK ../../instbin usr/sbin/chroot SYMLINK ../../instbin usr/sbin/update -# Minimize use of MFS -SYMLINK /tmp var/tmp - -# copy the MAKEDEV script and make some devices -COPY ${DESTDIR}/dev/MAKEDEV dev/MAKEDEV -COPY ${DESTDIR}/dev/MAKEDEV.local dev/MAKEDEV.local -SPECIAL cd dev; sh MAKEDEV all -SPECIAL /bin/rm dev/MAKEDEV +# `internal' crunchgen links +ARGVLINK mount_ffs ffs +ARGVLINK mount_nfs nfs +ARGVLINK mount_cd9660 cd9660 +ARGVLINK sh -sh # various files that we need in /etc for the install COPY ${DESTDIR}/etc/group etc/group @@ -86,14 +66,9 @@ COPY ${DESTDIR}/etc/pwd.db etc/pwd.db COPY ${DESTDIR}/etc/services etc/services COPY ${DESTDIR}/etc/spwd.db etc/spwd.db -# the zoneinfo -COPYDIR ${DESTDIR}/usr/share/zoneinfo usr/share/zoneinfo - -# and the termcap file -COPY ${CURDIR}/../../share/termcap/termcap.src usr/share/misc/termcap - # and the installation scripts COPY ${CURDIR}/install.sub install.sub COPY ${CURDIR}/install.sh install COPY ${CURDIR}/upgrade.sh upgrade +SPECIAL sed "/^VERSION=/s/=.*/=${REV}/" < ${CURDIR}/install.sub > install.sub SPECIAL chmod 755 install upgrade diff --git a/distrib/miniroot/list2sh.awk b/distrib/miniroot/list2sh.awk index 8fce89bffd7..2fa6f0b6e51 100644 --- a/distrib/miniroot/list2sh.awk +++ b/distrib/miniroot/list2sh.awk @@ -1,4 +1,4 @@ -# $NetBSD: list2sh.awk,v 1.1 1995/12/18 22:47:30 pk Exp $ +# $NetBSD: list2sh.awk,v 1.2 1996/05/04 15:45:31 pk Exp $ BEGIN { printf("cd ${OBJDIR}\n"); @@ -16,14 +16,30 @@ $1 == "COPY" { } $1 == "LINK" { printf("echo '%s'\n", $0); - printf("rm -f ${TARGDIR}/%s\n", $3); - printf("(cd ${TARGDIR}; ln %s %s)\n", $2, $3); + for (i = 3; i <= NF; i++) { + printf("rm -f ${TARGDIR}/%s\n", $i); + printf("(cd ${TARGDIR}; ln %s %s)\n", $2, $i); + } next; } $1 == "SYMLINK" { printf("echo '%s'\n", $0); - printf("rm -f ${TARGDIR}/%s\n", $3); - printf("(cd ${TARGDIR}; ln -s %s %s)\n", $2, $3); + for (i = 3; i <= NF; i++) { + printf("rm -f ${TARGDIR}/%s\n", $i); + printf("(cd ${TARGDIR}; ln -s %s %s)\n", $2, $i); + } + next; +} +$1 == "ARGVLINK" { + # crunchgen directive; ignored here + next; +} +$1 == "SRCDIRS" { + # crunchgen directive; ignored here + next; +} +$1 == "CRUNCHSPECIAL" { + # crunchgen directive; ignored here next; } $1 == "COPYDIR" { diff --git a/distrib/miniroot/makeconf.awk b/distrib/miniroot/makeconf.awk index a0af0e56d44..579c6c98862 100644 --- a/distrib/miniroot/makeconf.awk +++ b/distrib/miniroot/makeconf.awk @@ -1,59 +1,67 @@ -# $NetBSD: makeconf.awk,v 1.2 1995/12/19 00:54:08 pk Exp $ +# $NetBSD: makeconf.awk,v 1.3 1996/05/04 15:45:32 pk Exp $ + +# +# generate crunchgen(1) configuration file from `list' spec. +# BEGIN { - # a list of `aliases' - links["[",0] = "test"; - links["awk",0] = "gawk"; - links["chgrp",0] = "chown"; - links["egrep",0] = "grep"; - links["fgrep",0] = "grep"; - links["gzcat",0] = "gzip"; - links["gunzip",0] = "gzip"; - links["halt",0] = "reboot"; - links["reset",0] = "tset"; - links["rrestore",0] = "restore"; - links["sum",0] = "cksum"; - links["uncompress",0] = "compress"; - links["vi",0] = "common"; # XXX catch vi - links["zcat",0] = "compress"; - - argvlinks["mount_ffs"] = "ffs"; # mount invokes mount_* this way - argvlinks["mount_nfs"] = "nfs"; - argvlinks["mount_cd9660"] = "cd9660"; - argvlinks["sh"] = "-sh"; # init invokes the shell this way + printf("#\n# This file is automatically generated by `makeconf'\n#\n\n"); + printf("\nlibs -ledit -lutil -lcurses -ltermcap -lcrypt -ll -lm -lkvm\n"); + +} + +$1 == "SRCDIRS" { + $1 = tolower($1); + print; } ($1 == "LINK" || $1 == "SYMLINK") && index($2,CBIN) { + # find basenames for inclusion in crunchgen's `prog' and `ln' directives n = split($3, x, "/"); p = x[n]; - if ((p,0) in links) { - links[p,1] = links[p,0]; - p = links[p,0]; + progs[p] = NF - 3; + for (i = 4; i <= NF; i++) { + n = split($i, x, "/"); + l = x[n]; + links[i - 3, p] = l; } - progs[p] = 1; - if (argvlinks[p]) - links[argvlinks[p],1] = p; +} + +$1 == "ARGVLINK" { + # add extra `ln' entries (these don't appear in the filesystem) + n = progs[$2]; + progs[$2] = ++n; + links[n, $2] = $3; +} + +$1 == "CRUNCHSPECIAL" { + # collect crunchgen `special' directives + $1 = ""; + specials[$0] = 1; } END { # write crunchgen configuration - printf("#\n# This file is automatically generated by `makeconf'\n#\n"); - printf("srcdirs bin sbin usr.bin usr.sbin gnu/usr.bin usr.bin/vi\n"); - - i = 0; + # `prog' directives; print 8 to a line + column = 0; for (p in progs) { - if ((i++ % 8) == 0) + if ((column++ % 8) == 0) printf("\nprogs"); printf(" %s", p); } printf("\n\n"); - for (I in links) { - split(I, l, SUBSEP); - if (l[2]) - printf("ln %s %s\n", links[l[1],1], l[1]); + # `ln' directives + for (p in progs) { + n = progs[p]; + for (i = 1; i <= n; i++) + printf("ln %s %s\n", p, links[i,p]); } + printf("\n\n"); - printf("\nlibs -ledit -lutil -lcurses -ltermcap -lcrypt -ll -lm -lkvm\n"); + # `special' directives + for (s in specials) { + printf("special %s\n", s); + } } diff --git a/distrib/miniroot/mtree.conf b/distrib/miniroot/mtree.conf index 27bcebb1e71..ad16fcaf94d 100644 --- a/distrib/miniroot/mtree.conf +++ b/distrib/miniroot/mtree.conf @@ -1,4 +1,4 @@ -# $NetBSD: mtree.conf,v 1.1 1995/12/18 22:47:33 pk Exp $ +# $NetBSD: mtree.conf,v 1.1.4.2 1996/07/15 06:29:38 leo Exp $ /set type=dir uname=root gname=wheel mode=0755 # . @@ -70,6 +70,18 @@ zoneinfo # ./usr/share/zoneinfo .. +# ./usr/share/keymaps +keymaps +# ./usr/share/keymaps + +# ./usr/share/keymaps/atari +atari +# ./usr/share/keymaps/atari +.. + +# ./usr/share/keymaps +.. + # ./usr/share .. diff --git a/distrib/miniroot/upgrade.sh b/distrib/miniroot/upgrade.sh index 8272fcc9847..572ce51174d 100644 --- a/distrib/miniroot/upgrade.sh +++ b/distrib/miniroot/upgrade.sh @@ -1,6 +1,5 @@ #!/bin/sh -# $OpenBSD: upgrade.sh,v 1.2 1996/03/28 21:48:20 niklas Exp $ -# $NetBSD: upgrade.sh,v 1.2 1996/02/28 00:47:45 thorpej Exp $ +# $NetBSD: upgrade.sh,v 1.2.4.5 1996/08/27 18:15:08 gwr Exp $ # # Copyright (c) 1996 The NetBSD Foundation, Inc. # All rights reserved. @@ -37,34 +36,38 @@ # POSSIBILITY OF SUCH DAMAGE. # -# OpenBSD installation script. +# NetBSD installation script. # In a perfect world, this would be a nice C program, with a reasonable # user interface. -VERSION=1.1 -export VERSION # XXX needed in subshell ROOTDISK="" # filled in below -trap "umount /tmp > /dev/null 2>&1" 0 +trap "unmount_fs -fast /tmp/fstab.shadow > /dev/null 2>&1; rm -f /tmp/fstab.shadow" 0 MODE="upgrade" # include machine-dependent functions # The following functions must be provided: +# md_copy_kernel() - copy a kernel to the installed disk # md_get_diskdevs() - return available disk devices # md_get_cddevs() - return available CD-ROM devices # md_get_ifdevs() - return available network interfaces +# md_get_partition_range() - return range of valid partition letters # md_installboot() - install boot-blocks on disk -# md_checkfordisklabel() - check for valid disklabel # md_labeldisk() - put label on a disk # md_welcome_banner() - display friendly message # md_not_going_to_install() - display friendly message # md_congrats() - display friendly message + +# include machine dependent subroutines . install.md # include common subroutines . install.sub +# which sets? +THESETS="$UPGRSETS" + # Good {morning,afternoon,evening,night}. md_welcome_banner echo -n "Proceed with upgrade? [n] " @@ -85,41 +88,15 @@ md_set_term # XXX Work around vnode aliasing bug (thanks for the tip, Chris...) ls -l /dev > /dev/null 2>&1 -# We don't like it, but it sure makes a few things a lot easier. -do_mfs_mount "/tmp" "2048" +# Make sure we can write files (at least in /tmp) +# This might make an MFS mount on /tmp, or it may +# just re-mount the root with read-write enabled. +md_makerootwritable while [ "X${ROOTDISK}" = "X" ]; do getrootdisk done -# Make sure there's a disklabel there. If there isn't, puke after -# disklabel prints the error message. -md_checkfordisklabel ${ROOTDISK} -case $rval in - 1) - cat << \__disklabel_not_present_1 - -FATAL ERROR: There is no disklabel present on the root disk! You must -label the disk with SYS_INST before continuing. - -__disklabel_not_present_1 - exit - ;; - - 2) - cat << \__disklabel_corrupted_1 - -FATAL ERROR: The disklabel on the root disk is corrupted! You must -re-label the disk with SYS_INST before continuing. - -__disklabel_corrupted_1 - exit - ;; - - *) - ;; -esac - # Assume partition 'a' of $ROOTDISK is for the root filesystem. Confirm # this with the user. Check and mount the root filesystem. resp="" # force one iteration @@ -150,7 +127,6 @@ if [ ! -f /mnt/etc/fstab ]; then echo "ERROR: no /etc/fstab!" exit 1 fi -cp /mnt/etc/fstab /tmp/fstab # Grab the hosts table so we can use it. if [ ! -f /mnt/etc/hosts ]; then @@ -202,27 +178,20 @@ __network_config_2 esac # Now that the network has been configured, it is safe to configure the -# fstab. We remove all but ufs/ffs/nfs. +# fstab. We remove all but ufs/ffs. ( - rm -f /tmp/fstab.new - while read line; do - _fstype=`echo $line | awk '{print $3}'` + > /tmp/fstab + while read _dev _mp _fstype _rest ; do if [ "X${_fstype}" = X"ufs" -o \ - "X${_fstype}" = X"ffs" -o \ - "X${_fstype}" = X"nfs" ]; then - echo $line >> /tmp/fstab.new + "X${_fstype}" = X"ffs" ]; then + if [ "X${_fstype}" = X"ufs" ]; then + # Convert ufs to ffs. + _fstype=ffs + fi + echo "$_dev $_mp $_fstype $_rest" >> /tmp/fstab fi done -) < /tmp/fstab - -if [ ! -f /tmp/fstab.new ]; then - echo "ERROR: strange fstab!" - exit 1 -fi - -# Convert ufs to ffs. -sed -e 's/ufs/ffs/' < /tmp/fstab.new > /tmp/fstab -rm -f /tmp/fstab.new +) < /mnt/etc/fstab echo "The fstab is configured as follows:" echo "" @@ -239,7 +208,7 @@ echo -n "Edit the fstab? [n] " getresp "n" case "$resp" in y*|Y*) - vi /tmp/fstab + ${EDITOR} /tmp/fstab ;; *) @@ -260,21 +229,40 @@ check_fs /tmp/fstab.shadow # Mount filesystems. mount_fs /tmp/fstab.shadow +echo -n "Are the upgrade sets on one of your normally mounted (local) filesystems? [y] " +getresp "y" +case "$resp" in + y*|Y*) + get_localdir /mnt + ;; + *) + ;; +esac + # Install sets. -install_sets $UPGRSETS +install_sets # Get timezone info get_timezone # Fix up the fstab. echo -n "Converting ufs to ffs in /etc/fstab..." -sed -e 's/ufs/ffs/' < /mnt/etc/fstab > /tmp/fstab +( + > /tmp/fstab + while read _dev _mp _fstype _rest ; do + if [ "X${_fstype}" = X"ufs" ]; then + # Convert ufs to ffs. + _fstype=ffs + fi + echo "$_dev $_mp $_fstype $_rest" >> /tmp/fstab + done +) < /mnt/etc/fstab echo "done." echo -n "Would you like to edit the resulting fstab? [y] " getresp "y" case "$resp" in y*|Y*) - vi /tmp/fstab + ${EDITOR} /tmp/fstab ;; *) @@ -298,15 +286,13 @@ esac echo "done." echo -n "Making devices..." - pid=`twiddle` + _pid=`twiddle` cd /mnt/dev sh MAKEDEV all - kill $pid + kill $_pid echo "done." - echo -n "Copying kernel..." - cp -p /bsd /mnt/bsd - echo "done." + md_copy_kernel md_installboot ${ROOTDISK} ) |