3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
6 # T2 SDE: scripts/Config
7 # Copyright (C) 2004 - 2021 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 if [ -z "${lines:=$LINES}" -o -z "${columns:=$COLUMNS}" ]; then
19 if [ "$( type -p stty )" ]; then
20 lines
="$( stty size 2> /dev/null | cut -d' ' -f1 )"
21 columns
="$( stty size 2> /dev/null | cut -d' ' -f2 )"
23 [ -z "$lines" -o "$lines" -le 0 ] 2> /dev
/null
&& lines
=24
24 [ -z "$columns" -o "$columns" -le 0 ] 2> /dev
/null
&& columns
=80
27 eval "$(egrep '^sdever=' scripts/parse-config)"
38 echo "Usage: $0 [ -delete | -oldconfig ] [ -cfg <config> ]"
41 echo " -profile create a config.profile with profiling data"
47 -cycle) do_config_cycle
=1; shift ;;
48 -delete) delete_mode
=1 ; shift ;;
49 -profile) profile
='-profile' ; shift ;;
50 -oldconfig) oldconfig
='-oldconfig' ; shift ;;
51 -cfg) config
="$2" ; shift; shift ;;
58 if [ -z "$config" ]; then
63 if [ ! -d config
/$config -a -n "$oldconfig" ]; then
64 echo "Abort: -oldconfig is not supported for new configs"
69 if [ ! -d config
/$config -a -e /etc
/SDE-CONFIG
/config
]; then
70 echo "Using /etc/SDE-CONFIG/ as default config"
71 mkdir
-p config
/$config
72 cp -vf /etc
/SDE-CONFIG
/* config
/$config/
73 sed -i -E '/SDECFG_(PARALLEL_MAX|CROSSBUILD)/d' \
77 if [ $delete_mode = 1 ]; then
84 if [ $do_config_cycle = 0 ]; then
86 mkdir
-p config
/$config
87 touch config
/$config/{config
,packages
}
90 echo "Aquiring config write lock (may take until other configs finished)"
92 exec 200>> config
/$config/lock.pid
94 echo $$
> config
/$config/lock.pid
97 mkdir
-p $cfgtmpdir # src
99 if [ -z "$oldconfig" -a ! -f src
/confdialog.bin
]; then
100 echo "Creating confdialog tool"
101 command="cc misc/confdialog/*.c `
102 `-Imisc/confdialog -lncurses -o src/confdialog.bin"
104 if ! eval "$command.$$"; then
105 echo "Compilation of the dialog tool failed, ncurses-devel missing?"
108 mv src
/confdialog.bin.$$ src
/confdialog.bin
111 # don't let Ctrl-C interrupt, because it destroys the configurations
114 echo "T2 $sdever configuration"
115 while "$0" -cfg $config $oldconfig $profile -cycle; do :; done
119 rm config
/$config/lock.pid
123 echo "Building src/luabash.so"
124 rm -rf src
/luabash.so
125 j
="$(nproc 2>/dev/null)"
126 make -j${j:-1} --no-print-directory -C misc
/luabash X_OUTTOP
=$PWD/src
install
129 if [ ! -f src
/luabash.so
]; then
130 echo "Error building the Lua bash accelerator"
134 if ! enable -f src
/luabash.so luabash
; then
135 echo "Failed to enable the Lua bash accelerator"
139 luabash load
scripts
/config-functions.lua ||
exit 1
141 if [ -z "$profile" ]; then
145 if [ ! -f src
/bash_profiler.so
-o misc
/tools-source
/bash_profiler.c
-nt src
/bash_profiler.so
]; then
146 echo "Building src/bash_profiler.so"
147 cc
-shared -fPIC -Wall -o src
/bash_profiler.so misc
/tools-source
/bash_profiler.c ||
exit 1
149 enable -f src
/bash_profiler.so bprof ||
exit 1
151 local cprof
=$cfgtmpdir/config.profile
152 bprof all print
>> $cprof
154 $4 == "profiled" { next; }
155 $4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; }
156 { count[$4]+=$1; time[$4]+=$2; }
159 printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id;
161 ' < $cprof |
sort -n -k2 > $cprof.new
168 .
scripts
/config-functions.
in
169 arch
=`uname -m | uname2arch`
170 current
=""; export SDECFG_ARCH
="$arch"; export SDECFG_KERNEL
="linux"; export SDECFG_EXPERT
=0
171 menu_this
=0; menu_current
=0; menu_counter
=0
172 menu_stack
=x
; menu_back
=-1; menu_backpos
=-1
174 configtitle
="$(printf ' %-50s %6s active packages ]' \
175 "T2
$sdever Configuration
- $config" \
176 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)" )"
180 . .
/config
/$config/config
183 rm -f $cfgtmpdir/config.
{dialog
,data
,help}
184 touch $cfgtmpdir/config.
{dialog
,data
,help}
185 echo -e "#\n# T2 $sdever Config File\n#" > config
/$config/config
186 spacer
=""; expert
=0; tabspace
="5"; tabspace_list
=""
187 commentnr
=0; editfilenr
=0
189 bprof mkpkglist start
190 cmd
="scripts/Create-PkgList $SDECFG_ARCH"
191 if [ "$cmd" != "`cat $cfgtmpdir/config.pcache.cmd 2> /dev/null`" ]; then
192 eval "$cmd" |
tee $cfgtmpdir/config.pcache.data
> config
/$config/packages
193 echo "$cmd" > $cfgtmpdir/config.pcache.cmd
195 cat $cfgtmpdir/config.pcache.data
> config
/$config/packages
199 # Create lists of .in files
202 export SDECFG_ID
="$sdever"; pkgin
; .
scripts
/config.
in; pkgout
203 echo "export SDECFG_ID='$SDECFG_ID'" >> config
/$config/config
204 rm -f $cfgtmpdir/*.tmp
206 cut
-f1,2,4,5,8- -d' ' config
/$config/packages |
sed 's, [^ ]*$,,' | \
207 tr ' ' '\t' |
expand -t2,15,35, > $cfgtmpdir/packages.txt
209 configtitle
="$(printf ' %-50s %6s active packages ]' \
210 "T2
$sdever Configuration
- $config" \
211 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)" )"
215 if [ -z "$oldconfig" ]; then
216 eval "./src/confdialog.bin --title 'Build Config' \
217 --backtitle '$configtitle' \
218 --menu 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
219 $(( $lines - 4 )) $(( $columns - 5 )) $(( $lines - 12 )) \
220 '$current' `tr '\n' ' ' < $cfgtmpdir/config.dialog`" 2> $cfgtmpdir/config.out
221 returncode
=$?
; item
="$(< $cfgtmpdir/config.out)"
228 [ "$returncode" = 1 -a "$menu_back" -ne -1 ] && returncode
="menu-back"
230 case "$returncode" in
232 command="`grep "^
$item " $cfgtmpdir/config.data | cut -f2-`"
233 { echo -e "\n# Remember menu position:\ncurrent='$item'"
234 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
235 echo -e "\n# Execute this config command:\n$command"
236 } >> config
/$config/config
239 { echo -e "\n# New menu position:\ncurrent='$menu_backpos'"
240 echo -e "\n# New sub-menu:\nmenu_current='$menu_back'"
241 } >> config
/$config/config
245 echo "New config written to: config/$config/"
251 item
=$
(echo $item | cut
-f1 -d' ') # dialog(1) bug?
252 { echo -e "\n# Remember menu position:\ncurrent='$item'"
253 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
254 } >> config
/$config/config
256 get_help
$item > $cfgtmpdir/config.dialog
259 .
/src
/confdialog.bin
--title 'T2 Config - Help' \
260 --backtitle "T2 $sdever Configuration" \
261 --textbox $cfgtmpdir/config.dialog \
262 $
(( $lines - 4 )) $
(( $columns - 5 ))
266 echo "unknown returncode: $returncode"