fix(kernel-headers): preserve build-time autoconf.h across postinst olddefconfig (#9425)#9426
fix(kernel-headers): preserve build-time autoconf.h across postinst olddefconfig (#9425)#9426iav wants to merge 1 commit intoarmbian:mainfrom
Conversation
📝 WalkthroughWalkthroughPreserves build-time kernel configuration during linux-headers packaging by creating an include/generated/.armbian-build.tar.gz sidecar (when include/config/auto.conf exists) and restoring its contents in the package's postinst finish to avoid target-side Changes
Sequence Diagram(s)sequenceDiagram
participant Packager
participant Package
participant TargetPostinst
participant Filesystem
Packager->>Filesystem: check for include/config/auto.conf
alt auto.conf exists
Packager->>Filesystem: create include/generated/.armbian-build.tar.gz (include/config + generated files)
Packager->>Package: include tarball in linux-headers package
end
Note right of Package: Package shipped to target
Package->>TargetPostinst: postinst runs on install
TargetPostinst->>Filesystem: run make olddefconfig / prepare scripts/
TargetPostinst->>Filesystem: if .armbian-build.tar.gz exists, extract to restore saved config
TargetPostinst->>Filesystem: remove .armbian-build.tar.gz
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/functions/compilation/kernel-debs.sh (1)
495-502: Sidecar tarball will trigger a false positive in the DEBUG binary check
include/generated/.armbian-build.tar.gzis a gzip binary. Thegrep -vfilter at line 500 excludesinclude/config/but notinclude/generated/, sofilewill report it as an unexpected binary whenDEBUG=yes.♻️ Proposed fix — exclude the sidecar from the binary scan
- find . -type f | grep -v -e "include/config/" -e "\.h$" -e ".c$" -e "Makefile$" -e "Kconfig$" -e "Kbuild$" -e "\.cocci$" | xargs file | grep -v -e "ASCII" -e "script text" -e "empty" -e "Unicode text" -e "symbolic link" -e "CSV text" -e "SAS 7+" || true + find . -type f | grep -v -e "include/config/" -e "include/generated/\.armbian-build\.tar\.gz" -e "\.h$" -e ".c$" -e "Makefile$" -e "Kconfig$" -e "Kbuild$" -e "\.cocci$" | xargs file | grep -v -e "ASCII" -e "script text" -e "empty" -e "Unicode text" -e "symbolic link" -e "CSV text" -e "SAS 7+" || true🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/functions/compilation/kernel-debs.sh` around lines 495 - 502, The DEBUG binary-scan in kernel-debs.sh (inside the if [[ "${DEBUG}" == "yes" ]] block that cd's into "${headers_target_dir}" and runs the find | grep -v ... | xargs file pipeline) falsely flags include/generated/.armbian-build.tar.gz; update the grep -v filter in that pipeline to also exclude the include/generated/ sidecar (or the specific filename .armbian-build.tar.gz) so the file is ignored by the binary check, keeping the rest of the exclusion rules intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/functions/compilation/kernel-debs.sh`:
- Around line 495-502: The DEBUG binary-scan in kernel-debs.sh (inside the if [[
"${DEBUG}" == "yes" ]] block that cd's into "${headers_target_dir}" and runs the
find | grep -v ... | xargs file pipeline) falsely flags
include/generated/.armbian-build.tar.gz; update the grep -v filter in that
pipeline to also exclude the include/generated/ sidecar (or the specific
filename .armbian-build.tar.gz) so the file is ignored by the binary check,
keeping the rest of the exclusion rules intact.
…lddefconfig (armbian#9425) При упаковке linux-headers скомпилированные бинарники из scripts/ удаляются, так как они собраны под хост сборки, а не под целевую машину (типичный случай кросс-сборки). Поэтому postinst при установке пакета пересобирает их нативно, предварительно запустив `make olddefconfig`. Однако olddefconfig не только подготавливает окружение — он заново вычисляет конфигурацию ядра, проверяя тулчейн, доступный на целевом хосте при установке. Если инструменты, использовавшиеся при сборке ядра, на целевой машине отсутствуют или имеют другую версию, olddefconfig молча отключает соответствующие CONFIG_* опции (например, CONFIG_CC_IS_CLANG, CONFIG_LTO_CLANG, CONFIG_DEBUG_INFO_BTF). В результате установленный пакет заголовков описывает не то ядро, которое реально собрано и работает, а то, которое можно было бы собрать на данном хосте. Это затрагивает: - include/generated/autoconf.h (используется препроцессором C) - include/config/auto.conf + маркер-файлы include/config/ (используются make-правилами kbuild) - include/generated/rustc_cfg (используется Rust-сборками) Все эти файлы — артефакты сборки и должны описывать скомпилированное ядро, а не возможности хоста установки. Исправление: при упаковке сохраняем сайдкар-тарбол с build-time версиями include/config/ и include/generated/{autoconf.h,rustc_cfg}; восстанавливаем его в postinst в самом конце, после всех make-шагов. Fixes: armbian#9425 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59a3ab7 to
5c893ea
Compare
Summary
Fixes #9425.
The
linux-headerspostinstscript runsmake olddefconfigbefore nativelyrecompiling
scripts/on the target host (necessary for cross-built kernels).However,
olddefconfigre-evaluates toolchain availability on the installationhost and silently disables
CONFIG_*options whose tools are absent there —even though the compiled kernel image was built with those options enabled.
This causes the installed headers package to describe a different kernel than
the one actually running.
Affected files:
include/generated/autoconf.h— used by the C preprocessorinclude/config/auto.conf+include/config/marker files — used by kbuild make rules in external modulesinclude/generated/rustc_cfg— used by Rust buildsFix: at packaging time, save a sidecar tarball of the build-time
include/config/andinclude/generated/{autoconf.h,rustc_cfg}; restore itin
postinstas the very last step, after allmaketargets complete.Completed tests
linux-headersforBOARD=odroidn2(aarch64, native build) withkernel-rustextension (CONFIG_RUST=y)linux-headersforBOARD=odroidm1(aarch64, cross-compiled onx86_64)linux-headersforBOARD=uefi-x86(amd64) — exercises thetools/objtoolpostinst block.deb:include/generated/.armbian-build.tar.gzcontaininginclude/config/,autoconf.h,rustc_cfgrustcin$PATH;postinstcompletes successfullyinclude/generated/autoconf.h:#define CONFIG_RUST 1,CONFIG_RUSTC_VERSION 108500(not0)include/config/auto.conf:CONFIG_RUST=yinclude/generated/rustc_cfg:--cfg=CONFIG_RUST