|
18 | 18 | # (A) Kernel .deb mode (recommended / upstream-friendly) |
19 | 19 | # - Provide a Debian kernel package (.deb) as input. |
20 | 20 | # - The script extracts the .deb via `dpkg-deb -R` into a temp directory. |
21 | | -# - DTBs are expected to be present under: |
22 | | -# $DEB_DIR/usr/lib/firmware/$BASE_KERNEL_VERSION/device-tree (usrmerge layout) |
23 | | -# $DEB_DIR/lib/firmware/$BASE_KERNEL_VERSION/device-tree (legacy layout) |
24 | | -# where $BASE_KERNEL_VERSION can be anything. |
25 | | -# - The script assumes there is exactly ONE device-tree directory across |
26 | | -# both search paths. |
| 21 | +# - DTBs are located by probing the following paths in order: |
| 22 | +# 1. $DEB_DIR/usr/lib/linux-image-*/ (Debian standard — direct, no symlink) |
| 23 | +# 2. $DEB_DIR/usr/lib/firmware/*/device-tree (Ubuntu compat, usrmerge layout) |
| 24 | +# 3. $DEB_DIR/lib/firmware/*/device-tree (Ubuntu compat, legacy layout) |
| 25 | +# Probing the Debian standard path first ensures correct operation on |
| 26 | +# both Debian and Ubuntu regardless of whether the compat symlink exists. |
| 27 | +# - The script assumes there is exactly ONE matching directory. |
27 | 28 | # |
28 | 29 | # (B) DTB source directory mode (dev/kernel-tree mode) |
29 | 30 | # - Provide the DTB source directory directly (e.g. a kernel build tree): |
@@ -171,10 +172,11 @@ usage() { |
171 | 172 | cat <<EOF |
172 | 173 | Usage: $0 (--kernel-deb <kernel.deb> | --dtb-src <path>) --manifest <file> [--size <MB>] [--out <file>] |
173 | 174 |
|
174 | | - --kernel-deb, -kernel-deb Path to Debian kernel package (.deb). DTBs read from: |
175 | | - <extract>/usr/lib/firmware/*/device-tree (usrmerge layout) |
176 | | - <extract>/lib/firmware/*/device-tree (legacy layout) |
177 | | - Exactly one device-tree directory must be found. |
| 175 | + --kernel-deb, -kernel-deb Path to Debian kernel package (.deb). DTBs located by probing: |
| 176 | + 1. <extract>/usr/lib/linux-image-*/ (Debian standard) |
| 177 | + 2. <extract>/usr/lib/firmware/*/device-tree (Ubuntu, usrmerge) |
| 178 | + 3. <extract>/lib/firmware/*/device-tree (Ubuntu, legacy) |
| 179 | + Exactly one directory must be found across all search paths. |
178 | 180 |
|
179 | 181 | --dtb-src, -dtb-src Path to DTB source directory |
180 | 182 | (e.g. arch/arm64/boot/dts/qcom) |
@@ -364,19 +366,27 @@ if [[ -n "${KERNEL_DEB}" ]]; then |
364 | 366 | echo "[INFO] Extracting kernel .deb to: ${DEB_DIR}" |
365 | 367 | dpkg-deb -R "${KERNEL_DEB}" "${DEB_DIR}" |
366 | 368 |
|
367 | | - # Locate exactly one device-tree directory. |
368 | | - # Modern packages (usrmerge / pkg-linux-qcom) install the compat symlink under |
369 | | - # usr/lib/firmware/<KVER>/device-tree; legacy packages used lib/firmware/. |
370 | | - # Check usr/lib/firmware/ first; fall back to lib/firmware/. |
| 369 | + # Locate the DTB directory from the extracted .deb. |
| 370 | + # Probe in order (most to least preferred): |
| 371 | + # 1. usr/lib/linux-image-*/ — Debian standard install location (direct, no symlink). |
| 372 | + # Works on both Debian and Ubuntu regardless of usrmerge. |
| 373 | + # 2. usr/lib/firmware/*/device-tree — Ubuntu compat symlink (usrmerge layout). |
| 374 | + # 3. lib/firmware/*/device-tree — Ubuntu compat symlink (legacy layout). |
| 375 | + # Searching the Debian standard path first avoids any dependency on the Ubuntu |
| 376 | + # compat symlink and is correct on pure Debian systems that never install it. |
371 | 377 | shopt -s nullglob |
372 | | - dt_dirs=( "${DEB_DIR}/usr/lib/firmware"/*/device-tree ) |
| 378 | + dt_dirs=( "${DEB_DIR}/usr/lib/linux-image-"*/ ) |
| 379 | + if (( ${#dt_dirs[@]} == 0 )); then |
| 380 | + dt_dirs=( "${DEB_DIR}/usr/lib/firmware"/*/device-tree ) |
| 381 | + fi |
373 | 382 | if (( ${#dt_dirs[@]} == 0 )); then |
374 | 383 | dt_dirs=( "${DEB_DIR}/lib/firmware"/*/device-tree ) |
375 | 384 | fi |
376 | 385 | shopt -u nullglob |
377 | 386 |
|
378 | 387 | if (( ${#dt_dirs[@]} == 0 )); then |
379 | 388 | echo "[ERROR] No DTB directory found under:" >&2 |
| 389 | + echo " '${DEB_DIR}/usr/lib/linux-image-*/'" >&2 |
380 | 390 | echo " '${DEB_DIR}/usr/lib/firmware/*/device-tree'" >&2 |
381 | 391 | echo " '${DEB_DIR}/lib/firmware/*/device-tree'" >&2 |
382 | 392 | exit 1 |
|
530 | 540 | if (( dtb_count == 0 )); then |
531 | 541 | echo "[ERROR] No DTB files found under ${DTB_SRC}" >&2 |
532 | 542 | echo " Verify the kernel package was built with DTB support" >&2 |
533 | | - echo " and that usr/lib/firmware/*/device-tree resolves correctly." >&2 |
| 543 | + echo " and that usr/lib/linux-image-*/ is present in the package." >&2 |
534 | 544 | exit 1 |
535 | 545 | fi |
536 | 546 | echo "[INFO] Staged ${dtb_count} DTB file(s) to ${DTB_STAGE}" |
|
0 commit comments