Skip to content

feat: add cross-compilation support and Docker containerized builds for kernel packaging - #57

Open
guanquan (GuanquanTian) wants to merge 10 commits into
qualcomm-linux:mainfrom
GuanquanTian:build-kernel-deb-cross-improvements
Open

feat: add cross-compilation support and Docker containerized builds for kernel packaging#57
guanquan (GuanquanTian) wants to merge 10 commits into
qualcomm-linux:mainfrom
GuanquanTian:build-kernel-deb-cross-improvements

Conversation

@GuanquanTian

@GuanquanTian guanquan (GuanquanTian) commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add cross-compilation support to build-kernel-deb.sh (foreign-arch, cross build profile, DEB_HOST_ARCH/GNU_TYPE/MULTIARCH propagation)
  • Build the kernel build image locally from a checked-in Dockerfile instead of relying on a prebuilt image
  • Bind-mount only the paths required for the build and run the container as the host uid/gid
  • Support building the Docker image behind a proxy (HTTP_PROXY/HTTPS_PROXY/NO_PROXY, scoped to the apt-get RUN steps only)
  • Opt-in INCREMENTAL_BUILD flag (default 1) and JOBS default lowered to 8
  • add DBGSYM flag (default 0) to build -dbgsym.ddeb packages
  • Document the local kernel build workflow in scripts/README.md

According to PR # 33 review's feedback, complete the corresponding modifications and add support for setting container content proxies.
#33

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

…uisites before clean

- Detect a build/host arch mismatch and enable cross builds via dpkg
  foreign-architecture, the "cross" build profile, and
  DEB_HOST_ARCH/GNU_TYPE/MULTIARCH propagation.
- Factor debian/control generation and native-host-tool-dep patching into
  scripts/lib/gen-real-control.sh, shared with build-docker-image.sh.
- Install fakeroot/debhelper before running `debian/rules clean`, which
  requires both to run.
- Mark native-host build tools (e.g. llvm-*-dev) `:native` via a
  pattern-keyed NATIVE_HOST_TOOL_DEPS table, and restore debian/control
  from a backup on exit.
- Support OUTPUT_DIR override, and exit with an explicit error message
  when apt-get build-dep or dch need root but no sudo binary is available.
- Add binary-indep to the build targets so the arch:all
  linux-qcom-headers-* package is produced alongside the flavour packages.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
…rfile

- Add scripts/Dockerfile.kernel-build, built FROM
  docker.io/library/ubuntu:resolute (falling back to
  public.ecr.aws/ubuntu/ubuntu:resolute), with build deps resolved
  dynamically from the kernel tree's own debian/control via
  `debian/rules clean`.
- Add scripts/build-docker-image.sh to drive it: runs `debian/rules clean`
  on the host, copies the generated debian/control into a scratch build
  context, and passes TARGET_ARCH/CROSS build args.
- The image is built from a Dockerfile checked into this repo.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
…t uid/gid

- Build the local image on demand via build-docker-image.sh if not
  already present.
- Bind-mount the current directory, OUTPUT_DIR, SOURCE_DIR's parent
  (where debian/rules writes .deb/.changes/.buildinfo), and the script
  directory (read-only).
- Run the container as the invoking host uid/gid.
- Resolve SOURCE_DIR from the path passed in.
- Support OUTPUT_DIR override, created on the host before the container
  starts.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
Add scripts/README.md covering build-kernel-deb.sh,
docker-build-kernel.sh, and build-docker-image.sh usage, arguments,
environment variables, and cross-compilation notes.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
- Pass HTTP_PROXY/HTTPS_PROXY/NO_PROXY as Docker build args, scoped to
  the individual RUN steps in Dockerfile.kernel-build (not ENV), so
  they never leak into the built image or its containers.
- Document the one-time, per-machine proxy setup and the two new env
  vars in scripts/README.md.
- Note that linux-headers-*-qcom depends on linux-qcom-headers-*, so
  the latter must be installed first.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
@GuanquanTian
guanquan (GuanquanTian) force-pushed the build-kernel-deb-cross-improvements branch 3 times, most recently from ccf55ae to 1d1c23c Compare August 31, 2026 04:37
debian/rules clean wipes debian/build/ and debian/stamps/ on every
build, discarding kbuild's own object/cmd tracking and the per-flavour
stamp state even when nothing changed. Add INCREMENTAL_BUILD to skip
that destructive step (falling back to a full clean on the first build
for a given SOURCE_DIR), while still refreshing debian/control and
invalidating just the flavour-specific stamps so make re-enters those
recipes. Incremental is the default; set INCREMENTAL_BUILD=0 to force
a full clean.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
Higher parallelism scales worse than expected on incremental
(mostly-cached) rebuilds, since scheduling overhead outweighs the
gains once most translation units are skipped or near-instant.
Override explicitly (e.g. JOBS=$(nproc)) for from-scratch builds on
many-core machines.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
build-kernel-deb.sh's VERSION_SUFFIX=auto path and gen-real-control.sh's
is_git_worktree() checks shell out to git, but the build image never
installed it, so builds using VERSION_SUFFIX=auto failed inside the
container. git is a script-level tool dependency, not a kernel build
dependency, so it belongs in the hand-maintained base-tools layer rather
than in the dynamically generated extra-tools.txt.

Also document that docker-build-kernel.sh only builds the image when
missing locally, so this (or any future Dockerfile) change requires
removing the stale cached image before it takes effect.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
DBGSYM (default 0) maps to do_dbgsym_package=true/false on the
debian/rules invocation, and .ddeb artifacts are now collected into
OUTPUT_DIR alongside .deb/.changes/.buildinfo. docker-build-kernel.sh
forwards DBGSYM into the container the same way it already does for
INCREMENTAL_BUILD.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
build-kernel-deb.sh and docker-build-kernel.sh now print their
Usage/Arguments/Environment/Output/Notes documentation when called
with -h or --help, instead of it only being available as a header
comment.

Signed-off-by: Guanquan Tian <guanquan@qti.qualcomm.com>
@GuanquanTian
guanquan (GuanquanTian) force-pushed the build-kernel-deb-cross-improvements branch from 376adb2 to ddef691 Compare August 31, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants