build-dtb-image/build-kernel-deb: drop root requirement - #223
Open
Xinzheng Long (xinlon-z) wants to merge 2 commits into
Open
build-dtb-image/build-kernel-deb: drop root requirement#223Xinzheng Long (xinlon-z) wants to merge 2 commits into
Xinzheng Long (xinlon-z) wants to merge 2 commits into
Conversation
The script previously needed root because it used losetup + mount to write the combined DTB / FIT image into a FAT image. Replace that pipeline with mkfs.vfat formatting the image file directly and mcopy from mtools to populate it, which removes every privileged operation. Switch the kernel .deb extraction from `dpkg-deb -R` to `dpkg-deb --fsys-tarfile | tar -x --no-same-owner --no-same-permissions` so non-root extraction is reliable (dpkg-deb -R warns/fails on chown when not run as root). Drop the EUID guard, simplify the cleanup trap (no more umount / losetup -d / mountpoint), and remove the now-unused MNT_DIR / LOOP_DEV variables. The CLI is unchanged; existing callers that wrap the script in sudo continue to work -- sudo is now allowed but no longer required. Tooling change: Add mcopy (mtools) -- always Add tar -- only in --kernel-deb mode Remove losetup, mount, umount, mountpoint Signed-off-by: Xinzheng Long <xinzheng.long@oss.qualcomm.com>
The script previously self-elevated via `exec sudo "$0" "$@"`, but every operation it performs is local: it stages files under `$DEB_DIR` in the current working directory and runs `dpkg-deb --build`. None of those need root. Pass `--root-owner-group` to `dpkg-deb --build` so all entries in the resulting `.deb` are recorded as `root:root` regardless of the build user's uid/gid. This is the standard mechanism for building Debian packages without fakeroot or a real root shell, and matches what the postinst/preinst scripts assume at install time on the target. Drop the `EUID` guard and the self-sudo block. The CLI is unchanged; existing callers that wrap the script in sudo continue to work -- sudo is now allowed but no longer required. Verified by building a synthetic `out/` tree (Image, .config, modules, .dtb, .dtbo) and running the script as a normal user; `dpkg-deb --contents` on the resulting package shows every entry owned by `root/root`, and the preinst/postinst/postrm maintainer scripts are intact and executable. Signed-off-by: Xinzheng Long <xinzheng.long@oss.qualcomm.com>
Xinzheng Long (xinlon-z)
force-pushed
the
no-sudo-requirement
branch
from
August 11, 2026 08:18
a397777 to
032cac5
Compare
Contributor
|
Xinzheng Long (@xinlon-z) it has been quite a while that build-dtb-image tool moved to qcom-dtb-metadata: https://github.com/qualcomm-linux/qcom-dtb-metadata/blob/main/build-dtb-image.sh. Please consider this tool in build-utils depricated. |
Contributor
Author
sure, thanks for providing this info, will update this PR. |
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.
In some environments, such as AI-driven workflows, sudo privileges may not be available, which makes it difficult to run the existing scripts. To make things a bit more flexible, I did some update in
kernel/scripts/build-dtb-image.shandkernel/scripts/build-kernel-deb.shso they can be executed without requiring root privileges, bringing their behavior just like Yocto.