1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: scripts/config-functions.in
3 # Copyright (C) 2004 - 2021 The T2 SDE Project
4 # Copyright (C) 1998 - 2003 ROCK Linux Project
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 . scripts/core-functions.in
15 # Function to cache config.in and subconfig.in file lists
17 create_configin_list() {
18 bprof cache_configin_list start
19 if [ ! -f $cfgtmpdir/noexpert-config.in -o ! -f $cfgtmpdir/expert-config.in ]; then
20 local file= prio= name=
22 rm -f $cfgtmpdir/{no,}expert-config.in{,.$$}
23 rm -f $cfgtmpdir/subconfig-*.in{,.$$}
25 touch $cfgtmpdir/{no,}expert-config.in{,.$$}
28 # FIXME: this expression may produce duplicated entries!! //mnemoc
29 ls -1 {package/*,misc}/*/config{,-[a-z]*}{,-[0-9]*}.in 2> /dev/null | while read file; do
30 prio="$( echo "${file##*/}" | sed -n -e "s,.*-\([0-9]*\).in,\1,p" )"
31 if [ ${prio:-750} -le 500 ]; then
32 echo "$prio $file" >> $cfgtmpdir/noexpert-config.in.$$
34 echo "${prio:-750} $file" >> $cfgtmpdir/expert-config.in.$$
37 sort -u $cfgtmpdir/noexpert-config.in.$$ | sed 's,^[^ ]* ,. ,g' > $cfgtmpdir/noexpert-config.in
38 sort -u $cfgtmpdir/expert-config.in.$$ | sed 's,^[^ ]* ,. ,g' > $cfgtmpdir/expert-config.in
40 rm -f $cfgtmpdir/{no,}expert-config.in.$$
43 ls -1 package/*/*/subconfig-[a-z]*.in 2> /dev/null | while read file; do
44 prio="$( echo "${file##*/}" | sed -n -e "s,.*-\([0-9]*\).in,\1,p" )"
45 name="$( echo "${file##*/}" | sed -e "s,-\([0-9]*\).in,.in," )"
46 echo "${prio:-750} $file" >> $cfgtmpdir/$name.$$
48 for file in $cfgtmpdir/subconfig-[a-z]*.in.$$; do
49 sort -n $file | sed 's,^[^ ]* ,. ,g' > ${file%.$$}
53 bprof cache_configin_list stop
56 # Function to cache config.in and subconfig.in file lists
58 create_dot_in_lists() {
60 # {architecture,misc,target,package/*}/*/{pre,post}config.in
61 bprof cache_dotin_list start
62 for x in preconfig.in postconfig.in; do
63 for y in architecture kernel misc target; do
65 if [ ! -f $file ]; then
66 ls -1 $y/*/$x 2> /dev/null | sed 's,^,. ,' > $file
71 if [ ! -f $file ]; then
72 ls -1 $y/*/*/$x 2> /dev/null | sed 's,^,. ,' > $file
75 bprof cache_dotin_list stop
77 # and {sub,}config.in, which is more complex
81 # Functions for working with config/$config/packages
83 # pkgenable package-list
84 # pkgdisable package-list
85 # pkgremove package-list
86 # pkgcheck package|oacjage X|O|.
87 # pkgfilter cmd arg1 ...
88 # pkgsel_parse parse pkgsel file
90 pkgin() { pkglistread config/$config/packages; }
91 pkgout() { pkglistwrite config/$config/packages; }
94 pkglistwrite $cfgtmpdir/packages.tmp
95 "$@" < $cfgtmpdir/packages.tmp > config/$config/packages
96 pkglistread config/$config/packages
100 # pkgchecklicense -- checks for files with license issues
102 rm -f config/$config/license-issue.*
103 while read a b c repo pkg dummy; do
104 if grep -E "\[(L|LICENSE)\][ ]*(Commercial|Restricted)" \
105 package/$repo/$pkg/$pkg.desc &> /dev/null; then
106 echo $pkg >> config/$config/license-issue.ask
108 done < <(grep "^X" config/$config/packages)
113 if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
114 [ $menu_current = $menu_this ]; then
116 echo "COMMENT_$commentnr '$spacer$1'" >> $cfgtmpdir/config.dialog
118 if [ "$2" != "" ]; then
119 set_help "COMMENT_$commentnr" "$2"
126 bprof comment_id start
127 if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
128 [ $menu_current = $menu_this ]; then
129 echo "$2 '$spacer$1'" >> $cfgtmpdir/config.dialog
131 if [ "$3" != "" ]; then
135 bprof comment_id stop
141 local v="${2//$q/$q\\$q$q}"
143 echo "export $1='$v'" >> config/$config/config
147 # Usage: set_data NAME DEFAULT
151 local q="'" set_name="SDECFGSET_${1#SDECFG_}"
153 if eval "[ \"\$$set_name\" ]"; then
154 eval "data=\"\$$set_name\""
156 if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ]
157 then menumode=2; else menumode=0; fi
159 elif [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ]; then
160 eval "data=\"\${$1:-$2}\""
164 data="$2"; eval "$1=\"\$data\""
169 echo "export $1='${data//$q/$q\\$q$q}'" >> config/$config/config
176 # desired default value
180 # reset to default if current value is not in list
181 # and default to first element if it's not in list
184 eval "value=\$$1"; name=$1; dval=$defval; shift; shift
185 while [ "$#" != 0 ]; do
186 [ "$dval" = "$1" ] && dval=""
187 [ "$value" = "$1" ] && name=""; shift; shift
189 [ "$dval" ] && echo "unset defval;"
190 [ "$name" ] && echo "unset $name"
193 set_data "$1" "${defval:-$3}"
195 if [ "$menumode" -eq 1 -a $menu_current = $menu_this ]; then
196 { echo -en "$item\tchoice_action '$1' '$data'"; shift; shift
197 for x; do echo -n " '$x'"; done; echo; } >> $cfgtmpdir/config.data
200 if [ "$menumode" -gt 0 -a $menu_current = $menu_this ]; then
201 if [ "$menumode" -eq 1 ]; then xdata="($data)"
202 else xdata="=$data="; fi
204 while [ "$1" -a "$1" != "$data" ]; do shift; shift; done
205 printf "'$item' '$spacer%-${tabspace}s ${2//_/ }'\n" \
206 "$xdata" >> $cfgtmpdir/config.dialog
213 command="./src/confdialog.bin --title 'Build Config' \
214 --backtitle '$configtitle' \
215 --radiolist 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
216 $(( $lines - 4 )) $(( $columns - 5 )) $(( $lines - 12 ))"
217 default=$2; item=$1; shift; shift
219 if [ "$1" = "$default" ]
220 then command="$command '$1' '${2//_/ }' ON"
221 else command="$command '$1' '${2//_/ }' OFF"; fi
224 eval "$command" 2> $cfgtmpdir/config.out
228 eval "$item='$(< $cfgtmpdir/config.out)'"
231 2) echo "No help."; sleep 1 ;;
232 *) echo "unknown returncode: $?"; exit 1 ;;
241 if [ "$menumode" -eq 1 -a $menu_current = $menu_this ]; then
242 echo -e "$2\ttext_action '$1' '$2'" \
243 "'${data//$q/$q\\$q$q}'" >> $cfgtmpdir/config.data
246 if [ "$menumode" -gt 0 -a $menu_current = $menu_this ]; then
247 xdata="$( printf "%-${tabspace}s" \
248 "$(echo $data | cut -c1-20)")"
249 if [ "$menumode" -eq 1 ]; then xdata="($xdata)"
250 else xdata="=$xdata="; fi
252 printf "'$2' '$spacer%s $1'\n" \
253 "${xdata//$q/$q\\$q$q}" >> $cfgtmpdir/config.dialog
255 if [ "$4" != "" ]; then
263 ./src/confdialog.bin --title 'Build Config' \
264 --backtitle "$configtitle" \
265 --inputbox "$1" 9 $(( $columns - 5 )) "$3" 2> $cfgtmpdir/config.out
266 [ "$?" -eq 0 -o "$?" -eq 1 ] && eval "$2=\"\$(< $cfgtmpdir/config.out)\""
274 if [ "$menumode" -eq 1 -a $menu_current = $menu_this ]; then
275 echo -e "$2\tbool_action '$1' '$2' '$data'" >> $cfgtmpdir/config.data
278 if [ "$menumode" -gt 0 -a $menu_current = $menu_this ]; then
279 if [ "$menumode" -eq 1 ]; then
280 if [ $data -eq 0 ]; then x='[ ]'; else x='[*]'; fi
282 if [ $data -eq 0 ]; then x='= ='; else x='=*='; fi
284 printf "$2 '$spacer%-${tabspace}s ${1//_/ }'\n" \
285 "$x" >> $cfgtmpdir/config.dialog
287 if [ "$4" != "" ]; then
295 if [ $3 -eq 0 ]; then eval "$2=1"
301 if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ]; then
302 local x="$spacer" q="'"
303 comment ",----< $3 >----."
304 block_begin 0; spacer="${spacer%??}| "
309 line="${line//$q/$q\\$q$q}"
310 if [ $menu_current = $menu_this ]; then
311 printf "$1:${editfilenr} '$spacer%-${tabspace}s %s'\n" \
312 `printf "%03d:" $line_nr` "$line" >> $cfgtmpdir/config.dialog
314 echo -e "$1:${editfilenr}\teditfile_action $2" \
315 "$line_nr '$3'" >> $cfgtmpdir/config.data
322 if [ $menu_current = $menu_this ]; then
323 printf "$1:${editfilenr} '$spacer%-${tabspace}s %s'\n" \
324 `printf "%03d:" $line_nr` "<add new rule>" >> $cfgtmpdir/config.dialog
326 echo -e "$1:${editfilenr}\teditfile_action $2" \
327 "$line_nr '$3'" >> $cfgtmpdir/config.data
333 comment "\`------${3//?/-}------'\''"
342 line="`tail -n +$2 $1 | head -n 1`"
344 ./src/confdialog.bin --title 'Build Config' \
345 --backtitle "$configtitle" \
346 --inputbox "$3 - Line $3" \
347 9 $(( $columns - 5 )) "$line" 2> $cfgtmpdir/config.out
349 head -n $(( $2 - 1 )) $1 > $1.new
350 [ -s $cfgtmpdir/config.out ] && echo "$(< $cfgtmpdir/config.out)" >> $1.new
351 tail -n +$(( $2 + 1 )) $1 >> $1.new
357 bprof startprog start
358 if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
359 [ $menu_current = $menu_this ]; then
360 printf "$1 '$spacer%-${tabspace}s %s'\n" \
361 "-->" "$2" >> $cfgtmpdir/config.dialog
362 echo -e "$1\t$3" >> $cfgtmpdir/config.data
368 bprof block_begin start
369 if [ $menu_current = $menu_this ]; then
370 [ "$tabspace_list" ] && spacer="$spacer "
371 tabspace_list="$tabspace $tabspace_list"
372 tabspace="$(( $tabspace + $1 - 2 ))"
374 bprof block_begin stop
378 bprof block_end start
379 if [ $menu_current = $menu_this ]; then
380 spacer="${spacer%??}"
381 tabspace="${tabspace_list%% *}"
382 tabspace_list="${tabspace_list#* }"
388 expert=$(( $exprt + 1 ))
392 expert=$(( $exprt - 1 ))
396 bprof menu_begin start
397 menu_counter=$(( $menu_counter + 1 ))
399 if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
400 [ $menu_current = $menu_this ]; then
401 printf "$1 '$spacer%-${tabspace}s %s'\n" \
402 "===>" "$2" >> $cfgtmpdir/config.dialog
403 echo -e "$1\tmenu_current=$menu_counter" >> $cfgtmpdir/config.data
405 if [ $SDECFG_EXPERT -eq 1 -o $expert -eq 0 ] &&
406 [ $menu_current = $menu_counter ]; then
407 echo "$1 '===> $2'" >> $cfgtmpdir/config.dialog
408 echo -e "$1\tmenu_current=$menu_this" >> $cfgtmpdir/config.data
411 if [ $menu_current = $menu_counter ]; then
416 menu_stack="$menu_this $menu_stack"
417 menu_this=$menu_counter
420 bprof menu_begin stop
426 menu_this="${menu_stack%% *}"
427 menu_stack="${menu_stack#* }"
433 (echo -ne "$1 '$1:\n\n$2'" | sed 's,$,\\n,' |
434 tr -d '\n' | sed 's,\\n$,,'; echo ) >> $cfgtmpdir/config.help
440 # Create standard help output ...
442 There is no help on '$1' available.
444 This is the T2 $sdever Configuration Tool.
446 Please read the Quick Start and the Handbook on
447 http://t2sde.org/buildintro.html and
448 http://t2sde.org/t2-handbook/ respectively
451 More information can be found on the T2 Homepage:
455 Subscribe to the mailing list by sending an e-mail with the
456 subject 'subscribe t2' to <lists@t2sde.org>."
458 # Ok let us find a help for the current item ...
460 # First of all mask all special chars in the item name
461 # Comment: this is sick. You can't get any \n this way !!!
462 item_name=$( echo "$1" | sed 's/[][\/.^$*]/\\&/g' )
463 # Now search *.hlp files
464 hlp_text=$( sed -n "/^$item_name[ ]*\$/,\${
465 /^$item_name[ ]*\$/c\\
472 }" scripts/config*.hlp architecture/*/config*.hlp \
473 package/*/*/subconfig-*.hlp package/*/*/config*.hlp target/*/config*.hlp \
474 misc/config/config*.hlp 2>/dev/null )
476 # Get help strings out of the temporary file.
477 tmp_text=$(grep "^$item_name" $cfgtmpdir/config.help | cut -f2- -d' ' | sed -e "s,^',," -e "s,'$,," )
479 # Let us see what we have ...
480 if [ "$hlp_text" -a "$tmp_text" ]; then
482 There are two help text's... one in one of the config.in files and one
483 in one of the config.hlp files. Please remove one of them to get rid of
486 Here the one out of config.in:
490 Here the one out of config.hlp:
493 elif [ "$hlp_text" ]; then
495 elif [ "$tmp_text" ]; then