3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Config
5 # Copyright (C) 2004 - 2022 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> ]"
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
='-profile' ; shift ;;
47 -oldconfig) oldconfig
='-oldconfig' ; shift ;;
48 -cfg) config
="$2" ; shift; shift ;;
55 if [ -z "$config" ]; then
60 if [ ! -d config
/$config -a -n "$oldconfig" ]; then
61 echo "Abort: -oldconfig is not supported for new configs"
66 if [ ! -d config
/$config -a -e /etc
/SDE-CONFIG
/config
]; then
67 echo "Using /etc/SDE-CONFIG/ as default config"
68 mkdir
-p config
/$config
69 cp -vf /etc
/SDE-CONFIG
/* config
/$config/
70 sed -i -E '/SDECFG_(PARALLEL_MAX|CROSSBUILD|PKGSEL_TMPL)/d' \
74 if [ $delete_mode = 1 ]; then
81 if [ $do_config_cycle = 0 ]; then
83 mkdir
-p config
/$config
84 touch config
/$config/{config
,packages
}
87 echo "Aquiring config write lock (may take until other configs finished)"
89 exec 200>> config
/$config/lock.pid
91 echo $$
> config
/$config/lock.pid
94 mkdir
-p $cfgtmpdir # src
96 if [ -z "$oldconfig" -a ! -f src
/confdialog.bin
]; then
97 echo "Creating confdialog tool"
98 command="cc misc/confdialog/*.c `
99 `-Imisc/confdialog -lncurses -o src/confdialog.bin"
101 if ! eval "$command.$$"; then
102 echo "Compilation of the dialog tool failed, ncurses-devel missing?"
105 mv src
/confdialog.bin.$$ src
/confdialog.bin
108 # don't let Ctrl-C interrupt, because it destroys the configurations
111 echo "T2 $sdever configuration"
112 while "$0" -cfg $config $oldconfig $profile -cycle; do :; done
116 rm config
/$config/lock.pid
120 echo "Building src/bash/luabash"
121 j
="$(nproc 2>/dev/null)"
122 make -j${j:-1} --no-print-directory -C misc
/luabash \
123 X_OUTARCH
=$PWD/src
${HOSTCC:+CC=$HOSTCC} ${HOSTCC:+LD=ld}
126 if [ ! -f src
/bash
/luabash.??
* ]; then
127 echo "Error building the Lua bash accelerator"
131 if ! enable -f $PWD/src
/bash
/luabash.??
* luabash
; then
132 echo "Failed to enable the Lua bash accelerator"
136 luabash load
scripts
/config-functions.lua ||
exit 1
138 if [ -z "$profile" ]; then
142 if [ ! -f src
/bash_profiler.so
-o misc
/tools-source
/bash_profiler.c
-nt src
/bash_profiler.so
]; then
143 echo "Building src/bash_profiler.so"
144 cc
-shared -fPIC -Wall -o src
/bash_profiler.so misc
/tools-source
/bash_profiler.c ||
exit 1
146 enable -f src
/bash_profiler.so bprof ||
exit 1
148 local cprof
=$cfgtmpdir/config.profile
149 bprof all print
>> $cprof
151 $4 == "profiled" { next; }
152 $4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; }
153 { count[$4]+=$1; time[$4]+=$2; }
156 printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id;
158 ' < $cprof |
sort -n -k2 > $cprof.new
165 .
scripts
/config-functions.
in
166 arch
=`uname -m | uname2arch`
167 current
=""; export SDECFG_ARCH
="$arch"; export SDECFG_KERNEL
="linux"; export SDECFG_EXPERT
=0
168 menu_this
=0; menu_current
=0; menu_counter
=0
169 menu_stack
=x
; menu_back
=-1; menu_backpos
=-1
171 configtitle
="$(printf ' %-50s %6s active packages ]' \
172 "T2
$sdever Configuration
- $config" \
173 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)" )"
177 . .
/config
/$config/config
180 rm -f $cfgtmpdir/config.
{dialog
,data
,help}
181 touch $cfgtmpdir/config.
{dialog
,data
,help}
182 echo -e "#\n# T2 $sdever Config File\n#" > config
/$config/config
183 spacer
=""; expert
=0; tabspace
="5"; tabspace_list
=""
184 commentnr
=0; editfilenr
=0
186 bprof mkpkglist start
187 cmd
="scripts/Create-PkgList $SDECFG_ARCH"
188 if [ "$cmd" != "`cat $cfgtmpdir/config.pcache.cmd 2> /dev/null`" ]; then
189 eval "$cmd" |
tee $cfgtmpdir/config.pcache.data
> config
/$config/packages
190 echo "$cmd" > $cfgtmpdir/config.pcache.cmd
192 cat $cfgtmpdir/config.pcache.data
> config
/$config/packages
196 # Create lists of .in files
199 export SDECFG_ID
="$sdever"; pkgin
; .
scripts
/config.
in; pkgout
200 echo "export SDECFG_ID='$SDECFG_ID'" >> config
/$config/config
201 rm -f $cfgtmpdir/*.tmp
203 cut
-f1,2,4,5,8- -d' ' config
/$config/packages |
sed 's, [^ ]*$,,' | \
204 tr ' ' '\t' |
expand -t2,15,35, > $cfgtmpdir/packages.txt
206 configtitle
="$(printf ' %-50s %6s active packages ]' \
207 "T2
$sdever Configuration
- $config" \
208 "[ $
(echo `grep '^X' config/$config/packages | wc -l`)" )"
212 if [ -z "$oldconfig" ]; then
213 eval "./src/confdialog.bin --title 'Build Config' \
214 --backtitle '$configtitle' \
215 --menu 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
216 $(( $lines - 4 )) $(( $columns - 5 )) $(( $lines - 12 )) \
217 '$current' `tr '\n' ' ' < $cfgtmpdir/config.dialog`" 2> $cfgtmpdir/config.out
218 returncode
=$?
; item
="$(< $cfgtmpdir/config.out)"
225 [ "$returncode" = 1 -a "$menu_back" -ne -1 ] && returncode
="menu-back"
227 case "$returncode" in
229 command="`grep "^
$item " $cfgtmpdir/config.data | cut -f2-`"
230 { echo -e "\n# Remember menu position:\ncurrent='$item'"
231 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
232 echo -e "\n# Execute this config command:\n$command"
233 } >> config
/$config/config
236 { echo -e "\n# New menu position:\ncurrent='$menu_backpos'"
237 echo -e "\n# New sub-menu:\nmenu_current='$menu_back'"
238 } >> config
/$config/config
242 echo "New config written to: config/$config/"
248 item
=$
(echo $item | cut
-f1 -d' ') # dialog(1) bug?
249 { echo -e "\n# Remember menu position:\ncurrent='$item'"
250 echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
251 } >> config
/$config/config
253 get_help
$item > $cfgtmpdir/config.dialog
256 .
/src
/confdialog.bin
--title 'T2 Config - Help' \
257 --backtitle "T2 $sdever Configuration" \
258 --textbox $cfgtmpdir/config.dialog \
259 $
(( $lines - 4 )) $
(( $columns - 5 ))
263 echo "unknown returncode: $returncode"