diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/config | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/scripts/config b/scripts/config index db6084b78a10..30825a5677f6 100755 --- a/scripts/config +++ b/scripts/config | |||
@@ -26,8 +26,6 @@ options: | |||
26 | 26 | ||
27 | config doesn't check the validity of the .config file. This is done at next | 27 | config doesn't check the validity of the .config file. This is done at next |
28 | make time. | 28 | make time. |
29 | The options need to be already in the file before they can be changed, | ||
30 | but sometimes you can cheat with the --*-after options. | ||
31 | EOL | 29 | EOL |
32 | exit 1 | 30 | exit 1 |
33 | } | 31 | } |
@@ -45,8 +43,18 @@ checkarg() { | |||
45 | ARG="`echo $ARG | tr a-z A-Z`" | 43 | ARG="`echo $ARG | tr a-z A-Z`" |
46 | } | 44 | } |
47 | 45 | ||
48 | replace() { | 46 | set_var() { |
49 | sed -i -e "$@" $FN | 47 | local name=$1 new=$2 before=$3 |
48 | |||
49 | name_re="^($name=|# $name is not set)" | ||
50 | before_re="^($before=|# $before is not set)" | ||
51 | if test -n "$before" && grep -Eq "$before_re" "$FN"; then | ||
52 | sed -ri "/$before_re/a $new" "$FN" | ||
53 | elif grep -Eq "$name_re" "$FN"; then | ||
54 | sed -ri "s:$name_re.*:$new:" "$FN" | ||
55 | else | ||
56 | echo "$new" >>"$FN" | ||
57 | fi | ||
50 | } | 58 | } |
51 | 59 | ||
52 | if [ "$1" = "--file" ]; then | 60 | if [ "$1" = "--file" ]; then |
@@ -70,20 +78,19 @@ while [ "$1" != "" ] ; do | |||
70 | case "$CMD" in | 78 | case "$CMD" in |
71 | --enable|-e) | 79 | --enable|-e) |
72 | checkarg "$1" | 80 | checkarg "$1" |
73 | replace "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" | 81 | set_var "CONFIG_$ARG" "CONFIG_$ARG=y" |
74 | shift | 82 | shift |
75 | ;; | 83 | ;; |
76 | 84 | ||
77 | --disable|-d) | 85 | --disable|-d) |
78 | checkarg "$1" | 86 | checkarg "$1" |
79 | replace "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" | 87 | set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set" |
80 | shift | 88 | shift |
81 | ;; | 89 | ;; |
82 | 90 | ||
83 | --module|-m) | 91 | --module|-m) |
84 | checkarg "$1" | 92 | checkarg "$1" |
85 | replace "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ | 93 | set_var "CONFIG_$ARG" "CONFIG_$ARG=m" |
86 | -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" | ||
87 | shift | 94 | shift |
88 | ;; | 95 | ;; |
89 | 96 | ||
@@ -109,9 +116,7 @@ while [ "$1" != "" ] ; do | |||
109 | A=$ARG | 116 | A=$ARG |
110 | checkarg "$2" | 117 | checkarg "$2" |
111 | B=$ARG | 118 | B=$ARG |
112 | replace "/CONFIG_$A=[my]/aCONFIG_$B=y" \ | 119 | set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A" |
113 | -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=y" \ | ||
114 | -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=y/" | ||
115 | shift | 120 | shift |
116 | shift | 121 | shift |
117 | ;; | 122 | ;; |
@@ -121,9 +126,7 @@ while [ "$1" != "" ] ; do | |||
121 | A=$ARG | 126 | A=$ARG |
122 | checkarg "$2" | 127 | checkarg "$2" |
123 | B=$ARG | 128 | B=$ARG |
124 | replace "/CONFIG_$A=[my]/a# CONFIG_$B is not set" \ | 129 | set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A" |
125 | -e "/# CONFIG_$ARG is not set/a/# CONFIG_$ARG is not set" \ | ||
126 | -e "s/CONFIG_$ARG=[my]/# CONFIG_$ARG is not set/" | ||
127 | shift | 130 | shift |
128 | shift | 131 | shift |
129 | ;; | 132 | ;; |
@@ -133,10 +136,7 @@ while [ "$1" != "" ] ; do | |||
133 | A=$ARG | 136 | A=$ARG |
134 | checkarg "$2" | 137 | checkarg "$2" |
135 | B=$ARG | 138 | B=$ARG |
136 | replace "/CONFIG_$A=[my]/aCONFIG_$B=m" \ | 139 | set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A" |
137 | -e "/# CONFIG_$ARG is not set/a/CONFIG_$ARG=m" \ | ||
138 | -e "s/CONFIG_$ARG=y/CONFIG_$ARG=m/" \ | ||
139 | -e "s/# CONFIG_$ARG is not set/CONFIG_$ARG=m/" | ||
140 | shift | 140 | shift |
141 | shift | 141 | shift |
142 | ;; | 142 | ;; |