build-dtb-image: recurse vendor subdirs and prefer Debian standard DTB path with usrmerge fallback; build-rootfs: bypass zz-update-grub systemd guard in chroot#133
Merged
bjordiscollaku merged 4 commits intomainfrom Apr 14, 2026
Conversation
a6f0307 to
dd9d3f1
Compare
a5f5a8f to
03c46c0
Compare
The FIT image build path used a flat glob to collect DTBs from the
resolved source directory:
cp -rap "${DTB_SRC}"/*.dtb* "${DTB_STAGE}/"
This assumes all DTB files reside directly in DTB_SRC. In practice,
DTBs are always installed one level deeper under a vendor subdirectory:
lib/firmware/<KVER>/device-tree/qcom/*.dtb
When --kernel-deb is used, DTB_SRC resolves to the device-tree
directory (a symlink to usr/lib/linux-image-<KVER>/). The glob
expands to nothing because the DTBs are in qcom/, not at the top
level, causing the build to fail:
cp: cannot stat '.../device-tree/*.dtb*': No such file or directory
Replace the flat glob with find -L, which follows symlinks and
recurses into all vendor subdirectories, copying every *.dtb and
*.dtbo file flat into the mkimage staging directory
(arch/arm64/boot/dts/qcom/) as the ITS file expects.
Also add a post-copy count check and a sorted DTB listing so that
an empty or misconfigured DTB source is caught early with a clear
diagnostic rather than a cryptic mkimage FATAL ERROR.
Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
The /etc/kernel/postinst.d/zz-update-grub hook (grub-common) guards its update-grub call with a systemd check: if [ -d /run/systemd/system ]; then update-grub || true; fi In a chroot environment systemd is not running, so /run/systemd/system does not exist and update-grub is silently skipped. This left /boot/grub/grub.cfg absent, causing the subsequent sed-based GRUB cleanup to fail with: sed: can't read /boot/grub/grub.cfg: No such file or directory The build-kernel-deb.sh-generated package calls update-grub directly in its postinst (unconditionally), so it was unaffected. The pkg-linux-qcom package follows the Debian standard of delegating to postinst.d hooks, which exposed this chroot-specific gap. Fix: call update-grub explicitly in the chroot immediately after kernel installation, bypassing the systemd guard. No changes to the kernel package postinst — grub.cfg generation is the build script's responsibility in a chroot context. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
pkg-linux-qcom now installs the device-tree compat symlink under usr/lib/firmware/<KVER>/device-tree (usrmerge layout). Update the --kernel-deb DTB discovery to check usr/lib/firmware/ first and fall back to lib/firmware/ for legacy packages, so both layouts are handled transparently. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
… mode When extracting DTBs from a kernel .deb, probe paths in order: 1. usr/lib/linux-image-*/ (Debian standard — direct, no symlink) 2. usr/lib/firmware/*/device-tree (Ubuntu compat, usrmerge layout) 3. lib/firmware/*/device-tree (Ubuntu compat, legacy layout) Probing the Debian standard path first avoids any dependency on the Ubuntu compat symlink and works correctly on pure Debian systems that never install it, as well as on Ubuntu regardless of usrmerge layout. The fallback chain is fully backward compatible: legacy packages (built by build-kernel-deb.sh) only populate lib/firmware/, so the script falls through steps 1 and 2 and resolves via step 3 as before. Signed-off-by: Bjordis Collaku <bcollaku@qti.qualcomm.com>
03c46c0 to
e5b64c7
Compare
keerthi-go
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Three independent failures surface when the CI pipeline switches from the
legacy
build-kernel-deb.sh-generated package to thepkg-linux-qcomDebian package (
linux-image-<KVER>-qcom) built viadebian/metadata.1 —
build-dtb-image.sh: flat glob misses DTBs in vendor subdirectoriesThe FIT image build path collected DTBs using a flat glob:
This assumes all DTB files reside directly in
DTB_SRC. In practice,DTBs are always installed one level deeper under a vendor subdirectory:
When
--kernel-debis used,DTB_SRCresolves to thedevice-treedirectory (a symlink to the Debian-standard install path
usr/lib/linux-image-<KVER>/). The glob expands to nothing and thebuild fails:
2 —
build-dtb-image.sh: device-tree directory not found in usrmerge packagespkg-linux-qcomnow installs thedevice-treecompat symlink underusr/lib/firmware/<KVER>/device-tree(required to fix broken symlinkresolution on usrmerge systems where
/lib → usr/lib). The previousdiscovery glob only searched
lib/firmware/*/device-tree:This expands to nothing for packages built with the updated
debian/rules,causing
--kernel-debmode to fail immediately after extraction.3 —
build-rootfs.sh:/boot/grub/grub.cfgnever created in chrootThe
pkg-linux-qcompostinst correctly follows the Debian standard ofdelegating bootloader updates to
/etc/kernel/postinst.dhooks. Thezz-update-grubhook (fromgrub-common) guards itsupdate-grubcallwith a systemd check:
In a chroot, systemd is not running, so
/run/systemd/systemdoes notexist and
update-grubis silently skipped —/boot/grub/grub.cfgisnever created. The subsequent
sed-based GRUB cleanup then fails:The
build-kernel-deb.sh-generated package calledupdate-grubunconditionally in its postinst, so it was unaffected.
Fix
1 —
build-dtb-image.sh: recursive DTB collectionReplace the flat glob with
find -L, which follows symlinks and recursesinto all vendor subdirectories, copying every
*.dtband*.dtbofileflat into the
mkimagestaging directory (arch/arm64/boot/dts/qcom/),as the ITS file expects:
find -Lfollows symlinks transparently, so this works correctly whetherdevice-treeis a real directory or a relative directory symlink (asintroduced in pkg-linux-qcom#11).
A post-copy count check and sorted DTB listing are also added so that an
empty or misconfigured DTB source is caught early with a clear diagnostic
rather than a cryptic
mkimageFATAL ERROR:2 —
build-dtb-image.sh: Debian-standard-first DTB discoveryProbe paths in order, falling back only if the preferred path is absent:
Probing the Debian standard path first avoids any dependency on the Ubuntu
compat symlink and works correctly on pure Debian systems that never install
it. The fallback chain is fully backward compatible: legacy packages (built
by
build-kernel-deb.sh) only populatelib/firmware/, so the scriptfalls through steps 1 and 2 and resolves via step 3 as before.
3 —
build-rootfs.sh: explicitupdate-grubin chrootCall
update-grubexplicitly in the chroot immediately after kernelinstallation, bypassing the systemd guard.
build-rootfs.showns thechroot environment and is the right place to ensure
grub.cfgisgenerated — the kernel package postinst is intentionally unchanged:
Changes
kernel/scripts/build-dtb-image.sh: replacecp -rap *.dtb*flat globwith recursive
find -L+cploop in FIT image mode; add staged DTBcount check and listing; probe
usr/lib/linux-image-*/first (Debianstandard), then
usr/lib/firmware/*/device-tree(usrmerge), thenlib/firmware/*/device-tree(legacy) for full backward compatibilityrootfs/scripts/build-rootfs.sh: callupdate-grubexplicitly afterkernel
.debinstallation to ensure/boot/grub/grub.cfgis generatedin chroot environments where the
zz-update-grubsystemd guard skips itTesting