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