1 # $NetBSD: install.md,v 1.26 2008/04/30 13:10:47 martin Exp $
4 # Copyright (c) 1996,2006 The NetBSD Foundation, Inc.
7 # This code is derived from software contributed to The NetBSD Foundation
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
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.
19 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
33 # machine dependent section of installation/upgrade script.
36 # Machine-dependent install sets
37 MDSETS="kern-GENERIC xbase xcomp xetc xfont xserver"
40 if [ ! -z "$TERM" ]; then
43 echo -n "Specify terminal type [vt220]: "
51 # Force kern_fs to be mounted
53 if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
54 mkdir /kern > /dev/null 2>&1
55 /sbin/mount_kernfs /kern /kern >/dev/null 2>&1
59 md_makerootwritable() {
60 # Mount root rw for convenience of the tester ;-)
61 if ! cp /dev/null /tmp/.root_writable >/dev/null 2>&1; then
63 # XXX: Use /kern/rootdev instead?
64 mount -t ffs -u /kern/rootdev / > /dev/null 2>&1
69 # return available disk devices
71 sed -n -e '/^[sw]d[0-9] /s/ .*//p' \
72 < /kern/msgbuf | sort -u
76 # return available CDROM devices
78 sed -n -e '/^cd[0-9] /s/ .*//p' \
79 < /kern/msgbuf | sort -u
82 md_get_partition_range() {
83 # return an expression describing the valid partition id's
88 if [ -x /mnt/usr/sbin/installboot ]; then
89 echo -n "Should a boot block be installed? [y] "
93 echo "Installing boot block..."
94 chroot /mnt /usr/sbin/installboot /dev/r${1}a /usr/mdec/bootxx_ffs
95 cp -p /mnt/usr/mdec/boot.amiga /mnt/
98 echo "No bootblock installed."
101 elif [ "$MODE" = "install" ]; then
102 cat << \__md_installboot_1
103 There is no installboot program found on the installed filesystems. No boot
104 programs are installed.
107 cat << \__md_installboot_2
108 There is no installboot program found on the upgraded filesystems. No boot
109 programs are installed.
122 md_prep_disklabel() {
125 md_view_labels_possible=1
127 _DKDEVS=`md_get_diskdevs`
128 echo "If you like, you can now examine the labels of your disks."
130 echo -n "Available are "${_DKDEVS}". Look at which? [skip this step] "
132 while [ "X$resp" != "Xdone" ]; do
136 echo -n "Available are "${_DKDEVS}". Look at which? [done] "
139 cat << \__prep_disklabel_1
141 As a reminder: the 'c' partition is assigned to the whole disk and can't
142 normally be used for a any file system!
150 md_welcome_banner() {
151 if [ "$MODE" = "install" ]; then
153 echo "Welcome to the NetBSD/amiga ${VERSION} installation program."
154 cat << \__welcome_banner_1
156 This program is designed to help you put NetBSD on your disk,
157 in a simple and rational way. You'll be asked several questions,
158 and it would probably be useful to have your disk's hardware
159 manual, the installation notes, and a calculator handy.
164 echo "Welcome to the NetBSD/amiga ${VERSION} upgrade program."
165 cat << \__welcome_banner_2
167 This program is designed to help you upgrade your NetBSD system in a
168 simple and rational way.
170 As a reminder, installing the `etc' binary set is NOT recommended.
171 Once the rest of your system has been upgraded, you should manually
172 merge any changes to files in the `etc' set into those files which
173 already exist on your system.
177 cat << \__welcome_banner_3
179 As with anything which modifies your disk's contents, this
180 program can cause SIGNIFICANT data loss, and you are advised
181 to make sure your data is backed up before beginning the
182 installation process.
184 Default answers are displayed in brackets after the questions.
185 You can hit Control-C at any time to quit, but if you do so at a
186 prompt, you may have to hit return. Also, quitting in the middle of
187 installation may leave your system in an inconsistent state.
192 md_not_going_to_install() {
193 cat << \__not_going_to_install_1
195 OK, then. Enter `halt' at the prompt to halt the machine. Once the
196 machine has halted, power-cycle the system to load new boot code.
198 Note: If you wish to have another try. Just type '^D' at the prompt. After
199 a moment, the installer will restart itself.
201 __not_going_to_install_1
206 if [ "$MODE" = "install" ]; then
211 cat << __congratulations_1
213 CONGRATULATIONS! You have successfully $what NetBSD!
214 To boot the installed system, enter halt at the command prompt. Once the
215 system has halted, reset the machine and boot from the disk.
217 Note: If you wish to have another try. Just type '^D' at the prompt. After
218 a moment, the installer will restart itself.
224 # This is largely a copy of install_disk and install_from_mounted_fs()
225 # with some special frobbing.
232 if [ "$MODE" = "install" ]; then
233 echo -n "Adding keymap initialization to rc.local..."
234 echo /usr/sbin/loadkmap ${__keymap__} >> /mnt/etc/rc.local
238 if [ -e /netbsd ]; then
239 if [ -e /mnt/netbsd ]; then
240 echo "On the installation filesystem there is this kernel: "
242 echo "The already installed kernel is: "
244 echo "Do you want to replace the already installed kernel by the kernel"
245 echo -n "on the installation filesystem? (y/n) [n] "
248 if [ "${resp}" != "y" -a "${resp}" != "Y" ]; then
253 echo -n "Copying kernel..."
254 cp -p /netbsd /mnt/netbsd
259 cat << \__md_copy_kernel_1
260 Your installation set did not include a netbsd kernel on the installation
261 filesystem. You are now given the opportunity install it from either the
262 kernel-floppy from the distribution or another location on one of your disks.
264 The following disk devices are installed on your system; please select
265 the disk device containing the partition with the netbsd kernel:
268 _DKDEVS=`md_get_diskdevs`
272 _DKDEVS="$_DKDEVS fd0" # Might be on the kernel floppy!
273 echo -n "Which is the disk with the kernel? [abort] "
275 if mount_a_disk ; then
276 return # couldn't mount the disk
279 # Get the directory where the file lives
280 resp="" # force one iteration
281 while [ "X${resp}" = X"" ]; do
282 echo "Enter the directory relative to the mount point that"
283 echo -n "contains the file. [${_directory}] "
284 getresp "${_directory}"
288 _sets=`(cd /mnt2/$_directory; ls netbsd* 2> /dev/null)`
289 if [ -z "$_sets" ]; then
290 echo "There are no NetBSD kernels available in \"$1\""
291 umount -f /mnt2 > /dev/null 2>&1
295 echo "The following kernels are available:"
298 for _f in $_sets ; do
303 echo -n "File name [$1]? "
306 _filename="/mnt2/$_directory/$_f"
309 if [ ! -f $_filename ]; then
310 echo "File $_filename does not exist. Check to make"
311 echo "sure you entered the information properly."
312 echo -n "Do you want to retry [y]? "
314 if [ "$resp" = "n" ]; then
324 umount -f /mnt2 > /dev/null 2>&1
329 test -h $1 && return 1
330 test -f $1 || return 1
332 [ "`dd if=$1 bs=1 skip=1 count=3 2> /dev/null`" = "ELF" ] && return 1
340 for f in $root/usr/lib/lib*.so.[0-9]*.[0-9]* ; do
341 md_lib_is_aout $f || continue
342 mv -f $f $root/emul/aout/usr/lib || return 1
347 md_x_shlib_set_14=" \
366 for f in $md_x_shlib_set_14; do
367 md_lib_is_aout $root/$xlibdir/$f || continue
368 mv -f $root/$xlibdir/$f $root/emul/aout/$xlibdir || return 1
377 root=/mnt # XXX - should be global
379 if [ -d $root/emul/aout/. ]; then
380 echo "Using existing /emul/aout directory"
382 echo "Creating /emul/aout hierachy"
383 mkdir -p $root/usr/aout || return 1
385 if [ ! -d $root/emul ]; then
386 mkdir $root/emul || return 1
389 if [ -h $root/emul/aout ]; then
390 echo "Preserving existing symbolic link from /emul/aout"
391 mv -f $root/emul/aout $root/emul/aout.old || return 1
394 ln -s ../usr/aout $root/emul/aout || return 1
397 # Create /emul/aout/etc and /emul/aout/usr/lib
398 if [ ! -d $root/emul/aout/etc ]; then
399 mkdir $root/emul/aout/etc || return 1
401 if [ ! -d $root/emul/aout/usr/lib ]; then
402 mkdir -p $root/emul/aout/usr/lib || return 1
406 if [ -f $root/etc/ld.so.conf ]; then
407 mv -f $root/etc/ld.so.conf $root/emul/aout/etc || return 1
410 # Finally, move the aout shared libraries from /usr/lib
411 md_mv_usr_lib $root || return 1
413 # If X11 is installed, move the those libraries as well
414 xlibdir="/usr/X11R6/lib"
415 if [ -d $root/$xlibdir/. ]; then
416 mkdir -p $root/emul/aout/$xlibdir || return 1
417 md_mv_x_lib $root $xlibdir || return 1
420 echo "a.out emulation environment setup completed."
426 This release uses the ELF binary object format. Existing (a.out) binaries
427 can still be used on your system after it has been upgraded, provided
428 that the shared libraries needed by those binaries are made available
429 in the filesystem hierarchy rooted at /emul/aout.
431 This upgrade procedure will now establish this hierarchy by moving all
432 shared libraries in a.out format found in /usr/lib to /emul/aout/usr/lib.
433 It will also move the X11 shared libraries in a.out format from previous
434 NetBSD/amiga X11 installation sets, if they are installed.
438 echo "Failed to setup a.out emulation environment"
444 # Flag to notify upgrade.sh of the existence of md_prepare_upgrade()
445 md_upgrade_prep_needed=1