3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Config
5 # Copyright (C) 2004 - 2024 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 if [ -z "${lines:=$LINES}" -o -z "${columns:=$COLUMNS}" ]; then
16 if [ "$(type -p stty)" ]; then
17 lines
="$( stty size 2> /dev/null | cut -d' ' -f1)"
18 columns
="$(stty size 2> /dev/null | cut -d' ' -f2)"
20 [ -z "$lines" -o "$lines" -le 0 ] 2> /dev
/null
&& lines
=24
21 [ -z "$columns" -o "$columns" -le 0 ] 2> /dev
/null
&& columns
=80
24 eval "$(egrep '^sdever=' scripts/parse-config)"
35 echo "Usage: $0 [ -delete | -oldconfig ] [ -cfg <config> ] [ key[=value ] ]"
38 echo " -profile create a config.profile with profiling data"
44 -cycle) do_config_cycle
=1; shift ;;
45 -delete) delete_mode
=1 ; shift ;;
46 -profile) profile
=$1 ; shift ;;
47 -oldconfig) oldconfig
=$1 ; shift ;;
48 -cfg) config
="$2" ; shift; shift ;;
49 -*) show_usage
; exit 1 ;;
54 if [ -z "$config" ]; then
59 # get/set config key=value
68 sed -i "/SDECFG_$key=/{s/=.*/='$val'/}" config
/$config/config
71 sed -n "/SDECFG_$key=/x; \${x; s/^[^=]*=//; s/^'\(.*\)'$/\1/; s/.\+/$key=&/p}" config
/$config/config
73 [ $# -gt 0 ] && exit 0
75 if [ ! -d config
/$config -a -e /etc
/SDE-CONFIG
/config
-a $config = default
]; then
76 echo "Using /etc/SDE-CONFIG/ as default config"
77 mkdir
-p config
/$config
78 cp -vf /etc
/SDE-CONFIG
/* config
/$config/
79 sed -i -E '/SDECFG_(CROSSBUILD|OPT|LTO|PARALLE|PKGSEL_TMPL|TMPFS|C_FLAGS)/d' \
83 if [ ! -d config
/$config -a -n "$oldconfig" ]; then
84 echo "Error: -oldconfig is not supported for a new config"
89 if [ $delete_mode = 1 ]; then
96 if [ $do_config_cycle = 0 ]; then
97 echo "T2 $sdever configuration"
100 mkdir
-p config
/$config
101 touch config
/$config/{config
,packages
}
104 echo "Aquiring config lock ..."
106 exec 200>> config
/$config/lock.pid
108 echo $$
> config
/$config/lock.pid
111 mkdir
-p $cfgtmpdir # src
113 if [ -z "$oldconfig" -a ! -f src
/confdialog.bin
]; then
114 echo "Creating confdialog tool"
115 command="cc -O2 misc/confdialog/*.c `
116 `-Imisc/confdialog -lncurses -o src/confdialog.bin"
118 if ! eval "$command.$$"; then
119 echo "Compilation of the dialog tool failed, ncurses-devel missing?"
122 mv src
/confdialog.bin.$$ src
/confdialog.bin
125 # don't let Ctrl-C interrupt, because it destroys the configurations
128 while "$0" -cfg $config $oldconfig $profile -cycle; do :; done
132 rm config
/$config/lock.pid
136 if [ ! -f src
/bash
/luabash.??
* ]; then
137 echo "Building src/bash/luabash"
138 j
="$(nproc 2>/dev/null)"
139 make -j${j:-1} --no-print-directory -C misc
/luabash \
140 X_OUTARCH
=$PWD/src
${HOSTCC:+CC=$HOSTCC} ${HOSTCC:+LD=ld}
144 if [ ! -f src
/bash
/luabash.??
* ]; then
145 echo "Error building the Lua bash accelerator"
149 if ! enable -f $PWD/src
/bash
/luabash.??
* luabash
; then
150 echo "Error enabling the Lua bash accelerator: bash built with plugin support?"
154 luabash load
scripts
/config-functions.lua ||
exit 1
156 if [ -z "$profile" ]; then
160 if [ ! -f src
/bash_profiler.so
-o misc
/tools-source
/bash_profiler.c
-nt src
/bash_profiler.so
]; then
161 echo "Building src/bash_profiler.so"
162 cc
-O2 -shared -fPIC -Wall -o src
/bash_profiler.so misc
/tools-source
/bash_profiler.c ||
exit 1
164 enable -f src
/bash_profiler.so bprof ||
exit 1
166 local cprof
=$cfgtmpdir/config.profile
167 bprof all print
>> $cprof
169 $4 == "profiled" { next; }
170 $4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; }
171 { count[$4]+=$1; time[$4]+=$2; }
174 printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id;
176 ' < $cprof |
sort -n -k2 > $cprof.new
183 .
scripts
/config-functions.
in
184 arch
=`uname -m | uname2arch`
186 export SDECFG_ARCH
="$arch" SDECFG_KERNEL
="linux" SDECFG_EXPERT
=0
187 menu_this
=0 menu_current
=0 menu_counter
=0
188 menu_stack
=x menu_back
=-1 menu_backpos
=-1
190 configtitle
="$(printf ' %-50s %6s active packages ]' \
191 "T2
$sdever Configuration
- $config" \
192 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)")"
196 . config
/$config/config
199 rm -f $cfgtmpdir/config.
{dialog
,data
,help}
200 touch $cfgtmpdir/config.
{dialog
,data
,help}
201 echo -e "#\n# T2 $sdever Config File\n#" > config
/$config/config
202 spacer
="" expert
=0 tabspace
="5" tabspace_list
=""
203 commentnr
=0 editfilenr
=0
205 bprof mkpkglist start
206 cmd
="scripts/Create-PkgList $SDECFG_ARCH $SDECFG_KERNEL"
207 if [ "$cmd" != "`cat $cfgtmpdir/config.pcache.cmd 2> /dev/null`" ]; then
208 $cmd |
tee $cfgtmpdir/config.pcache.data
> config
/$config/packages
209 echo "$cmd" > $cfgtmpdir/config.pcache.cmd
211 cat $cfgtmpdir/config.pcache.data
> config
/$config/packages
215 # Create lists of .in files
218 export SDECFG_ID
="$sdever"; pkgin
; .
scripts
/config.
in; pkgout
219 echo "export SDECFG_ID='$SDECFG_ID'" >> config
/$config/config
220 rm -f $cfgtmpdir/*.tmp
222 cut
-f1,2,4,5,8- -d' ' config
/$config/packages |
sed 's, [^ ]*$,,' | \
223 tr ' ' '\t' |
expand -t2,15,35, > $cfgtmpdir/packages.txt
225 configtitle
="$(printf ' %-50s %6s active packages ]' \
226 "T2
$sdever Configuration
- $config" \
227 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)")"
231 if [ -z "$oldconfig" ]; then
232 eval "src/confdialog.bin --title 'Build Config' \
233 --backtitle '$configtitle' \
234 --menu 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
235 $(($lines - 4)) $(($columns - 5)) $(($lines - 12)) \
236 '$current' `tr '\n' ' ' < $cfgtmpdir/config.dialog`" 2> $cfgtmpdir/config.out
237 returncode
=$? item
="$(< $cfgtmpdir/config.out)"
244 [ "$returncode" = 1 -a "$menu_back" -ne -1 ] && returncode
="menu-back"
246 case "$returncode" in
248 command="`grep "^
$item " $cfgtmpdir/config.data | cut -f2-`"
249 { echo -e "\n# Remember menu position:\ncurrent='$item'"
250 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
251 echo -e "\n# Execute this config command:\n$command"
252 } >> config
/$config/config
255 { echo -e "\n# New menu position:\ncurrent='$menu_backpos'"
256 echo -e "\n# New sub-menu:\nmenu_current='$menu_back'"
257 } >> config
/$config/config
261 echo "New config written to: config/$config/"
267 item
=$
(echo $item | cut
-f1 -d' ') # dialog(1) bug?
268 { echo -e "\n# Remember menu position:\ncurrent='$item'"
269 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
270 } >> config
/$config/config
272 get_help
$item > $cfgtmpdir/config.dialog
275 src
/confdialog.bin
--title 'T2 Config - Help' \
276 --backtitle "T2 $sdever Configuration" \
277 --textbox $cfgtmpdir/config.dialog \
278 $
(($lines - 4)) $
(($columns - 5))
282 echo "unknown returncode: $returncode"