diff options
author | Karel Kočí <cynerd@email.cz> | 2018-03-25 21:42:41 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2018-03-25 21:42:41 +0200 |
commit | cc482421612132d3561ea7bf7407535358c8984c (patch) | |
tree | 0f6063c3f492bf6bd680324eadd851c2c90247f8 /sys-kernel/linux/files/config_prepare.sh | |
parent | aa2b5583aae3e9f7873b10485de1e051748ce5f6 (diff) | |
download | gentoo-personal-overlay-cc482421612132d3561ea7bf7407535358c8984c.tar.gz gentoo-personal-overlay-cc482421612132d3561ea7bf7407535358c8984c.tar.bz2 gentoo-personal-overlay-cc482421612132d3561ea7bf7407535358c8984c.zip |
linux: allow chaining configurations
Diffstat (limited to 'sys-kernel/linux/files/config_prepare.sh')
-rwxr-xr-x | sys-kernel/linux/files/config_prepare.sh | 83 |
1 files changed, 44 insertions, 39 deletions
diff --git a/sys-kernel/linux/files/config_prepare.sh b/sys-kernel/linux/files/config_prepare.sh index c2b5854..ede6fc8 100755 --- a/sys-kernel/linux/files/config_prepare.sh +++ b/sys-kernel/linux/files/config_prepare.sh @@ -3,60 +3,65 @@ set -e B="$(dirname $0)" -BASE=arch.config -OVERLAY=overlay.config - if [ "$1" = "amd" ]; then - OVERLAY=amd.config + BASE="archbase.config" + CONFIG="overlay.config amd.config" +elif [ "$1" = "intel" ]; then + BASE="archbase.config" + CONFIG="overlay.config intel.config" elif [ "$1" = "virt" ]; then - BASE= - OVERLAY=virt.config + BASE="" + CONFIG="virt.config" +else + BASE="archbase.config" + CONFIG="overlay.config" fi ################################################################################# # First just deploy base configuration (provided or just kernel default) -if [ -n "$BASE" ]; then - cp "$B/$BASE" .config -else +if [ -z "$BASE" ]; then make defconfig +else + cp "$B/$BASE" .config fi -# We are done if no overlay is specified -[ -n "$OVERLAY" ] || exit 0 - -# And now apply changes from overlay.config -while read L; do - echo "$L" | grep -qE "^[[:space:]]*$" && continue # ignore empty lines - echo "$L" | grep -qE "#.*" && continue # Ignore comments - # Remove lines with changed settings - OPTION="$(echo "$L" | grep -oE '^CONFIG_.*=')" - sed -i "#^$OPTION#d" .config - # Put config - echo "$L" >> .config -done < "$B/$OVERLAY" +# Apply changes in config +for CNF in $CONFIG; do + while read L; do + echo "$L" | grep -qE "^[[:space:]]*$" && continue # ignore empty lines + echo "$L" | grep -qE "#.*" && continue # Ignore comments + # Remove lines with changed settings + sed -i "#^$(echo "$L" | grep -oE '^CONFIG_.*=')#d" .config + # Put config + echo "$L" >> .config + done < "$B/$CNF" +done # As next step run olddefconfig (note: stderr contains some output about overrided # options so I am ignoring it) make olddefconfig 2>/dev/null # Now let's check that configuration -EC=0 -while read L; do - echo "$L" | grep -qE "^[[:space:]]*$" && continue # ignore empty lines - echo "$L" | grep -qE "#.*" && continue # Ignore comments - OPTION="$(echo "$L" | grep -oE '^CONFIG_.*=')" - VALUE="$(echo "$L" | grep -oE '=.*$')" - if [ "$VALUE" = "=n" ]; then - if grep -qE "^$OPTION=y" .config; then - EC=1 - echo -e "\e[1;31mY:\e[0m$L" - fi - else - if ! grep -qE "^$L$" .config; then - EC=1 - echo -e "\e[1;31mN:\e[0m$L" +for CNF in $CONFIG; do + EC=0 + while read L; do + echo "$L" | grep -qE "^[[:space:]]*$" && continue # ignore empty lines + echo "$L" | grep -qE "#.*" && continue # Ignore comments + OPTION="$(echo "$L" | grep -oE '^CONFIG_.*=')" + VALUE="$(echo "$L" | grep -oE '=.*$')" + if [ "$VALUE" = "=n" ]; then + # Handle =n and "not set" as being same + if grep -qE "^$OPTION=y" .config; then + EC=1 + echo -e "\e[1;31m$CNF:\e[0m$L" + fi + else + if ! grep -qE "^$L$" .config; then + EC=1 + echo -e "\e[1;31m$CNF:\e[0m$L" + fi fi - fi -done < "$B/$OVERLAY" + done < "$B/$CNF" +done exit $EC |