|
51 | 51 | # Notes: |
52 | 52 | # • Supports native (arm64 host) and cross (amd64 host, e.g. via dpkg |
53 | 53 | # cross-architecture + gcc-aarch64-linux-gnu) builds. |
54 | | -# • Needs ~20 GB free disk space. |
55 | | -# • A full build (all flavours) takes 2+ hours; a single flavour ~1 hour. |
56 | 54 | # • Designed to run inside a Docker container with preinstalled dependencies. |
57 | 55 | # • For Docker builds, use the docker-build-kernel.sh wrapper. |
| 56 | +# • Running this script directly on a bare host (not via |
| 57 | +# docker-build-kernel.sh) requires the host's own apt sources to match |
| 58 | +# the Ubuntu release SOURCE_DIR's debian/control targets (e.g. resolute); |
| 59 | +# apt-get build-dep will fail to resolve packages on a host running a |
| 60 | +# different release (e.g. noble), since the matching package mirror |
| 61 | +# for that release won't be configured. |
58 | 62 |
|
59 | 63 | set -euo pipefail |
60 | 64 |
|
| 65 | +usage() { |
| 66 | + cat <<'EOF' |
| 67 | +Usage: build-kernel-deb.sh [SOURCE_DIR] [ARCH] [FLAVOR] [JOBS] [VERSION_SUFFIX] |
| 68 | +
|
| 69 | +Build Ubuntu kernel .deb packages from a Canonical source tree (as checked |
| 70 | +out from a series branch). |
| 71 | +
|
| 72 | +Arguments: |
| 73 | + SOURCE_DIR Root of the kernel source tree containing debian/ (default: .) |
| 74 | + ARCH Target Debian architecture to compile for: arm64 (default: arm64). |
| 75 | + Build host may be arm64 (native) or amd64 (cross-compile via |
| 76 | + gcc-aarch64-linux-gnu); amd64 is not a supported target since |
| 77 | + the qcom/qcom-rt flavours are arm64-only. |
| 78 | + FLAVOR Kernel flavour: qcom | qcom-rt | all (default: qcom) |
| 79 | + JOBS Parallel make jobs (default: 8; incremental rebuilds with |
| 80 | + few changed files scale worse than expected past this |
| 81 | + due to scheduling overhead — override explicitly for a |
| 82 | + from-scratch build on a many-core machine) |
| 83 | + VERSION_SUFFIX Optional string appended to the package/kernel version, |
| 84 | + e.g. "+g1a2b3c4" or "+myuser1" (default: none). Pass |
| 85 | + "auto" to generate "+g<short commit>" from SOURCE_DIR's |
| 86 | + current HEAD (requires SOURCE_DIR to be a git work tree). |
| 87 | + Modifies debian.qcom/changelog, but the script restores it |
| 88 | + to HEAD before every run, so this never leaves the tree |
| 89 | + dirty. |
| 90 | +
|
| 91 | +Environment: |
| 92 | + INCREMENTAL_BUILD Set to 0/false/no/off to force debian/rules clean's |
| 93 | + rm -rf debian/build debian/stamps even when prior |
| 94 | + build state exists, so the next build is guaranteed |
| 95 | + clean (default: 1, incremental — kbuild only |
| 96 | + recompiles files that actually changed). Falls back |
| 97 | + to a full clean automatically on the first build for |
| 98 | + a given SOURCE_DIR. Do not leave enabled across a |
| 99 | + change to debian/control-level Build-Depends, or |
| 100 | + when a guaranteed-clean build is needed (e.g. before |
| 101 | + a release/CI run). |
| 102 | + DBGSYM Set to 1/true/yes/on to also build the unstripped |
| 103 | + -dbgsym.ddeb debug symbol packages alongside the |
| 104 | + .deb packages (default: 0, disabled). |
| 105 | +
|
| 106 | +Output: |
| 107 | + Built .deb packages are placed in ./output/ relative to the working |
| 108 | + directory from which this script is invoked, unless OUTPUT_DIR is set |
| 109 | + in the environment (relative or absolute; normalized to an absolute path |
| 110 | + up front), in which case that path is used instead. |
| 111 | +
|
| 112 | +Notes: |
| 113 | + • Supports native (arm64 host) and cross (amd64 host, e.g. via dpkg |
| 114 | + cross-architecture + gcc-aarch64-linux-gnu) builds. |
| 115 | + • Designed to run inside a Docker container with preinstalled dependencies. |
| 116 | + • For Docker builds, use the docker-build-kernel.sh wrapper. |
| 117 | + • Running this script directly on a bare host (not via |
| 118 | + docker-build-kernel.sh) requires the host's own apt sources to match |
| 119 | + the Ubuntu release SOURCE_DIR's debian/control targets (e.g. resolute); |
| 120 | + apt-get build-dep will fail to resolve packages on a host running a |
| 121 | + different release (e.g. noble), since the matching package mirror |
| 122 | + for that release won't be configured. |
| 123 | +EOF |
| 124 | +} |
| 125 | + |
| 126 | +case "${1:-}" in |
| 127 | + -h|--help) usage; exit 0 ;; |
| 128 | +esac |
| 129 | + |
61 | 130 | SOURCE_DIR="${1:-.}" |
62 | 131 | ARCH="${2:-arm64}" |
63 | 132 | FLAVOR="${3:-qcom}" |
|
0 commit comments