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