Skip to content

Commit 510aa7d

Browse files
committed
Update linux_headers_image to support >= 6.3 kernels. Add additional kernel versions to header builder list
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 301198f commit 510aa7d

3 files changed

Lines changed: 113 additions & 6 deletions

File tree

tools/docker/Makefile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ LINUX_KERNEL_VERSIONS := 4.14.304 \
101101
5.18.19 \
102102
5.19.17 \
103103
6.0.19 \
104-
6.1.8
104+
6.1.8 \
105+
6.2.16 \
106+
6.3.13 \
107+
6.6.53 \
108+
6.8.12 \
109+
6.10.12 \
110+
6.11.1
105111

106112
LINUX_HEADER_X86_64_TEMPLATE := linux-headers-x86_64-%.tar.gz
107113
LINUX_HEADER_ARM64_TEMPLATE := linux-headers-arm64-%.tar.gz
@@ -210,19 +216,39 @@ ifndef LINUX_HEADERS_REV
210216
$(error set LINUX_HEADERS_REV to a valid value)
211217
endif
212218
@mkdir -p $(@D)
219+
# Linux 6.3 and later has differences in the build process.
220+
# We need to use a different Dockerfile for these versions.
221+
KERN_MAJ=$$(echo $* | cut -d. -f1); \
222+
KERN_MIN=$$(echo $* | cut -d. -f2); \
223+
HEADERS_DOCKERFILE_SUFFIX=""; \
224+
if [ $${KERN_MAJ} -le 6 ] && [ $${KERN_MIN} -lt 3 ]; then \
225+
HEADERS_DOCKERFILE_SUFFIX=".bionic"; \
226+
fi; \
213227
linux_headers_image_tag="gcr.io/pixie-oss/pixie-dev-public:$*-$(LINUX_HEADERS_REV)"; \
214-
$(DOCKER) build --build-arg KERN_VERSION=$* --build-arg ARCH=x86_64 linux_headers_image -t "$${linux_headers_image_tag}" && \
228+
$(DOCKER) build --build-arg KERN_VERSION=$* \
229+
--build-arg ARCH=x86_64 linux_headers_image \
230+
-t "$${linux_headers_image_tag}" \
231+
-f linux_headers_image/Dockerfile$${HEADERS_DOCKERFILE_SUFFIX} && \
215232
$(DOCKER) run --rm -v $(PWD)/$(LINUX_HEADER_ASSETS_BUILD_DIR):/output "$${linux_headers_image_tag}"
216233

217234
$(LINUX_HEADER_ASSETS_BUILD_DIR)/linux-headers-arm64-%.tar.gz: linux_headers_image/Dockerfile linux_headers_image/arm64_config
218235
ifndef LINUX_HEADERS_REV
219236
$(error set LINUX_HEADERS_REV to a valid value)
220237
endif
221238
@mkdir -p $(@D)
239+
# Linux 6.3 and later has differences in the build process.
240+
# We need to use a different Dockerfile for these versions.
241+
KERN_MAJ=$$(echo $* | cut -d. -f1); \
242+
KERN_MIN=$$(echo $* | cut -d. -f2); \
243+
HEADERS_DOCKERFILE_SUFFIX=""; \
244+
if [ $${KERN_MAJ} -le 6 ] && [ $${KERN_MIN} -lt 3 ]; then \
245+
HEADERS_DOCKERFILE_SUFFIX=".bionic"; \
246+
fi; \
222247
linux_headers_image_tag="gcr.io/pixie-oss/pixie-dev-public:$*-$(LINUX_HEADERS_REV)"; \
223248
$(DOCKER) build --build-arg KERN_VERSION=$* \
224249
--build-arg ARCH=arm64 \
225250
--build-arg CROSS_COMPILE=aarch64-linux-gnu- \
251+
-f linux_headers_image/Dockerfile$(HEADERS_DOCKERFILE_SUFFIX) \
226252
linux_headers_image -t "$${linux_headers_image_tag}" && \
227253
$(DOCKER) run --rm -v $(PWD)/$(LINUX_HEADER_ASSETS_BUILD_DIR):/output "$${linux_headers_image_tag}"
228254

tools/docker/linux_headers_image/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616

17-
FROM ubuntu:18.04@sha256:8aa9c2798215f99544d1ce7439ea9c3a6dfd82de607da1cec3a8a2fae005931b
17+
# debhelper-compat (= 12) needed for kernels >= 6.3
18+
FROM ubuntu:20.04@sha256:6d8d9799fe6ab3221965efac00b4c34a2bcc102c086a58dff9e19a08b913c7ef
1819

1920
# Install required packages
2021
RUN apt-get update
2122
RUN apt-get upgrade -y -q
22-
RUN apt-get install -y -q build-essential \
23+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q build-essential \
2324
bc \
2425
libelf-dev \
2526
libssl-dev \
@@ -32,6 +33,7 @@ RUN apt-get install -y -q build-essential \
3233
binutils-aarch64-linux-gnu \
3334
gcc-aarch64-linux-gnu \
3435
dwarves \
36+
debhelper \
3537
python3
3638

3739
ARG KERN_VERSION
@@ -54,11 +56,12 @@ WORKDIR /px/src/linux-${KERN_VERSION}
5456
RUN cp /configs/${ARCH} .config
5557
RUN make ARCH=${ARCH} olddefconfig
5658
RUN make ARCH=${ARCH} clean
57-
RUN make ARCH=${ARCH} -j $(nproc) deb-pkg LOCALVERSION=-pl
59+
RUN make ARCH=${ARCH} -j $(nproc) bindeb-pkg LOCALVERSION=-pl
5860

5961
# Extract headers into a tarball
6062
WORKDIR /px
61-
RUN DEB_ARCH=$(echo ${ARCH} | sed 's/x86_64/amd64/g'); dpkg -x src/linux-headers-${KERN_VERSION}-pl_${KERN_VERSION}-pl-1_${DEB_ARCH}.deb .
63+
# Linux 6.3 and later name the resulting package differently (there is no additional -pl suffix)
64+
RUN DEB_ARCH=$(echo ${ARCH} | sed 's/x86_64/amd64/g'); dpkg -x src/linux-headers-${KERN_VERSION}-pl_${KERN_VERSION}-1_${DEB_ARCH}.deb .
6265

6366
# Remove broken symlinks
6467
RUN find usr/src/linux-headers-${KERN_VERSION}-pl -xtype l -exec rm {} +
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright 2018- The Pixie Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
FROM ubuntu:18.04@sha256:8aa9c2798215f99544d1ce7439ea9c3a6dfd82de607da1cec3a8a2fae005931b
18+
19+
# Install required packages
20+
RUN apt-get update
21+
RUN apt-get upgrade -y -q
22+
RUN apt-get install -y -q build-essential \
23+
bc \
24+
libelf-dev \
25+
libssl-dev \
26+
flex \
27+
bison \
28+
kmod \
29+
cpio \
30+
rsync \
31+
wget \
32+
binutils-aarch64-linux-gnu \
33+
gcc-aarch64-linux-gnu \
34+
dwarves \
35+
python3
36+
37+
ARG KERN_VERSION
38+
39+
# Download Linux sources
40+
WORKDIR /px/src
41+
RUN KERN_MAJ="$(echo "${KERN_VERSION}" | cut -d'.' -f1)"; \
42+
wget -nv http://mirrors.edge.kernel.org/pub/linux/kernel/v${KERN_MAJ}.x/linux-${KERN_VERSION}.tar.gz
43+
RUN tar zxf linux-${KERN_VERSION}.tar.gz
44+
45+
WORKDIR /configs
46+
ADD x86_64_config /configs/x86_64
47+
ADD arm64_config /configs/arm64
48+
49+
ARG ARCH
50+
ARG CROSS_COMPILE
51+
52+
# Build Linux kernel
53+
WORKDIR /px/src/linux-${KERN_VERSION}
54+
RUN cp /configs/${ARCH} .config
55+
RUN make ARCH=${ARCH} olddefconfig
56+
RUN make ARCH=${ARCH} clean
57+
RUN make ARCH=${ARCH} -j $(nproc) bindeb-pkg LOCALVERSION=-pl
58+
59+
# Extract headers into a tarball
60+
WORKDIR /px
61+
RUN DEB_ARCH=$(echo ${ARCH} | sed 's/x86_64/amd64/g'); dpkg -x src/linux-headers-${KERN_VERSION}-pl_${KERN_VERSION}-pl-1_${DEB_ARCH}.deb .
62+
63+
# Remove broken symlinks
64+
RUN find usr/src/linux-headers-${KERN_VERSION}-pl -xtype l -exec rm {} +
65+
66+
# Remove uneeded files to reduce size
67+
# Keep only:
68+
# - usr/src/linux-headers-x.x.x-pl/include
69+
# - usr/src/linux-headers-x.x.x-pl/arch/${ARCH}
70+
# This reduces the size by a little over 2x.
71+
RUN rm -rf usr/share
72+
RUN find usr/src/linux-headers-${KERN_VERSION}-pl -maxdepth 1 -mindepth 1 ! -name include ! -name arch -type d \
73+
-exec rm -rf {} +
74+
RUN find usr/src/linux-headers-${KERN_VERSION}-pl/arch -maxdepth 1 -mindepth 1 ! -name $(echo ${ARCH} | sed 's/x86_64/x86/g') -type d -exec rm -rf {} +
75+
RUN tar zcf linux-headers-${ARCH}-${KERN_VERSION}.tar.gz usr
76+
77+
VOLUME /output
78+
CMD ["sh", "-c", "cp linux-headers-*.tar.gz /output/"]

0 commit comments

Comments
 (0)