|
64 | 64 | cd ..
|
65 | 65 | rm -rf "$musl"
|
66 | 66 |
|
67 |
| -# Download, configure, build, and install musl-sanitized kernel headers: |
68 |
| -kernel_header_ver="4.19.88" |
69 |
| -curl --retry 5 -L \ |
70 |
| - "https://github.com/sabotage-linux/kernel-headers/archive/v${kernel_header_ver}.tar.gz" | |
71 |
| - tar xzf - |
| 67 | +# Download, configure, build, and install musl-sanitized kernel headers. |
| 68 | + |
| 69 | +# Alpine follows stable kernel releases, 3.20 uses Linux 6.6 headers. |
| 70 | +alpine_version=3.20 |
| 71 | +alpine_git=https://gitlab.alpinelinux.org/alpine/aports |
| 72 | + |
| 73 | +# This routine piggybacks on: https://git.alpinelinux.org/aports/tree/main/linux-headers?h=3.20-stable |
| 74 | +git clone -n --depth=1 --filter=tree:0 -b "${alpine_version}-stable" "$alpine_git" |
72 | 75 | (
|
73 |
| - cd "kernel-headers-${kernel_header_ver}" |
74 |
| - make ARCH="${kernel_arch}" prefix="/musl-${musl_arch}" install -j4 |
| 76 | + cd aports |
| 77 | + git sparse-checkout set --no-cone main/linux-headers |
| 78 | + git checkout |
| 79 | + |
| 80 | + cd main/linux-headers |
| 81 | + cp APKBUILD APKBUILD.vars |
| 82 | + cat <<- EOF >> APKBUILD.vars |
| 83 | + echo "\$source" > alpine-source |
| 84 | + echo "\$_kernver" > alpine-kernver |
| 85 | + echo "\$pkgver" > alpine-pkgver |
| 86 | + echo "\$sha512sums" > alpine-sha512sums |
| 87 | +EOF |
| 88 | + |
| 89 | + # Retrieve all the variables |
| 90 | + sh APKBUILD.vars |
| 91 | + |
| 92 | + cat APKBUILD.vars |
| 93 | + |
| 94 | + kernel_version=$(tr -d "[:space:]" < alpine-kernver) |
| 95 | + pkg_version=$(tr -d "[:space:]" < alpine-pkgver) |
| 96 | + |
| 97 | + urls=$(grep -o 'https.*' alpine-source) |
| 98 | + kernel="" |
| 99 | + patch="" |
| 100 | + for url in $urls; do |
| 101 | + base=$(basename "$url") |
| 102 | + curl --retry 5 -L "$url" > "$base" |
| 103 | + case $base in |
| 104 | + linux-*) kernel=$base;; |
| 105 | + patch-*) patch=$base;; |
| 106 | + esac |
| 107 | + # Check if file is known |
| 108 | + grep -o "$base" alpine-sha512sums |
| 109 | + done |
| 110 | + |
| 111 | + # Double check checksums |
| 112 | + sha512sum -c alpine-sha512sums |
| 113 | + |
| 114 | + # Extract, apply patches, compile and install headers |
| 115 | + tar -xf "$kernel" |
| 116 | + cd "linux-$kernel_version" |
| 117 | + if [ "$pkg_version" != "$kernel_version" ]; then |
| 118 | + unxz -c < "../$patch" | patch -p1 |
| 119 | + fi |
| 120 | + for p in ../*.patch; do |
| 121 | + patch -p1 < "$p" |
| 122 | + done |
| 123 | + make headers_install ARCH="${kernel_arch}" INSTALL_HDR_PATH="/musl-${musl_arch}" |
75 | 124 | )
|
76 |
| -rm -rf kernel-headers-${kernel_header_ver} |
| 125 | + |
| 126 | +rm -rf aports |
0 commit comments