Re: flash-kernel: handle DTBs in vendor subdir
* Ian Campbell <ijc@debian.org> [2016-07-31 10:20]:
> I've attached the two patches I had sitting in my branch here, they
> look sensible but I honestly can't remember what state they are in.
>
> AFAICT the main difference is that they preserve the directory layout
> rather than collapsing it. Not sure there is any particular reason to
> favour either way of doing it so feel free to either ignore or pickup
> these patches.
The boot script looks for dtbs/${fk_kvers}/${fdtfile} and $fdtfile
doesn't contain the vendor subdir, so I think this approach is wrong.
> One thing my patches handles which I'm not sure yours does is the pre-
> subdir-transition versions on ARM64, which my commit log says happened
> in v3.19-rc1. That might be important for backports and/or upgrades.
I looked at your other patch and I like the approach since it supports
the old and new way. Personally I found search_for_dtb_file_in_prefix
a bit hard to read and wonder if a simple 'find' might do.
What do you think of this approach? This no longer requires the
vendor subdir in DTB-Id. I think this is better since e.g. the RPi3
has the same device tree on 32 and 64 bit and I assume one will be in
a vendor subdir whereas the other won't be.
Any comments?
diff --git a/README b/README
index 02ba3fd..9458a23 100644
--- a/README
+++ b/README
@@ -115,9 +115,13 @@ The supported fields are:
This option is ignored if a DTB is to be appended, via either DTB-Append or
DTB-Append-From.
-* DTB-Id: (optional) specifies the name of the DTB file for this device. If
- the value begins with a `!' then the field is a script which should be run.
- The script must produce the DTB filename (and nothing else) on stdout.
+* DTB-Id: (optional) specifies the name of the DTB file for this device
+ relative to the kernel package DTB dir or /etc/flash-kernel/dtbs.
+ It's not necessary to specify the directory if the DTB is in a vendor
+ subdirectory as flash-kernel will search for the filename in
+ subdirectories. If the value begins with a `!' then the field is a script
+ which should be run. The script must produce the DTB filename (just the
+ filename, without a vendor subdirectory) on stdout (and nothing else).
* DTB-Append: (optional) when yes the DTB specified by DTB-Id will be appended
to the kernel image.
diff --git a/functions b/functions
index 0f597b8..f008515 100644
--- a/functions
+++ b/functions
@@ -241,6 +241,12 @@ get_dtb_name() {
;;
esac
if [ -n "$dtb_name" ] ; then
+ # DTBs on arm64 are stored in subdirs for each vendor; strip
+ # the dir away (in case someone specified it, although it's
+ # not needed).
+ # The DTB will be stored in /boot/dtbs/$kvers/ without
+ # additional subdirs.
+ dtb_name=$(basename $dtb_name)
echo "DTB: $dtb_name" >&2
fi
}
@@ -558,11 +564,11 @@ find_dtb_file() {
echo "$dtb_name"
;;
*)
- if [ -e "/etc/flash-kernel/dtbs/$dtb_name" ] ; then
- echo "/etc/flash-kernel/dtbs/$dtb_name"
- else
- echo "/usr/lib/linux-image-$kvers/$dtb_name"
+ local dtb=$(find /etc/flash-kernel/dtbs -name $dtb_name 2>/dev/null | head -n 1)
+ if [ -z "$dtb" ]; then
+ dtb=$(find /usr/lib/linux-image-$kvers -name $dtb_name 2>/dev/null | head -n 1)
fi
+ echo $dtb
;;
esac
}
@@ -597,8 +603,8 @@ handle_dtb() {
rmdir --ignore-fail-on-non-empty /boot/dtbs
fi
else
- if [ -e $dtb ]; then
- echo "Installing $dtb_name into /boot/dtbs/$kvers/$dtb_name" >&2
+ if [ -e "$dtb" ]; then
+ echo "Installing $dtb into /boot/dtbs/$kvers/$dtb_name" >&2
mkdir -p /boot/dtbs/$kvers/
cp "$dtb" "/boot/dtbs/$kvers/$dtb_name.new"
backup_and_install \
--
Martin Michlmayr
http://www.cyrius.com/
Reply to: