xref: /netbsd/distrib/sparc/install.md (revision bf9ec67e)
1#	$NetBSD: install.md,v 1.18 2002/05/07 12:27:26 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
44MDSETS="kern xbase xcomp xcontrib xfont xserver"
45
46if [ "$MODE" = upgrade ]; then
47	RELOCATED_FILES_13="${RELOCATED_FILES_13} /usr/sbin/installboot /usr/mdec/installboot"
48fi
49
50md_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
60md_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
69FATAL 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
79md_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
84md_get_cddevs() {
85	# return available CDROM devices
86	dmesg | sed -n -e 's/^\(cd[0-9]\) .*/\1/p' | sort -u
87}
88
89md_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
94md_get_partition_range() {
95    # return range of valid partition letters
96    echo "[a-h]"
97}
98
99md_installboot() {
100	# $1 is the boot disk
101	echo "Installing boot block..."
102	cp -p /usr/mdec/boot /mnt/boot
103	/usr/sbin/installboot -v /dev/r${1}a /usr/mdec/bootxx /boot
104}
105
106md_native_fstype() {
107}
108
109md_native_fsopts() {
110}
111
112md_checkfordisklabel() {
113	# $1 is the disk to check
114	local rval
115	local cfdl
116
117	cfdl=`disklabel $1 2>&1 > /dev/null | \
118	    sed -n -e '/no disk label/{s/.*/ndl/p;q;}; \
119		 /disk label corrupted/{s/.*/dlc/p;q;}; \
120		 $s/.*/no/p'`
121	if [ x$cfdl = xndl ]; then
122		rval=1
123	elif [ x$cfdl = xdlc ]; then
124		rval=2
125	else
126		rval=0
127	fi
128
129	return $rval
130}
131
132md_prep_disklabel()
133{
134	local _disk
135
136	_disk=$1
137	md_checkfordisklabel $_disk
138	case $? in
139	0)
140		echo -n "Do you wish to edit the disklabel on $_disk? [y]"
141		;;
142	1)
143		echo "WARNING: Disk $_disk has no label"
144		echo -n "Do you want to create one with the disklabel editor? [y]"
145		;;
146	2)
147		echo "WARNING: Label on disk $_disk is corrupted"
148		echo -n "Do you want to try and repair the damage using the disklabel editor? [y]"
149		;;
150	esac
151
152	getresp "y"
153	case "$resp" in
154	y*|Y*) ;;
155	*)	return ;;
156	esac
157
158	# display example
159	cat << \__md_prep_disklabel_1
160
161Here is an example of what the partition information will look like once
162you have entered the disklabel editor. Disk partition sizes and offsets
163are in sector (most likely 512 bytes) units. Make sure these size/offset
164pairs are on cylinder boundaries (the number of sector per cylinder is
165given in the `sectors/cylinder' entry, which is not shown here).
166
167Do not change any parameters except the partition layout and the label name.
168It's probably also wisest not to touch the `8 partitions:' line, even
169in case you have defined less than eight partitions.
170
171[Example]
1728 partitions:
173#        size   offset    fstype   [fsize bsize   cpg]
174  a:    50176        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 111)
175  b:    64512    50176      swap                        # (Cyl.  112 - 255)
176  c:   640192        0   unknown                        # (Cyl.    0 - 1428)
177  d:   525504   114688    4.2BSD     1024  8192    16   # (Cyl.  256 - 1428)
178[End of example]
179
180__md_prep_disklabel_1
181	echo -n "Press [Enter] to continue "
182	getresp ""
183	disklabel -W ${_disk}
184	if [ -f /usr/bin/vi ]; then
185		disklabel -e ${_disk}
186	else
187		disklabel -i ${_disk}
188	fi
189}
190
191md_copy_kernel() {
192	if [ ! -f /mnt/netbsd ]; then
193		echo -n "WARNING: No kernel installed; "
194		if [ -f /netbsd ]; then
195			echo -n "copying miniroot kernel... "
196			cp -p /netbsd /mnt/netbsd
197			echo "done."
198		else
199			echo -n "install a kernel manually."
200		fi
201	fi
202}
203
204md_welcome_banner() {
205{
206	if [ "$MODE" = "install" ]; then
207		echo ""
208		echo "Welcome to the NetBSD/sparc ${VERSION} installation program."
209		cat << \__welcome_banner_1
210
211This program is designed to help you put NetBSD on your disk,
212in a simple and rational way.  You'll be asked several questions,
213and it would probably be useful to have your disk's hardware
214manual, the installation notes, and a calculator handy.
215__welcome_banner_1
216
217	else
218		echo ""
219		echo "Welcome to the NetBSD/sparc ${VERSION} upgrade program."
220		cat << \__welcome_banner_2
221
222This program is designed to help you upgrade your NetBSD system in a
223simple and rational way.
224
225As a reminder, installing the `etc' binary set is NOT recommended.
226Once the rest of your system has been upgraded, you should manually
227merge any changes to files in the `etc' set into those files which
228already exist on your system.
229__welcome_banner_2
230	fi
231
232cat << \__welcome_banner_3
233
234As with anything which modifies your disk's contents, this
235program can cause SIGNIFICANT data loss, and you are advised
236to make sure your data is backed up before beginning the
237installation process.
238
239Default answers are displayed in brackets after the questions.
240You can hit Control-C at any time to quit, but if you do so at a
241prompt, you may have to hit return.  Also, quitting in the middle of
242installation may leave your system in an inconsistent state.
243
244__welcome_banner_3
245} | more
246}
247
248md_not_going_to_install() {
249	cat << \__not_going_to_install_1
250
251OK, then.  Enter `halt' at the prompt to halt the machine.  Once the
252machine has halted, power-cycle the system to load new boot code.
253
254__not_going_to_install_1
255}
256
257md_congrats() {
258	local what;
259	if [ "$MODE" = "install" ]; then
260		what="installed";
261	else
262		what="upgraded";
263	fi
264	cat << __congratulations_1
265
266CONGRATULATIONS!  You have successfully $what NetBSD!
267To boot the installed system, enter halt at the command prompt. Once the
268system has halted, reset the machine and boot from the disk.
269
270__congratulations_1
271}
272
273md_lib_is_aout() {
274	local r
275	test -h $1 && return 1
276	test -f $1 || return 1
277
278	r=`file $1 | sed -n -e '/ELF/p'`
279	test -z "$r" || return 1
280	return 0
281}
282
283
284md_mv_usr_lib() {
285	local root
286	root=$1
287	for f in $root/usr/lib/lib*.so.[0-9]*.[0-9]* ; do
288		md_lib_is_aout $f || continue
289		mv -f $f $root/emul/aout/usr/lib || return 1
290	done
291	return 0
292}
293
294md_x_shlib_set_14=" \
295	libICE.so.6.3 \
296	libPEX5.so.6.0 \
297	libSM.so.6.0 \
298	libX11.so.6.1 \
299	libXIE.so.6.0 \
300	libXaw.so.6.1 \
301	libXext.so.6.3 \
302	libXi.so.6.0 \
303	libXmu.so.6.0 \
304	libXp.so.6.2 \
305	libXt.so.6.0 \
306	libXtst.so.6.1 \
307	liboldX.so.6.0"
308
309md_mv_x_lib() {
310	local root xlibdir
311	root=$1
312	xlibdir=$2
313	for f in $md_x_shlib_set_14; do
314		md_lib_is_aout $root/$xlibdir/$f || continue
315		mv -f $root/$xlibdir/$f $root/emul/aout/$xlibdir || return 1
316	done
317	return 0
318}
319
320md_mv_aout_libs()
321{
322	local root xlibdir
323
324	root=/mnt	# XXX - should be global
325
326	if [ -d $root/emul/aout/. ]; then
327		echo "Using existing /emul/aout directory"
328	else
329		echo "Creating /emul/aout hierachy"
330		mkdir -p $root/usr/aout || return 1
331
332		if [ ! -d $root/emul ]; then
333			mkdir $root/emul || return 1
334		fi
335
336		if [ -h $root/emul/aout ]; then
337			echo "Preserving existing symbolic link from /emul/aout"
338			mv -f $root/emul/aout $root/emul/aout.old || return 1
339		fi
340
341		ln -s ../usr/aout $root/emul/aout || return 1
342	fi
343
344	# Create /emul/aout/etc and /emul/aout/usr/lib
345	if [ ! -d $root/emul/aout/etc ]; then
346		mkdir $root/emul/aout/etc || return 1
347	fi
348	if [ ! -d $root/emul/aout/usr/lib ]; then
349		mkdir -p $root/emul/aout/usr/lib || return 1
350	fi
351
352	# Move ld.so.conf
353	if [ -f $root/etc/ld.so.conf ]; then
354		mv -f $root/etc/ld.so.conf $root/emul/aout/etc || return 1
355	fi
356
357	# Finally, move the aout shared libraries from /usr/lib
358	md_mv_usr_lib $root || return 1
359
360	# If X11 is installed, move the those libraries as well
361	xlibdir="/usr/X11R6/lib"
362	if [ -d $root/$xlibdir/. ]; then
363		mkdir -p $root/emul/aout/$xlibdir || return 1
364		md_mv_x_lib $root $xlibdir || return 1
365	fi
366
367	echo "a.out emulation environment setup completed."
368}
369
370md_prepare_upgrade()
371{
372cat << 'EOF'
373This release uses the ELF binary object format. Existing (a.out) binaries
374can still be used on your system after it has been upgraded, provided
375that the shared libraries needed by those binaries are made available
376in the filesystem hierarchy rooted at /emul/aout.
377
378This upgrade procedure will now establish this hierarchy by moving all
379shared libraries in a.out format found in /usr/lib to /emul/aout/usr/lib.
380It will also move the X11 shared libraries in a.out format from previous
381NetBSD/sparc X11 installation sets, if they are installed.
382
383EOF
384	md_mv_aout_libs || {
385		echo "Failed to setup a.out emulation environment"
386		return 1
387	}
388	return 0
389}
390
391# Flag to notify upgrade.sh of the existence of md_prepare_upgrade()
392md_upgrade_prep_needed=1
393