On Tue, 20 Sep 2022 16:28:38 +0200 Arnaud Ferraris
<aferra...@debian.org> wrote:
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.
Hmm, since this patch is about 1 year old, attaching the rebased version
so it applies seamlessly on current master.
Cheers,
Arnaud
Cheers,
Arnaud
From 03db7668f3c371a5a2d564ca14c9e671c6a754b3 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 69da211..41fd0de 100755
--- a/u-boot-update
+++ b/u-boot-update
@@ -90,12 +90,21 @@ 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-}"
U_BOOT_FDT_OVERLAYS="${U_BOOT_FDT_OVERLAYS:-}"
U_BOOT_FDT_OVERLAYS_DIR="${U_BOOT_FDT_OVERLAYS_DIR:-/boot/dtbo}"
U_BOOT_INITRD="${U_BOOT_INITRD:-initrd.img}"
+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
@@ -267,4 +276,3 @@ done
_NUMBER=""
Update "${_U_BOOT_DIRECTORY}/extlinux.conf" "${_CONFIG}"
-
diff --git a/u-boot-update.8 b/u-boot-update.8
index dfc3cd7..6536c6e 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