From 1ae3ff23df2c1f59e6f1ee094ca9ed5d82fc9455 Mon Sep 17 00:00:00 2001 From: Pedro Tammela Date: Thu, 12 Sep 2024 15:13:07 -0300 Subject: [PATCH] ci: update musl headers to Linux 6.6 Update the musl headers in CI to use alpine-linux instead of sabotage-linux. Alpine also uses musl but follows the linux stable releases, providing more up-to-date headers. Signed-off-by: Pedro Tammela (backport ) (cherry picked from commit acc75e75f119483a56fb46e06951004e8cfa5594) Signed-off-by: Trevor Gross --- .../aarch64-unknown-linux-musl/Dockerfile | 2 +- .../arm-unknown-linux-musleabihf/Dockerfile | 2 +- ci/docker/i686-unknown-linux-musl/Dockerfile | 4 +- ci/docker/s390x-unknown-linux-musl/Dockerfile | 3 +- .../x86_64-unknown-linux-musl/Dockerfile | 3 +- ci/install-musl.sh | 66 ++++++++++++++++--- 6 files changed, 66 insertions(+), 14 deletions(-) diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index 65932bd48cfac..053ed837b2e7c 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:24.10 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ - gcc-aarch64-linux-gnu qemu-user + gcc-aarch64-linux-gnu qemu-user xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh aarch64 diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index 7ed23611c351e..c6bd116b6f1cb 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -5,7 +5,7 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ - gcc-arm-linux-gnueabihf qemu-user + gcc-arm-linux-gnueabihf qemu-user xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh arm diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index ea5e2e963910b..287f325e9151f 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -1,12 +1,12 @@ FROM ubuntu:23.10 - # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ /etc/apt/sources.list && \ dpkg --add-architecture i386 && \ apt-get update && apt-get install -y --no-install-recommends \ - gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 + gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 \ + xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh i686 diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index 4e202d1905902..2d4ea759c5fbf 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -4,7 +4,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ gcc \ gcc-s390x-linux-gnu \ - qemu-user + qemu-user \ + xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh s390x diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index d03df5b4f54ce..5c1b4b177880c 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -2,7 +2,8 @@ FROM ubuntu:24.10 RUN apt-get update RUN apt-get install -y --no-install-recommends \ - gcc make libc6-dev git curl ca-certificates + gcc make libc6-dev git curl ca-certificates \ + xz-utils patch rsync COPY install-musl.sh / RUN /install-musl.sh x86_64 diff --git a/ci/install-musl.sh b/ci/install-musl.sh index 5f8c681fa6678..1cf1ec6500cde 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -64,13 +64,63 @@ esac cd .. rm -rf "$musl" -# Download, configure, build, and install musl-sanitized kernel headers: -kernel_header_ver="4.19.88" -curl --retry 5 -L \ - "https://github.com/sabotage-linux/kernel-headers/archive/v${kernel_header_ver}.tar.gz" | - tar xzf - +# Download, configure, build, and install musl-sanitized kernel headers. + +# Alpine follows stable kernel releases, 3.20 uses Linux 6.6 headers. +alpine_version=3.20 +alpine_git=https://gitlab.alpinelinux.org/alpine/aports + +# This routine piggybacks on: https://git.alpinelinux.org/aports/tree/main/linux-headers?h=3.20-stable +git clone -n --depth=1 --filter=tree:0 -b "${alpine_version}-stable" "$alpine_git" ( - cd "kernel-headers-${kernel_header_ver}" - make ARCH="${kernel_arch}" prefix="/musl-${musl_arch}" install -j4 + cd aports + git sparse-checkout set --no-cone main/linux-headers + git checkout + + cd main/linux-headers + cp APKBUILD APKBUILD.vars + cat <<- EOF >> APKBUILD.vars + echo "\$source" > alpine-source + echo "\$_kernver" > alpine-kernver + echo "\$pkgver" > alpine-pkgver + echo "\$sha512sums" > alpine-sha512sums +EOF + + # Retrieve all the variables + sh APKBUILD.vars + + cat APKBUILD.vars + + kernel_version=$(tr -d "[:space:]" < alpine-kernver) + pkg_version=$(tr -d "[:space:]" < alpine-pkgver) + + urls=$(grep -o 'https.*' alpine-source) + kernel="" + patch="" + for url in $urls; do + base=$(basename "$url") + curl --retry 5 -L "$url" > "$base" + case $base in + linux-*) kernel=$base;; + patch-*) patch=$base;; + esac + # Check if file is known + grep -o "$base" alpine-sha512sums + done + + # Double check checksums + sha512sum -c alpine-sha512sums + + # Extract, apply patches, compile and install headers + tar -xf "$kernel" + cd "linux-$kernel_version" + if [ "$pkg_version" != "$kernel_version" ]; then + unxz -c < "../$patch" | patch -p1 + fi + for p in ../*.patch; do + patch -p1 < "$p" + done + make headers_install ARCH="${kernel_arch}" INSTALL_HDR_PATH="/musl-${musl_arch}" ) -rm -rf kernel-headers-${kernel_header_ver} + +rm -rf aports