Skip to content

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

Open
guanquan (GuanquanTian) wants to merge 5 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 5 commits into
qualcomm-linux:mainfrom
GuanquanTian:build-kernel-deb-cross-improvements

Conversation

@GuanquanTian

@GuanquanTian guanquan (GuanquanTian) commented Jul 27, 2026

Copy link
Copy Markdown

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)
  • Document the local kernel build workflow in scripts/README.md

Test plan

  • Run build-kernel-deb.sh natively on an arm64 host
  • Run build-kernel-deb.sh cross-compiling arm64 on an x86_64 host
  • Run docker-build-kernel.sh end to end, including first-run image build behind a proxy
  • Verify generated .deb packages install and boot

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

…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>
@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.

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