Home | History | Annotate | Line # | Download | only in miniroot
install.md revision 1.27
      1  1.27  mlelstv #	$NetBSD: install.md,v 1.27 2009/05/24 22:59:18 mlelstv Exp $
      2   1.1       is #
      3   1.1       is #
      4  1.25       is # Copyright (c) 1996,2006 The NetBSD Foundation, Inc.
      5   1.1       is # All rights reserved.
      6   1.1       is #
      7   1.1       is # This code is derived from software contributed to The NetBSD Foundation
      8   1.1       is # by Jason R. Thorpe.
      9   1.1       is #
     10   1.1       is # Redistribution and use in source and binary forms, with or without
     11   1.1       is # modification, are permitted provided that the following conditions
     12   1.1       is # are met:
     13   1.1       is # 1. Redistributions of source code must retain the above copyright
     14   1.1       is #    notice, this list of conditions and the following disclaimer.
     15   1.1       is # 2. Redistributions in binary form must reproduce the above copyright
     16   1.1       is #    notice, this list of conditions and the following disclaimer in the
     17   1.1       is #    documentation and/or other materials provided with the distribution.
     18   1.1       is #
     19   1.1       is # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1       is # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1       is # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.3      jtc # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.3      jtc # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1       is # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1       is # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1       is # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1       is # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1       is # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1       is # POSSIBILITY OF SUCH DAMAGE.
     30   1.1       is #
     31   1.1       is 
     32   1.1       is #
     33   1.1       is # machine dependent section of installation/upgrade script.
     34   1.1       is #
     35   1.1       is 
     36   1.1       is # Machine-dependent install sets
     37  1.24   mhitch MDSETS="kern-GENERIC xbase xcomp xetc xfont xserver"
     38   1.1       is 
     39   1.1       is md_set_term() {
     40   1.1       is 	if [ ! -z "$TERM" ]; then
     41   1.1       is 		return
     42   1.1       is 	fi
     43   1.1       is 	echo -n "Specify terminal type [vt220]: "
     44   1.1       is 	getresp "vt220"
     45   1.1       is 	TERM="$resp"
     46   1.1       is 	export TERM
     47   1.1       is }
     48   1.1       is 
     49   1.1       is __mount_kernfs() {
     50   1.1       is 	#
     51   1.1       is 	# Force kern_fs to be mounted
     52   1.1       is 	#
     53   1.1       is 	if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
     54   1.1       is 		mkdir /kern > /dev/null 2>&1
     55   1.1       is 		/sbin/mount_kernfs /kern /kern >/dev/null 2>&1
     56   1.1       is 	fi
     57   1.1       is }
     58   1.1       is 
     59   1.1       is md_makerootwritable() {
     60   1.1       is 	# Mount root rw for convenience of the tester ;-)
     61  1.21       is 	if ! cp /dev/null /tmp/.root_writable >/dev/null 2>&1; then
     62   1.1       is 		__mount_kernfs
     63   1.1       is 		# XXX: Use /kern/rootdev instead?
     64  1.15       is 		mount -t ffs -u /kern/rootdev / > /dev/null 2>&1
     65   1.1       is 	fi
     66   1.1       is }
     67   1.1       is 
     68   1.1       is md_get_diskdevs() {
     69   1.1       is 	# return available disk devices
     70   1.1       is 	__mount_kernfs
     71   1.1       is 	sed -n -e '/^[sw]d[0-9] /s/ .*//p' \
     72   1.1       is 		< /kern/msgbuf | sort -u
     73   1.1       is }
     74   1.1       is 
     75   1.1       is md_get_cddevs() {
     76   1.1       is 	# return available CDROM devices
     77   1.1       is 	__mount_kernfs
     78   1.1       is 	sed -n -e '/^cd[0-9] /s/ .*//p' \
     79   1.1       is 		< /kern/msgbuf | sort -u
     80   1.1       is }
     81   1.1       is 
     82   1.1       is md_get_partition_range() {
     83   1.1       is 	# return an expression describing the valid partition id's
     84   1.1       is 	echo '[a-p]'
     85   1.1       is }
     86   1.1       is 
     87   1.1       is md_installboot() {
     88  1.22   mhitch 	if [ -x /mnt/usr/sbin/installboot ]; then
     89   1.1       is 		echo -n "Should a boot block be installed? [y] "
     90   1.1       is 		getresp "y"
     91   1.1       is 		case "$resp" in
     92   1.1       is 			y*|Y*)
     93   1.1       is 				echo "Installing boot block..."
     94  1.22   mhitch 				chroot /mnt /usr/sbin/installboot /dev/r${1}a /usr/mdec/bootxx_ffs
     95  1.18   mhitch 				cp -p /mnt/usr/mdec/boot.amiga /mnt/
     96   1.1       is 				;;
     97   1.1       is 			*)
     98  1.13       is 				echo "No bootblock installed."
     99   1.1       is 				;;
    100   1.1       is 		esac
    101   1.1       is 	elif [ "$MODE" = "install" ]; then
    102   1.1       is 		cat << \__md_installboot_1
    103   1.1       is There is no installboot program found on the installed filesystems. No boot
    104   1.1       is programs are installed.
    105   1.1       is __md_installboot_1
    106   1.1       is 	else
    107   1.1       is 		cat << \__md_installboot_2
    108   1.1       is There is no installboot program found on the upgraded filesystems. No boot
    109   1.1       is programs are installed.
    110   1.1       is __md_installboot_2
    111   1.1       is 	fi
    112   1.1       is }
    113   1.1       is 
    114   1.1       is md_native_fstype() {
    115   1.1       is 	echo "ados"
    116   1.1       is }
    117   1.1       is 
    118   1.1       is md_native_fsopts() {
    119   1.6    veego 	echo "ro"
    120   1.1       is }
    121   1.1       is 
    122   1.1       is md_prep_disklabel() {
    123  1.25       is }
    124  1.25       is 
    125  1.25       is md_view_labels_possible=1
    126  1.25       is md_view_labels() {
    127   1.9       is 	_DKDEVS=`md_get_diskdevs`
    128   1.9       is 	echo "If you like, you can now examine the labels of your disks."
    129   1.9       is 	echo ""
    130   1.9       is 	echo -n "Available are "${_DKDEVS}". Look at which? [skip this step] "
    131  1.11       is 	getresp	"done"
    132  1.11       is 	while [ "X$resp" != "Xdone" ]; do
    133   1.9       is 		echo ""
    134   1.9       is 		disklabel ${resp}
    135   1.9       is 		echo ""
    136   1.9       is 		echo -n "Available are "${_DKDEVS}". Look at which? [done] "
    137  1.11       is 		getresp	"done"
    138   1.9       is 	done
    139  1.10       is 	cat << \__prep_disklabel_1
    140  1.10       is 
    141  1.10       is As a reminder: the 'c' partition is assigned to the whole disk and can't
    142  1.10       is normally be used for a any file system!
    143  1.10       is 
    144  1.10       is __prep_disklabel_1
    145   1.1       is }
    146   1.1       is 
    147   1.1       is md_labeldisk() {
    148   1.1       is }
    149   1.1       is 
    150   1.1       is md_welcome_banner() {
    151   1.1       is 	if [ "$MODE" = "install" ]; then
    152   1.1       is 		echo ""
    153   1.1       is 		echo "Welcome to the NetBSD/amiga ${VERSION} installation program."
    154   1.1       is 		cat << \__welcome_banner_1
    155   1.1       is 
    156   1.1       is This program is designed to help you put NetBSD on your disk,
    157   1.1       is in a simple and rational way.  You'll be asked several questions,
    158   1.1       is and it would probably be useful to have your disk's hardware
    159   1.1       is manual, the installation notes, and a calculator handy.
    160   1.1       is __welcome_banner_1
    161   1.1       is 
    162   1.1       is 	else
    163   1.1       is 		echo ""
    164   1.1       is 		echo "Welcome to the NetBSD/amiga ${VERSION} upgrade program."
    165   1.1       is 		cat << \__welcome_banner_2
    166   1.1       is 
    167   1.1       is This program is designed to help you upgrade your NetBSD system in a
    168   1.1       is simple and rational way.
    169   1.1       is 
    170   1.1       is As a reminder, installing the `etc' binary set is NOT recommended.
    171   1.1       is Once the rest of your system has been upgraded, you should manually
    172   1.1       is merge any changes to files in the `etc' set into those files which
    173   1.1       is already exist on your system.
    174   1.1       is __welcome_banner_2
    175   1.1       is 	fi
    176   1.1       is 
    177   1.1       is cat << \__welcome_banner_3
    178   1.1       is 
    179   1.1       is As with anything which modifies your disk's contents, this
    180   1.1       is program can cause SIGNIFICANT data loss, and you are advised
    181   1.1       is to make sure your data is backed up before beginning the
    182   1.1       is installation process.
    183   1.1       is 
    184   1.1       is Default answers are displayed in brackets after the questions.
    185   1.1       is You can hit Control-C at any time to quit, but if you do so at a
    186   1.1       is prompt, you may have to hit return.  Also, quitting in the middle of
    187   1.1       is installation may leave your system in an inconsistent state.
    188   1.1       is 
    189   1.1       is __welcome_banner_3
    190   1.1       is }
    191   1.1       is 
    192   1.1       is md_not_going_to_install() {
    193   1.1       is 	cat << \__not_going_to_install_1
    194   1.1       is 
    195   1.1       is OK, then.  Enter `halt' at the prompt to halt the machine.  Once the
    196   1.1       is machine has halted, power-cycle the system to load new boot code.
    197   1.1       is 
    198   1.1       is Note: If you wish to have another try. Just type '^D' at the prompt. After
    199   1.1       is       a moment, the installer will restart itself.
    200   1.1       is 
    201   1.1       is __not_going_to_install_1
    202   1.1       is }
    203   1.1       is 
    204   1.1       is md_congrats() {
    205   1.1       is 	local what;
    206   1.1       is 	if [ "$MODE" = "install" ]; then
    207   1.1       is 		what="installed";
    208   1.1       is 	else
    209   1.1       is 		what="upgraded";
    210   1.1       is 	fi
    211   1.1       is 	cat << __congratulations_1
    212   1.1       is 
    213   1.1       is CONGRATULATIONS!  You have successfully $what NetBSD!
    214   1.1       is To boot the installed system, enter halt at the command prompt. Once the
    215   1.1       is system has halted, reset the machine and boot from the disk.
    216   1.1       is 
    217   1.1       is Note: If you wish to have another try. Just type '^D' at the prompt. After
    218   1.1       is       a moment, the installer will restart itself.
    219   1.1       is 
    220   1.1       is __congratulations_1
    221   1.1       is }
    222   1.1       is 
    223   1.1       is md_copy_kernel() {
    224   1.1       is 	# This is largely a copy of install_disk and install_from_mounted_fs()
    225   1.1       is 	# with some special frobbing.
    226   1.1       is 
    227   1.1       is 	local _directory
    228   1.1       is 	local _sets
    229   1.1       is 	local _filename
    230   1.1       is 	local _f
    231   1.7       is 
    232   1.7       is 	if [ "$MODE" = "install" ]; then
    233   1.7       is 		echo -n "Adding keymap initialization to rc.local..."
    234   1.7       is 		echo /usr/sbin/loadkmap ${__keymap__} >> /mnt/etc/rc.local
    235   1.7       is 		echo "done."
    236   1.7       is 	fi
    237   1.1       is 
    238   1.1       is 	if [ -e /netbsd ]; then
    239  1.14       is 		if [ -e /mnt/netbsd ]; then
    240  1.14       is 			echo "On the installation filesystem there is this kernel: "
    241  1.14       is 			ls -l /netbsd
    242  1.14       is 			echo "The already installed kernel is: "
    243  1.14       is 			ls -l /mnt/netbsd
    244  1.14       is 			echo	"Do you want to replace the already installed kernel by the kernel"
    245  1.14       is 			echo -n "on the installation filesystem? (y/n) [n] "
    246  1.14       is 			resp="n"
    247  1.14       is 			getresp ""
    248  1.14       is 			if [ "${resp}" != "y" -a "${resp}" != "Y" ]; then
    249  1.14       is 				return
    250  1.14       is 			fi
    251  1.14       is 		fi
    252  1.14       is 
    253   1.1       is 		echo -n "Copying kernel..."
    254   1.1       is 		cp -p /netbsd /mnt/netbsd
    255   1.1       is 		echo "done."
    256   1.1       is 		return
    257   1.1       is 	fi
    258   1.1       is 
    259   1.1       is cat << \__md_copy_kernel_1
    260   1.1       is Your installation set did not include a netbsd kernel on the installation
    261   1.1       is filesystem. You are now given the opportunity install it from either the
    262   1.1       is kernel-floppy from the distribution or another location on one of your disks.
    263   1.1       is 
    264   1.1       is The following disk devices are installed on your system; please select
    265   1.1       is the disk device containing the partition with the netbsd kernel:
    266   1.1       is __md_copy_kernel_1
    267   1.1       is 
    268   1.1       is 	_DKDEVS=`md_get_diskdevs`
    269   1.1       is 	echo    "$_DKDEVS"
    270   1.1       is 	echo	"fd0"
    271   1.1       is 	echo	""
    272   1.1       is 	_DKDEVS="$_DKDEVS fd0"		# Might be on the kernel floppy!
    273   1.1       is 	echo -n	"Which is the disk with the kernel? [abort] "
    274   1.1       is 
    275   1.1       is 	if mount_a_disk ; then
    276   1.1       is 		return	# couldn't mount the disk
    277   1.1       is 	fi
    278   1.1       is 
    279   1.1       is 	# Get the directory where the file lives
    280   1.1       is 	resp=""		# force one iteration
    281   1.1       is 	while [ "X${resp}" = X"" ]; do
    282   1.1       is 		echo "Enter the directory relative to the mount point that"
    283   1.1       is 		echo -n "contains the file. [${_directory}] "
    284   1.1       is 		getresp "${_directory}"
    285   1.1       is 	done
    286   1.1       is 	_directory=$resp
    287   1.1       is 
    288   1.1       is 	_sets=`(cd /mnt2/$_directory; ls netbsd* 2> /dev/null)`
    289   1.1       is 	if [ -z "$_sets" ]; then
    290   1.1       is 		echo "There are no NetBSD kernels available in \"$1\""
    291   1.1       is 		umount -f /mnt2 > /dev/null 2>&1
    292   1.1       is 		return
    293   1.1       is 	fi
    294   1.1       is 	while : ; do
    295   1.1       is 		echo "The following kernels are available:"
    296   1.1       is 		echo ""
    297   1.1       is 
    298   1.1       is 		for _f in $_sets ; do
    299   1.1       is 			echo "    $_f"
    300   1.1       is 		done
    301   1.1       is 		echo ""
    302   1.1       is 		set -- $_sets
    303   1.1       is 		echo -n "File name [$1]? "
    304   1.1       is 		getresp "$1"
    305   1.1       is 		_f=$resp
    306   1.1       is 		_filename="/mnt2/$_directory/$_f"
    307   1.1       is 
    308   1.1       is 		# Ensure file exists
    309   1.1       is 		if [ ! -f $_filename ]; then
    310   1.1       is 			echo "File $_filename does not exist.  Check to make"
    311   1.1       is 			echo "sure you entered the information properly."
    312   1.1       is 			echo -n "Do you want to retry [y]? "
    313   1.1       is 			getresp "y"
    314   1.1       is 			if [ "$resp" = "n" ]; then
    315   1.1       is 				break
    316   1.1       is 			fi
    317   1.1       is 			continue
    318   1.1       is 		fi
    319   1.1       is 
    320   1.1       is 		# Copy the kernel
    321   1.1       is 		cp $_filename /mnt
    322   1.1       is 		break
    323   1.1       is 	done
    324   1.1       is 	umount -f /mnt2 > /dev/null 2>&1
    325   1.1       is }
    326  1.19   mhitch 
    327  1.19   mhitch md_lib_is_aout() {
    328  1.19   mhitch 	local r
    329  1.19   mhitch 	test -h $1 && return 1
    330  1.19   mhitch 	test -f $1 || return 1
    331  1.19   mhitch 
    332  1.27  mlelstv 	[ "`dd if=$1 bs=1 skip=1 count=3 2> /dev/null`" = "ELF" ] && return 1
    333  1.19   mhitch 	return 0
    334  1.19   mhitch }
    335  1.19   mhitch 
    336  1.19   mhitch 
    337  1.19   mhitch md_mv_usr_lib() {
    338  1.19   mhitch 	local root
    339  1.19   mhitch 	root=$1
    340  1.19   mhitch 	for f in $root/usr/lib/lib*.so.[0-9]*.[0-9]* ; do
    341  1.19   mhitch 		md_lib_is_aout $f || continue
    342  1.19   mhitch 		mv -f $f $root/emul/aout/usr/lib || return 1
    343  1.19   mhitch 	done
    344  1.19   mhitch 	return 0
    345  1.19   mhitch }
    346  1.19   mhitch 
    347  1.19   mhitch md_x_shlib_set_14=" \
    348  1.19   mhitch 	libICE.so.6.3 \
    349  1.19   mhitch 	libPEX5.so.6.0 \
    350  1.19   mhitch 	libSM.so.6.0 \
    351  1.19   mhitch 	libX11.so.6.1 \
    352  1.19   mhitch 	libXIE.so.6.0 \
    353  1.19   mhitch 	libXaw.so.6.1 \
    354  1.19   mhitch 	libXext.so.6.3 \
    355  1.19   mhitch 	libXi.so.6.0 \
    356  1.19   mhitch 	libXmu.so.6.0 \
    357  1.19   mhitch 	libXp.so.6.2 \
    358  1.19   mhitch 	libXt.so.6.0 \
    359  1.19   mhitch 	libXtst.so.6.1 \
    360  1.19   mhitch 	liboldX.so.6.0"
    361  1.19   mhitch 
    362  1.19   mhitch md_mv_x_lib() {
    363  1.19   mhitch 	local root xlibdir
    364  1.19   mhitch 	root=$1
    365  1.19   mhitch 	xlibdir=$2
    366  1.19   mhitch 	for f in $md_x_shlib_set_14; do
    367  1.19   mhitch 		md_lib_is_aout $root/$xlibdir/$f || continue
    368  1.19   mhitch 		mv -f $root/$xlibdir/$f $root/emul/aout/$xlibdir || return 1
    369  1.19   mhitch 	done
    370  1.19   mhitch 	return 0
    371  1.19   mhitch }
    372  1.19   mhitch 
    373  1.19   mhitch md_mv_aout_libs()
    374  1.19   mhitch {
    375  1.19   mhitch 	local root xlibdir
    376  1.19   mhitch 
    377  1.19   mhitch 	root=/mnt	# XXX - should be global
    378  1.19   mhitch 
    379  1.19   mhitch 	if [ -d $root/emul/aout/. ]; then
    380  1.19   mhitch 		echo "Using existing /emul/aout directory"
    381  1.19   mhitch 	else
    382  1.19   mhitch 		echo "Creating /emul/aout hierachy"
    383  1.19   mhitch 		mkdir -p $root/usr/aout || return 1
    384  1.19   mhitch 
    385  1.19   mhitch 		if [ ! -d $root/emul ]; then
    386  1.19   mhitch 			mkdir $root/emul || return 1
    387  1.19   mhitch 		fi
    388  1.19   mhitch 
    389  1.19   mhitch 		if [ -h $root/emul/aout ]; then
    390  1.19   mhitch 			echo "Preserving existing symbolic link from /emul/aout"
    391  1.19   mhitch 			mv -f $root/emul/aout $root/emul/aout.old || return 1
    392  1.19   mhitch 		fi
    393  1.19   mhitch 
    394  1.19   mhitch 		ln -s ../usr/aout $root/emul/aout || return 1
    395  1.19   mhitch 	fi
    396  1.19   mhitch 
    397  1.19   mhitch 	# Create /emul/aout/etc and /emul/aout/usr/lib
    398  1.19   mhitch 	if [ ! -d $root/emul/aout/etc ]; then
    399  1.19   mhitch 		mkdir $root/emul/aout/etc || return 1
    400  1.19   mhitch 	fi
    401  1.19   mhitch 	if [ ! -d $root/emul/aout/usr/lib ]; then
    402  1.19   mhitch 		mkdir -p $root/emul/aout/usr/lib || return 1
    403  1.19   mhitch 	fi
    404  1.19   mhitch 
    405  1.19   mhitch 	# Move ld.so.conf
    406  1.19   mhitch 	if [ -f $root/etc/ld.so.conf ]; then
    407  1.19   mhitch 		mv -f $root/etc/ld.so.conf $root/emul/aout/etc || return 1
    408  1.19   mhitch 	fi
    409  1.19   mhitch 
    410  1.19   mhitch 	# Finally, move the aout shared libraries from /usr/lib
    411  1.19   mhitch 	md_mv_usr_lib $root || return 1
    412  1.19   mhitch 
    413  1.19   mhitch 	# If X11 is installed, move the those libraries as well
    414  1.19   mhitch 	xlibdir="/usr/X11R6/lib"
    415  1.19   mhitch 	if [ -d $root/$xlibdir/. ]; then
    416  1.19   mhitch 		mkdir -p $root/emul/aout/$xlibdir || return 1
    417  1.19   mhitch 		md_mv_x_lib $root $xlibdir || return 1
    418  1.19   mhitch 	fi
    419  1.19   mhitch 
    420  1.19   mhitch 	echo "a.out emulation environment setup completed."
    421  1.19   mhitch }
    422  1.19   mhitch 
    423  1.19   mhitch md_prepare_upgrade()  
    424  1.19   mhitch {
    425  1.19   mhitch cat << 'EOF'
    426  1.19   mhitch This release uses the ELF binary object format. Existing (a.out) binaries
    427  1.19   mhitch can still be used on your system after it has been upgraded, provided
    428  1.19   mhitch that the shared libraries needed by those binaries are made available
    429  1.19   mhitch in the filesystem hierarchy rooted at /emul/aout.
    430  1.19   mhitch 
    431  1.19   mhitch This upgrade procedure will now establish this hierarchy by moving all
    432  1.19   mhitch shared libraries in a.out format found in /usr/lib to /emul/aout/usr/lib.
    433  1.19   mhitch It will also move the X11 shared libraries in a.out format from previous
    434  1.22   mhitch NetBSD/amiga X11 installation sets, if they are installed.
    435  1.19   mhitch 
    436  1.19   mhitch EOF
    437  1.19   mhitch 	md_mv_aout_libs || {
    438  1.19   mhitch 		echo "Failed to setup a.out emulation environment"
    439  1.19   mhitch 		return 1
    440  1.19   mhitch 	}
    441  1.19   mhitch 	return 0
    442  1.19   mhitch }
    443  1.19   mhitch 
    444  1.19   mhitch # Flag to notify upgrade.sh of the existence of md_prepare_upgrade()
    445  1.19   mhitch md_upgrade_prep_needed=1
    446