Bug 12395

Summary: kernel set up with devtool modify builds with wrong config after cleaning
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Paul Eggleton <bluelightning>
Component: Scripts and ToolsAssignee: Eilís Ní Fhlannagáin <pidge>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Medium+ CC: ccasciato, jacobpanov, randy.macleod, ross.burton, tim.orling
Version: 2.4   
Target Milestone: 5.99   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Fix for kernel config loss in devtool modify workflow none

Description Paul Eggleton 2017-12-05 02:15:42 UTC
If you run devtool modify on the kernel, run bitbake -c clean, then try to build the kernel again the configuration will be different:

devtool modify virtual/kernel
bitbake virtual/kernel
cp tmp/work-shared/qemux86-64/kernel-build-artifacts/.config kconfig-good
bitbake -c clean virtual/kernel
bitbake virtual/kernel
diff -udN kconfig-good tmp/work/qemux86_64-poky-linux/linux-yocto/4.12.14+git999-r0/linux-yocto-4.12.14+git999/.config

(The second build of the kernel will almost certainly fail because it will try to generate X.509 certificates and openssl-native isn't in DEPENDS, so the openssl command won't be available to run.)

There is some logic set up in the workspace bbappend for the kernel that sets up the configuration, and I suspect this is where the problem lies - it moves the configuration into place from ${S} to ${B} the first time but the second time around it's not there to move, and you get the default kernel configuration instead.
Comment 1 Randy MacLeod 2022-05-12 15:30:01 UTC
May also need a test.
Comment 2 Randy MacLeod 2023-10-24 14:24:33 UTC
Bulk move from 4.99 or 0.00 to 5.99
Comment 3 Jacob Panov 2025-07-27 01:15:04 UTC
I found that the do_kernel_configme:prepend function standard.py unconditionally moved existing .config files, causing legitimate user configurations to be lost after clean/rebuild cycles.

I changed the logic to preserve legitimate user configurations by checking for .config.baseline presence:

# Before (problematic):
if [ -e ${S}/.config ]; then
    mv ${S}/.config ${S}/.config.old
fi

# After:
if [ -e ${S}/.config ] && [ ! -e ${S}/.config.baseline ]; then
    mv ${S}/.config ${S}/.config.old
fi

User configs with.config.baseline are preserved and stale configs without .config.baseline are moved appropriately.

Patch available for integration.
Comment 4 Jacob Panov 2025-07-27 01:19:16 UTC
Created attachment 5128 [details]
Fix for kernel config loss in devtool modify workflow

The do_kernel_configme:prepend function in scripts/lib/devtool/standard.py unconditionally moved existing .config files, causing legitimate user configurations to be lost after clean/rebuild cycles.

Enhanced the logic to preserve legitimate user configurations by checking for .config.baseline presence:

# Before:
if [ -e ${S}/.config ]; then
    mv ${S}/.config ${S}/.config.old
fi

# After:
if [ -e ${S}/.config ] && [ ! -e ${S}/.config.baseline ]; then
    mv ${S}/.config ${S}/.config.old
fi