From d45906bc1aed4c777448b56f9c90b2a3d6d7cbe6 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Wed, 6 Feb 2008 11:49:35 -0300 Subject: [PATCH] Introduced lib/boot/boot.in as a wrapper to the boot code of the active bootloaders, handling extensions from the architecture and overloads from the target. --- lib/boot/boot.in | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lib/boot/boot.in diff --git a/lib/boot/boot.in b/lib/boot/boot.in new file mode 100644 index 0000000..e997cb3 --- /dev/null +++ b/lib/boot/boot.in @@ -0,0 +1,49 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: lib/boot/boot.in +# Copyright (C) 2008 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + +# by default we will peek the first suitable bootloader found +# +boot_choose_bootloader() { head -n 1; } + +# variables +# +bootloader= + +# load stuff from the architecture, if anything to load. +[ ! -s "architecture/$arch/boot.in" ] || . "architecture/$arch/boot.in" +# and allow targets to overload these functions and variables +[ ! -s "target/$target/boot.in" ] || . "target/$target/boot.in" + + +# if the target didn't choose one already, find the suitables and choose one +if [ -z "$bootloader" ]; then + bootloader="$( + ls -1d `sed -n -e 's,^X [^ ]\+ [^ ]\+ \([^ ]\+\) \([^ ]\+\) .* BOOT .*,package/\1/\2/boot/boot.in,p' \ + "config/$config/packages"` 2> /dev/null | + cut -d/ -f'2,3' | boot_choose_bootloader )" +fi + +# validate the module, and source. +# +if [ -z "$bootloader" ]; then + echo_error "boot: couldn't find any suitable bootloader." + exit 1 +elif [ ! -e "package/$bootloader/boot/boot.in" ]; then + echo_error "boot: '$bootloader' is not suitable." +else + echo_status "boot: using $bootloader." +fi + +. "package/$bootloader/boot/boot.in" +