@@ -49,50 +49,48 @@ mkdir -p "${WORKSPACE}"/src
4949pushd " ${WORKSPACE} " /src || exit
5050
5151KERN_MAJ=$( echo " ${KERN_VERSION} " | cut -d' .' -f1) ;
52- KERN_MIN=$( echo " ${KERN_VERSION} " | cut -d' .' -f2) ;
5352wget -nv http://mirrors.edge.kernel.org/pub/linux/kernel/v" ${KERN_MAJ} " .x/linux-" ${KERN_VERSION} " .tar.gz
5453
5554tar zxf linux-" ${KERN_VERSION} " .tar.gz
5655
5756pushd linux-" ${KERN_VERSION} " || exit
5857
59- cp /configs/" ${ARCH} " .config
60- make ARCH=" ${ARCH} " olddefconfig
61- make ARCH=" ${ARCH} " clean
62-
6358LOCALVERSION=" -pl"
6459
65- DEB_ARCH=" ${ARCH// x86_64/ amd64} "
66- # binary builds are required for non git trees after linux v6.3 (inclusive).
67- # The .deb file suffix is also different.
68- TARGET=' bindeb-pkg'
69- DEB_SUFFIX=" -1_${DEB_ARCH} .deb"
70- if [ " ${KERN_MAJ} " -lt 6 ] || { [ " ${KERN_MAJ} " -le 6 ] && [ " ${KERN_MIN} " -lt 3 ]; }; then
71- TARGET=' deb-pkg'
72- DEB_SUFFIX=" ${LOCALVERSION} -1_${DEB_ARCH} .deb"
73- fi
74- echo " Building ${TARGET} for ${KERN_VERSION}${LOCALVERSION} (${ARCH} )"
60+ cp /configs/" ${ARCH} " .config
61+ make ARCH=" ${ARCH} " olddefconfig
7562
76- make ARCH=" ${ARCH} " -j " $( nproc) " " ${TARGET} " LOCALVERSION=" ${LOCALVERSION} "
63+ # Only generate headers — no kernel or module compilation needed.
64+ # 'make prepare' generates include/generated/ and arch/*/include/generated/
65+ # which are the only outputs we package.
66+ echo " Generating headers for ${KERN_VERSION}${LOCALVERSION} (${ARCH} )"
67+ make ARCH=" ${ARCH} " prepare LOCALVERSION=" ${LOCALVERSION} "
7768
7869popd || exit
7970popd || exit
8071
81- # Extract headers into a tarball
82- dpkg -x src/linux-headers-" ${KERN_VERSION}${LOCALVERSION} _${KERN_VERSION}${DEB_SUFFIX} " .
72+ # Package headers into the same directory structure the old deb-pkg approach produced
73+ # (usr/src/linux-headers-<version><localversion>/{include,arch}).
74+ KERNEL_ARCH=" ${ARCH// x86_64/ x86} "
75+ HEADERS_DIR=" usr/src/linux-headers-${KERN_VERSION}${LOCALVERSION} "
76+
77+ mkdir -p " ${HEADERS_DIR} /arch"
78+ cp -a " src/linux-${KERN_VERSION} /include" " ${HEADERS_DIR} /"
79+ cp -a " src/linux-${KERN_VERSION} /arch/${KERNEL_ARCH} " " ${HEADERS_DIR} /arch/"
8380
8481# Remove broken symlinks
85- find usr/src/linux-headers-" ${KERN_VERSION}${LOCALVERSION} " -xtype l -exec rm {} +
86-
87- # Remove uneeded files to reduce size
88- # Keep only:
89- # - usr/src/linux-headers-x.x.x-pl/include
90- # - usr/src/linux-headers-x.x.x-pl/arch/${ARCH}
91- # This reduces the size by a little over 2x.
92- rm -rf usr/share
93- find usr/src/linux-headers-" ${KERN_VERSION}${LOCALVERSION} " -maxdepth 1 -mindepth 1 ! -name include ! -name arch -type d \
94- -exec rm -rf {} +
95- find usr/src/linux-headers-" ${KERN_VERSION}${LOCALVERSION} " /arch -maxdepth 1 -mindepth 1 ! -name " ${ARCH// x86_64/ x86} " -type d -exec rm -rf {} +
82+ find " ${HEADERS_DIR} " -xtype l -exec rm {} +
83+
84+ # Remove non-header files from arch/ to reduce size.
85+ # Only headers (.h), Makefiles, Kconfigs, and Kbuilds are needed.
86+ find " ${HEADERS_DIR} /arch" -type f \
87+ ! -name ' *.h' \
88+ ! -name ' Makefile' \
89+ ! -name ' Kconfig*' \
90+ ! -name ' Kbuild*' \
91+ -delete
92+ # Clean up empty directories left behind.
93+ find " ${HEADERS_DIR} /arch" -type d -empty -delete
9694
9795tar zcf linux-headers-" ${ARCH} " -" ${KERN_VERSION} " .tar.gz usr
9896
0 commit comments