Hi,

That sounds like an interesting thing to have indeed, I actually started working on this a while ago but didn't have the time/incentive to push it further.

Attaching the (draft) patch I came up with in case it can help moving forward.

Cheers,
Arnaud
From 067706bcd903e17534f789b37976a4aa9267ede2 Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferra...@collabora.com>
Date: Tue, 14 Sep 2021 20:36:54 +0200
Subject: [PATCH] u-boot-update: honor /etc/kernel/cmdline

---
 u-boot-update   | 12 ++++++++++--
 u-boot-update.8 |  7 ++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/u-boot-update b/u-boot-update
index da92918..6f74965 100755
--- a/u-boot-update
+++ b/u-boot-update
@@ -90,9 +90,18 @@ U_BOOT_DEFAULT="${U_BOOT_DEFAULT:-l0}"
 U_BOOT_ENTRIES="${U_BOOT_ENTRIES:-all}"
 U_BOOT_TIMEOUT="${U_BOOT_TIMEOUT:-50}"
 U_BOOT_MENU_LABEL="${U_BOOT_MENU_LABEL:-${PRETTY_NAME:-Debian GNU/Linux kernel}}"
-U_BOOT_PARAMETERS="${U_BOOT_PARAMETERS:-ro quiet}"
 U_BOOT_FDT_DIR="${U_BOOT_FDT_DIR:-/usr/lib/linux-image-}"
 
+if [ -z "${U_BOOT_PARAMETERS}" ] && [ -f /etc/kernel/cmdline ]
+then
+	U_BOOT_PARAMETERS="$(cat /etc/kernel/cmdline | sed -e 's/root=[^[:space:]]*//' -e 's/^[[:space:]]*//')"
+	if [ -z "${U_BOOT_ROOT}" ]
+	then
+		U_BOOT_ROOT="$(cat /etc/kernel/cmdline | sed -re 's/.*(root=[^[:space:]]*).*/\1/')"
+	fi
+fi
+U_BOOT_PARAMETERS="${U_BOOT_PARAMETERS:-ro quiet}"
+
 # Find parameter for root from fstab
 if [ -z "${U_BOOT_ROOT}" ]
 then
@@ -230,4 +239,3 @@ done
 _NUMBER=""
 
 Update "${_U_BOOT_DIRECTORY}/extlinux.conf" "${_CONFIG}"
-
diff --git a/u-boot-update.8 b/u-boot-update.8
index 38f533b..66af9d1 100644
--- a/u-boot-update.8
+++ b/u-boot-update.8
@@ -78,9 +78,10 @@ Otherwise, it defaults to 'Debian GNU/Linux, kernel'.
 .IP "U_BOOT_PARAMETERS=""\fBro quiet\fR""" 4
 This variable specifies additional boot parameters
 that are appended to each kernel entry.
-Value is an arbitrary string,
-default is 'ro quiet'
-(except for recovery entries, where quiet is avoided).
+Value is an arbitrary string, default is the content
+of /etc/kernel/cmdline, or 'ro quiet'
+(except for recovery entries, where quiet is avoided) if
+this file is not present or empty.
 
 .IP "U_BOOT_ROOT=""\fBroot\fR=\fIDEVICE\fR""" 4
 This variable specifies the root partition.
-- 
2.35.1

Reply via email to