]> git.ozlabs.org Git - yaboot.git/blobdiff - ybin/yabootconfig
Prepare 1.3.8-rc4
[yaboot.git] / ybin / yabootconfig
index e94c4efc5796dbcc684ea40913eb2798342d8483..7554f33b85fd96fb79baac519a07d01ccb95ac13 100755 (executable)
@@ -3,7 +3,7 @@
 ###############################################################################
 ##
 ## yabootconfig generates a simple /etc/yaboot.conf
-## Copyright (C) 2001 Ethan Benson
+## Copyright (C) 2001, 2002 Ethan Benson
 ##
 ## This program is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU General Public License
@@ -27,15 +27,23 @@ if [ -n "$PATH_PREFIX" ] ; then
     PATH="${PATH}:${PATH_PREFIX}/sbin:${PATH_PREFIX}/bin:${PATH_PREFIX}/usr/sbin:${PATH_PREFIX}/usr/bin:${PATH_PREFIX}/usr/local/sbin:${PATH_PREFIX}/usr/local/bin"
 fi
 PRG="${0##*/}"
-VERSION=1.0.3
+VERSION=1.0.7-rc4
 CHROOT=/
 ## $CONFIG is relative to $CHROOT
 CONFIG=etc/yaboot.conf
 NOINSTALL=0
 QUIET=0
+DEBUG=0
 SIGINT="$PRG: Interrupt caught ... exiting"
 export LC_COLLATE=C
 
+## avoid older versions of ofpath shipped in debian boot-floppies etc.
+if [ -x "${PATH_PREFIX}/usr/sbin/ofpath" ] ; then
+    OFPATH="${PATH_PREFIX}/usr/sbin/ofpath"
+else
+    OFPATH=ofpath
+fi
+
 ## catch signals, clean up temporary file
 trap "cleanup" 0
 trap "exit 129" 1
@@ -77,7 +85,7 @@ echo \
 "$PRG $VERSION
 Written by Ethan Benson
 
-Copyright (C) 2001 Ethan Benson
+Copyright (C) 2001, 2002 Ethan Benson
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 }
@@ -101,6 +109,12 @@ Generate a working /etc/yaboot.conf.
   -V, --version              output version information and exit"
 }
 
+debug()
+{
+    [ "$DEBUG" = 0 ] && return 0
+    $PRINTF 1>&2 "$PRG: DEBUG: $1"
+}
+
 confirm()
 {
     $PRINTF \
@@ -153,6 +167,7 @@ ckmacfdisk()
        echo 1>&2 "$PRG: `command -v $FDISK`: Permission denied"
        return 1
     fi
+    debug "mac-fdisk is: $FDISK\n"
     return 0
 }
 
@@ -173,6 +188,7 @@ ckfdisk()
        echo 1>&2 "$PRG: `command -v $FDISK`: Permission denied"
        return 1
     fi
+    debug "fdisk is: $FDISK\n"
     return 0
 }
 
@@ -184,12 +200,16 @@ findbootblock()
        ckmacfdisk || return 1
        if [ "$FDISK" = pdisk ] ; then
            ## handle braindamaged pdisk
+           debug "dealing with pdisk deficiency...\n"
            BOOT="$(v=`$FDISK -l "$DISK" 2>/dev/null | grep '\<Apple_Bootstrap\>'` ; echo ${v%%:*})"
+           debug "BOOT before fixup: $BOOT\n"
            if [ -n "$BOOT" ] ; then
                BOOT="${DISK}${BOOT}"
            fi
+           debug "BOOT after fixup: $BOOT\n"
        else
            BOOT="$(v=`$FDISK -l "$DISK" 2>/dev/null | grep '\<Apple_Bootstrap\>'` ; echo ${v%%[ ]*})"
+           debug "BOOT=$BOOT\n"
        fi
        if [ -z "$BOOT" ] ; then
            echo 1>&2 "$PRG: Unable to locate bootstrap partition on $DISK..."
@@ -199,6 +219,7 @@ findbootblock()
     else
        ckfdisk || return 1
        BOOT="$(v=`$FDISK -l "$DISK" 2>/dev/null | grep '\<PPC PReP Boot\>'` ; echo ${v%%[ ]*})"
+       debug "BOOT=$BOOT\n"
        if [ -z "$BOOT" ] ; then
            echo 1>&2 "$PRG: Unable to locate bootstrap partition on $DISK..."
            echo 1>&2 "$PRG: You must create an 800K type: 0x41 PPC PReP Boot partition to make the disk bootable"
@@ -306,6 +327,10 @@ if [ $# != 0 ] ; then
                NOINSTALL=1
                shift 1
                ;;
+           --debug)
+               DEBUG=1
+               shift 1
+               ;;
             "")
                 break
                 ;;
@@ -357,7 +382,8 @@ fi
 ## find / device
 if [ -z "$ROOT" ] ; then
     ## IMPORTANT! that last substitution is [<space><tab>] thats all ash will grok
-    ROOT="$(v=`grep '[[:blank:]]/[[:blank:]]' ${CHROOT}etc/fstab` ; echo ${v%%[        ]*})"
+    ROOT="$(v=`grep '^[^#].*[[:blank:]]/[[:blank:]]' ${CHROOT}etc/fstab` ; echo ${v%%[         ]*})"
+    debug "ROOT=$ROOT\n"
     if [ -z "$ROOT" ] ; then
        echo 1>&2 "$PRG: Could not determine root partition, aborting..."
        exit 1
@@ -442,6 +468,8 @@ else
     exit 1
 fi
 
+debug "KERNEL=$KERNEL\n"
+
 ## get partition number the kernel lives on, and the OF device= name
 ## of the whole disk.
 KERNDEV="$(v=`df "$KERNEL" 2> /dev/null | grep ^/dev/` ; echo ${v%%[ ]*})"
@@ -455,10 +483,13 @@ else
     KERNELDISK="${KERNDEV%%[0-9]*}"
 fi
 
+debug "KERNEL=$KERNEL\nKERNDEV=$KERNDEV\nKERNDIR=$KERNDIR\nLINKDEV=$LINKDEV\nPARTITION=$PARTITION\nKERNELDISK=$KERNELDISK\n"
+
 ## sanity check
 for i in "$KERNDEV" "$KERNDIR" "$LINKDEV" "$PARTITION" "$KERNELDISK" ; do
     if [ -z "$i" ] ; then
        echo 1>&2 "$PRG: Could not determine necessary information, aborting..."
+       echo 1>&2 "$PRG: Are you using chroot $PRG instead of $PRG --chroot ?"
        exit 1
     fi
 done
@@ -477,18 +508,13 @@ fi
 
 ## only powermacs appear to need device=
 if (cat /proc/cpuinfo 2>/dev/null | grep -q pmac-generation 2> /dev/null) ; then
-    DEVICE="\ndevice=$(ofpath $KERNELDISK)"
+    DEVICE="\ndevice=$($OFPATH $KERNELDISK)"
     if [ $? != 0 ] ; then
        echo 1>&2 "$PRG: Unable to determine OpenFirmware device name to $KERNELDISK, aborting..."
        exit 1
     fi
 fi
 
-## IBM hardware needs fstype=raw for ybin
-if (cat /proc/cpuinfo 2>/dev/null | grep ^machine | grep -q 'CHRP IBM') ; then
-    FSTYPE="\nfstype=raw"
-fi
-
 ## if there is a separate /boot partition we must strip off the /boot
 ## mountpoint or else yaboot will not find the kernel.
 if [ "$KERNDIR" != "$CHROOT" ] ; then
@@ -544,6 +570,15 @@ if [ -n "$KERNARGS" ] ; then
     APPEND="\tappend=\"${KERNARGS}\"\n"
 fi
 
+## avoid user confusion when they boot an installer with video=ofonly
+## (usually via a install-safe label) and then reboot and have the box
+## not boot properly again.
+if [ -z "$APPEND" ] ; then
+    if (grep -q '\<video=ofonly\>' /proc/cmdline 2> /dev/null) ; then
+       APPEND="\tappend=\"video=ofonly\"\n"
+    fi
+fi
+
 ## generate global section of yaboot.conf
 GLOBAL="## yaboot.conf generated by $PRG $VERSION
 ##
@@ -551,7 +586,7 @@ GLOBAL="## yaboot.conf generated by $PRG $VERSION
 ${HEADER}##
 ## For a dual-boot menu, add one or more of: 
 ## bsd=/dev/hdaX, macos=/dev/hdaY, macosx=/dev/hdaZ\n
-boot=${BOOT}${FSTYPE:-}${DEVICE:-}
+boot=${BOOT}${DEVICE:-}
 partition=$PARTITION
 root=$ROOT
 timeout=30