Allow packages to drop in files containing U-Boot commands to be executed by a
platform's bootscript before starting the OS. These files should be
dropped in /usr/share/flash-kernel/ubootenv.d. Users can add additional
stubs, or override stubs provided by packages, by adding files to
/etc/flash-kernel/ubootenv.d. Files in the /etc path that have the same
name as files in the /usr path will override the /usr counterparts.

Platform bootscripts must contain the @@UBOOT_ENV_EXTRA@@ macro for the
contents of these stubs to be incorporated.
---
 README      | 18 ++++++++++++++++++
 debian/dirs |  2 ++
 functions   | 14 ++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/README b/README
index 99e63a2..38d2953 100644
--- a/README
+++ b/README
@@ -172,6 +172,24 @@ Configuration files currently supported:
 * /etc/flash-kernel/db allows overriding / adding fields from the Machine
   database (but it doesn't allow removing fields or entries).
 
+* /etc/flash-kernel/ubootenv.d can be used to add or override u-boot
+  script snippets. See "Adding U-Boot Commands for Pre-Boot Execution"
+  below for more details.
+
 * /etc/default/flash-kernel currently contains a single variable,
   LINUX_KERNEL_CMDLINE, which should be used by bootscripts to set kernel
   options.
+
+
+Adding U-Boot Commands for Pre-Boot Execution
+- - - - - - - - - - - - - - - - - - - - - - -
+
+Packages can drop in files containing U-Boot commands to be executed by a
+platform's bootscript before starting the OS. These files should be
+dropped in /usr/share/flash-kernel/ubootenv.d. Users can add additional
+stubs, or override stubs provided by packages, by adding files to
+/etc/flash-kernel/ubootenv.d. Files in the /etc path that have the same
+name as files in the /usr path will override the /usr counterparts.
+
+Platform bootscripts must contain the @@UBOOT_ENV_EXTRA@@ macro for the
+contents of these stubs to be incorporated.
diff --git a/debian/dirs b/debian/dirs
index 236670a..2788a14 100644
--- a/debian/dirs
+++ b/debian/dirs
@@ -1 +1,3 @@
 usr/sbin
+etc/flash-kernel/ubootenv.d
+usr/share/flash-kernel/ubootenv.d
diff --git a/functions b/functions
index fc10684..58b7ad1 100644
--- a/functions
+++ b/functions
@@ -216,6 +216,19 @@ gen_kernel() {
        } >"$output"
 }
 
+gen_ubootenv() {
+       ENVSTUBDIRS="/etc/flash-kernel/ubootenv.d 
/usr/share/flash-kernel/ubootenv.d"
+       ENVSTUBS="$(find $ENVSTUBDIRS -type f -regex '.*/[0-9a-zA-Z_-]+' 
-printf '%f\n' | LC_ALL=C sort -u)"
+       for file in $ENVSTUBS; do
+               for dir in $ENVSTUBDIRS; do
+                       if [ -f $dir/$file ]; then
+                               cat $dir/$file
+                               break
+                       fi
+               done
+       done
+}
+
 append_dtb() {
        local kernel="$1"
        local dtb="$2"
@@ -293,6 +306,7 @@ mkimage_script() {
        printf "Generating boot script u-boot image... " >&2
        sed -e "s/@@KERNEL_VERSION@@/$kvers/g" \
             -e "s/@@LINUX_KERNEL_CMDLINE@@/$(get_kernel_cmdline)/g" \
+            -e "s/@@UBOOT_ENV_EXTRA@@/$(gen_ubootenv)/g" \
                < $sdata > $tdata
        mkimage -A arm -O linux -T script -C none -a "$saddr" -e "$saddr" \
                -n "$sdesc" -d "$tdata" "$script" >&2 1>/dev/null
-- 
2.0.0


-- 
To UNSUBSCRIBE, email to debian-arm-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
https://lists.debian.org/1401414889-16498-4-git-send-email-da...@debian.org

Reply via email to