Remove last remnants of the wd(4) driver which was moved to the Attic some
[dragonfly.git] / tools / tools / upgrade / doupgrade.sh
1 #!/bin/sh
2
3 # Simple helper script for upgrade target.
4
5 # Expects MACHINE to be passed in with the environment, the "pass number"
6 # as the first argument the name of the file to leave its droppings in
7 # as the second.  CURDIR is also passed in the environment from ${.CURDIR}
8 #
9 # $DragonFly: src/tools/tools/upgrade/Attic/doupgrade.sh,v 1.3 2005/02/26 12:00:55 swildner Exp $
10
11 PASS=$1
12 CONF=$2
13
14 cd ${CURDIR}/sys/${MACHINE}/conf
15
16 # Create kernel configuration file for pass #1
17 if [ $PASS -eq 1 ]; then
18         echo "The following files are in ${CURDIR}/sys/${MACHINE}/conf:"; echo
19         ls -C
20         echo; echo -n "Which config file do you wish to use? [GENERIC] "
21         read answer
22         if [ -z "${answer}" ]; then
23                 KERN=GENERIC
24         else
25                 KERN="${answer}"
26         fi
27         if [ ! -f ${KERN} ]; then
28                 KERN=GENERIC
29         fi
30         if ! grep -q atkbdc0 ${KERN}; then
31                 if [ ! -f ${KERN}.bkup ]; then
32                         cp ${KERN} ${KERN}.bkup
33                 fi
34                 sed -e 's/^device.*sc0.*$/ \
35 controller      atkbdc0 at isa? port IO_KBD tty \
36 device          atkbd0  at isa? tty irq 1 \
37 device          vga0    at isa? port ? conflicts \
38 device          sc0     at isa? tty \
39 pseudo-device   splash \
40 /' -e 's/sd\([0-9]\)/da\1/' -e 's/st\([0-9]\)/sa\1/' < ${KERN}.bkup > ${KERN}
41         fi
42
43         ROOTDEV=`awk '$2~/\/$/{print substr($1, 6, 3)}' /etc/fstab`
44         echo -n "What is your boot device (e.g. ad0 or sd0)? [${ROOTDEV}] "
45         read answer
46         if [ -n "${answer}" ]; then
47                 ROOTDEV="${answer}"
48         fi
49         echo "KERNEL=${KERN}" > ${CONF}
50         echo "ROOTDEV=${ROOTDEV}" >> ${CONF}
51         if ! file /kernel | grep -q ELF; then
52                 echo "NEWBOOT=YES" >> ${CONF}
53         fi
54 fi
55
56 # Build and install kernel as pass #2
57 if [ $PASS -eq 2 -a -f ${CONF} ]; then
58         . ${CONF}
59         if [ "x${NEWBOOT}" = "xYES" ]; then
60            echo "--------------------------------------------------------------"
61            echo " Installing new boot blocks"
62            echo "--------------------------------------------------------------"
63            if [ ! -f /boot/loader ]; then
64               (cd ${CURDIR}/lib/libstand; make obj; make -B depend all install)
65               (cd ${CURDIR}/sys/boot; make obj; make -B depend all install)
66            fi
67            if ! disklabel -B ${ROOTDEV}; then
68                 echo "Installation of new boot blocks failed!  Please correct"
69                 echo "this manually BEFORE you reboot your system!"
70                 exit 1
71            fi
72         fi
73         if ! file /kernel | grep -q ELF; then
74                 echo "--------------------------------------------------------------"
75                 echo " Building an elf kernel for ${KERNEL} using the new tools"
76                 echo "--------------------------------------------------------------"
77                 config -r ${KERNEL}
78                 cd ${CURDIR}/sys/compile/${KERNEL} && make -B depend -DFORCE all install
79         fi
80 fi