## define default configuration
boot=unconfigured
-## allow default to work on packaged and non-packaged yaboot.
+## allow default to work on packaged and non-packaged yaboot.
## no default for magicboot since it is not required everywhere.
if [ -f /usr/local/lib/yaboot/yaboot ] ; then
install=/usr/local/lib/yaboot/yaboot
## make fake `id' if its missing, outputs 0 since if its missing we
## are probably running on boot floppies and thus are root.
-if (command -v id > /dev/null 2>&1) ; then
+if (command -v id > /dev/null 2>&1) ; then
true
else
id()
-b, --boot set bootstrap partition device [ -b /dev/hda2 ]
-o, --ofboot set bootstrap partition OpenFirmware device
default: automatically determined [ -o hd:2 ]
+ --bootonce override default boot label for ONLY next boot
+ eg: --bootonce linux-2.6.20-testing
-i, --install pathname to the actual bootloader binary
default: /usr/{local/}lib/yaboot/yaboot same as
install= in config file [ -i bootloader_file ]
fi
local CONFERR=1
fi
-
+
if [ `echo ${#hfscreator}` != 4 ] ; then
if [ "$ARGCT" = 1 ] ; then
echo 1>&2 "$PRG: --creator must be 4 characters"
fi
## convert defaultos variable
- case "$defaultos" in
+ case "$defaultos" in
linux|Linux|GNU|Gnu|gnu)
defaultos=bootyaboot
;;
## This is gross, IBM CHRP OF needs a .note added to the yaboot
## binary, nobody knows whether this note will affect PowerMac OF or
-## not (or could in the future).
+## not (or could in the future).
hack_yaboot()
{
local YBDIR="${install%/*}"
## repoint magicboot as the real first stage loader if using the
## modern automatic generating ofboot.b.
- if [ -n "$FIRST" ] ; then
+ if [ -n "$FIRST" ] ; then
magicboot="$FIRST"
[ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: set magicboot to $FIRST"
fi
if [ "$protect" = yes ] ; then
local LOCK="+l"
fi
-
+
if [ "$hide" = yes ] ; then
local INVISIBLE="+i"
fi
mnt_install()
{
local BTFILE=yaboot
-
+
## msdosfs is broken, yaboot may not support this filename.
if [ "$fstype" = msdos ] ; then
local CFFILE=yaboot.cnf
}
## raw installation, for IBM RS/6000 hardware, yaboot is dded to the
-## bootstrap partition.
+## bootstrap partition.
raw_install()
{
## make sure the device is not mounted as a filesystem before
[ "$VERBOSE" = 1 ] && echo "$PRG: Creating DOS filesystem on $boot..."
if (command -v dd > /dev/null 2>&1) ; then
dd if=/dev/zero of="$boot" bs=512 count=1600 > /dev/null 2>&1
- fi
+ fi
mkdosfs -n bootstrap "$boot" > /dev/null
if [ $? != 0 ] ; then
echo 1>&2 "$PRG: DOS filesystem creation failed!"
## absurdly bloated case statement to parse command line options.
if [ $# != 0 ] ; then
while true ; do
- case "$1" in
+ case "$1" in
-V|--version)
version
exit 0
exit 1
fi
;;
+ --bootonce)
+ if [ -n "$2" ] ; then
+ bootonce="$2"
+ ARGS="$ARGS $1 $2"
+ shift 2
+ else
+ echo 1>&2 "$PRG: option requires an argument $1"
+ echo 1>&2 "Try \`$PRG --help' for more information."
+ exit 1
+ fi
+ ;;
-i|--install)
if [ -n "$2" ] ; then
install="$2"
## validate configuration for sanity.
checkconf || exit 1
+if [ "x$bootonce" != "x" ]; then
+ foundlabel=`sed s/\#.*// $bootconf | grep "label=$bootonce$" | wc -l`
+ if [ "$nonvram" = 0 ]; then
+ echo 1>&2 "$PRG: --bootonce specified, but nvsetenv not available."
+ exit 1
+ fi
+ if [ "$foundlabel" = 1 ]; then
+ nvsetenv boot-once "$bootonce"
+ foundlabel=`nvsetenv boot-once`
+ if [ "$foundlabel" != "boot-once=$bootonce" ]; then
+ echo 1>&2 "$PRG: Could not nvsetenv boot-once $bootonce"
+ exit 1
+ fi
+ [ "$VERBOSE" = 1 ] && echo "$PRG: nvsetenv boot-once $bootonce"
+ else
+ echo 1>&2 "$PRG: Could not find bootonce label [$bootonce] in $bootconf"
+ exit 1
+ fi
+fi
+
+bootparts=0
+
## check that we can use ofpath, its only needed for magicboot script
## building and nvram updates.
if [ -n "$magicboot" -o "$nonvram" = 0 ] ; then