Home | History | Annotate | Line # | Download | only in sparc
install.md revision 1.16
      1 #	$NetBSD: install.md,v 1.16 2000/11/17 17:53:53 pk Exp $
      2 #
      3 #
      4 # Copyright (c) 1996 The NetBSD Foundation, Inc.
      5 # All rights reserved.
      6 #
      7 # This code is derived from software contributed to The NetBSD Foundation
      8 # by Jason R. Thorpe.
      9 #
     10 # Redistribution and use in source and binary forms, with or without
     11 # modification, are permitted provided that the following conditions
     12 # are met:
     13 # 1. Redistributions of source code must retain the above copyright
     14 #    notice, this list of conditions and the following disclaimer.
     15 # 2. Redistributions in binary form must reproduce the above copyright
     16 #    notice, this list of conditions and the following disclaimer in the
     17 #    documentation and/or other materials provided with the distribution.
     18 # 3. All advertising materials mentioning features or use of this software
     19 #    must display the following acknowledgement:
     20 #        This product includes software developed by the NetBSD
     21 #        Foundation, Inc. and its contributors.
     22 # 4. Neither the name of The NetBSD Foundation nor the names of its
     23 #    contributors may be used to endorse or promote products derived
     24 #    from this software without specific prior written permission.
     25 #
     26 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36 # POSSIBILITY OF SUCH DAMAGE.
     37 #
     38 
     39 #
     40 # machine dependent section of installation/upgrade script.
     41 #
     42 
     43 # Machine-dependent install sets
     44 MDSETS="kern xbase xcomp xcontrib xfont xserver"
     45 
     46 if [ "$MODE" = upgrade ]; then
     47 	RELOCATED_FILES_13="${RELOCATED_FILES_13} /usr/sbin/installboot /usr/mdec/installboot"
     48 fi
     49 
     50 md_set_term() {
     51 	if [ ! -z "$TERM" ]; then
     52 		return
     53 	fi
     54 	echo -n "Specify terminal type [sun]: "
     55 	getresp "sun"
     56 	TERM="$resp"
     57 	export TERM
     58 }
     59 
     60 md_makerootwritable() {
     61 	# Was: do_mfs_mount "/tmp" "2048"
     62 	# /tmp is the mount point
     63 	# 2048 is the size in DEV_BIZE blocks
     64 
     65 	umount /tmp > /dev/null 2>&1
     66 	if ! mount_mfs -s 2048 swap /tmp ; then
     67 		cat << \__mfs_failed_1
     68 
     69 FATAL ERROR: Can't mount the memory filesystem.
     70 
     71 __mfs_failed_1
     72 		exit
     73 	fi
     74 
     75 	# Bleh.  Give mount_mfs a chance to DTRT.
     76 	sleep 2
     77 }
     78 
     79 md_get_diskdevs() {
     80 	# return available disk devices
     81 	dmesg | sed -n -e 's/^\(sd[0-9]\) .*/\1/p' -e 's/^\(x[dy][0-9]\) .*/\1/p' | sort -u
     82 }
     83 
     84 md_get_cddevs() {
     85 	# return available CDROM devices
     86 	dmesg | sed -n -e 's/^\(cd[0-9]\) .*/\1/p' | sort -u
     87 }
     88 
     89 md_get_ifdevs() {
     90 	# return available network devices
     91 	dmesg | sed -n -e 's/^\(le[0-9]\) .*/\1/p' -e 's/^\(ie[0-9]\) .*/\1/p' | sort -u
     92 }
     93 
     94 md_get_partition_range() {
     95     # return range of valid partition letters
     96     echo "[a-h]"
     97 }
     98 
     99 md_installboot() {
    100 	echo "Installing boot block..."
    101 	/usr/mdec/binstall ffs /mnt
    102 }
    103 
    104 md_native_fstype() {
    105 }
    106 
    107 md_native_fsopts() {
    108 }
    109 
    110 md_checkfordisklabel() {
    111 	# $1 is the disk to check
    112 	local rval
    113 	local cfdl
    114 
    115 	cfdl=`disklabel $1 2>&1 > /dev/null | \
    116 	    sed -n -e '/no disk label/{s/.*/ndl/p;q;}; \
    117 		 /disk label corrupted/{s/.*/dlc/p;q;}; \
    118 		 $s/.*/no/p'`
    119 	if [ x$cfdl = xndl ]; then
    120 		rval=1
    121 	elif [ x$cfdl = xdlc ]; then
    122 		rval=2
    123 	else
    124 		rval=0
    125 	fi
    126 
    127 	return $rval
    128 }
    129 
    130 md_prep_disklabel()
    131 {
    132 	local _disk
    133 
    134 	_disk=$1
    135 	md_checkfordisklabel $_disk
    136 	case $? in
    137 	0)
    138 		echo -n "Do you wish to edit the disklabel on $_disk? [y]"
    139 		;;
    140 	1)
    141 		echo "WARNING: Disk $_disk has no label"
    142 		echo -n "Do you want to create one with the disklabel editor? [y]"
    143 		;;
    144 	2)
    145 		echo "WARNING: Label on disk $_disk is corrupted"
    146 		echo -n "Do you want to try and repair the damage using the disklabel editor? [y]"
    147 		;;
    148 	esac
    149 
    150 	getresp "y"
    151 	case "$resp" in
    152 	y*|Y*) ;;
    153 	*)	return ;;
    154 	esac
    155 
    156 	# display example
    157 	cat << \__md_prep_disklabel_1
    158 
    159 Here is an example of what the partition information will look like once
    160 you have entered the disklabel editor. Disk partition sizes and offsets
    161 are in sector (most likely 512 bytes) units. Make sure these size/offset
    162 pairs are on cylinder boundaries (the number of sector per cylinder is
    163 given in the `sectors/cylinder' entry, which is not shown here).
    164 
    165 Do not change any parameters except the partition layout and the label name.
    166 It's probably also wisest not to touch the `8 partitions:' line, even
    167 in case you have defined less than eight partitions.
    168 
    169 [Example]
    170 8 partitions:
    171 #        size   offset    fstype   [fsize bsize   cpg]
    172   a:    50176        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 111)
    173   b:    64512    50176      swap                        # (Cyl.  112 - 255)
    174   c:   640192        0   unknown                        # (Cyl.    0 - 1428)
    175   d:   525504   114688    4.2BSD     1024  8192    16   # (Cyl.  256 - 1428)
    176 [End of example]
    177 
    178 __md_prep_disklabel_1
    179 	echo -n "Press [Enter] to continue "
    180 	getresp ""
    181 	disklabel -W ${_disk}
    182 	if [ -f /usr/bin/vi ]; then 
    183 		disklabel -e ${_disk}
    184 	else
    185 		disklabel -i ${_disk}
    186 	fi
    187 }
    188 
    189 md_copy_kernel() {
    190 	if [ ! -f /mnt/netbsd ]; then
    191 		echo -n "WARNING: No kernel installed; "
    192 		if [ -f /netbsd ]; then
    193 			echo -n "copying miniroot kernel... "
    194 			cp -p /netbsd /mnt/netbsd
    195 			echo "done."
    196 		else
    197 			echo -n "install a kernel manually."
    198 		fi
    199 	fi
    200 }
    201 
    202 md_welcome_banner() {
    203 {
    204 	if [ "$MODE" = "install" ]; then
    205 		echo ""
    206 		echo "Welcome to the NetBSD/sparc ${VERSION} installation program."
    207 		cat << \__welcome_banner_1
    208 
    209 This program is designed to help you put NetBSD on your disk,
    210 in a simple and rational way.  You'll be asked several questions,
    211 and it would probably be useful to have your disk's hardware
    212 manual, the installation notes, and a calculator handy.
    213 __welcome_banner_1
    214 
    215 	else
    216 		echo ""
    217 		echo "Welcome to the NetBSD/sparc ${VERSION} upgrade program."
    218 		cat << \__welcome_banner_2
    219 
    220 This program is designed to help you upgrade your NetBSD system in a
    221 simple and rational way.
    222 
    223 As a reminder, installing the `etc' binary set is NOT recommended.
    224 Once the rest of your system has been upgraded, you should manually
    225 merge any changes to files in the `etc' set into those files which
    226 already exist on your system.
    227 __welcome_banner_2
    228 	fi
    229 
    230 cat << \__welcome_banner_3
    231 
    232 As with anything which modifies your disk's contents, this
    233 program can cause SIGNIFICANT data loss, and you are advised
    234 to make sure your data is backed up before beginning the
    235 installation process.
    236 
    237 Default answers are displayed in brackets after the questions.
    238 You can hit Control-C at any time to quit, but if you do so at a
    239 prompt, you may have to hit return.  Also, quitting in the middle of
    240 installation may leave your system in an inconsistent state.
    241 
    242 __welcome_banner_3
    243 } | more
    244 }
    245 
    246 md_not_going_to_install() {
    247 	cat << \__not_going_to_install_1
    248 
    249 OK, then.  Enter `halt' at the prompt to halt the machine.  Once the
    250 machine has halted, power-cycle the system to load new boot code.
    251 
    252 __not_going_to_install_1
    253 }
    254 
    255 md_congrats() {
    256 	local what;
    257 	if [ "$MODE" = "install" ]; then
    258 		what="installed";
    259 	else
    260 		what="upgraded";
    261 	fi
    262 	cat << __congratulations_1
    263 
    264 CONGRATULATIONS!  You have successfully $what NetBSD!
    265 To boot the installed system, enter halt at the command prompt. Once the
    266 system has halted, reset the machine and boot from the disk.
    267 
    268 __congratulations_1
    269 }
    270 
    271 md_lib_is_aout() {
    272 	local r
    273 	test -h $f && return 1
    274 	test -f $f || return 1
    275 
    276 	r=`file $1 | sed -n -e '/ELF/p'`
    277 	test -z "$r" || return 1
    278 	return 0
    279 }
    280 
    281 
    282 md_mv_usr_lib() {
    283 	local root
    284 	root=$1
    285 	for f in $root/usr/lib/lib*.so.[0-9]*.[0-9]* ; do
    286 		md_lib_is_aout $f || continue
    287 		mv $f -f $root/emul/aout/usr/lib || return 1
    288 	done
    289 	return 0
    290 }
    291 
    292 md_x_shlib_set_14=" \
    293 	libICE.so.6.3 \
    294 	libPEX5.so.6.0 \
    295 	libSM.so.6.0 \
    296 	libX11.so.6.1 \
    297 	libXIE.so.6.0 \
    298 	libXaw.so.6.1 \
    299 	libXext.so.6.3 \
    300 	libXi.so.6.0 \
    301 	libXmu.so.6.0 \
    302 	libXp.so.6.2 \
    303 	libXt.so.6.0 \
    304 	libXtst.so.6.1 \
    305 	liboldX.so.6.0"
    306 
    307 md_mv_x_lib() {
    308 	local root xlibdir
    309 	root=$1
    310 	xlibdir=$2
    311 	for f in $md_x_shlib_set_14; do
    312 		md_lib_is_aout $root/$xlibdir/$f || continue
    313 		mv -f $root/$xlibdir/$f $root/emul/aout/$xlibdir || return 1
    314 	done
    315 	return 0
    316 }
    317 
    318 md_mv_aout_libs()
    319 {
    320 	local root xlibdir
    321 
    322 	root=/mnt	# XXX - should be global
    323 
    324 	if [ -d $root/emul/aout/. ]; then
    325 		echo "Using existing /emul/aout directory"
    326 	else
    327 		echo "Creating /emul/aout hierachy"
    328 		mkdir -p $root/usr/aout || return 1
    329 
    330 		if [ ! -d $root/emul ]; then
    331 			mkdir $root/emul || return 1
    332 		fi
    333 
    334 		if [ -h $root/emul/aout ]; then
    335 			echo "Preserving existing symbolic link from /emul/aout"
    336 			mv -f $root/emul/aout $root/emul/aout.old || return 1
    337 		fi
    338 
    339 		ln -s ../usr/aout $root/emul/aout || return 1
    340 	fi
    341 
    342 	# Create /emul/aout/etc and /emul/aout/usr/lib
    343 	if [ ! -d $root/emul/aout/etc ]; then
    344 		mkdir $root/emul/aout/etc || return 1
    345 	fi
    346 	if [ ! -d $root/emul/aout/usr/lib ]; then
    347 		mkdir -p $root/emul/aout/usr/lib || return 1
    348 	fi
    349 
    350 	# Move ld.so.conf
    351 	if [ -f $root/etc/ld.so.conf ]; then
    352 		mv -f $root/etc/ld.so.conf $root/emul/aout/etc || return 1
    353 	fi
    354 
    355 	# Finally, move the aout shared libraries from /usr/lib
    356 	md_mv_usr_lib || return 1
    357 
    358 	# If X11 is installed, move the those libraries as well
    359 	xlibdir="/usr/X11R6/lib"
    360 	if [ -d $root/$xlibdir/. ]; then
    361 		mkdir -p $root/emul/aout/$xlibdir || return 1
    362 		md_mv_x_lib $xlibdir || return 1
    363 	fi
    364 }
    365 
    366 md_prepare_upgrade()  
    367 {
    368 cat < 'EOF'
    369 This release uses the ELF binary object format. Existing (a.out) binaries
    370 can still be used on your system after it has been upgraded, provided
    371 that the shared libraries needed by those binaries are made available
    372 in the filesystem hierarchy rooted at /emul/aout.
    373 
    374 This upgrade procedure will now establish this hierarchy by moving all
    375 shared libraries in a.out format found in /usr/lib to /emul/aout/usr/lib.
    376 It will also move the X11 shared libraries in a.out format from previous
    377 NetBSD/sparc X11 installation sets, if they are installed.
    378 
    379 EOF
    380 	md_mv_aout_libs || {
    381 		echo "Failed to setup a.out emulation environment";
    382 		return 1;
    383 	}
    384 	return 0
    385 }
    386