[now with the patch attached :) ] On Vi, 06 dec 19, 15:17:37, Jonas Smedegaard wrote: > Hi Andrei, > > Quoting Andrei POPESCU (2019-12-06 14:45:11) > > Currently any changes done to /boot/extlinux/extlinux.conf will be > > overwritten on the next kernel update. > > > > It would be nice to have some mechanism to include custom entries. In > > my case I need an entry with a different root partition (to boot a > > different install). > > > > One idea would be to have a U_BOOT_CUSTOM configuration variable to > > specify a file to be included as is. > > > > If you think the idea is good I might be able to come up with a patch > > for it. > > I like the idea, and welcome a draft patch!
Ok, attached a patch against u-boot-menu on Salsa/debian implementing this. Comments welcome :) Kind regards, Andrei -- http://wiki.debian.org/FAQsFromDebianUser
From c36cbdd65e3bc9c4c6dc41fceda5463d52dcf5d7 Mon Sep 17 00:00:00 2001 From: Andrei POPESCU <andreimpope...@gmail.com> Date: Sun, 8 Dec 2019 11:53:36 +0200 Subject: [PATCH] Add option to append one or more custom entries from an external file This patch adds a new option U_BOOT_CUSTOM_ENTRIES to specify an external file to be appended to extlinux.conf. default: Add the new option commented out, with a suggested filename. u-boot-update: Do some basic checks on the file (exists, regular file, readable, non-zero length). Issue a warning in case the file is not owned by root, but don't error out (the sysadmin may have good reasons for that). u-boot-update.8: Document the new option in the manpage, including some safety/security warnings. --- default | 1 + u-boot-update | 35 +++++++++++++++++++++++++++++++++++ u-boot-update.8 | 2 ++ 3 files changed, 38 insertions(+) diff --git a/default b/default index 4389a87..7e6804d 100644 --- a/default +++ b/default @@ -11,4 +11,5 @@ #U_BOOT_TIMEOUT="50" #U_BOOT_FDT="" #U_BOOT_FDT_DIR="/usr/lib/linux-image-" +#U_BOOT_CUSTOM_ENTRIES="/etc/default/u-boot-custom" diff --git a/u-boot-update b/u-boot-update index 2bf151b..9302f7a 100755 --- a/u-boot-update +++ b/u-boot-update @@ -216,5 +216,40 @@ done _NUMBER="" +# Append custom entries if any +if [ -n "${U_BOOT_CUSTOM_ENTRIES}" ] + then + if [ ! -f "${U_BOOT_CUSTOM_ENTRIES}" ] + then + echo 'E: The file '"${U_BOOT_CUSTOM_ENTRIES}"' does not exist or is not a regular file' + exit 1 + fi + + if [ ! -r "${U_BOOT_CUSTOM_ENTRIES}" ] + then + echo 'E: The file '"${U_BOOT_CUSTOM_ENTRIES}"' is unreadable' + exit 1 + fi + + if [ ! -s "${U_BOOT_CUSTOM_ENTRIES}" ] + then + echo 'E: The file '"${U_BOOT_CUSTOM_ENTRIES}"' is empty' + exit 1 + fi + + if [ ! -O "${U_BOOT_CUSTOM_ENTRIES}" ] + then + echo 'W: The file '"${U_BOOT_CUSTOM_ENTRIES}"' is NOT owned by root' + fi + + echo 'P: Appending custom entries from '"${U_BOOT_CUSTOM_ENTRIES}"'...' + + # Writing custom entries + _CONFIG="${_CONFIG} + +$(< "${U_BOOT_CUSTOM_ENTRIES}") +" +fi + Update "${_U_BOOT_DIRECTORY}/extlinux.conf" "${_CONFIG}" diff --git a/u-boot-update.8 b/u-boot-update.8 index 3397bc8..7c209b4 100644 --- a/u-boot-update.8 +++ b/u-boot-update.8 @@ -26,6 +26,8 @@ This variable specifies additional boot parameters that are appended to each ker This variable specifies the root partition. It is automatically extracted from /etc/fstab. U\-BOOT supports both devices and UUIDs. .IP "U_BOOT_TIMEOUT=""\fB50\fR""" 4 This variable specifies the time that U\-BOOT should wait for user input during boot. Values are in decisecond greater than 0 (e.g. '10' for a 1 second timeout), 0 specifies to wait forever. The default is 50. +.IP "U_BOOT_CUSTOM_ENTRIES=""/path/to/file""" 4 +This variable specifies the name of a file containing one or more custom entries. The file is appended \fBas is\fR, without any checks for validity or safety. For security reasons the file should not be writable to untrusted users as it can be used to gain root access to the system (e.g. by adding a boot entry with "init=/bin/sh" as kernel parameter). u\-boot\-update will issue a warning if the file is not owned by root. .SH FILES /etc/default/u-boot -- 2.20.1
signature.asc
Description: PGP signature