Skip to content

configuration files for linux #55055

@paigeadelethompson

Description

@paigeadelethompson

This might be a better dialog for @Duncaen but I'm nothing the package for the kernel is using the generated (make *config) configuration which is I guess okay people do it but it's not exactly ideal. I'm guessing you use make olddefconfig whenever there's an update between versions. (ok) but did you know there is a tool provided in the scripts directory called scripts/config ? There's two downsides to actually using it:

  • you can only specify a single parameter per use:
  • there are a lot of options, but you can pretty easily convert to the commands and group them into multiple files that can be sourced in the correct order:
awk '
/^CONFIG_[A-Za-z0-9_]+=y$/ { 
    opt = substr($0, 1, index($0, "=")-1);
    unset_cmd = "scripts/config -d " opt;
    set_cmd = "scripts/config -e " opt;
    prefix = substr(opt, 8);
    sub(/_.*/, "", prefix);
    if (prefix == "") prefix = "MISC";
    file = "CONFIG_" prefix;
    print unset_cmd >> file;
    print set_cmd >> file;
    if (!seen[file]++) sources[file] = 1;
}
/^CONFIG_[A-Za-z0-9_]+=".*"$/ { 
    opt = substr($0, 1, index($0, "=")-1);
    val = substr($0, index($0, "=")+2, length($0)-index($0, "=")-2);
    unset_cmd = "scripts/config -d " opt;
    set_cmd = "scripts/config --set-str " opt " \"" val "\"";
    prefix = substr(opt, 8);
    sub(/_.*/, "", prefix);
    if (prefix == "") prefix = "MISC";
    file = "CONFIG_" prefix;
    print unset_cmd >> file;
    print set_cmd >> file;
    if (!seen[file]++) sources[file] = 1;
}
/^CONFIG_[A-Za-z0-9_]+=m$/ { 
    opt = substr($0, 1, index($0, "=")-1);
    unset_cmd = "scripts/config -d " opt;
    set_cmd = "scripts/config -m " opt;
    prefix = substr(opt, 8);
    sub(/_.*/, "", prefix);
    if (prefix == "") prefix = "MISC";
    file = "CONFIG_" prefix;
    print unset_cmd >> file;
    print set_cmd >> file;
    if (!seen[file]++) sources[file] = 1;
}
/^CONFIG_[A-Za-z0-9_]+=0x[0-9a-fA-F]+$/ { 
    opt = substr($0, 1, index($0, "=")-1);
    val = substr($0, index($0, "=")+1);
    unset_cmd = "scripts/config -d " opt;
    set_cmd = "scripts/config --set-val " opt " " val;
    prefix = substr(opt, 8);
    sub(/_.*/, "", prefix);
    if (prefix == "") prefix = "MISC";
    file = "CONFIG_" prefix;
    print unset_cmd >> file;
    print set_cmd >> file;
    if (!seen[file]++) sources[file] = 1;
}
/^CONFIG_[A-Za-z0-9_]+=[-0-9]+$/ { 
    opt = substr($0, 1, index($0, "=")-1);
    val = substr($0, index($0, "=")+1);
    unset_cmd = "scripts/config -d " opt;
    set_cmd = "scripts/config --set-val " opt " " val;
    prefix = substr(opt, 8);
    sub(/_.*/, "", prefix);
    if (prefix == "") prefix = "MISC";
    file = "CONFIG_" prefix;
    print unset_cmd >> file;
    print set_cmd >> file;
    if (!seen[file]++) sources[file] = 1;
}
END {
    # Print sources in alphabetical order
    PROCINFO["sorted_in"] = "@ind_str_asc";
    for (file in sources) {
        print "source " file;
    }
}' .config
  • rm .config && make allnoconfig
  • source CONFIG_* from wherever
  • grep "CONFIG_CC_VERSION_TEXT" .config
CONFIG_CC_VERSION_TEXT="ohai2u"

the awk script prints the grouped options so that it will produce them in the same order, but CONFIG. But you wouldn't run this awk script routinely or ever more than once. It's just something to put configuration management into better context for tracking configuration changes across revisions. And if you don't know by the time you've ran this what the differences are you can also do something like: diff <(zcat /proc/config.gz) .config or /boot or wherever you wanna get your old configuration from.

If you don't trust defaulting to =y for new options you can start from allnoconfig then source your options or do both and then diff the two to see what's changed.

I don't really care for it that much but at least this way you can put some context to what options are enabled vs the automatically generated file which has:

#
# Automatically generated file; DO NOT EDIT. <--- 
# Linux/x86 6.14.0-rc5 Kernel Configuration
#
#
# General setup
#
# CONFIG_COMPILE_TEST is not set
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set
# CONFIG_KERNEL_ZSTD is not set
# CONFIG_WATCH_QUEUE is not set
# CONFIG_USELIB is not set

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions