Skip to content

Commit 376adb2

Browse files
committed
scripts: add -h/--help usage output
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>
1 parent 1d1c23c commit 376adb2

2 files changed

Lines changed: 125 additions & 2 deletions

File tree

scripts/build-kernel-deb.sh

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,82 @@
5151
# Notes:
5252
# • Supports native (arm64 host) and cross (amd64 host, e.g. via dpkg
5353
# 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.
5654
# • Designed to run inside a Docker container with preinstalled dependencies.
5755
# • 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.
5862

5963
set -euo pipefail
6064

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+
61130
SOURCE_DIR="${1:-.}"
62131
ARCH="${2:-arm64}"
63132
FLAVOR="${3:-qcom}"

scripts/docker-build-kernel.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,60 @@
5151

5252
set -euo pipefail
5353

54+
usage() {
55+
cat <<'EOF'
56+
Usage: docker-build-kernel.sh [SOURCE_DIR] [ARCH] [FLAVOR] [JOBS] [VERSION_SUFFIX]
57+
58+
Build Ubuntu kernel .deb packages inside a Docker container. Wraps
59+
build-kernel-deb.sh and runs it inside a Docker container. Automatically
60+
detects the current architecture and, if the appropriate Docker image
61+
isn't already available locally, builds one via build-docker-image.sh
62+
(using SOURCE_DIR's own debian/control).
63+
64+
Arguments: positional args override env vars, which override defaults.
65+
SOURCE_DIR is resolved relative to the current working directory.
66+
67+
Arguments:
68+
SOURCE_DIR Root of the kernel source tree (relative to current directory, default: resolute-qcom-devel)
69+
ARCH Target Debian architecture: arm64 (default: arm64)
70+
FLAVOR Kernel flavour: qcom | qcom-rt | all (default: qcom)
71+
JOBS Parallel make jobs (default: 8)
72+
VERSION_SUFFIX Optional version suffix (default: none)
73+
74+
Environment:
75+
IMAGE Docker image to use (default: kernel-build-docker:resolute-target-<ARCH>,
76+
built on demand via build-docker-image.sh if not already
77+
present locally). Set this to use a different image
78+
instead — it must already exist locally, since this
79+
script no longer pulls from a registry.
80+
OUTPUT_DIR Where to place built .deb packages (default: ./output
81+
relative to the current directory). Set this to a fixed
82+
absolute path if you don't want the output location to
83+
depend on which directory you invoke this script from.
84+
Created on the host (with your uid/gid) before the
85+
container starts, so it's never auto-created by Docker
86+
as root.
87+
DEBEMAIL Email for changelog entries (default: build-kernel-deb@localhost)
88+
DEBFULLNAME Full name for changelog entries (default: build-kernel-deb.sh)
89+
INCREMENTAL_BUILD Set to 0/false/no/off to force a full debian/rules
90+
clean even when prior build state exists (default: 1,
91+
incremental). See build-kernel-deb.sh for details and
92+
caveats.
93+
DBGSYM Set to 1/true/yes/on to also build the unstripped
94+
-dbgsym.ddeb debug symbol packages alongside the .deb
95+
packages (default: 0, disabled). See build-kernel-deb.sh
96+
for details.
97+
98+
Output:
99+
Built .deb packages are placed in OUTPUT_DIR (default: ./output relative
100+
to the current directory).
101+
EOF
102+
}
103+
104+
case "${1:-}" in
105+
-h|--help) usage; exit 0 ;;
106+
esac
107+
54108
# Logging helpers
55109
log() { printf '[%s] %s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$*" >&2; }
56110
die() { log "ERROR: $*"; exit 1; }

0 commit comments

Comments
 (0)