Compare two kernel config files from the menuconfig perspective?

14,835

Solution 1

Try using scripts/diffconfig from the Linux kernel source tree.

Usage:

diffconfig config-a config-b

Shows a list of lines removed, modified and added to the config-b file with respect to config-a.

Solution 2

There is a script in the kernel source;

scripts/kconfig/merge_config.sh

It will take 2 kernel configs as arguments - it will merge the 2nd on top of the first. Anything in the 2nd config will override the first config - even if it is a line like "# CONFIG_ is not set"

See http://processors.wiki.ti.com/index.php/Quick_start_with_3.14_linux

Solution 3

If the two files are generated by make menuconfig, they will have the options in the same order, so a simple diff (via Meld or whatever frontend you like) will give a usable result.

You might get something more readable if you ignore comment lines:

diff -I '^#' old.config new.config

If for some reason the files aren't in the same order, you could sort them. This has the downside of putting related options far apart. Again, remove comments. Use comm to strip off the common lines.

comm -3 <(<old.config grep '^[^#]' | sort) <(<new.config grep '^[^#]' | sort)

Solution 4

You could try sorting the files before comparing:

meld <(sort config-a) <(sort config-b)

Solution 5

Use kdiff3 to compare two configs.

If anyone wants to compare .config (current configuration) file to some default configuration from kernel tree, first export defconfig from current configuration:

make savedefconfig

This will export defconfig file, which can be easily compared to any other default configuration file.

Share:
14,835

Related videos on Youtube

TheMeaningfulEngineer
Author by

TheMeaningfulEngineer

I like to think of myself as a Hardware/Software guy who will gladly discuss referential transparency during a code review and the next moment take a circular saw to build a casing for a self made power supply. My main interest can be summarized into Linux related software development, low power electronics and general DIY projects.

Updated on September 18, 2022

Comments

  • TheMeaningfulEngineer
    TheMeaningfulEngineer over 1 year

    I have a situation in which i have two kernel config files (for the same kernel source ). Both of them have a part of the functionality that i need (on one, USB works correctly, on other, the second I2C).

    I know that the differences between the two config files, from the perspective of menuconfig, include only a few selected options. (But don't know which ones)

    However when the config files are manually compared (meld between two .config files), the differences are not simple to identify. I have tried merging them manually without success. I'm sure I'll succeeded eventually but believe the process could be much more painless if the files were compared in a way they appear in the menuconfig.

    Can this be achieved, and if so, how?