Linux
linux核心配置的格式化列印
由於選項make menuconfig和make nconfig提供了一種配置核心選項的好方法,有沒有辦法讓這個分層結構列印出來?
類似於“樹”命令輸出的東西。
感謝@jeff-schaller 的重播,我為 Kconfiglib 項目做出了貢獻,現在這個任務有一個新的範例腳本。這些是使用它的步驟:
在包含 linux 原始碼的目錄中,複製 repo:
root@23e196045c6f:/usr/src/linux-source-4.9# git clone git://github.com/ulfalizer/Kconfiglib.git Cloning into 'Kconfiglib'... remote: Counting objects: 3367, done. remote: Compressing objects: 100% (57/57), done. remote: Total 3367 (delta 64), reused 89 (delta 50), pack-reused 3259 Receiving objects: 100% (3367/3367), 1.25 MiB | 1.79 MiB/s, done. Resolving deltas: 100% (2184/2184), done.
修補生成文件:
root@23e196045c6f:/usr/src/linux-source-4.9# patch -p1 < Kconfiglib/makefile.patch patching file scripts/kconfig/Makefile
根據需要進行配置,基本上是為了獲取 .config 文件:
root@23e196045c6f:/usr/src/linux-source-4.9# make menuconfig
使用配置文件執行腳本:
root@23e196045c6f:/usr/src/linux-source-4.9# make scriptconfig SCRIPT=Kconfiglib/examples/print_config_tree.py SCRIPT_ARG=.config ======== Linux/x86 4.9.65 Kernel Configuration ======== [*] 64-bit kernel (64BIT) General setup () Cross-compiler tool prefix (CROSS_COMPILE) [ ] Compile also drivers which will not load (COMPILE_TEST) () Local version - append to kernel release (LOCALVERSION) [ ] Automatically append version information to the version string (LOCALVERSION_AUTO) -*- Kernel compression mode --> Gzip (KERNEL_GZIP) Bzip2 (KERNEL_BZIP2) LZMA (KERNEL_LZMA) ...
但好處是可以傳遞不同的核心配置並輕鬆匹配更改:
root@23e196045c6f:/usr/src/linux-source-4.9# make scriptconfig SCRIPT=Kconfiglib/examples/print_config_tree.py SCRIPT_ARG=/tmp/config1 > config1-list.txt root@23e196045c6f:/usr/src/linux-source-4.9# make scriptconfig SCRIPT=Kconfiglib/examples/print_config_tree.py SCRIPT_ARG=/tmp/config2 > config2-list.txt
最後現在使用差異工具: